Business Components

oracle.jbo.common.ampool
Class ApplicationPoolImpl

java.lang.Object
  |
  +--oracle.jbo.common.ampool.ApplicationPoolImpl

public class ApplicationPoolImpl
extends java.lang.Object
implements ApplicationPool

This class provides the default implementation of the ApplicationPool interface.
View definition of ApplicationPool
View Implementation of ApplicationPoolImpl


Field Summary
static int CREATION_POLICY_ROUND_ROBIN
           
static int CREATION_POLICY_SERIAL
           
static int MAX_HANDLE_POLICY_ERROR
           
static int MAX_HANDLE_POLICY_SPILL
           
 
Constructor Summary
ApplicationPoolImpl()
          Constructor
 
Method Summary
 void checkin(ApplicationModule appModule)
          Checks in an application instance that had previously been checked out.
 java.lang.String checkinWithSessionState(ApplicationModule appModule)
          Check in and retain the state of the specified application module.
 ApplicationModule checkout()
          Checks out an application instance from the pool.
 ApplicationModule checkout(java.lang.String sessionId)
          Returns an application module for the specified session id.
 void commitAndSyncCache(ApplicationModule instance)
          Given an intitial Application Module instance, synchronizes the caches of all Application Module instances in the pool.
protected  void connect(ApplicationModule appModule)
          Establish the inital application module JDBC connection.
 ApplicationModule createNewInstance()
          Creates a new instance of an application without looking for an available instance in the pool.
protected  void disconnect(ApplicationModule appModule, boolean retainState)
          Disconnect an application module from its JDBC connection.
 java.lang.String getApplicationModuleClass()
          Return the class name of the application modules being managed by the pool.
 int getAvailableNumPools()
          Gets the snapshot of available number of pools returns number of available pools
 java.lang.String getConnectString()
          Return the connect string of the application modules being managed by the application pool.
 long getCreationTimeMillis(ApplicationModule instance)
          Gets the time when the app module was created (in milli-secs).
 java.util.Hashtable getEnvironment()
          Returns the Hashtable that was used to initialie the Contect for the application modules.
 ApplicationModule getInstance(int nIndex)
          Returns the application instance represented by the instance index.
 int getInstanceCount()
          Returns the number of instances that the Application Pool has created.
 java.lang.String getPassword()
          returns the password
 java.lang.String getPoolName()
          Returns the pool's name.
 long getTimeToCreateMillis(ApplicationModule instance)
          Gets the time that it will tke to create the application module (in milli-secs).
 java.util.Hashtable getUserData()
          returns the User Data hashtable.
 java.lang.String getUserName()
          returns the user name
 void initialize(java.lang.String sPoolName, java.lang.String sApplicationModule, java.lang.String sConnectString, java.util.Hashtable env)
          This initializes the ApplicationPool.
 boolean isAvailable(ApplicationModule instance)
          Indicates whether this application module is available.
protected  void reconnect(ApplicationModule appModule)
          Re-establish an application module's JDBC connection.
protected  void releaseInstance(ApplicationModule instance)
           
 void releaseInstances()
          Causes the pool to release all the application isntances that have been created so far.
 void setAvailable(ApplicationModule instance, boolean bSet)
          Sets the instance to available or not
 void setPassword(java.lang.String sPassword)
           
 void setUserData(java.util.Hashtable data)
          Replaces the userData with the new Hashtable.
 void setUserName(java.lang.String sUser)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CREATION_POLICY_SERIAL

public static int CREATION_POLICY_SERIAL

CREATION_POLICY_ROUND_ROBIN

public static int CREATION_POLICY_ROUND_ROBIN

MAX_HANDLE_POLICY_SPILL

public static int MAX_HANDLE_POLICY_SPILL

MAX_HANDLE_POLICY_ERROR

public static int MAX_HANDLE_POLICY_ERROR
Constructor Detail

ApplicationPoolImpl

public ApplicationPoolImpl()
Constructor
Method Detail

initialize

public void initialize(java.lang.String sPoolName,
                       java.lang.String sApplicationModule,
                       java.lang.String sConnectString,
                       java.util.Hashtable env)
