|
Oracle ADF Model and Business Components API Reference 10.1.2 B14022-01 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object oracle.jbo.common.ampool.SessionCookieImpl
Default SessionCookie implementation.
Default session cookie instances should only be instantiated by an
application pool. This is required because the default session cookie
uses the application pool framework to manage application state
and to share application module instances between requests. Please see
ApplicationPool.createSessionCookie(String, String, Properties)
for more information about creating session cookies.
The default implementation uses a session cookie lock to prevent access to the session cookie application module resource by multiple threads. A lock is obtained when a thread invokes useApplicationModule. The lock is released when the thread invokes releaseApplicationModule.
Please see SessionCookie
for more
information about session cookies.
Field Summary | |
protected java.util.Hashtable |
mEnvironment
|
Fields inherited from interface oracle.jbo.common.ampool.SessionCookie |
BUNDLED_EXC_MODE_KEY, FORCE_RELEASE_MODE, MANAGED_RELEASE_MODE, NULL_PASSIVATION_ID, REMOVE_RESOURCE, RESERVED_MANAGED_RELEASE_MODE, RESERVED_UNMANAGED_RELEASE_MODE, SHARED, SHARED_MANAGED_RELEASE_MODE, SHARED_RELEASE_MODE, SHARED_UNMANAGED_RELEASE_MODE, STATE_MANAGED, STATE_UNMANAGED, UNSHARED, VALUE_SINK_KEY |
Constructor Summary | |
SessionCookieImpl(java.lang.String applicationId,
java.lang.String sessionId,
ApplicationPool pool)
|
|
SessionCookieImpl(java.lang.String applicationId,
java.lang.String sessionId,
ApplicationPool pool,
java.security.Principal userPrincipal)
Constructor. |
Method Summary | |
protected void |
afterApplicationModuleRelease()
|
protected void |
beforeApplicationModuleRelease(ApplicationModule am)
|
void |
copyInto(SessionCookie cookie)
Copies the state of this cookie into the target cookie. |
boolean |
equals(java.lang.Object obj)
Session cookies are equal if their application and session identifiers are equal |
java.lang.String |
getApplicationId()
Returns the application id for this session cookie. |
java.util.Hashtable |
getClientEnvironment()
Returns a java.util.Hashtable representing the BC4J context that is related to this application session. |
java.lang.Object |
getClientEnvironment(java.lang.Object key)
Returns the value of the specified attribute from the ApplicationModuleHandle client environment. |
java.lang.String |
getEnvConfigurationName()
Return the name of the BC4J configuration that was used to initialize the SessionCookie environment. |
EnvInfoProvider |
getEnvInfoProvider()
|
java.util.Hashtable |
getEnvironment()
Returns a java.util.Hashtable representing the BC4J context that is related to this application session. |
java.lang.Object |
getEnvironment(java.lang.Object key)
Returns the value of the specified attribute from the ApplicationModuleHandle environment. |
boolean |
getIgnorePiggyback()
INTERNAL USE ONLY. |
java.util.Date |
getLastUpdate()
Returns a date value indicating the last time the state of this cookie was updated. |
int |
getMostRecentStackId()
If the current thread holds an active ApplicationModule reference then this method will delegate to ApplicationModule.getMostRecentStackId() . |
int |
getPassivationId()
Return an identifier for the last persisted session application state. |
long |
getPoolSignature()
Returns the signature of the pool for which this session cookie is a handle. |
protected boolean |
getProperty(java.lang.String name,
java.util.Hashtable environment,
boolean defaultValue)
|
int |
getReservedPassivationId()
Return the identifier that will be used to persist the session application state at the end of the request. |
java.lang.String |
getSessionId()
Returns the session identifier. |
java.lang.String |
getSSOSubscriber()
|
java.lang.String |
getSSOUserName()
|
java.lang.Object |
getSyncLock()
INTERNAL USE ONLY. |
int |
getThreadRefCount()
INTERNAL USE ONLY. |
java.util.Hashtable |
getUserData()
Returns a java.util.Hashtable which may be used to store user specific context that is related to this application session. |
java.lang.Object |
getUserData(java.lang.Object name)
Acquires the user data associated with the specified key from the SessionCookie user data map. |
java.lang.String |
getValue()
Returns the session cookie value. |
int |
hashCode()
|
boolean |
isActivationRequired()
Indicates that state activation is required upon the next checkout for this session. |
boolean |
isActivationRequired(ApplicationModule context)
Indicates that state activation is required upon the next checkout for this session. |
boolean |
isApplicationModuleReleased()
Determines if the ApplicationModule which is referenced by this session has been released to the ApplicationPool. |
boolean |
isApplicationModuleReleasedByThread()
If the cookie is multi-threaded then this method will determine if the invoking thread has released the SessionCookie ApplicationModule. |
boolean |
isApplicationModuleReserved()
Tests if the application module that is referenced by this session cookie has been reserved for exclusive access by this session cookie. |
boolean |
isConnectionPoolingEnabled()
Indicates that the session application module resource's JDBC connection should be released immediately upon release to the application pool. |
boolean |
isFailoverEnabled()
Indicates that session application module state should be persisted to secondary storage immediately upon a managed release. |
boolean |
isResetNonTransactionalState()
Indicates whether or not the non-transactional state of the session application module resource should be preserved upon an unmanaged release to the application pool. |
static int |
parsePassivationId(java.lang.String cookieValue)
|
static java.lang.String |
parseSessionId(java.lang.String cookieValue)
|
void |
passivateState(java.lang.Object sink)
Passivates the session ApplicationModule state. |
java.lang.String |
readValue(java.lang.Object source)
Read the cookie value to the specified data sink. |
void |
releaseApplicationModule(boolean checkin,
boolean manageState)
The default implementation will release the session cookie lock after having checked in the session application module. |
void |
releaseApplicationModule(boolean checkin,
boolean manageState,
long waitTimeout)
The default implementation will release the session cookie lock after having checked in the session application module. |
void |
releaseApplicationModule(int releaseFlags)
Release an application module for reuse. |
void |
releaseApplicationModule(int releaseFlags,
long waitTimeout)
Release an application module for reuse. |
protected void |
removeFromPool()
|
java.lang.Object |
removeUserData(java.lang.Object name)
Removes the user data associated with the specified key from the SessionCookie user data map. |
void |
reservePassivationId()
Reserves a unique identifier for the session application. |
void |
reservePassivationId(java.lang.Object sink)
Reserves a unique identifier for the session application. |
void |
resetState()
Reset the ApplicationModule state associated with this ApplicationModuleRef. |
void |
resetStateInternal()
INTERNAL USE ONLY. |
void |
setActivated(boolean activated)
INTERNAL USE ONLY. |
void |
setActivationRequired(boolean activationRequired)
May be used to force activation upon the next checkout for this session. |
void |
setEnvInfoProvider(EnvInfoProvider envInfo)
|
void |
setEnvironment(java.util.Hashtable environment)
Sets the session environment. |
void |
setEnvironment(java.lang.Object key,
java.lang.Object value)
Sets the session environment. |
void |
setIgnorePiggyback(boolean ignorePiggyback)
INTERNAL USE ONLY. |
void |
setMostRecentStackId(int mostRecentStackId)
INTERNAL USE ONLY. |
void |
setPassivationId(int passivationId)
Sets the identifier for the last persisted session application state. |
void |
setReferenceCounting(boolean isReferenceCounting)
Advanced Use Only: By default a SessionCookie may invoke useApplicationModule() an arbitrary number of times with only
one matching releaseApplicationModule(int) invocation. |
void |
setReservedPassivationId(int reservedPassivationId)
Set the identifier that will be used to persist the session application state. |
void |
setSessionCookieListener(SessionCookieListener listener)
Set a session cookie listener on the cookie. |
void |
setSingleThreaded(boolean isSingleThreaded)
Advanced Use Only: |
void |
setUserData(java.lang.Object name,
java.lang.Object value)
Puts user data in the SessionCookie user data map. |
void |
timeout()
Internal use only. |
java.lang.String |
toString()
|
ApplicationModule |
useApplicationModule()
Returns an application module instance without acquiring a session cookie lock. |
ApplicationModule |
useApplicationModule(boolean lock)
Returns an application module instance for the current thread. |
ApplicationModule |
useApplicationModule(boolean lock,
long waitTimeout)
The default implementation must obtain a session cookie lock before checking an application module instance out from the pool. |
boolean |
wasActivated()
INTERANL USE ONLY. |
void |
writeValue(java.lang.Object sink)
Write the cookie value to the specified data sink. |
void |
writeValue(java.lang.Object sink,
java.lang.String value)
Write the specified cookie value to the specified data sink. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
protected java.util.Hashtable mEnvironment
Constructor Detail |
public SessionCookieImpl(java.lang.String applicationId, java.lang.String sessionId, ApplicationPool pool, java.security.Principal userPrincipal)
Applications should not invoke this constructor directly. A session cookie factory should be used instead.
The implementation requires that all three parameters be not null.
applicationId
- a unique identifier for the session applicationsessionId
- a unique identifer for the sessionpool
- an application pool instancepublic SessionCookieImpl(java.lang.String applicationId, java.lang.String sessionId, ApplicationPool pool)
Method Detail |
public EnvInfoProvider getEnvInfoProvider()
getEnvInfoProvider
in interface SessionCookie
public void setEnvInfoProvider(EnvInfoProvider envInfo)
setEnvInfoProvider
in interface SessionCookie
public java.util.Date getLastUpdate()
SessionCookie
getLastUpdate
in interface SessionCookie
public java.lang.String toString()
toString
in interface SessionCookie
public int hashCode()
hashCode
in interface SessionCookie
public boolean equals(java.lang.Object obj)
equals
in interface SessionCookie
public long getPoolSignature()
SessionCookie
getPoolSignature
in interface SessionCookie
public java.lang.String getApplicationId()
SessionCookie
getApplicationId
in interface SessionCookie
public java.lang.String getSessionId()
SessionCookie
Session identifers should be uniques across sessions and consistent across servers.
getSessionId
in interface SessionCookie
public java.lang.String getValue()
SessionCookie
Session cookie values represent the session application state.
getValue
in interface SessionCookie
public java.lang.String getEnvConfigurationName()
SessionCookie
getEnvConfigurationName
in interface SessionCookie
public java.util.Hashtable getEnvironment()
ApplicationModuleHandle
getEnvironment
in interface ApplicationModuleHandle
public java.lang.Object getEnvironment(java.lang.Object key)
ApplicationModuleHandle
getEnvironment
in interface ApplicationModuleHandle
public java.util.Hashtable getClientEnvironment()
ApplicationModuleHandle
ApplicationModuleHandle.getEnvironment()
in
that the client environment will not be marshalled to the middle tier.
getClientEnvironment
in interface ApplicationModuleHandle
public java.lang.Object getClientEnvironment(java.lang.Object key)
ApplicationModuleHandle
getClientEnvironment
in interface ApplicationModuleHandle
public void setEnvironment(java.lang.Object key, java.lang.Object value)
SessionCookie
setEnvironment
in interface SessionCookie
public void setEnvironment(java.util.Hashtable environment)
SessionCookie
setEnvironment
in interface SessionCookie
public boolean isApplicationModuleReserved()
ApplicationModuleRef
isApplicationModuleReserved
in interface ApplicationModuleRef
public boolean isApplicationModuleReleased()
SessionCookie
This method differs from ApplicationModuleRef.isApplicationModuleReserved()
in that
isApplicationModuleReserved will return true if an unshared or reserved
release mode has been used to release an ApplicationModule.
isApplicationModuleReleased
in interface SessionCookie
public boolean isApplicationModuleReleasedByThread()
SessionCookie
If the SessionCookie ApplicationModule has been released then true will be returned.
If the invoking thread did not previously invoke
ApplicationModuleRef.useApplicationModule()
since the last release then true will be
returned.
If the cookie is single threaded then this method will return the same
result as SessionCookie.isApplicationModuleReleased()
isApplicationModuleReleasedByThread
in interface SessionCookie
{@link #isApplicationModuleReleased()}
public ApplicationModule useApplicationModule()
ApplicationModuleRef
useApplicationModule
in interface ApplicationModuleRef
ApplicationModuleRef.useApplicationModule(boolean, long)
public ApplicationModule useApplicationModule(boolean lock)
ApplicationModuleRef
useApplicationModule
in interface ApplicationModuleRef
lock
- specify whether a session lock should be acquired for the
shared application module resourceApplicationModuleRef.useApplicationModule(boolean, long)
public ApplicationModule useApplicationModule(boolean lock, long waitTimeout)
useApplicationModule
in interface ApplicationModuleRef
lock
- specify whether a session lock should be acquired for the
shared application module resourcewaitTimeout
- specifies the amount of time in milliseconds that the
thread should wait for the session cookie lockpublic void timeout()
protected void removeFromPool()
public void releaseApplicationModule(boolean checkin, boolean manageState)
releaseApplicationModule
in interface SessionCookie
checkin
- SHARED or UNSHAREDmanageState
- manage the session application state between requests
public void releaseApplicationModule(boolean checkin, boolean manageState, long waitTimeout)
releaseApplicationModule
in interface SessionCookie
checkin
- SHARED or UNSHAREDmanageState
- STATE_MANAGED or STATE_UNMANAGEDwaitTimeout
- specifies the amount of time in milliseconds that the
thread should wait for the session cookie lock
public void releaseApplicationModule(int releaseFlags)
SessionCookie
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 {@link #useApplicationModule(b oolean).
The SessionCookie 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 SessionCookie
releaseFlags
- 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_MODE
public void releaseApplicationModule(int releaseFlags, long waitTimeout)
SessionCookie
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 {@link #useApplicationModule(boolean).
The SessionCookie 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 SessionCookie
releaseFlags
- 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_MODEwaitTimeout
- specifies the amount of time in milliseconds that the
thread should wait for the session cookie lock
protected void beforeApplicationModuleRelease(ApplicationModule am)
protected void afterApplicationModuleRelease()
public void writeValue(java.lang.Object sink)
SessionCookie
writeValue
in interface SessionCookie
sink
- a data sinkpublic void writeValue(java.lang.Object sink, java.lang.String value)
SessionCookie
writeValue
in interface SessionCookie
sink
- a data sinkpublic java.lang.String readValue(java.lang.Object source)
SessionCookie
readValue
in interface SessionCookie
source
- a data sourcepublic final java.lang.Object getSyncLock()
SessionCookie
getSyncLock
in interface SessionCookie
public boolean isActivationRequired()
SessionCookie
isActivationRequired
in interface SessionCookie
public boolean isActivationRequired(ApplicationModule context)
SessionCookie
The ApplicationModule may not yet be in a valid state so care should be taken when accessing the ApplicationModule from a custom SessionCookie implementation.
This method is invoked only if the session's affinity to its ApplicationModule was maintained between requests. The return value of this method is ignored if the session's affinity to its ApplicationModule was lost. INTERNAL USE ONLY. Applications should not use this method.
isActivationRequired
in interface SessionCookie
public void setActivationRequired(boolean activationRequired)
SessionCookie
setActivationRequired
in interface SessionCookie
public int getPassivationId()
SessionCookie
getPassivationId
in interface SessionCookie
public void setPassivationId(int passivationId)
SessionCookie
setPassivationId
in interface SessionCookie
public int getMostRecentStackId()
SessionCookie
ApplicationModule.getMostRecentStackId()
.
If the current thread does not reference a reserved ApplicationModule then this method will return a local copy of the most recent stack id.
The local copy is updated in the following circumstances:
SessionCookie.reservePassivationId()
is invoked.
SessionCookie.getMostRecentStackId()
is invoked while the SessionCookie holds
an active ApplicationModule reference.
The local stack snapshot id allows SessionCookie clients to reuse persistent snapshot ids as stack snapshots. This will reduce the memory overhead of maintaining an in-memory snapshot of an ApplicationModule state. This method should only be used if failover has been enabled.
This method is really only useful for clients that have enabled failover
and require the stack id after the ApplicationModule has been released.
Invoking this method while an active ApplicationModule reference is held
is equivalent to invoking ApplicationModule.getMostRecentStackId()
and therefore does not add any value.
getMostRecentStackId
in interface SessionCookie
public void setMostRecentStackId(int mostRecentStackId)
SessionCookie
This method is used by the pooling framework to set the local most recent stack id.
setMostRecentStackId
in interface SessionCookie
{@link #getMostRecentStackId()}
public void passivateState(java.lang.Object sink)
SessionCookie
If a not null sink is passed then passivateState should persist
the passivation id to the sink using SessionCookie.writeValue(Object)
.
State passivation should not take place if failover is disabled.
passivateState
in interface SessionCookie
public void reservePassivationId()
SessionCookie
A passivation id should not be reserved if one has already been reserved or if failover is disabled.
reservePassivationId
in interface SessionCookie
SessionCookie.getReservedPassivationId()
public void reservePassivationId(java.lang.Object sink)
SessionCookie
If a not null sink is passed then reservePassivationId should persist
the reserved passivation id to the sink using SessionCookie.writeValue(Object)
.
A passivation id should not be reserved if one has already been reserved or if failover is disabled.
reservePassivationId
in interface SessionCookie
SessionCookie.getReservedPassivationId()
public int getReservedPassivationId()
SessionCookie
The next passivation id should be used when generating the session cookie value.
getReservedPassivationId
in interface SessionCookie
public void setReservedPassivationId(int reservedPassivationId)
SessionCookie
setReservedPassivationId
in interface SessionCookie
public java.util.Hashtable getUserData()
ApplicationModuleHandle
getUserData
in interface ApplicationModuleHandle
public java.lang.String getSSOUserName()
getSSOUserName
in interface SessionCookie
public java.lang.String getSSOSubscriber()
getSSOSubscriber
in interface SessionCookie
public void resetState()
ApplicationModuleRef
Invoking this method after an ApplicationModule has been released with state management specified will result in the affinity between the ApplicationModuleRef and the ApplicationModule state being lost. Consequently, the next time invocation of useApplicationModule on this ApplicationModuleRef will return a stateless Applicationmodule.
Invoking this method on an ApplicationModuleRef which is not referencing any ApplicationModule state will have no effect. Invoking this method on an ApplicationModuleRef which is currently reserving an ApplicationModule will result in an ApplicationPoolException.
resetState
in interface ApplicationModuleRef
public void resetStateInternal()
SessionCookie
resetStateInternal
in interface SessionCookie
public void copyInto(SessionCookie cookie)
SessionCookie
copyInto
in interface SessionCookie
cookie
- the target of the copy.public boolean isFailoverEnabled()
SessionCookie
Session cookie developers should be careful that this value not change after a session cookie has become active.
isFailoverEnabled
in interface SessionCookie
public boolean isConnectionPoolingEnabled()
SessionCookie
Session cookie developers should be careful that this value not change after a session cookie has become active.
isConnectionPoolingEnabled
in interface SessionCookie
public boolean isResetNonTransactionalState()
SessionCookie
Transactional state includes the state of the transaction caches (EO and VO) and database state. Non-transactional state includes child view usage and application module usage instances and their related state including dynamic where clauses, order by clauses, and bind parameters. If connection pooling has been disabled for the application pool then non-transaction state will also include any cached JDBC statements.
isResetNonTransactionalState
in interface SessionCookie
protected boolean getProperty(java.lang.String name, java.util.Hashtable environment, boolean defaultValue)
public void setSessionCookieListener(SessionCookieListener listener)
SessionCookie
setSessionCookieListener
in interface SessionCookie
public static java.lang.String parseSessionId(java.lang.String cookieValue)
public static int parsePassivationId(java.lang.String cookieValue)
public final int getThreadRefCount()
SessionCookie
getThreadRefCount
in interface SessionCookie
public void setSingleThreaded(boolean isSingleThreaded)
Setting this property will force the cookie to maintain a refcount for all threads that have invoked useApplicationModule after the property has been set. Only after the last thread that has used the application module releases the application will the application module actually be returned to the pool.
The default value of this property for
SessionCookieImpl
instances is true.
The default value of this property for
HttpSessionCookieImpl
instances is false.
public void setReferenceCounting(boolean isReferenceCounting)
SessionCookie
ApplicationModuleRef.useApplicationModule()
an arbitrary number of times with only
one matching SessionCookie.releaseApplicationModule(int)
invocation. The
release will always result in the ApplicationModule being released to
the ApplicationPool. If reference counting is enabled then the number of
release invocations must match the number of use invocations and only the
last release will result in the ApplicationModule being released
to the ApplicationPool.
setReferenceCounting
in interface SessionCookie
public void setUserData(java.lang.Object name, java.lang.Object value)
SessionCookie
SessionCookie user data is automatically synched with the ApplicationModule upon ApplicationModule use.
setUserData
in interface SessionCookie
public java.lang.Object getUserData(java.lang.Object name)
SessionCookie
getUserData
in interface SessionCookie
public java.lang.Object removeUserData(java.lang.Object name)
SessionCookie
removeUserData
in interface SessionCookie
public boolean wasActivated()
SessionCookie
wasActivated
in interface SessionCookie
public void setActivated(boolean activated)
SessionCookie
setActivated
in interface SessionCookie
public boolean getIgnorePiggyback()
SessionCookie
getIgnorePiggyback
in interface SessionCookie
public void setIgnorePiggyback(boolean ignorePiggyback)
SessionCookie
setIgnorePiggyback
in interface SessionCookie
|
Oracle ADF Model and Business Components API Reference 10.1.2 B14022-01 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 1997, 2004, Oracle. All rights reserved.