Session beans are used to group business methods for certain applications.
<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>registration</ejb-name>
<ejb-class>example.RegistrationBean</ejb-class>
<local-home>example.RegistrationHome</local-home>
<local>example.Registration</local>
...
</session>
</enterprise-beans>
</ejb-jar>
|
| ejb-class | Defines the bean's implementation class |
| ejb-name | The name of the bean |
| home | Defines the remote home interface of the bean |
| local | Defines the local interface for bean instances |
| local-home | Defines the local interface of the bean factory |
| remote | Defines the remote interface of the bean |
| session-type | Specifies whether the session is Stateful or Stateless |
| transaction-type | Specifies whether the transaction is handled by the Container
or the Bean |
| Session Bean Configuration |
ejb-class
Defines the bean's implementation class.
Each session bean must specify an implementation class
which implements the bean's methods. CMP session beans will leave
the container-managed fields abstract, while session beans and
CMP session beans must define all methods.
<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>students</ejb-name>
<ejb-class>example.StudentBean</ejb-class>
<local-home>example.StudentHome</local-home>
<local>example.Student</local>
...
</session>
</enterprise-beans>
</ejb-jar>
|
ejb-name
The name of the bean. The value of ejb-name is used to find
the bean in JNDI and as the default schema name for CMP beans.
home
Defines the remote home interface of the bean.
The remote home lets clients on different machines use the bean,
using some remote protocol like Burlap, Hessian, or CORBA/IIOP.
Beans may have both a local home and a remote home and the home
methods may expose different methods.
The remote home contains factory methods like find and
create and also global bean methods which do not depend on the
bean instance.
The remote home interface must extend javax.ejb.EJBHome.
<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>students</ejb-name>
<home>example.StudentRemoteHome</home>
<remote>example.StudentRemote</remote>
<local-home>example.StudentHome</local-home>
<local>example.StudentRemote</local>
...
</session>
</enterprise-beans>
</ejb-jar>
|
local
Defines the local interface for bean instances. Clients within the
same JVM use the local interface to call bean methods.
The local interface must extend javax.ejb.EJBLocalObject.
Session beans using container managed persistence (CMP) must define
a local interface. For BMP (bean managed persistence) beans, the
local interface is optional.
<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>students</ejb-name>
<ejb-class>example.StudentBean</ejb-class>
<local-home>example.StudentHome</local-home>
<local>example.Student</local>
...
</session>
</enterprise-beans>
</ejb-jar>
|
local-home
Defines the local interface of the bean factory. Clients within the
same JVM use the local home to call bean factory methods.
The local home interface must extend javax.ejb.EJBLocalHome.
Session beans using container managed persistence (CMP) must define
a local interface. For BMP (bean managed persistence) beans, the
local interface is optional.
<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>students</ejb-name>
<local-home>example.StudentHome</local-home>
<local>example.Student</local>
...
</session>
</enterprise-beans>
</ejb-jar>
|
remote
Defines the remote interface of the bean. The remote interface will
extend javax.ejb.EJBObject. Clients from different web-apps or even different
servers may use the remote interface.
<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>students</ejb-name>
<ejb-class>example.StudentBean</ejb-class>
<home>example.StudentRemoteHome</home>
<remote>example.StudentRemote</remote>
...
</;session>
</;enterprise-beans>
</;ejb-jar>
|
session-type
Specifies whether the session is Stateful or Stateless.
- Stateful session beans maintain state across several client requests.
- Stateless session beans only maintain state for a single request.
Users of stateless session beans may consider using entity home methods
as a simpler solution than stateless session beans.
transaction-type
Specifies whether the transaction is handled by the Container
or the Bean.
Copyright © 1998-2006 Caucho Technology, Inc. All rights reserved.
Resin® is a registered trademark,
and HardCoretm and Quercustm are trademarks of Caucho Technology, Inc. | ![]() |
|