com.sun.sgs.impl.nio
Class AsyncDatagramChannelImpl.MembershipKeyImpl

java.lang.Object
  extended by com.sun.sgs.nio.channels.MembershipKey
      extended by com.sun.sgs.impl.nio.AsyncDatagramChannelImpl.MembershipKeyImpl
Enclosing class:
AsyncDatagramChannelImpl

final class AsyncDatagramChannelImpl.MembershipKeyImpl
extends MembershipKey

A simple multicast membership key for datagram channels. Does not support source-specific filtering.


Constructor Summary
AsyncDatagramChannelImpl.MembershipKeyImpl(InetSocketAddress mcastaddr, NetworkInterface netIf)
          Creates a new membership key for the group.
 
Method Summary
 MembershipKey block(InetAddress source)
          Block multicast packets from the given source address.
 void drop()
          Drop membership.
 boolean equals(Object obj)
          
 MulticastChannel getChannel()
          Returns the channel for which this membership key was created.
 InetAddress getGroup()
          Returns the multicast group for which this membership key was created.
 NetworkInterface getNetworkInterface()
          Returns the network interface for which this membership key was created.
 InetAddress getSourceAddress()
          Returns the source address if this membership key is source specific, or null if this membership is not source specific.
 int hashCode()
          
 boolean isValid()
          Tells whether or not this membership is valid.
 MembershipKey unblock(InetAddress source)
          Unblock multicast packets from the given source address that was previously blocked using the MembershipKey.block(java.net.InetAddress) method.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AsyncDatagramChannelImpl.MembershipKeyImpl

AsyncDatagramChannelImpl.MembershipKeyImpl(InetSocketAddress mcastaddr,
                                           NetworkInterface netIf)
Creates a new membership key for the group.

Parameters:
mcastaddr - the multicast address of the group
netIf - the network interface of the group
Method Detail

isValid

public boolean isValid()
Tells whether or not this membership is valid.

A multicast group membership is valid upon creation and remains valid until the membership is dropped by invoking the MembershipKey.drop() method, or the channel is closed.

Specified by:
isValid in class MembershipKey
Returns:
true if this membership key is valid, false otherwise

drop

public void drop()
          throws IOException
Drop membership.

If the membership key represents a membership to receive all datagrams then the membership is dropped and the channel will no longer receive any datagrams sent to the group. If the membership key is source specific then the channel will no longer receive datagrams sent to the group from that source address.

After membership is dropped it may still be possible to receive datagams sent to the group. This can arise when datagrams are waiting to be received in the socket's receive buffer.

Upon return, this membership object will be invalid. If the multicast group membership is already invalid then invoking this method has no effect. Once a multicast group membership is invalid, it remains invalid forever.

Specified by:
drop in class MembershipKey
Throws:
IOException - if an I/O error occurs

block

public MembershipKey block(InetAddress source)
                    throws IOException
Block multicast packets from the given source address.

If this membership key is not source-specific, and the underlying operating system supports source filtering, then this method blocks multicast packets from the given source address. If the given source address is already blocked then this method has no effect. After a source address is blocked it may still be possible to receive datagams from that source. This can arise when datagrams are waiting to be received in the socket's receive buffer.

This implementation always throws UnsupportedOperationException.

Specified by:
block in class MembershipKey
Parameters:
source - the source address to block
Returns:
this membership key
Throws:
IOException - if an I/O error occurs

unblock

public MembershipKey unblock(InetAddress source)
                      throws IOException
Unblock multicast packets from the given source address that was previously blocked using the MembershipKey.block(java.net.InetAddress) method. This implementation always throws UnsupportedOperationException.

Specified by:
unblock in class MembershipKey
Parameters:
source - a list of source addresses to unblock
Returns:
this membership key
Throws:
IOException - if an I/O error occurs

getChannel

public MulticastChannel getChannel()
Returns the channel for which this membership key was created. This method will continue to return the channel even after the membership is dropped.

Specified by:
getChannel in class MembershipKey
Returns:
the channel

getGroup

public InetAddress getGroup()
Returns the multicast group for which this membership key was created. This method will continue to return the group even after the membership is dropped.

Specified by:
getGroup in class MembershipKey
Returns:
the multicast group

getNetworkInterface

public NetworkInterface getNetworkInterface()
Returns the network interface for which this membership key was created. This method will continue to return the network interface even after the membership is dropped or the channel is closed.

Specified by:
getNetworkInterface in class MembershipKey
Returns:
the network interface

getSourceAddress

public InetAddress getSourceAddress()
Returns the source address if this membership key is source specific, or null if this membership is not source specific.

This implementation is not source-specific, so always returns null.

Specified by:
getSourceAddress in class MembershipKey
Returns:
the source address if this membership key is source specific, otherwise null

equals

public boolean equals(Object obj)

Overrides:
equals in class Object

hashCode

public int hashCode()

Overrides:
hashCode in class Object

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