org.openbandy.event
Class EventSource

java.lang.Object
  extended by java.lang.Thread
      extended by org.openbandy.event.EventSource
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
EventSourceSimulation, MmsScanner, SmsScanner

public abstract class EventSource
extends java.lang.Thread

An EventSource is a thread that must eventually dispatch an event of the type it provides. Since Java does not allow to restart a terminated thread, an EventSource must be able to re-instantiate itself. For this purpose, it provides the newlyInstantiate() method, which will create a new instance object and subsequently advise its owning object to reset the reference.

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

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

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
EventSource(java.lang.String name, EventSourceOwner owner)
           
 
Method Summary
abstract  java.util.Vector getProvidedEventTypes()
          While registering at the EventService, the latter will request the EventSource to state the types of Events it will delegate.
 boolean isRunning()
           
abstract  EventSource newlyInstantiate()
          As the EventService must eventually create new instances of an EventSource in order to restart it, an EventSource must provide this method which must create (and return) a new instance and subsequently reset its reference in the class owning it.
abstract  void run()
          Starts the EventSource.
 void startEventSource(java.lang.String eventShortClassName)
           
abstract  void stopEventSource()
          Stops the source.
abstract  void stopEventSource(java.lang.String eventShortClassName)
          Advises the EventSource, that events of type eventShortClassName will no longer be conumsed.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EventSource

public EventSource(java.lang.String name,
                   EventSourceOwner owner)
Method Detail

isRunning

public boolean isRunning()
Returns:
True if this Source is running.

startEventSource

public void startEventSource(java.lang.String eventShortClassName)

run

public abstract void run()
Starts the EventSource.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

getProvidedEventTypes

public abstract java.util.Vector getProvidedEventTypes()
While registering at the EventService, the latter will request the EventSource to state the types of Events it will delegate.

Returns:
A Vector of Strings containing the short class names of the Events.

newlyInstantiate

public abstract EventSource newlyInstantiate()
As the EventService must eventually create new instances of an EventSource in order to restart it, an EventSource must provide this method which must create (and return) a new instance and subsequently reset its reference in the class owning it.


stopEventSource

public abstract void stopEventSource(java.lang.String eventShortClassName)
Advises the EventSource, that events of type eventShortClassName will no longer be conumsed. If non of the provided event types is consumed, stop the event source thread.

Parameters:
eventShortClassName -

stopEventSource

public abstract void stopEventSource()
Stops the source.