at.ac.tuwien.infosys.sm4all.copal.api.processor
Class ActionsMethod

java.lang.Object
  extended by at.ac.tuwien.infosys.sm4all.copal.api.processor.ActionsMethod

public class ActionsMethod
extends java.lang.Object

Invoker of an Actions Method. For method to be considered an Actions Method all these conditions must be met:

  1. Method must be annotated with Action or Actions.
  2. Method must be public.
  3. Method must have one or two parameters.
  4. The required parameter of Method must be of type ContextEvent or a subclass of it.
  5. The other (optional) parameter of Method must be of type ProcessorAction.
  6. Method must be void or return ContextEvent (or a subclass of it), array of ContextEvents (or a subclass of it), or Collection of ContextEvents (or a subclass of it).

Author:
sanjin

Constructor Summary
ActionsMethod(java.lang.Object processor, java.lang.reflect.Method method)
          Creates instance of invoker of specified Actions Method on specified processor.
 
Method Summary
 boolean canBeInvokedWith(ProcessorAction action, ContextEvent event)
          Returns if specified ProcessorAction with specified ContextEvent can be invoked with this Actions Method.
 ProcessorAction[] getActions()
          Returns ProcessorActions handled by this Actions Method.
 java.lang.String getName()
          Returns the name of this Actions Method.
 java.lang.Class<?>[] getParameters()
          Returns types of parameters of this Actions Method.
 java.lang.Class<?> getResult()
          Returns type of result of this Actions Method.
 ContextEvent[] invoke(ProcessorAction action, ContextEvent event)
          Invokes the underlying Actions Method for specified ProcessorAction with specified ContextEvent.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ActionsMethod

public ActionsMethod(java.lang.Object processor,
                     java.lang.reflect.Method method)
Creates instance of invoker of specified Actions Method on specified processor.

Parameters:
processor - the wrapped annotated processor.
method - the Actions Method.
Throws:
java.lang.NullPointerException - if specified wrapped annotated processor or Method is null.
java.lang.IllegalArgumentException - if specified Method has no Action or Actions annotation, is not public, has zero or more than two parameters, has no ContextEvent (or a subclass of it) parameter, other (optional) parameter is not ProcessorAction, or Method is not void or it doesn't return ContextEvent, array of ContextEvents, or Collection of ContextEvents.
Method Detail

getName

public java.lang.String getName()
Returns the name of this Actions Method.

Returns:
the name of this Actions Method.
See Also:
Method.getName()

getActions

public ProcessorAction[] getActions()
Returns ProcessorActions handled by this Actions Method.

Returns:
ProcessorActions handled by this Actions Method.
See Also:
Actions.value(), Action

getParameters

public java.lang.Class<?>[] getParameters()
Returns types of parameters of this Actions Method.

Returns:
types of parameters.
See Also:
Method.getParameterTypes()

getResult

public java.lang.Class<?> getResult()
Returns type of result of this Actions Method.

Returns:
the type of result of this Actions Method.
See Also:
Method.getReturnType()

canBeInvokedWith

public boolean canBeInvokedWith(ProcessorAction action,
                                ContextEvent event)
Returns if specified ProcessorAction with specified ContextEvent can be invoked with this Actions Method.

Parameters:
action - the ProcessorAction.
event - the ContextEvent.
Returns:
if specified ProcessorAction with specified ContextEvent can be invoked.
Throws:
java.lang.NullPointerException - if specified ContextEvent is null.

invoke

public ContextEvent[] invoke(ProcessorAction action,
                             ContextEvent event)
                      throws java.lang.IllegalAccessException,
                             java.lang.reflect.InvocationTargetException
Invokes the underlying Actions Method for specified ProcessorAction with specified ContextEvent. Result of invocation (or an empty array if there was no result) is returned if specified ProcessorAction has output.

Parameters:
action - the ProcessorAction.
event - the ContextEvent.
Returns:
the resulting ContextEvents of the underlying Actions Method.
Throws:
java.lang.IllegalAccessException - if this Actions Method enforces Java language access control and the underlying method is inaccessible.
java.lang.reflect.InvocationTargetException - if the underlying Actions Method throws an Exception.
java.lang.NullPointerException - if specified ProcessorAction or ContextEvent is null.
java.lang.IllegalArgumentException - if specified ProcessorAction with specified ContextEvent can not be invoked with this Actions Method i.e. the canBeInvokedWith(ProcessorAction, ContextEvent) method returns false.


Copyright © 2010 Distributed Systems Group, Vienna University of Technology. All Rights Reserved.