Writing a Client

The best way to learn how to use EJBs is to look at some examples. The process for a client to connect to a Bean is rather simple. For a client to work with an EJB, the client must perform the following:

  • Get a reference to a JNDI server.

  • Get a reference to the desired Bean’s home object.

  • Get a reference to a remote object by calling the create() method or a finder method.

  • Invoke the desired business method.

Now we’ll create a client that communicates to a weather Session Bean. This Bean simply connects to a Bean and returns to the client the current temperature. The following steps are required to create a client to connect to the weather Bean:

Create a client application:
 package sessionbean; class WeatherClient { public ...

Get Borland® JBuilder™ Developer’s Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.