com.sun.sgs.impl.service.session
Class ClientSessionWrapper

java.lang.Object
  extended by com.sun.sgs.impl.service.session.ClientSessionWrapper
All Implemented Interfaces:
ClientSession, ManagedObject, ManagedObjectRemoval, Serializable

public class ClientSessionWrapper
extends Object
implements ClientSession, Serializable, ManagedObjectRemoval

A wrapper for a ClientSessionImpl object that is passed to the application in the AppListener.loggedIn method when a client session logs in. A ClientSessionWrapper is passed to the application instead of a direct reference to a ClientSessionImpl instance to avoid the possibility of the application removing the ClientSessionImpl instance from the data service and interfering with the client session service's persistent data.

When a ClientSessionWrapper instance is removed from the data service, the underlying client session is disconnected.

See Also:
Serialized Form

Constructor Summary
ClientSessionWrapper(ManagedReference<ClientSessionImpl> sessionRef)
          Constructs an instance with the specified sessionRef.
 
Method Summary
 boolean equals(Object object)
          
 ClientSessionImpl getClientSession()
          Returns the underlying ClientSessionImpl instance for this wrapper.
 int getMaxMessageLength()
          Return the maximum message length supported by this session.
 String getName()
          Returns the login name used to authenticate this session.
 int hashCode()
          
 boolean isConnected()
          Returns true if the client is connected, otherwise returns false.
 void removingObject()
          Performs additional operations that are needed when this object is removed.
 ClientSession send(ByteBuffer message)
          Sends a message contained in the specified ByteBuffer to this session's client with the delivery guarantee of Delivery.RELIABLE.
 ClientSession send(ByteBuffer message, Delivery delivery)
          Sends a message contained in the specified ByteBuffer to this session's client in a manner that satisfies the specified delivery guarantee.
 Set<Delivery> supportedDeliveries()
          Returns a set containing the delivery guarantees supported by this session.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClientSessionWrapper

ClientSessionWrapper(ManagedReference<ClientSessionImpl> sessionRef)
Constructs an instance with the specified sessionRef.

Parameters:
sessionRef - a reference to a client session to wrap
Method Detail

getName

public String getName()
Returns the login name used to authenticate this session.

Specified by:
getName in interface ClientSession
Returns:
the name used to authenticate this session

supportedDeliveries

public Set<Delivery> supportedDeliveries()
Returns a set containing the delivery guarantees supported by this session. The returned set is serializable.

Specified by:
supportedDeliveries in interface ClientSession
Returns:
a set containing the supported delivery guarantees

getMaxMessageLength

public int getMaxMessageLength()
Return the maximum message length supported by this session.

Specified by:
getMaxMessageLength in interface ClientSession
Returns:
the maximum message length.

isConnected

public boolean isConnected()
Returns true if the client is connected, otherwise returns false.

Specified by:
isConnected in interface ClientSession
Returns:
true if the client is connected, otherwise returns false

send

public ClientSession send(ByteBuffer message)
Sends a message contained in the specified ByteBuffer to this session's client with the delivery guarantee of Delivery.RELIABLE. The message starts at the buffer's current position and ends at the buffer's limit. The buffer's position is not modified by this operation.

The ByteBuffer may be reused immediately after this method returns. Changes made to the buffer after this method returns will have no effect on the message sent to the client by this invocation.

This method is equivalent to invoking send with the specified message and Delivery.RELIABLE.

Specified by:
send in interface ClientSession
Parameters:
message - a message
Returns:
this client session

send

public ClientSession send(ByteBuffer message,
                          Delivery delivery)
Sends a message contained in the specified ByteBuffer to this session's client in a manner that satisfies the specified delivery guarantee. The message starts at the buffer's current position and ends at the buffer's limit. The buffer's position is not modified by this operation.

When possible, the message should be delivered using the most efficient means to satisfy the delivery guarantee. However, a stronger delivery guarantee may be used to deliver the message if the underlying protocol only supports stronger delivery guarantees. If the protocol is not able to satisfy the specified delivery guarantee (e.g., only supports weaker delivery guarantees than the one specified), then a DeliveryNotSupportedException will be thrown.

The ByteBuffer may be reused immediately after this method returns. Changes made to the buffer after this method returns will have no effect on the message sent to the client by this invocation.

Specified by:
send in interface ClientSession
Parameters:
message - a message
delivery - a delivery guarantee
Returns:
this client session

removingObject

public void removingObject()
Performs additional operations that are needed when this object is removed.

Specified by:
removingObject in interface ManagedObjectRemoval

equals

public boolean equals(Object object)

Overrides:
equals in class Object

hashCode

public int hashCode()

Overrides:
hashCode in class Object

toString

public String toString()

Overrides:
toString in class Object

getClientSession

public ClientSessionImpl getClientSession()
Returns the underlying ClientSessionImpl instance for this wrapper. If the underlying client session has been removed, then the client session has been disconnected, so IllegalStateException is thrown.

Returns:
the underlying ClientSessionImpl instance for this wrapper

RedDwarf, Version 0.10.1
2010-03-14 10:56:12

Copyright © 2010 The RedDwarf Authors. All rights reserved
Copyright © 2007-2010 Sun Microsystems, Inc. All rights reserved