Session Bean Configuration
Resin 2.1

Reference Guide
EJB Reference Guide

EJBServer
JNDI
Entity Config
Relation Config
Session Config
Resin-EJB Config
SQL mapping
Transaction Config
Message Config
EJB-QL
xdoclet
Config Summary
Burlap
JMS
CORBA/IIOP
Index
Relation Config
EJB Reference Guide
Resin-EJB Config

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-classDefines the bean's implementation class
ejb-nameThe name of the bean
homeDefines the remote home interface of the bean
localDefines the local interface for bean instances
local-homeDefines the local interface of the bean factory
remoteDefines the remote interface of the bean
session-typeSpecifies whether the session is Stateful or Stateless
transaction-typeSpecifies 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.

Formal Definition

session ::= (ejb-name,
             home?,
             remote?,
             local-home?,
             local?,
             ejb-class,
             session-type,
             transaction)


Relation Config
EJB Reference Guide
Resin-EJB Config
Copyright © 1998-2006 Caucho Technology, Inc. All rights reserved.
Resin® is a registered trademark, and HardCoretm and Quercustm are trademarks of Caucho Technology, Inc.