Description copied from interface: ApplicationPool
This initializes the ApplicationPool. The Pool name should be unique with respect to any other pools. An exception will be thrown on any errors such as duplicate pool name or mismatched information within the connectInfo parameter. Take a close look at the ConnectionInfo documentation since it controls the key information for initializing the application pool.
Specified by:
initialize in interface ApplicationPool
Tags copied from interface: ApplicationPool
Parameters:
sPoolName - the name of the application module pool.
sApplicationModule - name of the application module for which the pool will be created.
sConnectString - the connection string to use to connect to the database.
env - name of the hash table containing the environment variables for the selected platform.

getApplicationModuleClass

public java.lang.String getApplicationModuleClass()
Description copied from interface: ApplicationPool
Return the class name of the application modules being managed by the pool.
Specified by:
getApplicationModuleClass in interface ApplicationPool

getConnectString

public java.lang.String getConnectString()
Description copied from interface: ApplicationPool
Return the connect string of the application modules being managed by the application pool.
Specified by:
getConnectString in interface ApplicationPool

getEnvironment

public java.util.Hashtable getEnvironment()
Description copied from interface: ApplicationPool
Returns the Hashtable that was used to initialie the Contect for the application modules.
Specified by:
getEnvironment in interface ApplicationPool

checkin

public void checkin(ApplicationModule appModule)
Description copied from interface: ApplicationPool
Checks in an application instance that had previously been checked out. This makes the application instance avalable for subsequent checkout requests from this pool.
Specified by:
checkin in interface ApplicationPool
Tags copied from interface: ApplicationPool
Parameters:
instance - name of the application module instance to check in.

checkinWithSessionState

public java.lang.String checkinWithSessionState(ApplicationModule appModule)
Check in and retain the state of the specified application module. This method generates a cookie for the application module that can be used as a unique identifier for the application module's session state. Check-in with session state will also disconnect the application module's JDBC connection and return the JDBC connection to the JDBC connection pool for reuse. Consequently, when using this method there must not be any database state that must be saved across sessions. Examples of database state include pessimistic locks, open cursors, or posted but uncommited changes. If any database state must be saved between requests checkinWithSessionState should not be used. Instead the application module reference should be maintained by the client until the database state has been committed/rolled back.
Specified by:
checkinWithSessionState in interface ApplicationPool
Parameters:
doFailover - If true, the application module will be passivated immediately and the application passivation id will be returned with the session id. If false, the application module will not be passivated until it is reused by a session other than the session that has checked in the application module.

getTimeToCreateMillis

public long getTimeToCreateMillis(ApplicationModule instance)
Description copied from interface: ApplicationPool
Gets the time that it will tke to create the application module (in milli-secs).
Specified by:
getTimeToCreateMillis in interface ApplicationPool
Tags copied from interface: ApplicationPool
Parameters:
instance - the application module instance for which you want to know how long it will take to create it.

getCreationTimeMillis

public long getCreationTimeMillis(ApplicationModule instance)
Description copied from interface: ApplicationPool
Gets the time when the app module was created (in milli-secs).
Specified by:
getCreationTimeMillis in interface ApplicationPool
Tags copied from interface: ApplicationPool
Parameters:
instance - the application module instance for which you want to know the time of creation.

isAvailable

public boolean isAvailable(ApplicationModule instance)
Description copied from interface: ApplicationPool
Indicates whether this application module is available.
Specified by:
isAvailable in interface ApplicationPool
Tags copied from interface: ApplicationPool
Parameters:
instance - the application module instance that you want to test for availability.
Returns:
true if the application module is available; false otherwise.

setAvailable

public void setAvailable(ApplicationModule instance,
                         boolean bSet)
Description copied from interface: ApplicationPool
Sets the instance to available or not
Specified by:
setAvailable in interface ApplicationPool

createNewInstance

public ApplicationModule createNewInstance()
                                    throws java.lang.Exception
Description copied from interface: ApplicationPool
Creates a new instance of an application without looking for an available instance in the pool. This method should not be called directly, you should call ApplicationPool.checkout() instead.
Specified by:
createNewInstance in interface ApplicationPool

checkout

public ApplicationModule checkout()
                           throws java.lang.Exception
Description copied from interface: ApplicationPool
Checks out an application instance from the pool. If the pool doesn't have any available instances, it will create a new instance and return it to the caller.
Specified by:
checkout in interface ApplicationPool

releaseInstances

public void releaseInstances()
Description copied from interface: ApplicationPool
Causes the pool to release all the application isntances that have been created so far. The remove() method is called on the Application Modules being represented by the application instance class
Specified by:
releaseInstances in interface ApplicationPool

