org.lwes.emitter
Class MulticastEventEmitter

java.lang.Object
  extended by org.lwes.emitter.MulticastEventEmitter
All Implemented Interfaces:
EventEmitter

public class MulticastEventEmitter
extends java.lang.Object
implements EventEmitter

MulticastEventEmitter emits events to multicast groups on the network. This is the most common class used by users of the Light Weight Event System. Example code:

 MulticastEventEmitter emitter = new MulticastEventEmitter();
 emitter.setESFFilePath("/path/to/esf/file");
 emitter.setMulticastAddress(InetAddress.getByName("224.0.0.69"));
 emitter.setMulticastPort(9191);
 emitter.initialize();

 Event e = emitter.createEvent("MyEvent", false);
 e.setString("key","value");
 emitter.emit(e);
 

Since:
0.0.1
Author:
Michael P. Lum, Anthony Molinaro

Constructor Summary
MulticastEventEmitter()
          Default constructor.
 
Method Summary
 Event createEvent(java.lang.String eventName)
          Creates a new event named eventName.
 Event createEvent(java.lang.String eventName, boolean validate)
          Creates a new event named eventName.
protected  void emit(byte[] bytes)
          Emits a byte array to the network.
 void emit(Event event)
          Emits the event to the network.
 java.lang.String getESFFilePath()
          Gets the ESF file used for event validation
 java.io.InputStream getESFInputStream()
          Gets the InputStream being used for event validation.
 java.net.InetAddress getInterface()
          Gets the network interface for this emitter.
 java.net.InetAddress getMulticastAddress()
          Gets the multicast address for this emitter.
 int getMulticastPort()
          Gets the multicast port for this emitter.
 int getTimeToLive()
          Gets the multicast time-to-live for this emitter.
 void initialize()
          Initializes the emitter.
 void setESFFilePath(java.lang.String esfFilePath)
          Sets the ESF file used for event validation.
 void setESFInputStream(java.io.InputStream esfInputStream)
          Sets an InputStream to be used for event validation.
 void setInterface(java.net.InetAddress iface)
          Sets the network interface for this emitter.
 void setMulticastAddress(java.net.InetAddress address)
          Sets the multicast address for this emitter.
 void setMulticastPort(int port)
          Sets the multicast port for this emitter.
 void setTimeToLive(int ttl)
          Sets the multicast time-to-live for this emitter.
 void shutdown()
          Shuts down the emitter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MulticastEventEmitter

public MulticastEventEmitter()
Default constructor.

Method Detail

setMulticastAddress

public void setMulticastAddress(java.net.InetAddress address)
Sets the multicast address for this emitter.

Parameters:
address - the multicast address

getMulticastAddress

public java.net.InetAddress getMulticastAddress()
Gets the multicast address for this emitter.

Returns:
the address

setMulticastPort

public void setMulticastPort(int port)
Sets the multicast port for this emitter.

Parameters:
port - the multicast port

getMulticastPort

public int getMulticastPort()
Gets the multicast port for this emitter.

Returns:
the multicast port

setInterface

public void setInterface(java.net.InetAddress iface)
Sets the network interface for this emitter.

Parameters:
iface - the network interface

getInterface

public java.net.InetAddress getInterface()
Gets the network interface for this emitter.

Returns:
the interface address

setTimeToLive

public void setTimeToLive(int ttl)
Sets the multicast time-to-live for this emitter.

Parameters:
ttl - the time to live

getTimeToLive

public int getTimeToLive()
Gets the multicast time-to-live for this emitter.

Returns:
the time to live

setESFFilePath

public void setESFFilePath(java.lang.String esfFilePath)
Sets the ESF file used for event validation.

Specified by:
setESFFilePath in interface EventEmitter
Parameters:
esfFilePath - the path of the ESF file

getESFFilePath

public java.lang.String getESFFilePath()
Gets the ESF file used for event validation

Specified by:
getESFFilePath in interface EventEmitter
Returns:
the ESF file path

setESFInputStream

public void setESFInputStream(java.io.InputStream esfInputStream)
Sets an InputStream to be used for event validation.

Specified by:
setESFInputStream in interface EventEmitter
Parameters:
esfInputStream - an InputStream used for event validation

getESFInputStream

public java.io.InputStream getESFInputStream()
Gets the InputStream being used for event validation.

Specified by:
getESFInputStream in interface EventEmitter
Returns:
the InputStream of the ESF validator

initialize

public void initialize()
                throws java.io.IOException
Initializes the emitter.

Specified by:
initialize in interface EventEmitter
Throws:
java.io.IOException - if an I/O error occurs during initialization

shutdown

public void shutdown()
              throws java.io.IOException
Shuts down the emitter.

Specified by:
shutdown in interface EventEmitter
Throws:
java.io.IOException - if an I/O error occurs during initialization

createEvent

public Event createEvent(java.lang.String eventName)
                  throws EventSystemException
Creates a new event named eventName.

Specified by:
createEvent in interface EventEmitter
Parameters:
eventName - the name of the event to be created
Returns:
a new Event
Throws:
EventSystemException - if there is a problem creating the event

createEvent

public Event createEvent(java.lang.String eventName,
                         boolean validate)
                  throws EventSystemException
Creates a new event named eventName.

Specified by:
createEvent in interface EventEmitter
Parameters:
eventName - the name of the event to be created
validate - whether or not to validate the event against the EventTemplateDB
Returns:
a new Event
Throws:
EventSystemException - if there is a problem creating the event

emit

public void emit(Event event)
          throws java.io.IOException
Emits the event to the network.

Specified by:
emit in interface EventEmitter
Parameters:
event - the event to emit
Throws:
java.io.IOException - throws an IOException is there is a network error.

emit

protected void emit(byte[] bytes)
             throws java.io.IOException
Emits a byte array to the network.

Parameters:
bytes - the byte array to emit
Throws:
java.io.IOException - throws an IOException if there is a network error.