com.bea.adapter.event
Class LocalEventRouter

java.lang.Object
  extended by com.bea.adapter.event.LocalEventRouter
All Implemented Interfaces:
IEventRouter

public class LocalEventRouter
extends Object
implements IEventRouter

The actual worker object in the WLAI event router. Handles event subscriptions, instantiating and communicating with the event generator (by invoking both start() and refresh() on the event generator), IEventGenerator instance, and posting events back to subscribers.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.bea.wlai.event.IEventRouter
IEventRouter.IRoutingInfo
 
Constructor Summary
LocalEventRouter(AbstractWLIResourceAdapter ra, IEventGenerator eventGenerator)
           
 
Method Summary
 void addEventDef(EventMessageEndpointFactory emef, EventActivationSpec eas)
           
 void eisAvailable(String description)
          Allows the EventGenerator to indicate that its EIS instance is now available.
 void eisUnavailable(String reason)
          Allows the EventGenerator to indicate that its EIS instance is temporarily unavailable.
 Status getEventGeneratorStatus()
          Get an indication of the health/status of the EventGenerator.
 String[] getEventRouterInstanceIDs()
          Get a list of IDs this event router represents.
 IEventRouter.IRoutingInfo getEventRoutingInfo(com.bea.wlai.common.IEventDefinition eventDef)
          Prearrange for the delivery of events of the given type by getting a RoutingInfo object that allows for very efficient delivery of events conforming to the given IEventDefinition.
 com.bea.wlai.common.IEventDefinition[] getEventTypeSummary()
          Get a list of event definitions currently being serviced by this event router.
 String getGUID()
          Gets the globally unique ID of this event router instance or null if none was given.
 String getName()
          Gets the name of this event router instance or null if none was given.
 boolean isEISAvailable()
          Get the availability of the EIS instance for the EventGenerator.
 void postEvent(com.bea.wlai.common.IEvent event)
          Post the given event to all listeners for this event router.
 void postEvent(IEventRouter.IRoutingInfo ri, com.bea.wlai.common.IEvent event)
          Post an event to all subscribers using a RoutingInfo object obtained from a prior call to getRoutingInfo().
 void removeEventDef(EventMessageEndpointFactory emef, EventActivationSpec eas)
           
 void setEventGeneratorStatus(Status status)
          Allows an EventGenerator to indicate its health/status to the EventRouter.
 void start(Properties props)
           
 void stop()
           
protected  void storeRetryEvent(com.bea.wlai.common.IEvent event)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocalEventRouter

public LocalEventRouter(AbstractWLIResourceAdapter ra,
                        IEventGenerator eventGenerator)
Method Detail

getName

public String getName()
Description copied from interface: IEventRouter
Gets the name of this event router instance or null if none was given. The name can be thought to represent the logical purpose of this router and its generator as defined at design-time.

Specified by:
getName in interface IEventRouter

getGUID

public String getGUID()
Description copied from interface: IEventRouter
Gets the globally unique ID of this event router instance or null if none was given.

Specified by:
getGUID in interface IEventRouter

getEventRouterInstanceIDs

public String[] getEventRouterInstanceIDs()
Get a list of IDs this event router represents. An event router instance ID means different things for different adapters, but is generally thought to represent a planned/defined instance of the event router. This instance can be moved around from machine to machine to handle system outage and load balancing scenarios.

Specified by:
getEventRouterInstanceIDs in interface IEventRouter
Returns:
The list of IDs defined for this event router or null if none were defined.

getEventTypeSummary

public com.bea.wlai.common.IEventDefinition[] getEventTypeSummary()
Description copied from interface: IEventRouter
Get a list of event definitions currently being serviced by this event router.

Specified by:
getEventTypeSummary in interface IEventRouter
Returns:
An array of IEventDefinition objects representing all events this router has been asked to deliver.

addEventDef

public void addEventDef(EventMessageEndpointFactory emef,
                        EventActivationSpec eas)
                 throws EventRouterException
