flex.messaging
Class FlexSession

java.lang.Object
  extended by flex.messaging.util.TimeoutAbstractObject
      extended by flex.messaging.FlexSession
All Implemented Interfaces:
FlexClientListener, MessageClientListener
Direct Known Subclasses:
HttpFlexSession, NonHttpFlexSession

public abstract class FlexSession
extends TimeoutAbstractObject
implements FlexClientListener, MessageClientListener

The base for FlexSession implementations.


Field Summary
static String FLEX_SESSION_LOG_CATEGORY
          Log category for FlexSession related messages.
 
Method Summary
 void addSessionAttributeListener(FlexSessionAttributeListener listener)
          Adds a session attribute listener that will be notified when an attribute is added, removed or changed.
static void addSessionCreatedListener(FlexSessionListener listener)
          Adds a session created listener that will be notified when new sessions are created.
 void addSessionDestroyedListener(FlexSessionListener listener)
          Adds a session destroy listener that will be notified when the session is destroyed.
 void clearRemoteCredentials(String serviceId, String destinationId)
          Clears any stored remote credentials from the session for the specified service destination.
 Object getAttribute(String name)
          Returns the attribute bound to the specified name in the session, or null if no attribute is bound under the name.
 Enumeration getAttributeNames()
          Returns a snapshot of the names of all attributes bound to the session.
 List getFlexClients()
          Returns a snapshot of the FlexClients associated with the FlexSession when this method is invoked.
abstract  String getId()
          Returns the Id for the session.
 List getMessageClients()
          Returns a snapshot of the MessageClients (subscriptions) associated with the FlexSession when this method is invoked.
 FlexRemoteCredentials getRemoteCredentials(String serviceId, String destinationId)
          Returns the remote credentials stored in the session for the specified service destination.
 Principal getUserPrincipal()
          This method should be called on FlexContext and not on this class.
 void invalidate()
          Invalidates the FlexSession.
 boolean isUserInRole(String role)
          Returns whether the current user is in the specified role.
 boolean isValid()
          Returns whether the session is valid.
 void putRemoteCredentials(FlexRemoteCredentials credentials)
          Stores remote credentials in the session for proxied calls to remote systems.
 void removeAttribute(String name)
          Removes the attribute bound to the specified name in the session.
 void removeSessionAttributeListener(FlexSessionAttributeListener listener)
          Removes a session attribute listener.
static void removeSessionCreatedListener(FlexSessionListener listener)
          Removes a session created listener.
 void removeSessionDestroyedListener(FlexSessionListener listener)
          Removes a session destroy listener.
 void setAttribute(String name, Object value)
          Binds an attribute value to the session under the specified name.
 void setUserPrincipal(Principal userPrincipal)
          This method should be called on FlexContext and not on this class.
 void timeout()
          Default implementation invokes invalidate() upon timeout.
 
Methods inherited from class flex.messaging.util.TimeoutAbstractObject
cancelTimeout, getLastUse, getTimeoutFuture, getTimeoutManager, getTimeoutPeriod, getTimeoutTask, setLastUse, setTimeoutFuture, setTimeoutManager, setTimeoutPeriod, setTimeoutTask, updateLastUse
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface flex.messaging.client.FlexClientListener
clientCreated, clientDestroyed
 
Methods inherited from interface flex.messaging.MessageClientListener
messageClientCreated, messageClientDestroyed
 

Field Detail

FLEX_SESSION_LOG_CATEGORY

public static final String FLEX_SESSION_LOG_CATEGORY
Log category for FlexSession related messages.

See Also:
Constant Field Values
Method Detail

addSessionCreatedListener

public static void addSessionCreatedListener(FlexSessionListener listener)
Adds a session created listener that will be notified when new sessions are created.

Parameters:
listener - The listener to add.
See Also:
FlexSessionListener

removeSessionCreatedListener

public static void removeSessionCreatedListener(FlexSessionListener listener)
Removes a session created listener.

Parameters:
listener - The listener to remove.
See Also:
FlexSessionListener

getUserPrincipal

public Principal getUserPrincipal()
This method should be called on FlexContext and not on this class. Keeping this method for backwards compatibility. This method will produce correct results when perClientAuthentication is false. However, it will not return correct results when perClientAuthentication is true. Returns the principal associated with the session. If the client has not authenticated the principal will be null.

