org.alfresco.bm.event
Class ResultBarrier

java.lang.Object
  extended by org.alfresco.bm.event.AbstractEventProcessor
      extended by org.alfresco.bm.event.ResultBarrier
All Implemented Interfaces:
EventProcessor, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware

public class ResultBarrier
extends AbstractEventProcessor

Simple barrier that reschedules itself until a number of eventresults (RecordedEvents) are available. If the number is reached, an event is scheduled whose name is equal to the value of the property 'nextEventName'.

Input

No input required.

Data

Uses the ReportService as data-input.

Actions

Periodic check is performed to see if number is reached. If not, event is scheduled.

Output

If number is reached: getNextEventName(), if not: reschedules same event.

Author:
Frederik Heremans

Field Summary
 
Fields inherited from class org.alfresco.bm.event.AbstractEventProcessor
DEFAULT_WARN_DELAY, logger
 
Constructor Summary
ResultBarrier(String countEventName, long expectedCount, String nextEventName, ResultService resultService)
          Create a new barrier.
 
Method Summary
 String getNextEventName()
           
 EventResult processEvent(Event event)
          Process an event.
 void setCheckInterval(long checkInterval)
          Set the interval this event is scheduled to check if barrier can be released.
 void setNextEventName(String nextEventName)
           
 
Methods inherited from class org.alfresco.bm.event.AbstractEventProcessor
getWarnDelay, register, setBeanName, setEventName, setEventNames, setRegistry, setWarnDelay
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResultBarrier

public ResultBarrier(String countEventName,
                     long expectedCount,
                     String nextEventName,
                     ResultService resultService)
Create a new barrier.

Parameters:
nextEventName - name of the event to queue when barrier is released.
eventService - event service
Method Detail

processEvent

public EventResult processEvent(Event event)
                         throws Exception
Description copied from interface: EventProcessor
Process an event.

NOTE: All errors are treated as terminal i.e. there will be no follow-up events published. The event and result services are provided to allow event processing to be aware of previous and future work. If the service is used to modify queues, the results could be unexpected e.g. clearing the queue will not always mean that no more events will be processed.

Parameters:
event - the event (along with associated data)
Returns:
the result of the process (includes errors and next events)
Throws:
Exception

setNextEventName

public void setNextEventName(String nextEventName)
Parameters:
nextEventName - name of the event to queue when number is reached.

getNextEventName

public String getNextEventName()
Returns:
name of the event to queue when number is reached.

setCheckInterval

public void setCheckInterval(long checkInterval)
Set the interval this event is scheduled to check if barrier can be released.

Parameters:
checkInterval - interval in millis


Copyright © 2012. All Rights Reserved.