releaseInstance

protected void releaseInstance(ApplicationModule instance)

getAvailableNumPools

public int getAvailableNumPools()
Description copied from interface: ApplicationPool
Gets the snapshot of available number of pools returns number of available pools
Specified by:
getAvailableNumPools in interface ApplicationPool

getInstanceCount

public int getInstanceCount()
Description copied from interface: ApplicationPool
Returns the number of instances that the Application Pool has created.
Specified by:
getInstanceCount in interface ApplicationPool

getInstance

public ApplicationModule getInstance(int nIndex)
Description copied from interface: ApplicationPool
Returns the application instance represented by the instance index.
Specified by:
getInstance in interface ApplicationPool
Tags copied from interface: ApplicationPool
Parameters:
nIndex - the index of the application instance.

checkout

public ApplicationModule checkout(java.lang.String sessionId)
Description copied from interface: ApplicationPool
Returns an application module for the specified session id. The session id must have been generated by a previous call to ApplicationPool.checkinWithSessionState(ApplicationModule) against this application module pool.

The session id will be used to obtain an application module with the same state as the application module that had been returned by the session with checkinWithSessionState.

If an unrecognized session id is specified than the implementation returns an empty application module.

Specified by:
checkout in interface ApplicationPool
Tags copied from interface: ApplicationPool
Parameters:
sessionId - the name of the session ID for which you want to return the associated application module.

getPoolName

public java.lang.String getPoolName()
Description copied from interface: ApplicationPool
Returns the pool's name.
Specified by:
getPoolName in interface ApplicationPool

getUserData

public java.util.Hashtable getUserData()
returns the User Data hashtable. This is a generic container for any settings the user would like to associate with this application instance.
Specified by:
getUserData in interface ApplicationPool

setUserData

public void setUserData(java.util.Hashtable data)
Replaces the userData with the new Hashtable.
Specified by:
setUserData in interface ApplicationPool
Tags copied from interface: ApplicationPool
Parameters:
the - new hashtable to use for the environment information.

getUserName

public java.lang.String getUserName()
returns the user name
Specified by:
getUserName in interface ApplicationPool

setUserName

public void setUserName(java.lang.String sUser)
Specified by:
setUserName in interface ApplicationPool

setPassword

public void setPassword(java.lang.String sPassword)
Specified by:
setPassword in interface ApplicationPool

getPassword

public java.lang.String getPassword()
returns the password
Specified by:
getPassword in interface ApplicationPool

commitAndSyncCache

public void commitAndSyncCache(ApplicationModule instance)
Description copied from interface: ApplicationPool
Given an intitial Application Module instance, synchronizes the caches of all Application Module instances in the pool.

This method commits the transaction for instance. Then, it loops through all other instances of the Application Module in the pool and synchronizes their caches with the changes committed by instance. For example:

  // Insert a new row
     row = voEmp1.createRow();

     row.setAttribute("EmpNum", new Integer(9999));
     row.setAttribute("EmpName", "NewPers");
     row.setAttribute("EmpJob", "JOBX");

     voEmp1.insertRow(row);

  // Commit the changes for the specified instance, then sync 
  // them with the rest of the Application Module instances.
     pool1.commitAndSyncCache(am1);
 

Specified by:
commitAndSyncCache in interface ApplicationPool
Tags copied from interface: ApplicationPool
Parameters:
instance - an instance of an Application Module in the pool.

connect

protected void connect(ApplicationModule appModule)
Establish the inital application module JDBC connection. This method is invoked by the application module pool when new application module instances are instantiated. Application developers who would like to plug a custom connection framework into the application module pool may override this method.

reconnect

protected void reconnect(ApplicationModule appModule)
Re-establish an application module's JDBC connection. This method is invoked by the application module pool when an application module instance is recycled by the pool. Application developers who would like to plug a custom connection framework into the application module pool may override this method.

disconnect

protected void disconnect(ApplicationModule appModule,
                          boolean retainState)
Disconnect an application module from its JDBC connection. This method is invoked by the application module pool when an application module instance is checked into the pool. The method checks the application property jbo.doconnectionpooling before disconnecting the application module. Application developers who would like to plug a custom connection framework into the application module pool may override this method.
Parameters:
retainState - Indicates whether the state of the application module's caches should be retained while disconnecting. If true, the application module's Transaction should have not database state.

Business Components