org.sapia.ubik.mcast
Class BroadcastDispatcherImpl

java.lang.Object
  extended by org.sapia.ubik.mcast.BroadcastDispatcherImpl
All Implemented Interfaces:
BroadcastDispatcher

public class BroadcastDispatcherImpl
extends java.lang.Object
implements BroadcastDispatcher

Dispatches objects using a multicast channel.

Author:
Yanick Duchesne
Copyright:
Copyright © 2002-2003 Sapia Open Source Software. All Rights Reserved.
License:
Read the license.txt file of the jar or visit the license page at the Sapia OSS web site

Constructor Summary
BroadcastDispatcherImpl(EventConsumer cons, java.lang.String mcastHost, int mcastPort)
           
BroadcastDispatcherImpl(java.lang.String domain, java.lang.String mcastHost, int mcastPort)
           
BroadcastDispatcherImpl(java.lang.String node, java.lang.String domain, java.lang.String mcastHost, int mcastPort, int ttl)
           
 
Method Summary
 void close()
          Closes this instance, which should thereafter not be used.
 void dispatch(boolean alldomains, java.lang.String evtType, java.lang.Object data)
          Dispatches a multicast event holding the given parameters.
 void dispatch(java.lang.String domain, java.lang.String evtType, java.lang.Object data)
          Dispatches a multicast event to the given domain.
 java.lang.String getMulticastAddress()
          Returns this instance's multicast address.
 int getMulticastPort()
          Returns this instance's multicast port.
 java.lang.String getNode()
          Returns the node identifier of this instance.
 void registerAsyncListener(java.lang.String evtType, AsyncEventListener listener)
          Registers the given listener with the given event type.
 void setBufsize(int size)
          Sets this instance buffer size.
 void start()
          Starts this instance.
 void unregisterListener(AsyncEventListener listener)
          Unregisters the given listener from this instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BroadcastDispatcherImpl

public BroadcastDispatcherImpl(EventConsumer cons,
                               java.lang.String mcastHost,
                               int mcastPort)
                        throws java.io.IOException
Throws:
java.io.IOException

BroadcastDispatcherImpl

public BroadcastDispatcherImpl(java.lang.String node,
                               java.lang.String domain,
                               java.lang.String mcastHost,
                               int mcastPort,
                               int ttl)
                        throws java.io.IOException
Throws:
java.io.IOException

BroadcastDispatcherImpl

public BroadcastDispatcherImpl(java.lang.String domain,
                               java.lang.String mcastHost,
                               int mcastPort)
                        throws java.io.IOException
Throws:
java.io.IOException
Method Detail

setBufsize

public void setBufsize(int size)
Sets this instance buffer size. This size is used to create the byte arrays that store the data of incoming UDP datagrams.

The size should be large enough to hold the data of incoming datagrams.

Specified by:
setBufsize in interface BroadcastDispatcher
Parameters:
size - a buffer size - corresponding to the size of expected UDP datagrams.

getNode

public java.lang.String getNode()
Returns the node identifier of this instance.

Specified by:
getNode in interface BroadcastDispatcher
Returns:
this instance's node identifier.

close

public void close()
Closes this instance, which should thereafter not be used.

Specified by:
close in interface BroadcastDispatcher

dispatch

public void dispatch(boolean alldomains,
                     java.lang.String evtType,
                     java.lang.Object data)
              throws java.io.IOException
Description copied from interface: BroadcastDispatcher
Dispatches a multicast event holding the given parameters.

Specified by:
dispatch in interface BroadcastDispatcher
Parameters:
alldomains - if true sends an event to all domains.
evtType - the logical identifier of the event.
data - the data that is encapsulated within the event.
Throws:
java.io.IOException - if an IO problem occurs.
See Also:
BroadcastDispatcher.dispatch(boolean, String, Object)

dispatch

public void dispatch(java.lang.String domain,
                     java.lang.String evtType,
                     java.lang.Object data)
              throws java.io.IOException
Description copied from interface: BroadcastDispatcher
Dispatches a multicast event to the given domain.

Specified by:
dispatch in interface BroadcastDispatcher
Parameters:
domain - the domain to dispatch the event to.
evtType - the logical identifier of the event.
data - the data that is encapsulated within the event.
Throws:
java.io.IOException - if an IO problem occurs.
See Also:
BroadcastDispatcher.dispatch(String, String, Object)

registerAsyncListener

public void registerAsyncListener(java.lang.String evtType,
                                  AsyncEventListener listener)
Registers the given listener with the given event type.

Parameters:
evtType - the logical type of RemoteEvents to listen for.
listener - the AsyncEventListener to register.

unregisterListener

public void unregisterListener(AsyncEventListener listener)
Unregisters the given listener from this instance.

Parameters:
listener - the AsyncEventListener to unregister.

start

public void start()
Starts this instance.

Specified by:
start in interface BroadcastDispatcher

getMulticastAddress

public java.lang.String getMulticastAddress()
Description copied from interface: BroadcastDispatcher
Returns this instance's multicast address.

Specified by:
getMulticastAddress in interface BroadcastDispatcher
Returns:
a multicast address string.
See Also:
BroadcastDispatcher.getMulticastAddress()

getMulticastPort

public int getMulticastPort()
Description copied from interface: BroadcastDispatcher
Returns this instance's multicast port.

Specified by:
getMulticastPort in interface BroadcastDispatcher
Returns:
a multicast port.
See Also:
BroadcastDispatcher.getMulticastPort()


Copyright © 2010 Sapia OSS. All Rights Reserved.