您的位置:首页 >> 编程开发 >> Java >> J2EE >> 正文
RSS
 

J2EE FAQ @ JDJ

http://www.rdxx.com 05年08月10日 20:34 Java频道 我要投稿

关键词: JDJ , J2EE , FAQ

Q.  What is EJB 2.0?

A. EJB 2.0 is the latest release of the Enterprise JavaBeanspecification.  The major releases of the EJB specification have been1.0, 1,1, and 2.0.  EJB 2.0 adds several crucial features to version 1.1,including message-driven beans, local interfaces, an enhanced xontainer-managedpersistence, and EJB-QL (Query Language).


Q. What are the Main Interfaces in EJB 2.0?

A. The figure below illustrates the class hierarchy for EJB 2.0 and the interfacesthat are included. The main interfaces for EJBs are packaged under javax.ejb;they’re standard extensions to the core Java classes.

The javax.ejb package defines the interfaces you need to extend your application’s components. By definition, Enterprise JavaBean is a specification for distributed architecture. In Java terms, this means that a Java class running in one JVM should be able to communicate with an EJB component in another via an RMI call. First, let’s look at the EJBObject and EJBHome interfaces, which are shown in the middle pane of the figure. These interfaces extend the java.rmi.Remote interface. The Remote interface serves to identify interfaces whose methods may be invoked from a nonlocal virtual machine. Any object that’sa remote object must implement this interface.

As you probably know, EJBs can only run inside a J2EE EJB container. The container abstracts many of the low-level services from the application developer (you). One set of services that it abstracts is the life-cycle managementof the EJBs. The EJBHome interface is used to create this abstraction andcan be accessed remotely to create or find the actual EJB component. Themethods are invoked by the remote client, but are executed by the container.

The EJBObject interface is used to define the business methods for your EJB component. The interface defines methods to access the actual EJB class and to remove it when it’s no longer needed. The EJBObject is a delegator interface that delegates the actual execution of the business objects to theenterprise bean.

The latest release of the EJB specification adds classes and interfaces to support the concept of colocated EJBs (local interfaces). As you can seein the left pane of the figure, the local interfaces (EJBLocalObject andEJBLocalHome) don’t extend the java.rmi.Remote interface. You can’t use themto access distributed objects. The local interfaces were added to the EJBspecification in 2.0 so that component accesses to EJB components within thesame JVM don’t have to be done through RMI, which is very expensive since each call requires a distributed call.

The enterprise bean interfaces are illustrated on the left side of the figure. These interfaces were added to the EJB specification in 2.0. Local interfaces support the concept of colocated EJBs (local interfaces). The localinterfaces (EJBLocalObject and EJBLocalHome) don’t extend the java.rmi.Remote interface so you can’t use them to access distributed objects. Other than that, the EJBLocalObject is the equivalent of the EJBObject, and the EJBLocalHome is the equivalent of EJBHome. Note that the same EJB component can implement both interfaces simultaneously, thus allowing remote access through RMI and local access through a local method call.

共2页  1 2

 
 
标签: JDJ , J2EE , FAQ 打印本文
 
 
  热点搜索
 
 
 



Valid XHTML 1.0 Transitional
Copyright ©2005 - 2008 Rdxx.Com,All Rights Reserved
收藏本页
收藏本站