Java Reference
In-Depth Information
} catch (Exception e) {
In EJB 3.0, a reference to a resource may be obtained with a dependency injection
with the @EJB annotation. JNDI lookup and create() method invocation is not
required in EJB 3.0. The client class for the EJB 3.0 session bean is listed next:
public class CatalogClient {
CatalogBean catalogBean;
String publisher="OReilly";
String journal=catalogBean.getJournal(publisher);
System.out.println("Journal for Publisher: "+publisher +"
Simplified entity beans
An EJB 2.x Entity EJB bean class must implement the javax.ejb.
EntityBean interface, which defines callback methods setEntityContext ,
unsetEntityContext , ejbActivate , ejbPassivate , ejbLoad , ejbStore , and
ejbRemove that are called by the EJB container. An EJB 2.x provides implementation
for the callback methods in the interface. An EJB 2.x entity bean also includes the
ejbCreate and ejbPostCreate callback methods corresponding to one create
method in the home interface. An EJB 2.x entity bean's component and home
interfaces extend the EJBObject/EJBLocalObject and EJBHome/EJBLocalHome
interfaces respectively. In comparison, an EJB 3.0 entity bean class is a POJO
which does not implement the EntityBean interface. The callback methods
are not implemented in the EJB 3.0 entity bean class. Also, the component and
home interfaces and deployment descriptors are not required in EJB 3.0. The EJB
configuration information is included in the Entity bean POJO class using metadata
annotations. An EJB 2.1 entity bean also consists of getter/setter CMP ( Container
Managed Persistence ) field methods, and getter/setter CMR ( Container Managed
Relationships ) field methods. An EJB 2.x entity bean also defines finder and
ejbSelect methods in the home/local home interfaces for EJB-QL queries. An
example EJB 2.x entity bean is listed next:
import javax.ejb.EntityBean;
import javax.ejb.EntityContext;
public class CatalogBean implements EntityBean {
Search WWH ::

Custom Search