org.openbandy.event
Class EventSourceBroker

java.lang.Object
  extended by org.openbandy.event.EventSourceBroker

public class EventSourceBroker
extends java.lang.Object

The EventSourceBroker holds all references to event sources that are registered at the event service and is thus able to create new instances if necessary. Since sources may provide several types of events, they will consequently be referenced by multiple EventSourceControllers. Furthermore, sources are going to be newly instantiated from time to time in order to be restarted. Thus, we need a another level of abstraction to administer the references to the event sources. For this purpose, the EventSourceBroker manages a static list of event sources registered at the EventService.

(c) Copyright Philipp Bolliger 2007, ALL RIGHTS RESERVED.

Version:
1.0
Author:
Philipp Bolliger (philipp@bolliger.name)

Constructor Summary
EventSourceBroker()
           
 
Method Summary
 java.lang.Integer addEventSource(EventSource eventSource)
          Add an EventSource instance to the broker's pool
 EventSource getEventSource(java.lang.Integer index)
          Return the reference to an EventSource from the pool
 java.lang.Integer getEventSourceIndex(EventSource eventSource)
          Return the index of an EventSource instance in the pool
 EventSource getNewEventSourceInstance(java.lang.Integer index)
          Creates a new instance of the EventSource that is stored with the given index and replaces the old with the new instance.
 java.util.Enumeration getSources()
          List of all EventSource references currently in the pool
 boolean removeEventSource(EventSource eventSource)
          Remove an EventSource from the pool
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventSourceBroker

public EventSourceBroker()
Method Detail

addEventSource

public java.lang.Integer addEventSource(EventSource eventSource)
Add an EventSource instance to the broker's pool

Parameters:
eventSource - EventSource to be added
Returns:
The newly created index or 0, if this instance already is in the pool

getEventSource

public EventSource getEventSource(java.lang.Integer index)
Return the reference to an EventSource from the pool

Parameters:
index - Index of the EventSource in the pool
Returns:
Reference to the EventSource, null if not contained

getEventSourceIndex

public java.lang.Integer getEventSourceIndex(EventSource eventSource)
Return the index of an EventSource instance in the pool

Parameters:
eventSource - Reference to the EventSource
Returns:
Index of the EventSource, null in not contained

getSources

public java.util.Enumeration getSources()
List of all EventSource references currently in the pool

Returns:
Enumeration of EventSources

removeEventSource

public boolean removeEventSource(EventSource eventSource)
Remove an EventSource from the pool

Parameters:
eventSource - Reference to the EventSource
Returns:
true if successfully removed, false else

getNewEventSourceInstance

public EventSource getNewEventSourceInstance(java.lang.Integer index)
Creates a new instance of the EventSource that is stored with the given index and replaces the old with the new instance.

Parameters:
index - Index of the EventSource in the pool
Returns:
Reference to the newly created instance