org.hudsonci.utils.event
Class EventProcessorSupport<ContextType,HandlerType extends EventHandler>

java.lang.Object
  extended by org.hudsonci.utils.event.EventProcessorSupport<ContextType,HandlerType>
All Implemented Interfaces:
EventProcessor<ContextType>

public class EventProcessorSupport<ContextType,HandlerType extends EventHandler>
extends Object
implements EventProcessor<ContextType>

Support for event processing.

Since:
2.1.0
Author:
Jason Dillon

Field Summary
protected  org.slf4j.Logger log
           
 
Constructor Summary
EventProcessorSupport(List<HandlerType> handlers, HandlerType defaultHandler)
           
 
Method Summary
 HandlerType getDefaultHandler()
          Get the default handler.
protected  HandlerType getEventHandler(Object event)
          Get the event handler for the given event.
 List<HandlerType> getHandlers()
          Get installed handlers.
 void init(ContextType context)
          Initialize event handlers and their event type mapping.
protected  void onFailure(Exception cause)
           
 void process(Object event)
          Process an event.
 void setDefaultHandler(HandlerType defaultHandler)
          Set the default handler.
 void setHandlers(List<HandlerType> handlers)
          Set installed handlers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected final org.slf4j.Logger log
Constructor Detail

EventProcessorSupport

public EventProcessorSupport(List<HandlerType> handlers,
                             HandlerType defaultHandler)
Method Detail

getHandlers

public List<HandlerType> getHandlers()
Get installed handlers.


setHandlers

public void setHandlers(List<HandlerType> handlers)
Set installed handlers.


getDefaultHandler

public HandlerType getDefaultHandler()
Get the default handler.


setDefaultHandler

public void setDefaultHandler(HandlerType defaultHandler)
Set the default handler.


init

public void init(ContextType context)
Initialize event handlers and their event type mapping.

Specified by:
init in interface EventProcessor<ContextType>

process

public void process(Object event)
             throws Exception
Process an event. Selects the event handler and delegates.

Specified by:
process in interface EventProcessor<ContextType>
Throws:
Exception

onFailure

protected void onFailure(Exception cause)
                  throws Exception
Throws:
Exception

getEventHandler

protected HandlerType getEventHandler(Object event)
Get the event handler for the given event. If no handlers can accept use default.

Returns:
A handler, never null.


Copyright © 2004-2012 Hudson. All Rights Reserved.