EJB Module

EJB Module

The EJB Module generates either remote or local EJB Objects, EJB Homes and EJB Sessions for every bean. It also creates an Entity Beans and Session Beans for each bean.

The EJB Object provides bean level services for the EntityBean. The EJBObject, EJBObjectHome and EntityBean handle all the create, store, remove, load and find methods. The EJBObject and Entity bean can be (optionally) optimized in a number of ways (see the EJB properties below).

The EJB Session provides business level services for the Entity Bean. The EJBSession, EJBSessionHome and SessionBean handle all the count methods and all the business level bean methods.

The EJB Module contains the following classes: -

  • com.javelin.generator.ejb.EJBObjectInterfaceWriter
  • com.javelin.generator.ejb.EJBHomeInterfaceWriter
  • com.javelin.generator.ejb.EJBSessionInterfaceWriter
  • com.javelin.generator.ejb.EJBHomeSessionInterfaceWriter
  • com.javelin.generator.ejb.EntityBeanClassWriter
  • com.javelin.generator.ejb.SessionBeanClassWriter
  • com.javelin.generator.ejb.EJBDeploymentDescriptorWriter

In order to use the EJB module you need to include the following writer:

$GENERATOR.AggregateWriter ejb

Class Hierarchy

The top-level EJB Writer class hierarchy is illustrated below: -

EJB Properties

One or all beans can be defined at reentrant by using the following property: -

[<ClassName>.]ejb.beanReentrant=true|false

One or all Entity Beans can be defined as Container or Bean managed by using the following property: -

[<ClassName>.]ejb.persistenceType=Container|Bean

One or all Session Beans can be defined as Stateful or Stateless by using the following property: -

[<ClassName>.]ejb.sessionType=Stateful|Stateless

The EJB Version can be set to 2.0 or 1.1. It currently defaults to 2.0. This will effect the dtds that are used.

ejb.version=2.0

EJB Optimization

The EJB Beans can be optimized in a number of ways.

To make a Bean local use the following syntax: -

[<ClassName>.]ejb.local=true|false

By default ejb.local is set to false: -

ejb.local=false

To make just the Address and Person bean local do the following: -

Address.ejb.local=true
Person.ejb.local=true

One way to optimize beans is to serialize the EntityBean. When an EJB Object is loaded the EntityBean is serialized from the server. When a EJB Object is stored the Entity Bean is serialized to the server. Remember that under normal conditions the EJB Bean is hidden under the CJB Bean facades meaning that this serialization optimization is completely transparent to the user.

To use this form of serialization use the following syntax: -

[<ClassName>.]ejb.remoteMethod=EntityBean|Default

By default ejb.remoteMethod is set so that every property is accessed independently.

ejb.remoteMethod=Default

For example to switch on remoteMethod optimization for all the beans except the Address bean do the following: -

ejb.remoteMethod=EntityBean
Address.ejb.remoteMethod=Default

To switch on remoteMethod optimization for the Address and Person bean do the following: -

Person.ejb.remoteMethod=EntityBean
Address.ejb.remoteMethod=EntityBean

Abstract EJB Writer (com.javelin.generator.ejb.AbstractEJBWriter)

The AbstractEJBWriter is a super class that all EJB writers extend.

The AbstractEJBWriter has the following methods: -

  • public String getEJBObjectName()
  • public String getEJBObjectHomeName()
  • public String getEJBObjectHomeJndiName()
  • public String getEntityBeanName()
  • public String getEJBSessionName()
  • public String getEJBSessionHomeName()
  • public String getEJBSessionHomeJndiName()
  • public String getSessionBeanName()
  • public boolean isBeanReentrant( String tableName )
  • public boolean isBeanManaged( String tableName )
  • public boolean isContainerManaged( String tableName )
  • public boolean isSessionStateful( String tableName )
  • public String getEarName()
  • public String getWebXml()
  • public String getWarName()
  • public String getEjbJarName()
  • public String getEjbJarDescriptor()
  • public String getEJBJarXML()
  • public String getClientJarName()
  • public String getClientJarXML()
  • public String getEjbJdbcJndiName()
  • public String getEjbJdbcResRefName()
  • public boolean isLocal()
  • public String getEJBRemoteMethod()

EJB Object Interface Writer (com.javelin.generator.ejb.EJBObjectInterfaceWriter)

The EJBObjectInterfaceWriter is responsible for writing the EJBObject or EJBLocalObject interface.

By default the classes generated have the name and pattern: -

$EJBENTITYOBJECT=public interface $PACKAGE.ejb.$THIS extends $EJBPACKAGE.EJBObject

EJB Object Home Interface Writer (com.javelin.generator.ejb.EJBObjectHomeInterfaceWriter)

The EJBObjectHomeInterfaceWriter is responsible for writing the EJBHome or EJBLocalHome interfaces for EJBObjects/

By default the classes generated have the name and pattern: -

$EJBENTITYHOME=public interface $PACKAGE.ejb.$THIS extends $EJBPACKAGE.EJBHome

EJB Session Interface Writer (com.javelin.generator.ejb.EJBSessionInterfaceWriter)

The EJBSessionInterfaceWriter is responsible for writing the EJBSession or EJBLocalSession interface.

By default the classes generated have the name and pattern: -

$EJBSESSIONOBJECT=public interface $PACKAGE.ejb.$THIS extends $EJBPACKAGE.EJBObject

EJB Session Home Interface Writer (com.javelin.generator.ejb.EJBSessionHomeWriter)

The EJBSessionHomeInterfaceWriter is responsible for writing the EJBHome or EJBLocalHome interfaces for EJBSessions.

By default the classes generated have the name and pattern: -

$EJBSESSIONHOME=public interface $PACKAGE.ejb.$THIS extends $EJBPACKAGE.EJBHome

Entity Bean Class Writer (com.javelin.generator.ejb.EJBBeanClassWriter)

The EntityBeanClassWriter is responsible for writing the EntityBeans.

By default the classes generated have the name and pattern: -

$EJBENTITYBEAN=public class $PACKAGE.ejb.$THIS extends $BEANS.ejb.AbstractEntityBean

Session Bean Class Writer (com.javelin.generator.ejb.SessionBeanWriter)

The SessionBeanClassWriter is responsible for writing the SessionBeans.

By default the classes generated have the name and pattern: -

$EJBSESSIONBEAN=public class $PACKAGE.ejb.$THIS extends $BEANS.ejb.AbstractSessionBean

EJB Deployment Descriptor Writer (com.javelin.generator.ejb.EJBDeploymentDescriptorWriter)

The EJBDeployment Descriptor Writer writes standard ejbxml descriptor files for the the beans.

By default the ejb descriptor is created with the name: -

<ejbPath>/META-INF/ejb-jar.xml