groovyx.gpars.dataflow.operator
Class DataflowEventAdapter

java.lang.Object
  extended by groovyx.gpars.dataflow.operator.DataflowEventAdapter
All Implemented Interfaces:
DataflowEventListener
Direct Known Subclasses:
GracefulShutdownListener, ProcessorPauseResume

public class DataflowEventAdapter
extends java.lang.Object
implements DataflowEventListener

A default empty implementation of DataflowEventListener

Author:
Vaclav Pech

Constructor Summary
DataflowEventAdapter()
           
 
Method Summary
 void afterRun(DataflowProcessor processor, java.util.List<java.lang.Object> messages)
          Invoked when the operator completes a single run.
 void afterStart(DataflowProcessor processor)
          Invoked immediately after the operator starts by a pooled thread before the first message is obtained
 void afterStop(DataflowProcessor processor)
          Invoked immediately after the operator terminates
 java.util.List<java.lang.Object> beforeRun(DataflowProcessor processor, java.util.List<java.lang.Object> messages)
          Invoked when all messages required to trigger the operator become available in the input channels.
 java.lang.Object controlMessageArrived(DataflowProcessor processor, DataflowReadChannel<java.lang.Object> channel, int index, java.lang.Object message)
          Invoked when a control message (instances of ControlMessage) becomes available in an input channel.
 java.lang.Object customEvent(DataflowProcessor processor, java.lang.Object data)
          Invoked when the fireCustomEvent() method is triggered manually on a dataflow operator/selector.
 java.lang.Object messageArrived(DataflowProcessor processor, DataflowReadChannel<java.lang.Object> channel, int index, java.lang.Object message)
          Invoked when a message becomes available in an input channel.
 java.lang.Object messageSentOut(DataflowProcessor processor, DataflowWriteChannel<java.lang.Object> channel, int index, java.lang.Object message)
          Invoked when a message is being bound to an output channel.
 boolean onException(DataflowProcessor processor, java.lang.Throwable e)
          Invoked if an exception occurs.
 void registered(DataflowProcessor processor)
          Invoked immediately after the listener has been attached to a dataflow processor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataflowEventAdapter

public DataflowEventAdapter()
Method Detail

registered

public void registered(DataflowProcessor processor)
Invoked immediately after the listener has been attached to a dataflow processor.

Specified by:
registered in interface DataflowEventListener
Parameters:
processor - The reporting dataflow operator/selector

afterStart

public void afterStart(DataflowProcessor processor)
Invoked immediately after the operator starts by a pooled thread before the first message is obtained

Specified by:
afterStart in interface DataflowEventListener
Parameters:
processor - The reporting dataflow operator/selector

afterStop

public void afterStop(DataflowProcessor processor)
Invoked immediately after the operator terminates

Specified by:
afterStop in interface DataflowEventListener
Parameters:
processor - The reporting dataflow operator/selector

onException

public boolean onException(DataflowProcessor processor,
                           java.lang.Throwable e)
Invoked if an exception occurs. Unless overriden by subclasses this implementation returns true to terminate the operator. If any of the listeners returns true, the operator will terminate. Exceptions outside of the operator's body or listeners' messageSentOut() handlers will terminate the operator irrespective of the listeners' votes. When using maxForks, the method may be invoked from threads running the forks.

Specified by:
onException in interface DataflowEventListener
Parameters:
processor - The reporting dataflow operator/selector
e - The thrown exception
Returns:
True, if the operator should terminate in response to the exception, false otherwise.

messageArrived

public java.lang.Object messageArrived(DataflowProcessor processor,
                                       DataflowReadChannel<java.lang.Object> channel,
                                       int index,
                                       java.lang.Object message)
Invoked when a message becomes available in an input channel.

Specified by:
messageArrived in interface DataflowEventListener
Parameters:
processor - The reporting dataflow operator/selector
channel - The input channel holding the message
index - The index of the input channel within the operator
message - The incoming message
Returns:
The original message or a message that should be used instead

controlMessageArrived

public java.lang.Object controlMessageArrived(DataflowProcessor processor,
                                              DataflowReadChannel<java.lang.Object> channel,
                                              int index,
                                              java.lang.Object message)
Invoked when a control message (instances of ControlMessage) becomes available in an input channel.

Specified by:
controlMessageArrived in interface DataflowEventListener
Parameters:
processor - The reporting dataflow operator/selector
channel - The input channel holding the message
index - The index of the input channel within the operator
message - The incoming message
Returns:
The original message or a message that should be used instead

messageSentOut

public java.lang.Object messageSentOut(DataflowProcessor processor,
                                       DataflowWriteChannel<java.lang.Object> channel,
                                       int index,
                                       java.lang.Object message)
Invoked when a message is being bound to an output channel. When using maxForks, the method may be invoked from threads running the forks.

Specified by:
messageSentOut in interface DataflowEventListener
Parameters:
processor - The reporting dataflow operator/selector
channel - The output channel to send the message to
index - The index of the output channel within the operator
message - The message to send
Returns:
The original message or a message that should be used instead

beforeRun

public java.util.List<java.lang.Object> beforeRun(DataflowProcessor processor,
                                                  java.util.List<java.lang.Object> messages)
Invoked when all messages required to trigger the operator become available in the input channels.

Specified by:
beforeRun in interface DataflowEventListener
Parameters:
processor - The reporting dataflow operator/selector
messages - The incoming messages
Returns:
The original list of messages or a modified/new list of messages that should be used instead

afterRun

public void afterRun(DataflowProcessor processor,
                     java.util.List<java.lang.Object> messages)
Invoked when the operator completes a single run. When using maxForks, the method may be invoked from threads running the forks.

Specified by:
afterRun in interface DataflowEventListener
Parameters:
processor - The reporting dataflow operator/selector
messages - The incoming messages that have been processed

customEvent

public java.lang.Object customEvent(DataflowProcessor processor,
                                    java.lang.Object data)
Invoked when the fireCustomEvent() method is triggered manually on a dataflow operator/selector. This implementation returns the original piece of data. When using maxForks, the method may be invoked from threads running the forks.

Specified by:
customEvent in interface DataflowEventListener
Parameters:
processor - The reporting dataflow operator/selector
data - The custom piece of data provided as part of the event
Returns:
A value to return from the fireCustomEvent() method to the caller (event initiator)

Copyright © 2008–2012 Václav Pech. All Rights Reserved.