Business Components

oracle.jbo.http
Class SharedSessionCookieImpl

java.lang.Object
  |
  +--oracle.jbo.common.ampool.SessionCookieImpl
        |
        +--oracle.jbo.http.HttpSessionCookieImpl
              |
              +--oracle.jbo.http.SharedSessionCookieImpl
All Implemented Interfaces:
ApplicationModuleRef, oracle.jbo.http.BindingListener, HttpSessionCookie, java.io.Serializable, SessionCookie

public class SharedSessionCookieImpl
extends HttpSessionCookieImpl

A shared application module handle.

Some enterprise applications may define static data that is required across sessions and does not change very frequently. An example of this type of data might be application metadata that is used to render the application UI. If BC4J is used to access the static data then an unnecessary overhead is incurred if the static data caches are repopulated from the database for each application session on every request. In order to optimize performance common practice is to cache the shared static data for reuse across sessions and requests.

This class supports shared, static data caches by allowing requests from multiple sessions to share a single application module instance which is managed by an application pool for the lifetime of the web server VM. The SharedSessionCookieImpl extends the HttpSessionCookieImpl with the following logic for managing access to a shared application module instance:

  • Prevents unnecessary state passivation at the end of a request
  • Manages shared, transactional application module state across sessions and requests
  • The SharedSessionCookieFactory may be used to instantiate SharedSessionCookieImpl sessions for an application pool. The application developer may use the SharedSessionCookieImpl with an application pool by specifying the following BC4J property in the configuration of the application module that will be used to cache static data:

    jbo.ampool.sessioncookiefactoryclass=oracle.jbo.http.SharedSessionCookieFactory

    After having declared the property above the application developer may access the shared application module instance with any application pooling client like the BC4J data tags and the BC4J data web beans.

    Finally, the application developer should be careful about mutating the shared transactional state after a shared session cookie has been used. Most shared state should be "built and cached" only once after an application module is created or connected and before it has become available for use. This is important because the application pool may destroy application module instances during the lifetime of the pool in order to provide 24x7 availability.

    Please see HttpSessionCookieImpl for more infomartion regarding the http session cookie implementation.

    See Also:
    Serialized Form

    Fields inherited from interface oracle.jbo.common.ampool.SessionCookie
    NULL_PASSIVATION_ID
     
    Constructor Summary
    SharedSessionCookieImpl(java.lang.String applicationId, java.lang.String sessionId, ApplicationPool pool)
              This constructor may be used if the sessionId is already known.
     
    Method Summary
    TypeMethod
     boolean isFailoverEnabled()
              Indicates that session application module state should be persisted to secondary storage immediately upon a managed release.
     void releaseApplicationModule(boolean checkin, boolean manageState, long waitTimeout)
              Release an application module for reuse.
     void timeout()
              Internal use only.
     ApplicationModule useApplicationModule(boolean lock, long waitTimeout)
              Returns an application module instance for the current thread.
     
    Methods inherited from class oracle.jbo.http.HttpSessionCookieImpl
    readValue, timeout, valueBound, valueUnbound, writeValue
     
    Methods inherited from class oracle.jbo.common.ampool.SessionCookieImpl
    copyInto, equals, getApplicationId, getEnvInfoProvider, getEnvironment, getLastUpdate, getPassivationId, getPoolSignature, getProperty, getReservedPassivationId, getSessionId, getSyncLock, getUserData, getValue, hashCode, isActivationRequired, isApplicationModuleReserved, isConnectionPoolingEnabled, isResetNonTransactionalState, parsePassivationId, parseSessionId, releaseApplicationModule, reservePassivationId, resetState, setActivationRequired, setEnvInfoProvider, setEnvironment, setPassivationId, setReservedPassivationId, setSessionCookieListener, toString, useApplicationModule, useApplicationModule
     
    Methods inherited from class java.lang.Object
    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
     
    Methods inherited from interface oracle.jbo.common.ampool.SessionCookie
    copyInto, equals, getApplicationId, getEnvInfoProvider, getEnvironment, getLastUpdate, getPassivationId, getPoolSignature, getReservedPassivationId, getSessionId, getSyncLock, getUserData, getValue, hashCode, isActivationRequired, isConnectionPoolingEnabled, isResetNonTransactionalState, reservePassivationId, resetState, setActivationRequired, setEnvInfoProvider, setEnvironment, setPassivationId, setReservedPassivationId, setSessionCookieListener, toString
     
    Methods inherited from interface oracle.jbo.common.ampool.ApplicationModuleRef
    isApplicationModuleReserved, releaseApplicationModule, useApplicationModule, useApplicationModule
     

    Constructor Detail

    SharedSessionCookieImpl

    public SharedSessionCookieImpl(java.lang.String applicationId,
                                   java.lang.String sessionId,
                                   ApplicationPool pool)
    This constructor may be used if the sessionId is already known.
    Method Detail

    useApplicationModule

    public ApplicationModule useApplicationModule(boolean lock,
                                                  long waitTimeout)
    Description copied from interface: ApplicationModuleRef
    Returns an application module instance for the current thread.

    If the application session cookie references application state the application state should be activated in the returned application module.

    The lock parameter may be specified to acquire a lock for the shared application module resource. If a lock is acquired the application should be careful to release that lock after it is done using the application module resource. Application thread starvation may occur if the lock is held indefinitely.

    If another thread is holding the lock associated with the session cookie then the current thread will wait for the period specified by the waitTimeout parameter.

    Best practice would be to invoke ApplicationModuleRef.useApplicationModule(boolean) in a try...finally block that invokes during finally.

    Overrides:
    useApplicationModule in class SessionCookieImpl
    Following copied from interface: oracle.jbo.common.ampool.ApplicationModuleRef
    Parameters:
    lock - specify whether a session lock should be acquired for the shared application module resource
    waitTimeout - specifies the amount of time in milliseconds that the thread should wait for the session cookie lock

    releaseApplicationModule

    public void releaseApplicationModule(boolean checkin,
                                         boolean manageState,
                                         long waitTimeout)
    Description copied from interface: ApplicationModuleRef
    Release an application module for reuse.

    This method should be invoked at the end of each session request.

    If another thread is holding the lock associated with the session cookie then the current thread will wait for the period specified by the waitTimeout parameter. The current thread may be blocked upon invoking releaseApplicationModule if it did not acquire a session cookie lock when it dereferenced the application module with #useApplicationModule(boolean).

    The checkin parameter may be used to indicate that the session application module instance should be checked in for reuse by other sessions.

    The manageState parameter may be used to indicate that the session application state should be managed between requests by the pooling framework.

    I

    Overrides:
    releaseApplicationModule in class SessionCookieImpl
    Following copied from interface: oracle.jbo.common.ampool.ApplicationModuleRef
    Parameters:
    checkin -  
    manageState - manage the session application state between requests
    waitTimeout - specifies the amount of time in milliseconds that the thread should wait for the session cookie lock

    timeout

    public void timeout()
    Description copied from class: SessionCookieImpl
    Internal use only.
    Overrides:
    timeout in class SessionCookieImpl

    isFailoverEnabled

    public boolean isFailoverEnabled()
    Description copied from interface: SessionCookie
    Indicates that session application module state should be persisted to secondary storage immediately upon a managed release.

    Session cookie developers should be careful that this value not change after a session cookie has become active.

    Overrides:
    isFailoverEnabled in class HttpSessionCookieImpl

    Business Components