# 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 lists the different aspects in the Application, Enterprise Bean and web componenents development cycles which are specific to JOnAS, since they are not defined in the J2EE, EJB or Servlet/JSP 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 application server are specific to JOnAS. See section " Configuring JDBC DataSources".

## JOnAS Specific Deployment Descriptor

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 in case of container-managed persistence
  - see the section about 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 referenced bean's 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
  - see the section about WAR Deployment Descriptor for details.
- For Application ARchive (EAR)
  - there is no JOnAS specificity for the EAR
  - see the section about EAR 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).