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:

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

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.