Chapter 8: Creating Enterprise JavaBeans Clients
You can use EJB local invocations in servlet, JSP, or EJB component code to call EJB components hosted on the same server. Proxies for a local bean can be instantiated with almost the same code that would be used to instantiate remote proxies. The differences are:
You must create a local EJB reference for the called EJB component, and use the aliased JNDI name defined in the EJB local reference.
Parameters that are not primitive types are passed by reference, not by value. Changes to a parameter in the component implementation affect the variable passed from the caller.
You must narrow to the local home interface type, not the home interface type.
Local interfaces are available only to EJB components, Java servlets, and JSPs hosted on the same server as the target component. You must configure a local EJB reference for the call, as described in “Adding an EJB local reference” and “Editing an EJB local reference”.
If local interfaces are used, both the caller and the called component must be loaded by the same custom class loader.
When an EJB 2.0 component provides local interfaces, any other component or Web application that calls the local interface must use the same class loader. ClassCastException errors occur when local interface calls are made from entities that use a different class loader. Configure the custom class lists for the calling and called components and parent entries to allow sharing of the class instances as described in “Custom class lists for packages, applications, or servers”.
|Copyright © 2005. Sybase Inc. All rights reserved.|