JOnAS Specificity
Target Audience, Goals, and Content
The target audience for this guide is the Application provider, i.e. the
person in charge of developing the software components on the server side.
This section discusses the various JOnAS-specific elements in the development
cycle of the Application, Enterprise Bean, and web component that are not
defined in the J2EE, EJB, or Servlet/JSP 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
Configuration of DataSource Objects
Definition and configuration of the DataSource objects available on the
application server are specific to JOnAS. Refer to the section "Configuring JDBC DataSources."
JOnAS-Specific Deployment Descriptor
A JOnAS-specific deployment descriptor contains information assigned by the
deployer.
- For Enterprise Java Beans
- 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 for container-managed
persistence
- refer to the section "EJB Deployment
Descriptor" for details
- For Web components
- the JNDI name of the external resources referenced by a web
component
- the JNDI name of the external resources environment referenced by a
web component
- the JNDI name of the beans referenced by a web component
- the name of the virtual host on which to deploy the servlets
- the name of the context root on which to deploy the servlets
- refer to the section "WAR
Deployment Descriptor" for details
- For Application ARchive (EAR)
isModified Optimization for Container-managed
Entity Beans
To improve performance, JOnAS implements the isModified extension. Before
performing an update, the container calls a method of the bean whose name is
identified in the is-modified-method-name element of the
JOnAS-specific deployment descriptor. This method is responsible for
determining if the state of the bean has been changed. By doing this, the
container determines if it must store data in the database or not.
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 directs the bean to implement 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 must set the flag
isDirty to true.
Methods that restore the value of the bean from the database must reset the
flag isDirty to false. Therefore, the flag must be set to
false in the ejbLoad() and ejbStore() methods.
Passivation Timeout for Entity Beans
Entity bean instances are passivated at the end of the transaction and
reactivated at the beginning of the next transaction. In the event that these
instances are accessed outside a transaction, their state is kept in memory
to improve performance. However, a passivation will occur in three situations:
- When the bean is unloaded from the server, at a minimum when the server
is stopped.
- When a transaction is started on this instance.
- After a configurable timeout. If the bean is always accessed with no
transaction, it may be prudent to periodically store the bean state on
disk.
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 five second, if not accessed within
transactions.
Getting a UserTransaction object from a non-EJB
client
This information is specified in the Starting
Transactions from the Client Side Howto Guide.
Container Optimizations for Entity Beans
These types of optimizations are described in the Developing Entity Beans chapter of the
Programmer's Guide (section "Tuning Container for Entity Bean
Optimization").