|
Oracle Fusion Middleware Java API Reference for Oracle ADF Model 11g Release 1 (11.1.1.7.0) E10653-08 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectoracle.jbo.pool.ResourcePool
oracle.jbo.common.ampool.ApplicationPoolImpl
public class ApplicationPoolImpl
This class provides the default implementation of the ApplicationPool interface. A few notes about the locking strategy that has been employed to synchronize access to the shared application module resources in this pool. These notes are provided for the benefit of the application pool developer. They are not required to use the application pool.
The pool utilizes a singleton internal monitor object instance to synchronize read/write access to shared data.
In order to provide high pool availability, only those critical blocks that read/write from the shared data structures have been synchronized. Expensive application module operations like connect/disconnect, activiate/passivate, and rollback are performed outside of the pool lock. In order for this to work the application module is made not available inside of the pool lock before its state is modified. Using this strategy will prevent other sessions from attempting to recycle the application module instance while its state is not consistent.
This strategy of course assumes that application module access from the same session is properly synchronized. Consider the following scenario:
1. Request thread one from session one acquires a pool lock. While holding the lock the request sets the session application module as not available. Request thread one from session one then releases the pool lock and begins modifying the application module state.
2. Request thread two from session one comes along. Before the application module state has been modified by thread one above, request thread two invokes useApplicationModule. Request thread two acquires a pool lock and finds the application module instance associated with the request session (even though the application module is not available). Request thread two happily continues using the application module reference and a possible race condition between request threads one and two has occured.
In order to prevent this scenario, the pool assumes that session cookie access is also properly synchronized. This is indeed the case for the provided implementations of oracle.jbo.common.ampool.SessionCookie.
The discussion above introduces two levels of locking, session locking and pool locking. The pool's locking strategy utilizes the following rules to prevent deadlock:
1. Session locks are never acquired while pool locks are held. Please note that this rule does allow a pool lock to be acquired while a session lock is held. In fact, the pool depends upon this to prevent the race conditions mentioned above.
From an availability standpoint this rule makes sense since the rule implies that pool locks will be held for shorter duration then a session lock. However, because of the two levels of locking the application pool developer must be constantly aware of the potential for deadlock when implementing pool logic. To further understand the above rule consider the following scenario:
1. Request 1 for session 1 has acquired a pool lock without first acquiring a session lock. In the critical section the request updates some shared session state that requires a session lock to be acquired.
2. Concurrently, request 2 for session 1 acquires a session lock. In the critical section the request requires access to some shared application pool state that requires an application pool lock to be acquired.
Obviously, in the scenario above request one may be blocked waiting for the session lock that is held by request two and request two may be blocked waiting for the pool lock that is held by request one; the definition of deadlock.
Most pool methods should be accessed using a session cookie, so that the rule defined above holds true. However, there are some instances where a cookie lock could be acquired after a pool lock has been acquired:
1. When a request from session one recycles an application module that is referenced by session two. If the session two state must be passivated then the request thread from session one must update the passivation id of the session two cookie. This requires the request thread from session one to acquire a session lock for session two. It is safe to assume that a session lock for the session one has already been acquired because request one is an active request that must have accessed the pool using the session cookie API. It is not safe to assume that a session lock for session two has been acquired because the current pool request thread did not originate from session two. Attempting to acquire a session lock for session two while holding a pool lock may cause the deadlock mentioned above. This scenario is avoided by executing the section that requires the session lock for session two after the pool lock has been released.
2. When a referenced application module is removed by the high water mark functionality. This scenario is very similar to the one described in item one above. However, instead of the request thread from session one recycling an application module that is referenced by session two the request thread from session one is discarding the application module that is referenced by session two.
View definition of ApplicationPool
View Implementation of ApplicationPoolImpl
Nested Class Summary |
---|
Nested classes/interfaces inherited from class oracle.jbo.pool.ResourcePool |
---|
ResourcePool.AvailableListSelector |
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
|
Fields inherited from class oracle.jbo.pool.ResourcePool |
---|
MAX_WAIT_TIME, MAX_WEIGHT_DEFAULT, mLock, mLogger, WAIT_TIME_INCREMENT |
Constructor Summary | |
---|---|
ApplicationPoolImpl()
Constructor |
Method Summary | |
---|---|
void |
addSessionCookie(SessionCookie cookie)
Add an existing session cookie to the pool. |
protected void |
beforeResourceFinalized(java.lang.Object resource)
This method is invoked immediately before resource finalization. |
protected boolean |
canAllocateResource(java.lang.Object resource)
Invoked by allocateResource to determine that an existing resource can be allocated to the invoker. |
protected boolean |
canFinalizeResource(java.lang.Object resource)
Invoked by removeResource to determine if the resource can be removed from the pool by the current thread. |
protected boolean |
canRemoveResource(java.lang.Object resource)
Invoked from gc() to ensure that the specified resource may be removed from the ResourcePool. |
void |
checkin(ApplicationModule appModule)
Deprecated. Replaced by: SessionCookie.releaseApplicationModule(int) .
Application developers should invoke:
SessionCookie.releaseApplicationModule(SessionCookie.SHARED_UNMANAGED_RELEASE_MODE)
instead of this method. A session cookie instance may be acquired by
invoking:
This change was necessary to support the SessionCookie interface. Please
see:
|
java.lang.String |
checkinWithSessionState(ApplicationModule appModule)
Deprecated. Replaced by: SessionCookie.releaseApplicationModule(boolean, boolean) .
Application developers should invoke: SessionCookie.releaseApplicationModule(true, true)
instead of this method. A session cookie instance may be acquired by
invoking:
This change was necessary to support the SessionCookie interface. Please
see:
for more information about using SessionCookies with the application pool. |
ApplicationModule |
checkout()
Deprecated. Replaced by: ApplicationModuleRef.useApplicationModule() .
Application developers should invoke: SessionCookie.useApplicationModule()
instead of this method. A session cookie instance may be acquired by
invoking:
This change was necessary to support the SessionCookie interface. Please
see:
|
ApplicationModule |
checkout(java.lang.String cookieValue)
Deprecated. Replaced by: ApplicationModuleRef.useApplicationModule() .
Application developers should invoke: SessionCookie.useApplicationModule()
instead of this method. A session cookie instance may be acquired by
invoking:
This change was necessary to support the SessionCookie interface. Please
see:
for more information about using SessionCookies with the application pool. |
void |
commitAndSyncCache(ApplicationModule instance)
Given an intitial Application Module instance, synchronizes the caches of all Application Module instances in the pool. |
protected boolean |
compareConnectionMetadata(ConnectionMetadata oldConnectionMetadata,
ConnectionMetadata newConnectionMetadata)
Invoked by the application pool implementation when an application module instance is recycled for use by a session different than the session that had previously used that instance. |
protected void |
connect(ApplicationModule appModule,
java.util.Hashtable environment)
Deprecated. Replaced by ConnectionStrategy.connect(ApplicationModule, SessionCookie, EnvInfoProvider) .
All extending logic that was implemented here should be implemented in a
custom ConnectionStrategy class that extends DefaultConnectionStrategy . |
ApplicationModule |
createNewInstance()
Deprecated. Replaced by ConnectionStrategy.createApplicationModule(SessionCookie, EnvInfoProvider) .
All extending logic that was implemented here should be implemented in a
custom ConnectionStrategy class that extends:
DefaultConnectionStrategy .
|
protected ResourcePoolLogger |
createPoolLogger()
|
SessionCookie |
createSessionCookie(java.lang.String applicationId,
java.lang.String sessionId,
java.util.Properties properties)
Create a session cookie for access to this pool. |
protected void |
destroy()
Detroy the resource pool. |
protected void |
disconnect(ApplicationModule appModule,
boolean retainState,
java.util.Hashtable environment)
Deprecated. Replaced by ConnectionStrategy.disconnect(ApplicationModule, boolean, SessionCookie) .
All extending logic that was implemented here should be implemented in a
custom ConnectionStrategy class that extends DefaultConnectionStrategy . |
protected void |
finalizeResource(java.lang.Object resource,
java.lang.Object details)
Invoked during pool high water mark resolution. |
SessionCookie |
findOrCreateSessionCookie(java.lang.String applicationId,
java.lang.String sessionId,
java.util.Properties properties)
Returns the specified session cookie. |
SessionCookie |
findSessionCookie(java.lang.String applicationId,
java.lang.String sessionId)
Returns the specified session cookie. |
AMStatistics[] |
getAMStatistics()
This API is introduced for the MBean implementation on the ApplicationPool Statistics collection. |
AMStatistics |
getAMStatistics(int applicationModuleId)
This API is introduced for the MBean implementation of the Application Pool statistics reporting. |
java.lang.String |
getApplicationModuleClass()
Return the class name of the application modules being managed by the pool. |
int |
getAvailableInstanceCount()
Returns the available number of instances in the Application Pool. |
int |
getAvailableNumPools()
Deprecated. Replaced by getAvailableInstanceCount() |
int |
getConnectedInstanceCount()
Deprecated. |
ConnectionStrategy |
getConnectionStrategy()
Get the application module strategy that will be used to create, connect, disconnect, and reconnect the application module. |
protected java.lang.String |
getConnectionStrategyClassName()
|
java.lang.String |
getConnectString()
Deprecated. This value should be passed to the pool connection strategy as SessionCookie environment or by implementing an EnvInfoProvider. The value may be acquired from the ApplicationPool or SessionCookie environment by using the ConnectionStrategy.DB_CONNECT_STRING_PROPERTY key. |
long |
getCreationTimeMillis(ApplicationModule appModule)
Gets the time when the app module was created (in milli-secs). |
java.lang.String |
getEnvAppModuleClassName()
Return the name of the ApplicationModule class that is managed by this ApplicationPool. |
java.lang.String |
getEnvConfigurationName()
Return the name of the BC4J configuration that was used to initialize the pool environment. |
java.util.Hashtable |
getEnvironment()
Returns the Hashtable that was used to initialize the Context for the application module instances. |
int |
getInitPoolSize()
Return get initial pool size. |
ApplicationModule |
getInstance(int index)
|
int |
getInstanceCount()
Returns the number of instances that the Application Pool has created. |
protected java.util.Iterator |
getLRUAvailableIterator()
Returns an unthreadsafe iterator of the available resources in the pool. |
protected int |
getMaxAvailableSize()
Return the maximum number of available instances that should exist in the pool after pool garbage collection. |
protected int |
getMaxInactiveAge()
Return the duration in milliseconds that a resource may remain available before it is considered inactive. |
int |
getMaxPoolSize()
Return the maximum pool size. |
protected long |
getMaxWaitTime()
Determines how long a request should wait for an available application module instance when the maximum pool size has been reached. |
protected int |
getMinAvailableSize()
Return the minimum number of available instances that should exist in the pool after pool garbage collection. |
protected java.util.Iterator |
getMRUAvailableIterator()
Returns an unthreadsafe iterator of the available resources in the pool. |
java.lang.String |
getName()
Returns the pool's name. |
java.lang.String |
getPassword()
Deprecated. This value should be passed to the pool connection strategy as SessionCookie environment or by implementing an EnvInfoProvider. The value may be acquired from the ApplicationPool or SessionCookie environment by using the Configuration.DB_PASSWORD_PROPERTY key. |
java.lang.String |
getPoolName()
Deprecated. Replaced by getName() . |
protected int |
getRecycleThreshold()
|
protected java.lang.Object |
getResourceDetails(java.lang.Object resource)
This method is invoked for every removal candidate when the pool high water mark is reached. |
protected java.lang.Object |
getResourcePoolKey()
|
SessionCookieFactory |
getSessionCookieFactory()
Get the factory that will be used to create new session cookie instances. |
protected java.lang.String |
getSessionCookieFactoryClassName()
|
long |
getSignature()
Return a signature for the application pool. |
Statistics |
getStatistics()
Returns the pool statistics. |
long |
getTimeCreated()
|
long |
getTimeToCreateMillis(ApplicationModule appModule)
Gets the time that it will tke to create the application module (in milli-secs). |
protected int |
getTimeToLive()
Return the duration in milliseconds that a resource may remain in the pool. |
java.util.Hashtable |
getUserData()
Returns the User Data hashtable. |
java.lang.String |
getUserName()
Deprecated. This value should be passed to the pool connection strategy as SessionCookie environment or by implementing an EnvInfoProvider. The value may be acquired from the ApplicationPool or SessionCookie environment by using the Configuration.DB_USERNAME_PROPERTY key. |
void |
initialize()
|
void |
initialize(java.lang.String name,
java.lang.String applicationModuleClassName,
java.lang.String connectString,
java.util.Hashtable env)
This initializes the ApplicationPool. |
java.lang.Object |
instantiateResource(java.util.Properties properties)
Instantiate a new pooled resource. |
boolean |
isAMPoolingEnabled()
|
boolean |
isAvailable(ApplicationModule appModule)
Deprecated. Implementation detail. This method has been made protected. |
protected boolean |
isDoConnectionPooling()
Deprecated. This property is specific to the SessionCookie. Extending logic should be migrated to a custom extension of: SessionCookieImpl.isConnectionPoolingEnabled()
|
protected boolean |
isDoFailover()
Deprecated. This property is specific to the SessionCookie. Extending logic should be migrated to a custom extension of: SessionCookieImpl.isFailoverEnabled()
|
boolean |
isDynamicJDBCCredentials()
|
protected boolean |
isInstanceAlive(ApplicationModule instance)
Performs tests to determine if the application module instance is still alive. |
boolean |
isSupportsPassivation()
|
boolean |
isUseExclusive()
Determines if poooled resources are used serially. |
protected void |
notifyApplicationModuleReleased(ApplicationModule appModule,
boolean isReleased)
May be customized to perform special release processing. |
protected void |
prepareForGCRemove(java.lang.Object resource)
|
protected void |
prepareResource(java.lang.Object resource,
java.util.Properties props)
Invoked immediately before a resource is referenced. |
protected void |
reconnect(ApplicationModule appModule,
java.util.Hashtable environment)
Deprecated. Replaced by ConnectionStrategy.reconnect(ApplicationModule, SessionCookie, EnvInfoProvider) .
All extending logic that was implemented here should be implemented in a
custom ConnectionStrategy class that extends DefaultConnectionStrategy . |
void |
refreshAMStatistics()
This API will cause the available ApplicationModules to refresh its ApplicationModule specific statistics. |
void |
releaseApplicationModule(SessionCookie cookie,
boolean manageState)
Mark the session's application module as available for reuse by other sessions. |
void |
releaseApplicationModule(SessionCookie cookie,
int releaseFlags)
Mark the session's application module as available for reuse by other sessions. |
protected void |
releaseInstance(ApplicationModule instance)
Deprecated. |
void |
releaseInstances()
Deprecated. Replaced by removeResources() . Method may be
confused with releaseResource.
|
void |
releaseResource(java.lang.Object resource,
java.util.Properties properties)
Release a resource that was previously acquired from the pool with ResourcePool.useResource(Properties) . |
protected boolean |
removeFromManager()
|
java.util.ArrayList |
removeResources()
Remove all resources from the resource pool. |
void |
removeSessionCookie(SessionCookie cookie)
Destroy a session cookie. |
protected void |
resourceStateChanged(java.lang.Object appModule,
byte state,
byte oldState)
Invoked during setState. |
void |
setAvailable(ApplicationModule appModule)
This method may be used by clients if they are manually populating the pool with application module instances using ApplicationPool.createNewInstance()
to notify the pool when a new instance is ready for use by other threads. |
void |
setConfigEnvInfoProvider(EnvInfoProvider configEnvInfoProvider)
Internal use only. |
void |
setConnectionStrategy(ConnectionStrategy strategy)
Set the application module strategy that will be used to create, connect, disconnect, and reconnect the application module. |
void |
setPassword(java.lang.String password)
Deprecated. This value should be passed to the pool connection strategy as SessionCookie environment or by implementing an EnvInfoProvider. The value may be set in the ApplicationPool or SessionCookie environment by using the Configuration.DB_PASSWORD_PROPERTY key. |
void |
setSessionCookieFactory(SessionCookieFactory sessionCookieFactory)
Set the factory that will be used to create new session cookie instances. |
void |
setUserData(java.util.Hashtable userData)
Replaces the userData with the new Hashtable. |
void |
setUserName(java.lang.String userName)
Deprecated. This value should be passed to the pool connection strategy as SessionCookie environment or by implementing an EnvInfoProvider. The value may be set in the ApplicationPool or SessionCookie environment by using the Configuration.DB_USERNAME_PROPERTY key. |
ApplicationModule |
useApplicationModule(SessionCookie cookie,
boolean checkout)
Returns an application module for the specified session cookie. |
java.lang.Object |
useResource(java.util.Properties properties)
Acquire a resource from the pool for exclusive use. |
boolean |
validateSessionCookie(SessionCookie cookie)
Validate that a session cookie is a valid handle for this pool. |
boolean |
validateSessionCookieInPool(SessionCookie cookie)
Validate that a session cookie is a member of this pool. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface oracle.jbo.common.ampool.ApplicationPool |
---|
dumpPoolStatistics, removeResource |
Field Detail |
---|
public static int CREATION_POLICY_SERIAL
public static int CREATION_POLICY_ROUND_ROBIN
public static int MAX_HANDLE_POLICY_SPILL
public static int MAX_HANDLE_POLICY_ERROR
Constructor Detail |
---|
public ApplicationPoolImpl()
Method Detail |
---|
public long getSignature()
ApplicationPool
The pool signature will also be used to determine whether a cookie is a valid handle to the pool instance. The pool signature value should be unique across pools and consistent across VMs.
getSignature
in interface ApplicationPool
ApplicationPool.validateSessionCookie(SessionCookie)
public void initialize()
public void setConfigEnvInfoProvider(EnvInfoProvider configEnvInfoProvider)
public void initialize(java.lang.String name, java.lang.String applicationModuleClassName, java.lang.String connectString, java.util.Hashtable env)
ApplicationPool
initialize
in interface ApplicationPool
name
- the name of the application module pool.applicationModuleClassName
- name of the application module for which the pool
will be created.connectString
- the connection string to use to connect to the
database.env
- name of the hash table containing the environment variables for
the selected platform.public ConnectionStrategy getConnectionStrategy()
ApplicationPool
getConnectionStrategy
in interface ApplicationPool
public void setConnectionStrategy(ConnectionStrategy strategy)
ApplicationPool
setConnectionStrategy
in interface ApplicationPool
public SessionCookieFactory getSessionCookieFactory()
ApplicationPool
getSessionCookieFactory
in interface ApplicationPool
public void setSessionCookieFactory(SessionCookieFactory sessionCookieFactory)
ApplicationPool
setSessionCookieFactory
in interface ApplicationPool
public int getMaxPoolSize()
ResourcePool
getMaxPoolSize
in interface ApplicationPool
getMaxPoolSize
in class ResourcePool
ResourcePool.allocateResource()
public int getInitPoolSize()
ResourcePool
getInitPoolSize
in interface ApplicationPool
getInitPoolSize
in class ResourcePool
public SessionCookie findSessionCookie(java.lang.String applicationId, java.lang.String sessionId)
ApplicationPool
findSessionCookie
in interface ApplicationPool
public SessionCookie findOrCreateSessionCookie(java.lang.String applicationId, java.lang.String sessionId, java.util.Properties properties)
ApplicationPool
findOrCreateSessionCookie
in interface ApplicationPool
public SessionCookie createSessionCookie(java.lang.String applicationId, java.lang.String sessionId, java.util.Properties properties)
ApplicationPool
createSessionCookie
in interface ApplicationPool
applicationId
- an identifier which may be used to uniquely
identify this cookie within the context of a session
sessionId
- an option identifier which may be used to uniquely
identify this cookie across sessions.
properties
- an optional properties object which may be used
to pass additional creation properties to the SessionCookieFactory.public void addSessionCookie(SessionCookie cookie)
ApplicationPool
addSessionCookie
in interface ApplicationPool
ApplicationPool.createSessionCookie(String, String, Properties)
,
ApplicationPool.validateSessionCookie(SessionCookie)
public void removeSessionCookie(SessionCookie cookie)
ApplicationPool
removeSessionCookie
in interface ApplicationPool
public java.lang.String getApplicationModuleClass()
ApplicationPool
getApplicationModuleClass
in interface ApplicationPool
public java.lang.String getConnectString()
getConnectString
in interface ApplicationPool
ConnectionStrategy
,
EnvInfoProvider
,
SessionCookie
public java.util.Hashtable getEnvironment()
ApplicationPool
getEnvironment
in interface ApplicationPool
protected final java.lang.Object getResourceDetails(java.lang.Object resource)
ResourcePool
getResourceDetails
in class ResourcePool
protected void prepareForGCRemove(java.lang.Object resource)
prepareForGCRemove
in class ResourcePool
protected void beforeResourceFinalized(java.lang.Object resource)
ResourcePool
This method is invoked from within the pool monitor. Applications should be careful not to perform I/O from this method.
beforeResourceFinalized
in class ResourcePool
protected final java.util.Iterator getMRUAvailableIterator()
ResourcePool
getMRUAvailableIterator
in class ResourcePool
protected final java.util.Iterator getLRUAvailableIterator()
ResourcePool
getLRUAvailableIterator
in class ResourcePool
protected final void finalizeResource(java.lang.Object resource, java.lang.Object details)
ResourcePool
finalizeResource
in class ResourcePool
public void checkin(ApplicationModule appModule)
SessionCookie.releaseApplicationModule(int)
.
Application developers should invoke:
SessionCookie.releaseApplicationModule(SessionCookie.SHARED_UNMANAGED_RELEASE_MODE)
instead of this method. A session cookie instance may be acquired by
invoking:
createSessionCookie(String, String, Properties)
.
This change was necessary to support the SessionCookie interface. Please
see:
SessionCookie
for more information about using SessionCookies with the application pool.
checkin
in interface ApplicationPool
appModule
- instance name of the application module instance to check in.
SessionCookie.releaseApplicationModule(int)
,
ApplicationModuleRef.useApplicationModule()
public void releaseApplicationModule(SessionCookie cookie, boolean manageState)
ApplicationPool
If the managed flag is true then the pool will maintain logical application module state while still sharing an application module resource between sessions.
When an application module is marked available with managed state the application module will be passivated immediately if failover support has been requested (default). If failover support has been disabled, through the jbo.DoFailover system parameter, the application module will not be passivated until it is re-used by a session other than the session releasing in the application module.
Please see SessionCookie
for more
information regarding session identification and application state
tracking.
releaseApplicationModule
in interface ApplicationPool
cookie
- a session cookie equal to the session cookie that was
generated during checkoutmanageState
- indicates if the session's application module state
should be managed by the pool
public void releaseApplicationModule(SessionCookie cookie, int releaseFlags)
ApplicationPool
If the managed flag is true then the pool will maintain logical application module state while still sharing an application module resource between sessions.
When an application module is marked available with managed state the application module will be passivated immediately if failover support has been requested (default). If failover support has been disabled, through the jbo.DoFailover system parameter, the application module will not be passivated until it is re-used by a session other than the session releasing in the application module.
Please see SessionCookie
for more
information regarding session identification and application state
tracking.
The ApplicationPool supports the following release modes:
SHARED_MANAGED_RELEASE_MODE: Release the ApplicationModule for re-use by other sessions. Manage this session's ApplicationModule state.
SHARED_UNMANAGED_RELEASE_MODE: Release the ApplicationModule for re-use by other sessions. Do not manage this session's ApplicationModule state.
RESERVED_UNMANAGED_RELEASE_MODE: Do not release the ApplicationModule for re-use by other sessions. Do not manage this session's ApplicationModule state. This mode would be used if failover is not required.
RESERVED_MANAGED_RELEASE_MODE: Do not release the ApplicationModule for re-use by other sessions. Manage this session's ApplicationModule state. This mode would be used if failover is required for a reserved ApplicationModule instance.
releaseApplicationModule
in interface ApplicationPool
cookie
- a session cookie equal to the session cookie that was
generated during checkoutreleaseFlags
- the desired releaseFlags. Must be one of the
following release modes:
SHARED_MANAGED_RELEASE_MODE
SHARED_UNMANAGED_RELEASE_MODE
RESERVED_UNMANAGED_RELEASE_MODE
RESERVED_MANAGED_RELEASE_MODEprotected boolean canFinalizeResource(java.lang.Object resource)
ResourcePool
This method may be customized to prevent the eager deferral of a resource. For example, the ApplicationPool will return false if the ApplicationModule is still referenced.
Invoked inside of the pool monitor.
canFinalizeResource
in class ResourcePool
protected boolean canAllocateResource(java.lang.Object resource)
ResourcePool
canAllocateResource
in class ResourcePool
protected boolean canRemoveResource(java.lang.Object resource)
ResourcePool
canRemoveResource
in class ResourcePool
public java.lang.String checkinWithSessionState(ApplicationModule appModule)
SessionCookie.releaseApplicationModule(boolean, boolean)
.
Application developers should invoke: SessionCookie.releaseApplicationModule(true, true)
instead of this method. A session cookie instance may be acquired by
invoking:
createSessionCookie(String, String, Properties)
.
This change was necessary to support the SessionCookie interface. Please
see:
SessionCookie
for more information about using SessionCookies with the application pool.
This method should be used by pool clients that wish to maintain logical application module state while still sharing an application module resource across requests. The method returns a system generated session id for the check-in that should be used as the unique application module identifier by the client session.
The application module will be passivated immediately if failover support has been requested (default). If failover support has been disable, through the jbo.DoFailover system parameter, the application module will not be passivated until it is re-used by a session other than the session checking in the application module.
checkinWithSessionState
in interface ApplicationPool
appModule
- the application module that will be checked in
SessionCookie.releaseApplicationModule(boolean, boolean)
,
ApplicationModuleRef.useApplicationModule()
public void refreshAMStatistics()
public ApplicationModule createNewInstance() throws java.lang.Exception
ConnectionStrategy.createApplicationModule(SessionCookie, EnvInfoProvider)
.
All extending logic that was implemented here should be implemented in a
custom ConnectionStrategy class that extends:
DefaultConnectionStrategy
.
createNewInstance
in interface ApplicationPool
java.lang.Exception
ConnectionStrategy.createApplicationModule(SessionCookie, EnvInfoProvider)
public java.lang.Object instantiateResource(java.util.Properties properties)
ResourcePool
ResourcePool.useResource(Properties)
if it is necessary to create a new pooled resource. Applications should
implement this method to return a new instance of a pooled resource.
instantiateResource
in class ResourcePool
public ApplicationModule checkout() throws java.lang.Exception
ApplicationModuleRef.useApplicationModule()
.
Application developers should invoke: SessionCookie.useApplicationModule()
instead of this method. A session cookie instance may be acquired by
invoking:
createSessionCookie(String, String, Properties)
.
This change was necessary to support the SessionCookie interface. Please
see:
SessionCookie
for more information about using SessionCookies with the application pool.
checkout
in interface ApplicationPool
java.lang.Exception
ApplicationModuleRef.useApplicationModule()
,
SessionCookie.releaseApplicationModule(boolean, boolean)
public void releaseInstances()
removeResources()
. Method may be
confused with releaseResource.
releaseInstances
in interface ApplicationPool
removeResources()
protected void releaseInstance(ApplicationModule instance)
ResourcePool.removeResource(Object)
public java.util.ArrayList removeResources()
ResourcePool
removeResources
in interface ApplicationPool
removeResources
in class ResourcePool
protected void destroy()
ResourcePool
destroy
in class ResourcePool
public int getAvailableInstanceCount()
ApplicationPool
getAvailableInstanceCount
in interface ApplicationPool
public int getAvailableNumPools()
getAvailableInstanceCount()
getAvailableNumPools
in interface ApplicationPool
getAvailableInstanceCount()
public int getInstanceCount()
ApplicationPool
getInstanceCount
in interface ApplicationPool
public ApplicationModule getInstance(int index)
getInstance
in interface ApplicationPool
public ApplicationModule checkout(java.lang.String cookieValue)
ApplicationModuleRef.useApplicationModule()
.
Application developers should invoke: SessionCookie.useApplicationModule()
instead of this method. A session cookie instance may be acquired by
invoking:
createSessionCookie(String, String, Properties)
.
This change was necessary to support the SessionCookie interface. Please
see:
SessionCookie
for more information about using SessionCookies with the application pool.
checkinWithSessionState(ApplicationModule)
against this application module pool.
The session id should be used to re-create an application module state from a previous request.
If an unrecognized session id is specified then the pool should return a stateless application module instance.
checkout
in interface ApplicationPool
cookieValue
- a session identifier from a previous requestApplicationModuleRef.useApplicationModule()
,
SessionCookie.releaseApplicationModule(boolean, boolean)
public ApplicationModule useApplicationModule(SessionCookie cookie, boolean checkout)
ApplicationPool
The requesting thread may obtain an application module with the state from a previous request by passing the previous request's cookie instance. The cookie should be used by the pool to re-create an application module state from a previous request.
If an "empty" session cookie is specified then the pool should return a
stateless application module instance. An empty session cookie is defined
as a cookie that does not reference a previous application module state.
Please see SessionCookie.getPassivationId()
for more information regarding application state maintenance.
In order to persist some internal state information, the application pool may mutate the specified cookie. Application pool clients should consequently be careful to reference the cookie value that is returned in the cookie value after checkout has been invoked.
useApplicationModule
in interface ApplicationPool
cookie
- an empty/previous session cookiepublic java.lang.String getPoolName()
getName()
.
getPoolName
in interface ApplicationPool
getName()
public java.lang.String getName()
ApplicationPool
getName
in interface ApplicationPool
getName
in class ResourcePool
public java.util.Hashtable getUserData()
ApplicationPool
getUserData
in interface ApplicationPool
public void setUserData(java.util.Hashtable userData)
ApplicationPool
setUserData
in interface ApplicationPool
userData
- the new hashtable to use for the environment information.public java.lang.String getUserName()
getUserName
in interface ApplicationPool
ConnectionStrategy
,
EnvInfoProvider
,
SessionCookie
public void setUserName(java.lang.String userName)
setUserName
in interface ApplicationPool
ConnectionStrategy
,
EnvInfoProvider
,
SessionCookie
public java.lang.String getPassword()
getPassword
in interface ApplicationPool
ConnectionStrategy
,
EnvInfoProvider
,
SessionCookie
public void setPassword(java.lang.String password)
setPassword
in interface ApplicationPool
ConnectionStrategy
,
EnvInfoProvider
,
SessionCookie
public void commitAndSyncCache(ApplicationModule instance)
ApplicationPool
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);
commitAndSyncCache
in interface ApplicationPool
instance
- an instance of an Application Module in the pool.protected boolean isInstanceAlive(ApplicationModule instance)
This method may be overriden to provide a custom test.
public boolean validateSessionCookieInPool(SessionCookie cookie)
ApplicationPool
ApplicationPool.createSessionCookie(String, String, Properties)
.
SessionCookie(s) are unregistered as an ApplicationPool member when they
are removed from an an ApplicationPool with
ApplicationPool.removeSessionCookie(SessionCookie)
.
validateSessionCookieInPool
in interface ApplicationPool
public boolean validateSessionCookie(SessionCookie cookie)
ApplicationPool
This method only validates that a SessionCookie was created by an
ApplicationPool with the same signature as the target ApplicationPool. It
is used by the default ApplicationPool implementation to verify that a
SessionCookie may be added to the target pool. It does not validate that
the SessionCookie is a valid member of the target ApplicationPool. Please
use ApplicationPool.validateSessionCookieInPool(SessionCookie)
to validate that a SessionCookie is a member of the target
ApplicationPool.
validateSessionCookie
in interface ApplicationPool
ApplicationPool.getSignature()
,
ApplicationPool.validateSessionCookieInPool(SessionCookie)
protected void notifyApplicationModuleReleased(ApplicationModule appModule, boolean isReleased)
Please note that this notification may be delivered while the ApplicationPool is still in an inconsistent state. A customizing pool should *not* attempt to work with the pool when handling this notification.
Customizing pools should also be careful to minimize the amount of work performed by any notification handler as this notification may be delivered while the ApplicationPool monitor is held therefore preventing other threads from using the ApplicationPool.
The notification will be delivered before the ApplicationModule is released -- though, in the case that the pool monitor is held this will not make a difference since this codepath will be single threaded.
protected void prepareResource(java.lang.Object resource, java.util.Properties props)
ResourcePool
This block will be executed while the resource latch is held. So, the block will have exclusive access to the resource.
The properties object represents the context that was passed to the request that resulted in the resource state transition.
prepareResource
in class ResourcePool
protected void resourceStateChanged(java.lang.Object appModule, byte state, byte oldState)
ResourcePool
This block is executed while a pool monitor is held. Subclasses should be careful not to perform expensive operations.
resourceStateChanged
in class ResourcePool
public void setAvailable(ApplicationModule appModule)
ApplicationPool
ApplicationPool.createNewInstance()
to notify the pool when a new instance is ready for use by other threads.
Pool clients should not use this method after an application module
has been set available for the first time.
setAvailable
in interface ApplicationPool
appModule
- the application module which will be made availablepublic boolean isAvailable(ApplicationModule appModule)
isAvailable
in interface ApplicationPool
public long getCreationTimeMillis(ApplicationModule appModule)
ApplicationPool
getCreationTimeMillis
in interface ApplicationPool
appModule
- the application module instance for which you want to
know the time of creation.public long getTimeToCreateMillis(ApplicationModule appModule)
ApplicationPool
getTimeToCreateMillis
in interface ApplicationPool
appModule
- the application module instance for which you want to
know how long it will take to create it.protected int getMinAvailableSize()
ResourcePool
An available resource is defined as inactive if it has not been used for a duration longer than the pool's maximum inactive age.
getMinAvailableSize
in class ResourcePool
ResourcePool.getMaxInactiveAge()
protected int getMaxAvailableSize()
ResourcePool
getMaxAvailableSize
in class ResourcePool
protected int getMaxInactiveAge()
ResourcePool
getMaxInactiveAge
in class ResourcePool
ResourcePool.getMinAvailableSize()
protected int getTimeToLive()
ResourcePool
getTimeToLive
in class ResourcePool
protected int getRecycleThreshold()
protected ResourcePoolLogger createPoolLogger()
createPoolLogger
in class ResourcePool
public Statistics getStatistics()
ApplicationPool
getStatistics
in interface ApplicationPool
public AMStatistics[] getAMStatistics()
public AMStatistics getAMStatistics(int applicationModuleId)
applicationModuleId
- the Id for which the statistics is requested
protected long getMaxWaitTime()
getMaxWaitTime
in class ResourcePool
ResourcePool.getMaxPoolSize()
,
ResourcePool.allocateResource()
protected boolean compareConnectionMetadata(ConnectionMetadata oldConnectionMetadata, ConnectionMetadata newConnectionMetadata)
If compareConnectionMetadata returns true then the pool assumes that the oldConnectionMetadata and the newConnectionMetadata are equal and does not attempt to connect the application module with the new session connection metadata. If compareConnectionMetadata returns false then the pool assumes that the oldConnectionMetadata and the newConnectionMetadata are note equal and will attempt to connect the application module using the new connection metadata.
If it is known at design time that the connection metadata will not change then applications may set the property, jbo.ampool.dynamicjdbccredentials, equal to false. This will prevent the potential overhead of performing a disconnect/connect whenever a new session causes the pool to recycle an application module instance.
public java.lang.Object useResource(java.util.Properties properties)
ResourcePool
useResource
in class ResourcePool
properties
- Resource creation properties. These properties are passed
to ResourcePool.instantiateResource(Properties)
if it is necesary to create a new resource.public void releaseResource(java.lang.Object resource, java.util.Properties properties)
ResourcePool
ResourcePool.useResource(Properties)
. Throws an exception if the resource
was not checked out from the pool.
releaseResource
in class ResourcePool
protected boolean isDoFailover()
SessionCookieImpl.isFailoverEnabled()
SessionCookie.isFailoverEnabled()
public boolean isDynamicJDBCCredentials()
public boolean isAMPoolingEnabled()
public boolean isSupportsPassivation()
public boolean isUseExclusive()
ResourcePool
For example, assume that the pool maximum size is 5. If requests one through 5 acquire references to resources one through five respectively and in that order. If serial use is enabled then request six will wait until one of the other five resources released back to the pool. If serial use is not enabled then request six will acquire a reference to resource one. Continuing with the example, request seven would then acquire a reference to resource two.
isUseExclusive
in class ResourcePool
ResourcePool.useResource(Properties)
public int getConnectedInstanceCount()
protected boolean isDoConnectionPooling()
SessionCookieImpl.isConnectionPoolingEnabled()
SessionCookie.isConnectionPoolingEnabled()
protected void connect(ApplicationModule appModule, java.util.Hashtable environment)
ConnectionStrategy.connect(ApplicationModule, SessionCookie, EnvInfoProvider)
.
All extending logic that was implemented here should be implemented in a
custom ConnectionStrategy class that extends DefaultConnectionStrategy
.
ConnectionStrategy.connect(ApplicationModule, SessionCookie, EnvInfoProvider)
protected void reconnect(ApplicationModule appModule, java.util.Hashtable environment)
ConnectionStrategy.reconnect(ApplicationModule, SessionCookie, EnvInfoProvider)
.
All extending logic that was implemented here should be implemented in a
custom ConnectionStrategy class that extends DefaultConnectionStrategy
.
ConnectionStrategy.reconnect(ApplicationModule, SessionCookie, EnvInfoProvider)
protected void disconnect(ApplicationModule appModule, boolean retainState, java.util.Hashtable environment)
ConnectionStrategy.disconnect(ApplicationModule, boolean, SessionCookie)
.
All extending logic that was implemented here should be implemented in a
custom ConnectionStrategy class that extends DefaultConnectionStrategy
.
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.ConnectionStrategy.disconnect(ApplicationModule, boolean, SessionCookie)
protected java.lang.String getConnectionStrategyClassName()
protected java.lang.String getSessionCookieFactoryClassName()
public java.lang.String getEnvConfigurationName()
ApplicationPool
getEnvConfigurationName
in interface ApplicationPool
public java.lang.String getEnvAppModuleClassName()
ApplicationPool
getEnvAppModuleClassName
in interface ApplicationPool
public long getTimeCreated()
protected boolean removeFromManager()
removeFromManager
in class ResourcePool
protected java.lang.Object getResourcePoolKey()
getResourcePoolKey
in class ResourcePool
|
Oracle Fusion Middleware Java API Reference for Oracle ADF Model 11g Release 1 (11.1.1.7.0) E10653-08 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |