user manual

Chapter 11: Writing enterprise bean clients 109
Getting information about an enterprise bean
Getting information about an enterprise bean
Information about an enterprise bean is referred to as metadata. A client can
obtain metadata about a bean using the enterprise bean's home interface
getMetaData() method.
The getMetaData() method is most often used by development environments
and tool builders that need to discover information about an enterprise bean,
such as for linking together beans that have already been installed. Scripting
clients might also want to obtain metadata on the bean.
Once the client retrieves the home interface reference, it can call the
getEJBMetaData() method on the home interface. Then, the client can call the
EJBMetaData interface methods to extract such information as:
The bean's EJBHome home interface, using EJBMetaData.getEJBHome().
The bean's home interface class object, including its interfaces, classes,
fields, and methods, using EJBMetaData.getHomeInterfaceClass().
The bean's remote interface class object, including all class information,
using EJBMetaData.getRemoteInterfaceClass().
The bean's primary key class object, using
EJBMetaData.getPrimaryKeyClass().
Whether the bean is a session bean or an entity bean, using
EJBMetaData.isSession(). The method returns true if this is a session bean.
Whether a session bean is stateless or stateful, using
EJBMetaData.isStatelessSession(). The method returns true if the session
bean is stateless.
Support for JNDI
The EJB specification defines the JNDI API for locating home interfaces. JNDI
is implemented on top of other services, including CORBA's Naming Service,
LDAP/X.500, flat files, and proprietary directory services. The diagram below
illustrates the different implementation choices. Typically, the EJB server
provider selects a particular implementation of JNDI.
The technology implemented beneath JNDI is of no concern to the client. The
client needs to use only the JNDI API.