org.alfresco.bm.event

Class AbstractEventProcessor

    • Field Detail

      • DEFAULT_CHART

        protected static final boolean DEFAULT_CHART
      • DEFAULT_PROPAGATE_SESSION_ID

        protected static final boolean DEFAULT_PROPAGATE_SESSION_ID
      • logger

        protected org.apache.commons.logging.Log logger
        Resource for derived classes to use for logging
    • Constructor Detail

      • AbstractEventProcessor

        public AbstractEventProcessor()
        Default constructor
    • Method Detail

      • setBeanName

        public void setBeanName(String beanName)
        Specified by:
        setBeanName in interface org.springframework.beans.factory.BeanNameAware
      • setEventName

        public void setEventName(String eventName)
        Set the single event name that this processor can handle
      • setEventNames

        public void setEventNames(List<String> eventNames)
        Set the names of the events that this processor can handle
      • getWarnDelay

        public long getWarnDelay()
        Description copied from interface: EventProcessor
        Provide a hint for the processing framework on how much time should elapse before the warnings need to be issued over the delay
        Specified by:
        getWarnDelay in interface EventProcessor
        Returns:
        the processing time after which an warning is logged (default DEFAULT_WARN_DELAY)
      • setWarnDelay

        public void setWarnDelay(long warnDelay)
        Parameters:
        warnDelay - the time allowed for processing before a warning is logged
        See Also:
        getWarnDelay()
      • isChart

        public boolean isChart()
        Description copied from interface: EventProcessor
        Hint whether the result should be included in charts
        Specified by:
        isChart in interface EventProcessor
        Returns:
        true if results from this processor must be included in generated charts
      • setChart

        public void setChart(boolean chart)
        Parameters:
        chart - true to tag results for charting
        See Also:
        isChart()
      • setPropagateSessionId

        public void setPropagateSessionId(boolean propagateSessionId)
        Change the default session ID propagation behaviour
        Parameters:
        propagateSessionId - true to propagate session IDs to all new events otherwise false
      • propagateSessionId

        public void propagateSessionId(Event event,
                              Event nextEvent)
        Called by the framework after event processing and just prior to publishing an event to the event queue.

        The default behaviour is determined by the session propagation flag but implementations can override the behaviour on a case-by-case basis.

        Implementations can make use of the SessionService for creating new sessions, the details of which can then be attached to the next event(s).

        Specified by:
        propagateSessionId in interface EventProcessor
        Parameters:
        event - the original event
        nextEvent - a new event (possibly one of many)
      • register

        public void register()
        Register this instance for the event names that are handled.
      • suspendTimer

        protected long suspendTimer()
        Suspend the event processing timer.
        Throws:
        IllegalStateException - if the timer is not running
      • resumeTimer

        protected long resumeTimer()
        Continue timing the event processing
        Throws:
        IllegalStateException - if the timer is is not suspended
      • stopTimer

        protected long stopTimer()
        Stop timing the event processing. This does not need to be called by derived classes.
        Throws:
        IllegalStateException - if the timer is is not running or suspended
      • processEvent

        public final EventResult processEvent(Event event,
                               org.apache.commons.lang3.time.StopWatch stopWatch)
                                       throws Exception
        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.

        Timing: Event processing can StopWatch.start() and StopWatch.stop() the timer to better reflect actual event processing.

        The implementation overrides this method to store the StopWatch in a thread-local.

        Specified by:
        processEvent in interface EventProcessor
        Parameters:
        event - the event (along with associated data)
        stopWatch - the timer that will be used or null to have one created and attached to the process automatically
        Returns:
        the result of the process (includes errors and next events)
        Throws:
        Exception
      • processEvent

        protected abstract EventResult processEvent(Event event)
                                             throws Exception
        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.

        Timing: Where required, implementations can manually control the times recorded for event processing.

        Parameters:
        event - the event (along with associated data)
        Returns:
        the result of the process (includes errors and next events)
        Throws:
        Exception
        See Also:
        suspendTimer(), resumeTimer(), stopTimer()

Copyright © 2014. All rights reserved.