com.codemonster.surinam.controller
Class AbstractOperationAction

java.lang.Object
  extended by com.codemonster.surinam.controller.AbstractOperationAction
All Implemented Interfaces:
Action
Direct Known Subclasses:
AbstractContractOperationAction

public abstract class AbstractOperationAction
extends Object
implements Action

Some Actions are more related to operations on a Service Block and not about registering services. This abstract class simply provides some implementations for methods that are not normally used in such cases.


Constructor Summary
AbstractOperationAction()
           
 
Method Summary
abstract  void apply(ServiceBlock serviceBlock)
          This is the only callback that subclasses will need to provide implementations for; you take the ServiceBlock and do what you will.
 String getName()
          We want to be able to discern which operation is being performed by subclasses of this object.
 Iterator<ServiceToFieldInjectionPair> getRequiredServices()
          There are no required services for operations.
 void injectServices(ServiceBlock serviceBlock)
          This is another method we don't normally need.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractOperationAction

public AbstractOperationAction()
Method Detail

apply

public abstract void apply(ServiceBlock serviceBlock)
This is the only callback that subclasses will need to provide implementations for; you take the ServiceBlock and do what you will.

This is the primary execution point for all ServiceBlock actions. Not all operations will throw all of these exceptions but we wanted a unified interface for these actions to allow the code to handle a broad ranged of actions and still be able to respond in a fine-grained manner.

Note that if you aren't interested in fine-grained exceptions, all Surinam exceptions extend SurinamException, so you could just trap that along with the Java exceptions separately. Or catching Exception should do the trick.

Specified by:
apply in interface Action
Parameters:
serviceBlock - The ServiceBlock that the actions will be given access to.

getName

public String getName()
We want to be able to discern which operation is being performed by subclasses of this object.

Specified by:
getName in interface Action
Returns:
Returns the name of the action being performed.

getRequiredServices

public Iterator<ServiceToFieldInjectionPair> getRequiredServices()
There are no required services for operations. Get a list of fully qualified Contracts that this action requires. Contract actions will normally be empty but implementations could have a quite a few.

Specified by:
getRequiredServices in interface Action
Returns:
Returns a list of services, upon which, this service depends.

injectServices

public void injectServices(ServiceBlock serviceBlock)
                    throws ClassNotFoundException,
                           DependencyInjectionException,
                           IllegalAccessException
This is another method we don't normally need. This callback method is used to inject the ServiceBlock that the action will have access to in order to perform its work. Needless to say, Actions can be supremely powerful and therefore need to be trusted entities. This callback will probably be a NOP for all actions except implementations.

Specified by:
injectServices in interface Action
Parameters:
serviceBlock - The ServiceBlock that the actions will be given access to.
Throws:
ClassNotFoundException - Thrown if the class cannot be found; usually a classpath or packaging issue.
DependencyInjectionException - Thrown if injection fails.
IllegalAccessException - Thrown if there is a loader or hierarchy failure.


Copyright © 2010. All Rights Reserved.