BEA Systems, Inc.

com.connecterra.util.event
Class EventReceiver

java.lang.Object
  extended by com.connecterra.util.event.EventReceiver

public class EventReceiver
extends Object

An event receiver manages the accumulation and delivery of events to an event processor. Many threads may post events through the event receiver, which delivers them one at a time to the event processor. The event processor may therefore rely on its always being executed by a single thread. The thread that handles events is managed by a Scheduler instance associated with the event receiver.


Field Summary
static int ALWAYS_QUEUE
           
static int BLOCK
           
static int DROP
           
static int THROW
           
 
Constructor Summary
EventReceiver(String name, EventProcessor eventProcessor, com.connecterra.util.event.Scheduler scheduler, int eventLimit)
          Constructs a new event receiver for the specified event processor, using the specified scheduler to run the task that delivers events.
 
Method Summary
 EventProcessor getEventProcessor()
           
 void receiveEvent(Object event)
          This is the same as EventReceiver.receiveEvent(java.lang.Object)called with the ALWAYS_QUEUE argument, with the exceptions which cannot happen not declared.
 void receiveEventOrBlock(Object event)
          This is the same as EventReceiver.receiveEvent(java.lang.Object)called with the BLOCK argument, with the exceptions which cannot happen not declared.
 boolean receiveEventOrDrop(Object event)
          This is the same as EventReceiver.receiveEvent(java.lang.Object)called with the DROP argument, with the exceptions which cannot happen not declared.
 void receiveEventOrThrow(Object event)
          This is the same as EventReceiver.receiveEvent(java.lang.Object)called with the THROW argument, with the exceptions which cannot happen not declared.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ALWAYS_QUEUE

public static final int ALWAYS_QUEUE
See Also:
Constant Field Values

DROP

public static final int DROP
See Also:
Constant Field Values

THROW

public static final int THROW
See Also:
Constant Field Values

BLOCK

public static final int BLOCK
See Also:
Constant Field Values
Constructor Detail

EventReceiver

public EventReceiver(String name,
                     EventProcessor eventProcessor,
                     com.connecterra.util.event.Scheduler scheduler,
                     int eventLimit)
Constructs a new event receiver for the specified event processor, using the specified scheduler to run the task that delivers events. Hence, the event processor will do its work in a thread under the control of that scheduler.

Parameters:
name - used to identify this queue in log messages and other user-visible contexts
eventProcessor - the object to which events should be delivered
scheduler - the schedulers on which the event delivery task should be queued.
eventLimit - the high water mark for the queue. See EventReceiver.receiveEvent(Object, int)for more information. This value must be greater than or equal to -1. -1 or 0 is treated as no limit.
Method Detail

getEventProcessor

public EventProcessor getEventProcessor()
Returns:
the EventProcessorused to create this event receiver.

receiveEvent

public void receiveEvent(Object event)
This is the same as EventReceiver.receiveEvent(java.lang.Object)called with the ALWAYS_QUEUE argument, with the exceptions which cannot happen not declared.


receiveEventOrDrop

public boolean receiveEventOrDrop(Object event)
This is the same as EventReceiver.receiveEvent(java.lang.Object)called with the DROP argument, with the exceptions which cannot happen not declared.

Returns:
true if the event is queued, or false if it is dropped.

receiveEventOrThrow

public void receiveEventOrThrow(Object event)
                         throws QueueFullException
This is the same as EventReceiver.receiveEvent(java.lang.Object)called with the THROW argument, with the exceptions which cannot happen not declared.

Throws:
QueueFullException

receiveEventOrBlock

public void receiveEventOrBlock(Object event)
                         throws InterruptedException
This is the same as EventReceiver.receiveEvent(java.lang.Object)called with the BLOCK argument, with the exceptions which cannot happen not declared.

Throws:
InterruptedException

toString

public String toString()
Overrides:
toString in class Object

Documentation is available at
${DOCSWEBROOT}
Copyright 2007 BEA Systems Inc.