edu.berkeley.psi.seda.generic
Class EventSinkFactory

java.lang.Object
  extended by edu.berkeley.psi.seda.generic.EventSinkFactory
All Implemented Interfaces:
SinkFactoryIF

public class EventSinkFactory
extends java.lang.Object
implements SinkFactoryIF

Creates EventSink objects on demand. Can either (re)use a single EventHandlerIF object (which must be thread safe) or else generate new EventHandlerIF objects on demand, depending on how it is initialized. Both approaches have their merits, as using a single EventHandlerIF object may make it easier for a group of related EventSinks to communicate, while generating new EventHandlerIF objects may make it easier to have independent operation.


Field Summary
(package private)  EventHandlerFactoryIF factory
           
(package private)  EventHandlerIF handler
           
protected  EnqueuePredicateIF pred
           
protected  java.lang.String prefix
           
protected  java.util.concurrent.atomic.AtomicLong serial
           
 
Constructor Summary
EventSinkFactory(EventHandlerFactoryIF factory)
           
EventSinkFactory(EventHandlerFactoryIF factory, EnqueuePredicateIF predicate)
           
EventSinkFactory(EventHandlerFactoryIF factory, java.lang.String namePrefix)
           
EventSinkFactory(EventHandlerIF eh)
           
EventSinkFactory(EventHandlerIF eh, EnqueuePredicateIF predicate)
           
EventSinkFactory(EventHandlerIF eh, java.lang.String namePrefix)
           
 
Method Summary
protected  java.lang.String getPrefix()
          Returns the prefix of the factory, setting it if null.
 SinkIF newSink()
          Creates a new instance of a SinkIF
protected  SinkIF newSink(EventHandlerIF eh)
           
private  void setHashPrefix()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

handler

EventHandlerIF handler

factory

EventHandlerFactoryIF factory

prefix

protected java.lang.String prefix

pred

protected EnqueuePredicateIF pred

serial

protected java.util.concurrent.atomic.AtomicLong serial
Constructor Detail

EventSinkFactory

EventSinkFactory(EventHandlerIF eh)

EventSinkFactory

EventSinkFactory(EventHandlerIF eh,
                 java.lang.String namePrefix)

EventSinkFactory

EventSinkFactory(EventHandlerIF eh,
                 EnqueuePredicateIF predicate)

EventSinkFactory

EventSinkFactory(EventHandlerFactoryIF factory)

EventSinkFactory

EventSinkFactory(EventHandlerFactoryIF factory,
                 java.lang.String namePrefix)

EventSinkFactory

EventSinkFactory(EventHandlerFactoryIF factory,
                 EnqueuePredicateIF predicate)
Method Detail

newSink

protected SinkIF newSink(EventHandlerIF eh)

newSink

public SinkIF newSink()
Creates a new instance of a SinkIF

Specified by:
newSink in interface SinkFactoryIF

setHashPrefix

private void setHashPrefix()

getPrefix

protected java.lang.String getPrefix()
Returns the prefix of the factory, setting it if null. Uses test and test-and-set to avoid the lock overhead in most cases.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object