# JOnAS Specificity

## Target Audience, Goals and Content

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:

1. Target Audience, Goals and Content
2. Configuration of DataSource Objects
3. JOnAS Specific Deployment Descriptor
4. isModified Optimization for Container-managed Entity Beans
5. Passivation Timeout for Entity Beans
6. Getting a UserTransaction object from a non-EJB client
7. Container Optimizations for Entity Beans

## Configuration of DataSource Objects

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

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.

## isModified Optimization for Container-managed Entity Beans

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.

## Passivation Timeout for Entity Beans

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:

1. When the bean is unloaded from the server, at least when the server is stopped
2. When a transaction is started on this instance
3. 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.

## Getting a UserTransaction object from a non-EJB client

This is specified in the Starting Transactions from the Client Side Howto Guide.

## Container Optimizations for Entity Beans

Such optimizations are described in the Developing Entity Beans chapter of the Programmer's Guide (section Tuning Container for Entity Bean Optimizations).