com.sas.edir
Class EventQueue

java.lang.Object
  |
  +--com.sas.edir.EventQueue

public class EventQueue
extends java.lang.Object

Keep a persistent list of EventQueueMessage objects. Messages can be retrieved from queue in order, or by key. Messages are kept segregated by application name.

Version:
1.0
Author:
SAS

Constructor Summary
EventQueue()
          Construct an Event Queue
EventQueue(java.io.File store)
          Construct an Event Queue
 
Method Summary
 void clearMessages(EventQueueKey key, java.lang.String application)
          Clear messages from the queue matching the key.
 EventQueueMessage getMessage(EventQueueKey key, java.lang.String application)
          Get one message from the event queue.
 EventQueueMessage[] getMessages(EventQueueKey key, java.lang.String application)
          Get all the messages matching the key.
 EventQueueMessage peekMessage(EventQueueKey key, java.lang.String application)
          Peek at a message matching a key.
 EventQueueMessage[] peekMessages(EventQueueKey key, java.lang.String application)
          Peek at all the messages matching the key.
 void putEventMessage(EventQueueMessage eventMessage)
          Put a new message onto the Event Queue
 void registerListener(EventQueueListener el, EventQueueKey key, java.lang.String application)
          Register a listener.
 void unregisterListener(EventQueueListener el, EventQueueKey key, java.lang.String application)
          Remove a listener from the list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventQueue

public EventQueue()
Construct an Event Queue

EventQueue

public EventQueue(java.io.File store)
           throws java.io.IOException
Construct an Event Queue

Parameters:
A - File representing a persistent store
Method Detail

putEventMessage

public void putEventMessage(EventQueueMessage eventMessage)
Put a new message onto the Event Queue

Parameters:
eventMessage - The new message to add to the event queue
application - Name of the application this message belongs to.

getMessage

public EventQueueMessage getMessage(EventQueueKey key,
                                    java.lang.String application)
Get one message from the event queue. If the key isn't null, get the oldest message that the key matches. If it is null, get the oldest message.

Parameters:
key - A filter key
application - Name of the application this message belongs to.
Returns:
The oldest message matching the key.

getMessages

public EventQueueMessage[] getMessages(EventQueueKey key,
                                       java.lang.String application)
Get all the messages matching the key.

Parameters:
key - A filter key.
application - Name of the application to get messages for.
Returns:
An array of matching messages.

peekMessage

public EventQueueMessage peekMessage(EventQueueKey key,
                                     java.lang.String application)
Peek at a message matching a key. The message is returned, but not removed from the queue.

Parameters:
key - A filter key for finding a message.
application - Name of application to get messages for.
Returns:
A matching event message.

peekMessages

public EventQueueMessage[] peekMessages(EventQueueKey key,
                                        java.lang.String application)
Peek at all the messages matching the key.

Parameters:
key - A filter key.
application - Name of the application to get messages for.
Returns:
An array of matching messages.

clearMessages

public void clearMessages(EventQueueKey key,
                          java.lang.String application)
Clear messages from the queue matching the key.

Parameters:
key - A filter key to determine which messages are cleared.
application - Name of application to clear messages for.

registerListener

public void registerListener(EventQueueListener el,
                             EventQueueKey key,
                             java.lang.String application)
Register a listener. A listener listens for new events for a particular application, and can listen for an event for a particular ID, or any event for a user.

Parameters:
el - The EventQueueListener to register.
key - The key to listen for. Leave the unique id null to listen for any event for the user.
application - The application to listen for events for.

unregisterListener

public void unregisterListener(EventQueueListener el,
                               EventQueueKey key,
                               java.lang.String application)
Remove a listener from the list.

Parameters:
el - The lister to remove
key - The key to stop listening for.
application - The application to stop listening on.