|
Foundation |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface SessionContextInterface
The SessionContextInterface provides a control structure for maintaining state within a bound session and facilitates resource management and context passing. It is a convenience container for passing multiple contexts.
Objects are bound to the session context by name when they are
added with setAttribute(Object)
.
If the object bound to the session context implements
RemoteSessionContextStateChangedListener
, it will be notified when it is
removed from the session context or when the session context is
destroyed. This notification will
allow objects to cleanup any resources that are necessary. Additionally,
the session context acts as a convenience container for other
commonly used service resources, such as the
user context and the default logger.
Method Summary | |
---|---|
void |
destroy()
Destroy the session context. |
void |
destroy(long delay)
Destroy the session context after the specified delay. |
java.lang.Object |
getAttribute(java.lang.String name)
Returns the object bound with the specified name in this session context, or null if no object is bound under this name. |
LoggerInterface |
getLogger()
Deprecated. The Logging Service has been deprecated. Use Log4J directly instead of calling this method to get the Logging Service logger. |
SessionContextInterface |
getRootSessionContext()
Returns the root session context. |
SessionContextInterface |
getRootSessionContext(UserContextInterface userContext)
Returns the root session context. |
java.lang.String |
getRootSessionContextEntityKey()
Returns the entity key for the root session context. |
UserContextInterface |
getUserContext()
Returns the user context defined for this session context. |
boolean |
isDestroyPending()
Returns a flag indicating whether a destroy is pending for this session context. |
java.lang.Object |
lock(java.lang.String applicationName)
Locks the session context so that it cannot be destroyed. |
boolean |
removeAttribute(java.lang.String name)
Removes the object from the session context. |
java.lang.String |
setAttribute(java.lang.Object value)
Binds the object to the session context, creating and returning the unique key name that was used. |
java.lang.Object |
setAttribute(java.lang.String name,
java.lang.Object value)
Binds the object to the session context, using the specified name. |
void |
setTimeoutDisabled(boolean timeoutDisabled)
Set whether or not this session can timeout. |
void |
setUserContext(UserContextInterface userContext)
Sets the user context to bind to this session context. |
byte[] |
toByteArray()
This is a platform private method that should only be used internally by the Platform Services. |
void |
touch()
Touch the session so that its last access time is updated as recently used. |
void |
unlock(java.lang.Object lockObject)
Unlocks the session context. |
Method Detail |
---|
SessionContextInterface getRootSessionContext() throws java.lang.IllegalStateException, java.rmi.RemoteException
SessionContextPermission
is required to obtain the root
session context.
SessionContextInterface
that is the root session context.
java.lang.IllegalStateException
- If the session context has
already been destroyed.
java.rmi.RemoteException
- If a network anomaly is encountered.SessionContextInterface getRootSessionContext(UserContextInterface userContext) throws java.lang.IllegalStateException, java.rmi.RemoteException
SessionContextPermission
is required to obtain the root
session context.
userContext
- A user context whose principals will be checked
for permission to perform the getRootSessionContext function. This can
be null, but if the method is invoked remotely, it will always
fail with a null user context.
SessionContextInterface
that is the root session context.
java.lang.IllegalStateException
- If the session context has
already been destroyed.
java.rmi.RemoteException
- If a network anomaly is encountered.java.lang.String getRootSessionContextEntityKey() throws java.rmi.RemoteException
String
the entity key for the root session context.
java.lang.IllegalStateException
- If the session context has
already been destroyed.
java.rmi.RemoteException
- If a network anomaly is encountered.UserContextInterface getUserContext() throws java.lang.IllegalStateException, java.rmi.RemoteException
setUserContext(UserContextInterface)
, this will return the user context assigned
by setUserContext.
UserContextInterface
The user context bound to this
session context. This may be null if no user context has been set yet.
java.lang.IllegalStateException
- If the session context has
already been destroyed.
java.rmi.RemoteException
- If a network anomaly is encountered.void setUserContext(UserContextInterface userContext) throws java.lang.IllegalStateException, java.rmi.RemoteException
getUserContext()
. If
the session context was created with a null user context, then
the user context can be set at a later time. Once
the user context has been set, it cannot be changed.
userContext
- The user context to bind to this session.
java.lang.IllegalStateException
- If the session context has
already been destroyed or if the user context has already been set.
java.rmi.RemoteException
- If a network anomaly is encountered.LoggerInterface getLogger() throws java.lang.IllegalStateException, java.rmi.RemoteException
java.lang.IllegalStateException
- If the session context has
already been destroyed.
java.rmi.RemoteException
- If a network anomaly is encountered.java.lang.Object setAttribute(java.lang.String name, java.lang.Object value) throws java.lang.IllegalStateException, java.rmi.RemoteException
RemoteSessionContextStateChangedListener
, the
session context will invoke
RemoteSessionContextStateChangedListener.contextStateChanged(SessionContextStateChangedEvent)
when the session is destroyed or when the object is removed from the session context.
This allows the object to cleanup any resources that are necessary.
If an object of the same name is already bound to the session context,
the object is replaced. If the object that is replaced implements
RemoteSessionContextStateChangedListener
, the session context will
invoke
RemoteSessionContextStateChangedListener.contextStateChanged(SessionContextStateChangedEvent)
so that it will be notified of its removal from the session context.
The SessionContextInterface is a remotable interface. Distributed applications should ensure that bound objects are remotable.
name
- String that identifies the name of the object bound
to the session context; cannot be null.value
- The object to bind to the session context; can be null.
null
if there was no mapping for key
java.lang.IllegalArgumentException
- If a null name is specified.
java.lang.IllegalStateException
- If the session context has
already been destroyed.
java.rmi.RemoteException
- If a network anomaly is encountered.java.lang.String setAttribute(java.lang.Object value) throws java.lang.IllegalStateException, java.rmi.RemoteException
value
- The object to bind to the session context; can be null
.
String
The generated unique key name used to track
the object. The name will be in the form of
"session1", "session2", ..., "sessionN".
java.lang.IllegalStateException
- If the session context has
already been destroyed.
java.rmi.RemoteException
- If a network anomaly is encountered.java.lang.Object getAttribute(java.lang.String name) throws java.lang.IllegalStateException, java.rmi.RemoteException
name
- A string that identifies the name of the object; cannot be null.
Object
The object.
java.lang.IllegalArgumentException
- If a null name
is specified.
java.lang.IllegalStateException
- If the session context has
already been destroyed.
java.rmi.RemoteException
- If a network anomaly is encountered.boolean removeAttribute(java.lang.String name) throws java.lang.IllegalStateException, java.rmi.RemoteException
If the object being removed implements
RemoteSessionContextStateChangedListener
, the session context will invoke
RemoteSessionContextStateChangedListener.contextStateChanged(SessionContextStateChangedEvent)
.
name
- Name that identifies the object; cannot be null.
boolean
that is true if the object was removed or
false if an object with the specified name was not
found.
java.lang.IllegalArgumentException
- If a null name
is specified.
java.lang.IllegalStateException
- If the session context has
already been destroyed.
java.rmi.RemoteException
- If a network anomaly is encountered.java.lang.Object lock(java.lang.String applicationName) throws java.lang.IllegalStateException, java.rmi.RemoteException
lock
method will return a unique lock object that must be
used by that application to unlock the session context. The session context
cannot be destroyed until all locks have been removed.
See Session Context Sharing
for details on session context locking and sharing.
applicationName
- The application name that will be used by the session
context for logging and monitoring purposes.
Object
The lock object that will be required to unlock
the session context.
java.lang.IllegalStateException
- If the session context has
already been destroyed.
java.rmi.RemoteException
- If a network anomaly is encountered.void unlock(java.lang.Object lockObject) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException, java.rmi.RemoteException
lockObject
- The lock object returned by lock(String)
.
java.lang.IllegalArgumentException
- If an invalid lockObject
is specified.
java.lang.IllegalStateException
- If the session context has
already been destroyed.
java.rmi.RemoteException
- If a network anomaly is encountered.void destroy() throws LockingException, java.lang.IllegalStateException, java.rmi.RemoteException
RemoteSessionContextStateChangedListener
, the session context will
invoke
RemoteSessionContextStateChangedListener.contextStateChanged(SessionContextStateChangedEvent)
.
This allows objects to be notified when they are removed from the
session context so they can perform any necessary cleanup.
The session context cannot be destroyed until all locks have been
removed using the unlock
method.
See Session Context Sharing
for details on session context locking and sharing.
LockingException
- If the session context is
locked.
java.lang.IllegalStateException
- If the session context has
already been destroyed.
java.rmi.RemoteException
- If a network anomaly is encountered.void destroy(long delay) throws ServiceException, java.lang.IllegalStateException, java.rmi.RemoteException
RemoteSessionContextStateChangedListener
, the session context will
invoke
RemoteSessionContextStateChangedListener.contextStateChanged(SessionContextStateChangedEvent)
.
This allows objects to be notified when they are removed from the
session context so they can perform any necessary cleanup.
The session context cannot be destroyed until all locks have been
removed using the unlock
method.
See Session Context Sharing
for details on session context locking and sharing.
delay
- delay in milliseconds before the session context
will be destroyed.
ServiceException
- If the service encounters an error
with the deferred destroy.
java.lang.IllegalStateException
- If the session context has
already been destroyed.
java.rmi.RemoteException
- If a network anomaly is encountered.byte[] toByteArray() throws java.rmi.RemoteException, ServiceException
ServiceException
- if a service level error occurs.
java.rmi.RemoteException
- in the event of remote object failure.void touch() throws java.rmi.RemoteException
java.rmi.RemoteException
- in the event of remote object failure.boolean isDestroyPending() throws java.rmi.RemoteException
true
if the Session Context is in a destroy
pending state; otherwise false
is returned.
java.rmi.RemoteException
- if a network error occurs.void setTimeoutDisabled(boolean timeoutDisabled) throws java.rmi.RemoteException
timeoutDisabled
- true if the session should not timeout, false otherwise
java.rmi.RemoteException
|
Foundation |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |