Monday, 22 April 2013

Application Module Basics

Application Module:
The interface for Application Modules. An Application Module is a logical container for coordinated objects related to a particular task with optional programming logic.

Root Application Module and Nested Application Module:
An Application Module may be a root Application Module or a nested Application Module.
A root Application Module is not contained in another Application Module. It provides transaction context for all objects contained in it. It may optionally contain nested Application Modules. A root Application Module is created through JDNI calls. See below for details.

A nested Application Module is contained in another Application Module. The containing Application Module is referred to as the parent Application Module. If one traverses this containership ancestry, one will eventually find the root Application Module (which does not have a parent Application Module). A nested Application Module uses the transaction context provided by the root Application Module. Thus, data modifications performed in Application Modules parented by one root Application Module will commit or rollback together.

Transaction:
Associated with the root Application Module is the Transaction object, which provides this transaction context. From any (root or nested) Application Module, the user can retrieve the transaction object through a call to getTransaction(). In reality, getTransaction() first locates the root Application Module and then returns the transaction object from it.

The Transaction object manages connection to database and Entity caches. Thus, changes made through one View Object are visible to other View Objects as long as these View Objects all parented by the one root Application Module. In contrast, if two View Objects are parented by two separate root Application Modules, then changes made through the View Object will not be seen by the second View Object until the changes are committed to database through the first root Application Module and the second VO executes query (to retrieve the most up-to-date data from database).

Creating Application Module
A root Application Module is created by:

Finding the Application Module home through JNDI.
Calling create() on the Application Module home.
Here is a sample code to create a root Application Module:

java.util.Hashtable env = new java.util.Hashtable();

// Add environment entries into env...

javax.naming.Context ic = new InitialContext(env);

// 'defName' is the JNDI name for the Application Module
// definition from which the root Application Module is to
// be created
String defName = ...;

oracle.jbo.ApplicationModuleHome home = ic.lookup(defName);
oracle.jbo.ApplicationModule am = home.create();


One creates a nested Application Module by calling createApplicationModule on the parent Application Module.

Application Module definitions are managed by oracle.jbo.server.MetaObjectManager. One can find a specific definition object by issuing:

String defName = ...;
oracle.jbo.server.ApplicationModuleDefImpl def;

def = oracle.jbo.server.ApplicationModuleDefImpl.findDefObject(defName);

No comments:

Post a Comment