You are on page 1of 3

EJB Quick Learn Type of EJB 1) Session Bean Stateful Stateless 2) Entity Bean 3) Message Bean Common Architecture-

e- In this Session Bean and Entity Bean 1- Home Interface 2- Component Interface 3- Bean Class Home Interface - Is the communication point for the Container. Must have the following method declaration and extends EJBHome interface Public Icomponent_interface create() throws RemoteException,CreateException Remote Interface Is the communication point for the Home Interface .Must extends EJBObject interface and Method declaration of which is exposed for the bean. Note it can contain method which is not in bean but it will not meaningful. Bean- Extends the respective bean interface for the type of bean Sample ejb-jar.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd"> <ejb-jar id="ejb-jar_ID"> <display-name>Tst_ejb_session_v2</display-name> <enterprise-beans> <session> <display-name>Tst_ejb_session_v2_displayname</displayname> <ejb-name>MyBean(name for the ejb bean)</ejb-name> <home>com.component.IHome(home interface)</home> <remote>com.component.IComponent(component interface)</remote> <ejb-class>com.component.MyBean(bean class)</ejb-class> <session-type>Stateless(type of bean)</session-type> <transaction-type>Bean</transaction-type> <security-identity> <description></description> <use-caller-identity /> </security-identity> </session> </enterprise-beans> </ejb-jar>

EJB Client 1) 2) 3) 4) Get the reference of the Jndi INITIAL_CONTEXT. Use the INITIAL_CONTEXT to look up the home interface. Narrow and cast the thing we get in lookup. Call the create on the home interface to get back the reference of component interface. 5) Call the method of the bean. :) Before writing the client code we first have to create the EJB Client jar and then share it with the respective party to use that jar in the API and that api is used by the client for typecasting and using that in code. Learn where each method lives and what is the signature of these method.. Note: The Home interface job is to handover the object references to that beans component interface.(Except in entity bean. there is some other operation it performs) Complete Example :Tst_ejb_session_v2.rar

Different server config file:1). For glassfish Server- file name is sun-ejb-jar.xml. 2). For weblogic Server-file name is weblogic-ejb-jar.xml. 3). For websphere Server- ibm-ejb-jar-bnd.xmi,ibm-ejb-jar-ext.xml,ibm-ejb-accessbean.xml

Arguments and returen type of remote method 1) 2) 3) 4) Primitive. Serializable. Remote. Array or collection of serializable or remote.

Note: wheather to pass serialize object or stubs of remote object is a critical decision? 1) If object is passed as an argument or return value ,the object is send as a serialize copy ,then de serialize on the remote objects local heap.

2) If remote object is send as argument or return value the object is send as stub.

You might also like