org.gcube.common.core.utils.handlers
Class GCUBEComplexHandler<HANDLED>

java.lang.Object
  extended by org.gcube.common.core.utils.handlers.GCUBEHandler<HANDLED>
      extended by org.gcube.common.core.utils.handlers.GCUBEComplexHandler<HANDLED>
Type Parameters:
HANDLED - the type of the object handled by the component handlers.
All Implemented Interfaces:
GCUBEIHandler<HANDLED>
Direct Known Subclasses:
GCUBEParallelHandler, GCUBESequentialHandler

public abstract class GCUBEComplexHandler<HANDLED>
extends GCUBEHandler<HANDLED>

An abstract extension of GCUBEHandler that manages one or more component handlers.

A GCUBEComplexHandler may constrain its components to handle objects of the same type (by instantiating the type parameter to a type other than Object). In turn, the component handlers may be built so as to share the same handled object.

Author:
Fabio Simeoni (University of Strathclyde)

Field Summary
 
Fields inherited from class org.gcube.common.core.utils.handlers.GCUBEHandler
handled, logger, producer
 
Constructor Summary
GCUBEComplexHandler(GCUBEIHandler<? extends HANDLED>... components)
          Creates an instance with a list of component handlers.
 
Method Summary
 void addHandlers(GCUBEIHandler<? extends HANDLED>... components)
          Adds one or more handlers to the list of component handlers.
 List<GCUBEIHandler<? extends HANDLED>> getHandlers()
          Returns the component handlers.
 boolean removeHandler(GCUBEIHandler<? extends HANDLED> component)
          Removes (the first occurrence of) a handler from the list of component handlers.
 void setLogger(GCUBELog logger)
          Sets the logger.
 void undo()
          Reverts the actions of the handler.
 
Methods inherited from class org.gcube.common.core.utils.handlers.GCUBEHandler
clearBlackboard, getBlackboard, getHandled, getId, getLogger, getName, getScopeManager, getSecurityManager, getState, notify, run, setBlackboard, setHandled, setName, setScopeManager, setSecurityManager, setState, subscribe, unsubscribe
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GCUBEComplexHandler

public GCUBEComplexHandler(GCUBEIHandler<? extends HANDLED>... components)
Creates an instance with a list of component handlers.

Parameters:
components - the component handlers.
Method Detail

addHandlers

public void addHandlers(GCUBEIHandler<? extends HANDLED>... components)
                 throws IllegalArgumentException
Adds one or more handlers to the list of component handlers.

Parameters:
components - the handlers.
Throws:
IllegalArgumentException

setLogger

public void setLogger(GCUBELog logger)
Sets the logger.

Specified by:
setLogger in interface GCUBEIHandler<HANDLED>
Overrides:
setLogger in class GCUBEHandler<HANDLED>
Parameters:
logger - the logger.

removeHandler

public boolean removeHandler(GCUBEIHandler<? extends HANDLED> component)
Removes (the first occurrence of) a handler from the list of component handlers.

Parameters:
component - the handler.
Returns:
true if the handler was in the list, false otherwise.

getHandlers

public List<GCUBEIHandler<? extends HANDLED>> getHandlers()
Returns the component handlers.

Returns:
the handlers. Note that modifications to the list will have no effect on the state of the handler.

undo

public void undo()
Reverts the actions of the handler. By default, it simply debug-logs the invocation. If required, override as per handler semantics. For robustness, do not assume the invocation occurs after the execution of the handler.

Specified by:
undo in interface GCUBEIHandler<HANDLED>
Overrides:
undo in class GCUBEHandler<HANDLED>


Copyright © 2012. All Rights Reserved.