12.11.2014 Views

web server - Borland Technical Publications

web server - Borland Technical Publications

web server - Borland Technical Publications

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter<br />

11<br />

11Writing enterprise bean clients<br />

Chapter<br />

Important<br />

For documentation updates, go to www.borland.com/techpubs/bes.<br />

Client view of an enterprise bean<br />

A client of an enterprise bean is an application, a stand-alone application, an<br />

application client container, servlet, or applet--or another enterprise bean. In all cases,<br />

the client must do the following things to use an enterprise bean:<br />

■<br />

■<br />

■<br />

Locate the bean's home interface. The EJB specification states that the client<br />

should use the JNDI (Java Naming and Directory Interface) API to locate home<br />

interfaces.<br />

Obtain a reference to an enterprise bean object's remote interface. This involves<br />

using methods defined on the bean's home interface. You can either create a<br />

session bean, or you can create or find an entity bean.<br />

Invoke one or more methods defined by the enterprise bean. A client does not<br />

directly invoke the methods defined by the enterprise bean. Instead, the client<br />

invokes the methods on the enterprise bean object's remote interface. The methods<br />

defined in the remote interface are the methods that the enterprise bean has<br />

exposed to clients.<br />

Initializing the client<br />

The SortClient application imports the necessary JNDI classes and the SortBean home<br />

and remote interfaces. The client uses the JNDI API to locate an enterprise bean's<br />

home interface.<br />

A client application can also use logical names (as recommended in the various J2EE<br />

specifications) to access resources such as database connections, remote enterprise<br />

beans, and environment variables. The container, per the J2EE specification, exposes<br />

these resources as administered objects in the local JNDI name space (that is,<br />

java:comp/env).<br />

Chapter 11: Writing enterprise bean clients 85

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!