|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.sgs.impl.service.channel.ChannelWrapper
class ChannelWrapper
A wrapper for a ChannelImpl object that is returned to the
application when a channel is created. A ChannelWrapper is
handed back to the application instead of a direct reference to a
ChannelImpl instance to avoid the possibility of the application
removing the ChannelImpl instance from the data service and
interfering with the channel service's persistent data.
When a ChannelWrapper instance is removed from the data
service, the underlying channel is closed.
| Constructor Summary | |
|---|---|
ChannelWrapper(ManagedReference<ChannelImpl> channelRef)
Constructs an instance with the specified channelRef. |
|
| Method Summary | |
|---|---|
boolean |
equals(Object object)
|
BigInteger |
getChannelId()
Returns this channel's ID as a BigInteger. |
Delivery |
getDelivery()
Returns the delivery guarantee of this channel. |
String |
getName()
Returns the name bound to this channel. |
Iterator<ClientSession> |
getSessions()
Returns an iterator for the client sessions joined to this channel. |
int |
hashCode()
|
boolean |
hasSessions()
Returns true if this channel has client sessions
joined to it, otherwise returns false. |
Channel |
join(ClientSession session)
Adds a client session to this channel. |
Channel |
join(Set<? extends ClientSession> sessions)
Adds the specified client sessions to this channel. |
Channel |
leave(ClientSession session)
Removes a client session from this channel. |
Channel |
leave(Set<? extends ClientSession> sessions)
Removes the specified client sessions from this channel, If a session in the specified set is not joined to this channel, then no action for that session is taken. |
Channel |
leaveAll()
Removes all client sessions from this channel. |
void |
removingObject()
Performs additional operations that are needed when this object is removed. |
Channel |
send(ByteBuffer message)
Sends the message contained in the specified buffer to all client sessions joined to this channel. |
Channel |
send(ClientSession sender,
ByteBuffer message)
Sends the message contained in the specified buffer to all client sessions joined to this channel. |
(package private) void |
setChannelRef(ManagedReference<ChannelImpl> channelRef)
Set the channel reference for this wrapper to the specified channelRef. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
ChannelWrapper(ManagedReference<ChannelImpl> channelRef)
channelRef.
channelRef - a reference to a channel to wrap| Method Detail |
|---|
public String getName()
getName in interface Channelpublic Delivery getDelivery()
getDelivery in interface Channelpublic boolean hasSessions()
true if this channel has client sessions
joined to it, otherwise returns false.
The returned result may not reflect changes to the membership that occurred in the current transaction. Such membership changes may be handled asynchronously, after the task making the changes completes.
hasSessions in interface Channeltrue if this channel has sessions joined
to it, otherwise returns falsepublic Iterator<ClientSession> getSessions()
The returned iterator may not reflect recent changes (in the current transaction or another recent transaction) to the channel's membership. Membership changes may be handled asynchronously, after the task making the changes completes. Therefore, the iterator may not include sessions that have been recently joined to the channel, or may include sessions that have recently left the channel (by being explicitly removed from the channel, or by being disconnected).
Note: This operation may be expensive, so it should be used judiciously.
getSessions in interface Channelpublic Channel join(ClientSession session)
DeliveryNotSupportedException will be
thrown.
join in interface Channelsession - a client session
public Channel join(Set<? extends ClientSession> sessions)
DeliveryNotSupportedException will be
thrown.
join in interface Channelsessions - a set of client sessions
public Channel leave(ClientSession session)
leave in interface Channelsession - a client session
public Channel leave(Set<? extends ClientSession> sessions)
leave in interface Channelsessions - a set of client sessions
public Channel leaveAll()
leaveAll in interface Channelpublic Channel send(ByteBuffer message)
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 channel by this invocation.
The maximum length of a message that can be sent over the channel is
dependent on the maximum message length supported by all joined client
sessions. (See: ClientSession.getMaxMessageLength())
send in interface Channelmessage - a message
public Channel send(ClientSession sender,
ByteBuffer message)
This send method, which has a sender argument, is
used to forward a message to a channel from the channel's ChannelListener. When the channel's listener receives a message
via its receivedMessage
method, the listener can perform access control operations on the
sender, alter the message content, and/or perform other operations
before (optionally) using this method, specifying the given sender, to forward the message to the channel.
If sender specified to this method is non-null,
it must be the sender supplied to the ChannelListener's receivedMessage method. If that sender
is not a member of this channel when the message is processed to be
sent, then the message will not be forwarded to the channel for
delivery. If the sender specified to this method is
non-null and is not the sender supplied to the
ChannelListener, then the channel message may not get
delivered to the channel.
If the sender is null, the message will be
forwarded to the channel.
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 channel by this invocation.
The maximum length of a message that can be sent over the channel is
dependent on the maximum message length supported by all joined client
sessions. See ClientSession.getMaxMessageLength().
send in interface Channelsender - the sending client session, or nullmessage - a message
public void removingObject()
removingObject in interface ManagedObjectRemovalpublic BigInteger getChannelId()
BigInteger.
BigIntegerpublic boolean equals(Object object)
equals in class Objectpublic int hashCode()
hashCode in class Objectpublic String toString()
toString in class Objectvoid setChannelRef(ManagedReference<ChannelImpl> channelRef)
channelRef. The underlying channel reference changes when the
application invokes leaveAll on the channel, which closes
and removes the old channel (except for the channel's name binding)
and reuses the existing wrapper, replacing the previous channel
reference with a reference to the "next generation" channel of the
same name.
channelRef - the new channel reference
|
RedDwarf, Version 0.10.1 2010-03-14 10:56:12 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||