Returns:
The principal associated with the session.

setUserPrincipal

public void setUserPrincipal(Principal userPrincipal)
This method should be called on FlexContext and not on this class. Keeping this method for backwards compatibility. Calling this when perClientAuthentication is true will not correctly set the UserPrincipal.

Parameters:
userPrincipal - The principal to associate with the session.

addSessionAttributeListener

public void addSessionAttributeListener(FlexSessionAttributeListener listener)
Adds a session attribute listener that will be notified when an attribute is added, removed or changed.

Parameters:
listener - The listener to add.

addSessionDestroyedListener

public void addSessionDestroyedListener(FlexSessionListener listener)
Adds a session destroy listener that will be notified when the session is destroyed. Session destroy listeners are notified after all attributes have been unbound from the session and any FlexSessionBindingListeners and FlexSessionAttributeListeners have been notified.

Parameters:
listener - The listener to add.
See Also:
FlexSessionListener

getAttribute

public Object getAttribute(String name)
Returns the attribute bound to the specified name in the session, or null if no attribute is bound under the name.

Parameters:
name - The name the target attribute is bound to.
Returns:
The attribute bound to the specified name.

getAttributeNames

public Enumeration getAttributeNames()
Returns a snapshot of the names of all attributes bound to the session.

Returns:
A snapshot of the names of all attributes bound to the session.

removeAttribute

public void removeAttribute(String name)
Removes the attribute bound to the specified name in the session.

Parameters:
name - The name of the attribute to remove.

removeSessionAttributeListener

public void removeSessionAttributeListener(FlexSessionAttributeListener listener)
Removes a session attribute listener.

Parameters:
listener - The listener to remove.

removeSessionDestroyedListener

public void removeSessionDestroyedListener(FlexSessionListener listener)
Removes a session destroy listener.

Parameters:
listener - The listener to remove.
See Also:
FlexSessionListener

setAttribute

public void setAttribute(String name,
                         Object value)
Binds an attribute value to the session under the specified name.

Parameters:
name - The name to bind the attribute under.
value - The value of the attribute.

putRemoteCredentials

public void putRemoteCredentials(FlexRemoteCredentials credentials)
Stores remote credentials in the session for proxied calls to remote systems.

Parameters:
credentials - The remote credentials.

getRemoteCredentials

public FlexRemoteCredentials getRemoteCredentials(String serviceId,
                                                  String destinationId)
Returns the remote credentials stored in the session for the specified service destination.

Parameters:
serviceId - The service id.
destinationId - The destination id.
Returns:
The stored remote credentials for the specified service destination.

clearRemoteCredentials

public void clearRemoteCredentials(String serviceId,
                                   String destinationId)
Clears any stored remote credentials from the session for the specified service destination.

Parameters:
serviceId - The service Id.
destinationId - The destination Id.

invalidate

public void invalidate()
Invalidates the FlexSession.


getFlexClients

public List getFlexClients()
Returns a snapshot of the FlexClients associated with the FlexSession when this method is invoked. This list is not guaranteed to remain consistent with the actual list of active FlexClients associated with the FlexSession over time.

Returns:
A snapshot of the current list of FlexSessions associated with the FlexClient.

getMessageClients

public List getMessageClients()
Returns a snapshot of the MessageClients (subscriptions) associated with the FlexSession when this method is invoked. This list is not guaranteed to remain consistent with the actual list of active MessageClients associated with the FlexSession over time.

Returns:
A snapshot of the current list of MessageClients associated with the FlexSession.

getId

public abstract String getId()
Returns the Id for the session.

Returns:
The Id for the session.

isUserInRole

public boolean isUserInRole(String role)
Returns whether the current user is in the specified role.

Parameters:
role - The role to test.
Returns:
true if the user is in the role; otherwise false.

isValid

public boolean isValid()
Returns whether the session is valid.

Returns:
true if the session is valid; otherwise false.

timeout

public void timeout()
Default implementation invokes invalidate() upon timeout.

See Also:
TimeoutCapable.timeout()


Copyright © 2008 Adobe Systems Inc. All Rights Reserved.

 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/blazeds/1/javadoc/flex/messaging/FlexSession.html