flex.messaging
Class FlexSession

java.lang.Object
  extended byflex.messaging.FlexSession

public abstract class FlexSession
extends Object

The base for FlexSession implementations.


Field Summary
protected  Object mutex
          Internal mutex to protect mutable members of a session instance (listeners/attributes/etc.).
 
Constructor Summary
FlexSession()
           
 
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 create 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.
protected  void checkValid()
          Ensures that the session has not been invalidated.
 void clearRemoteCredentials(String service, String destination)
           
protected  void destroy()
          Invoked by subclass upon session destruction to notify all registered session destroy listeners of the event.
 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 the names of all attributes bound to the session.
abstract  String getId()
          Returns a unique identifier association with this session.
 flex.messaging.FlexRemoteCredentials getRemoteCredentials(String service, String destination)
           
 Principal getUserPrincipal()
          Returns the principal associated with the session.
abstract  void invalidate()
          Invalidate this FlexSession.
 boolean isUserInRole(String role)
          Return whether the current user is in the specified role.
 boolean isValid()
          Return whether the session is valid.
protected  void notifyAttributeAdded(String name, Object value)
          Notify attribute listeners that an attribute has been added.
protected  void notifyAttributeBound(String name, Object value)
          Notify binding listener that it has been bound to the session.
protected  void notifyAttributeRemoved(String name, Object value)
          Notify attribute listeners that an attribute has been removed.
protected  void notifyAttributeReplaced(String name, Object value)
          Notify attribute listeners that an attribute has been replaced.
protected  void notifyAttributeUnbound(String name, Object value)
          Notify binding listener that it has been unbound from the session.
protected  void notifyOfCreation()
          Invoked by subclass upon session creation to notify all registered session create listeners of the event.
 void putRemoteCredentials(flex.messaging.FlexRemoteCredentials creds)
           
 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 create 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)
          Sets the principal associated with the session.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mutex

protected final Object mutex
Internal mutex to protect mutable members of a session instance (listeners/attributes/etc.).

Constructor Detail

FlexSession

public FlexSession()
Method Detail

getUserPrincipal

public Principal getUserPrincipal()
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)
Sets the principal associated with the session.

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

addSessionCreatedListener

public static void addSessionCreatedListener(FlexSessionListener listener)
Adds a session create 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 create listener.

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

addSessionAttributeListener

public void addSessionAttributeListener(FlexSessionAttributeListener listener)
Adds a session attribute listener that will be notified when an attribute is added, removed or changed. If the attribute implements FlexSessionBindingListener, it will be notified before any FlexSessionAttributeListeners are notified.

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

destroy

protected void destroy()
Invoked by subclass upon session destruction to notify all registered session destroy listeners of the event.


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 the names of all attributes bound to the session.

Returns:
The names of all attributes bound to the session.

notifyOfCreation

protected void notifyOfCreation()
Invoked by subclass upon session creation to notify all registered session create listeners of the event.


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(flex.messaging.FlexRemoteCredentials creds)

getRemoteCredentials

public flex.messaging.FlexRemoteCredentials getRemoteCredentials(String service,
                                                                 String destination)

clearRemoteCredentials

public void clearRemoteCredentials(String service,
                                   String destination)

invalidate

public abstract void invalidate()
Invalidate this FlexSession. The session will be destroyed and a new session will need to replace it.


getId

public abstract String getId()
Returns a unique identifier association with this session. If this is an HTTPSession, it returns the HTTPSession id as specified by the HttpSession.getId() method. For an RTMP session, it returns a unique id for that RTMP session.


isUserInRole

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

Parameters:
role -
Returns:
true if the user is in the role

isValid

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

Returns:
true if the session is valid.

checkValid

protected void checkValid()
Ensures that the session has not been invalidated.


notifyAttributeAdded

protected void notifyAttributeAdded(String name,
                                    Object value)
Notify attribute listeners that an attribute has been added.

Parameters:
name - The name of the attribute.
value - The new value of the attribute.

notifyAttributeBound

protected void notifyAttributeBound(String name,
                                    Object value)
Notify binding listener that it has been bound to the session.

Parameters:
name - The attribute name.
value - The attribute that has been bound.

notifyAttributeRemoved

protected void notifyAttributeRemoved(String name,
                                      Object value)
Notify attribute listeners that an attribute has been removed.

Parameters:
name - The name of the attribute.
value - The previous value of the attribute.

notifyAttributeReplaced

protected void notifyAttributeReplaced(String name,
                                       Object value)
Notify attribute listeners that an attribute has been replaced.

Parameters:
name - The name of the attribute.
value - The previous value of the attribute.

notifyAttributeUnbound

protected void notifyAttributeUnbound(String name,
                                      Object value)
Notify binding listener that it has been unbound from the session.

Parameters:
name - The attribute name.
value - The attribute that has been unbound.


Copyright © 2006 Adobe Systems Inc. All Rights Reserved. (Updated August 2, 2006)