JOnAS Specificity
The target audience for this guide is the Enterprise Bean provider, i.e.
the person in charge of developing the software components on the server
side. This section lists the different aspects in the Enterprise Bean development
cycle which are specific to JOnAS, since they are not defined in the EJB
specification.
The content of this guide is the following:
- Target Audience, Goals and Content
- Configuration of DataSource Objects
- JOnAS Specific Deployment Descriptor
- isModified Optimization for Container-managed Entity Beans
- Passivation Timeout for Entity Beans
- Getting a UserTransaction object from a non-EJB client
- Container Optimizations for Entity Beans
Definition and configuration of the DataSource objects available on the
EJB platform are specific to JOnAS. See section "
Configuring JDBC DataSources".
JOnAS specific deployment descriptor contains information assigned
by the deployer:
- the JNDI name assigned to the enterprise bean home
- the JNDI names of the referenced resources
- the JNDI names of JMS administered objects
- the JNDI names of the referenced EJBs
- the database mapping information in case of container-managed persistence
See the section about Deployment Descriptor for details.
In order to improve performance JOnAS implements the isModified extension.
Before performing an update the container will call a method of the bean
whose name is indicated in the is-modified-method-name element of the JOnAS specific
deployment descriptor. This method is responsible to tell if the state
of the bean has been changed. Doing so, the container is able to know if it must
store data in the database or if it's useless.
Example
The bean implementation manages a boolean isDirty and implements
a method that returns the value of this boolean: isModified
private transient boolean isDirty;
public boolean isModified() {
return isDirty;
}
The JOnAS specific deployment descriptor indicates that the bean implements
an isModified method:
<jonas-entity>
<ejb-name>Item</ejb-name>
<is-modified-method-name>isModified</is-modified-method-name>
.....
</jonas-entity>
Methods that modify the value of the bean need to set the flag isDirty to
true.
Methods that restore the value of the bean from the database need to reset
the flag isDirty to false. So, be sure to set the flag to false
in ejbLoad() and ejbStore() methods.
Entity bean instances are passivated at the end of the transaction, and reactivacted at
the beginning of the next transaction.
In case these instances are accessed outside
any transaction, their state is kept in memory to improve performances. However a passivation
will occur in 3 circumstances:
- When the bean is unloaded from the server, at least when the server is stopped
- When a transaction is started on this instance
- After a configurable timeout. This may be interesting to be sure that the bean state
is periodically stored on disk, if the bean is always accessed with no transaction.
This passivation timeout can be configured in the jonas specific deployment descriptor,
with a non mandatory tag <passivation-timeout>.
Example:
<jonas-entity>
<ejb-name>Item</ejb-name>
<passivation-timeout>5</passivation-timeout>
.....
</jonas-entity>
This entity bean will be passivated every 5 second, if not accessed within transactions.
This is specified in the Starting Transactions from the Client Side
Howto Guide.
Such optimizations are described in the
Developing Entity Beans chapter of the Programmer's
Guide (section Tuning Container for Entity Bean Optimizations).