24,Suite 303 ,3 26,Suite 305 ,3 28,Suite 307 (Make web site)
January 1st, 200824,Suite 303 ,3 26,Suite 305 ,3 28,Suite 307 ,3 Bean metadata EJBHome.getEJBMetaData() returns an instance of javax.ejb.EJBMetaData that describes the remote home interface, remote interface, and primary key classes, plus whether the enterprise bean is a session or entity bean3. This type of metadata is valuable to Java tools like IDEs that have wizards or other mechanisms for interacting with an enteprise bean from a client s perspective. A tool could, for example, use the class definitions provided by the EJBMetaData with Java reflection to create an environment where deployed enterprise beans can be wired together by developers. Of course, information such as the JNDI names and URLs of the enterprise beans is also needed. Most application developers rarely use the EJBMetaData. Knowing that it s there, however, is valuable when you need to create automatic code generators or some other automatic facility. In those cases, familiarity with the Reflection API is necessary.4 The following code shows the interface definition for EJBMetaData. Any class that implements the EJBMetaData interface must be serializable; it cannot be a stub to a distributed object. This allows IDEs and other tools to save the EJBMetaData for later use. public interface javax.ejb.EJBMetaData { public abstract EJBHome getEJBHome(); public abstract Class getHomeInterfaceClass(); public abstract Class getPrimaryKeyClass(); public abstract Class getRemoteInterfaceClass(); public abstract boolean isSession(); } The following code shows how the EJBMetaData for the Cabin EJB could be used to get more information about the enterprise bean. Notice that there is no way to get the bean class using the EJBMetaData; the bean class is not part of the client API and therefore doesn t belong to the metadata. Context jndiContext = getInitialContext(); Object ref = jndiContext.lookup(”CabinHome”); CabinHomeRemote c_home = (CabinHomeRemote) PortableRemoteObject.narrow(ref, CabinHomeRemote.class); 3 Message-driven beans in EJB 2.0 don t have component interfaces and can t be accessed by Java RMI-IIOP. The Reflection API is outside the scope of this book, but it is covered in Java in a Nutshell, by David Flanagan (O Reilly). Copyright (c) 2001 O’Reilly & Associates
We provides quality the CPanel Web Hosting. All our web hosting plans regular, business and expert are competitively priced and unsurpassed in reliability, uptime, and quality of service.