Throws:
EventRouterException

removeEventDef

public void removeEventDef(EventMessageEndpointFactory emef,
                           EventActivationSpec eas)
                    throws EventRouterException
Throws:
EventRouterException

getEventRoutingInfo

public IEventRouter.IRoutingInfo getEventRoutingInfo(com.bea.wlai.common.IEventDefinition eventDef)
                                              throws Exception
Prearrange for the delivery of events of the given type by getting a RoutingInfo object that allows for very efficient delivery of events conforming to the given IEventDefinition. The caller can use the returned RoutingInfo for future calls to postEvent(RoutingInfo, IEvent). This method and the postEvent(RoutingInfo, IEvent) method together provide a facility for increasing event delivery throughput for events of a given type. This is true because the dynamic linkage between event and subscriber is only calculated once in the call to getRoutingInfo() and not repeately as it would be when calling postEvent(IEvent).

Specified by:
getEventRoutingInfo in interface IEventRouter
Throws:
Exception
See Also:
IEventRouter.postEvent(com.bea.wlai.common.IEvent)

postEvent

public void postEvent(com.bea.wlai.common.IEvent event)
               throws Exception
Description copied from interface: IEventRouter
Post the given event to all listeners for this event router.

Specified by:
postEvent in interface IEventRouter
Parameters:
event - The event to post
Throws:
Exception - if any error occurs delivering the event. It is the responsibility of the caller to handle storing this event for delivery at a later time.

postEvent

public void postEvent(IEventRouter.IRoutingInfo ri,
                      com.bea.wlai.common.IEvent event)
               throws Exception
Post an event to all subscribers using a RoutingInfo object obtained from a prior call to getRoutingInfo().

Specified by:
postEvent in interface IEventRouter
Parameters:
ri -
event -
Throws:
Exception
See Also:
IEventRouter.getEventRoutingInfo(com.bea.wlai.common.IEventDefinition)

storeRetryEvent

protected void storeRetryEvent(com.bea.wlai.common.IEvent event)

start

public void start(Properties props)
           throws EventRouterException
Throws:
EventRouterException

stop

public void stop()
          throws EventRouterException
Throws:
EventRouterException

eisUnavailable

public void eisUnavailable(String reason)
Allows the EventGenerator to indicate that its EIS instance is temporarily unavailable. The EventRouter will force the status of the EventGenerator to SUSPENDED and use the given description as the reason for the EventGenerator being suspended. EventGenerator implementations should provide meaningful reason information when calling this method.

Specified by:
eisUnavailable in interface IEventRouter

eisAvailable

public void eisAvailable(String description)
Allows the EventGenerator to indicate that its EIS instance is now available. The EventRouter will force the status of the EventGenerator to HEALTHY and use the given description as the reason for the EventGenerator being resumed. If no description is available or needed, pass null for the description.

Specified by:
eisAvailable in interface IEventRouter

isEISAvailable

public boolean isEISAvailable()
Get the availability of the EIS instance for the EventGenerator. By default the event router will return true until a call is made by the event generator to eisUnavailable().

Specified by:
isEISAvailable in interface IEventRouter

setEventGeneratorStatus

public void setEventGeneratorStatus(Status status)
Allows an EventGenerator to indicate its health/status to the EventRouter. The method should not be used to indicate that the EIS instance is unavailable/available (use the eisUnavailable() and eisAvailable() methods for this). The status parameter should be one of the defined Status.XXX values if possible. If no pre-defined status value is appropriate to describe the status of the EventGenerator, it may use values greater than 100 to indicate the status. The adapter should then document what the adapter-specific status codes mean.

Specified by:
setEventGeneratorStatus in interface IEventRouter

getEventGeneratorStatus

public Status getEventGeneratorStatus()
Get an indication of the health/status of the EventGenerator. Status values greater than 100 are adapter-specific. The adapter should document what the adapter-specific status codes mean.

Specified by:
getEventGeneratorStatus in interface IEventRouter