HANDLED - the type of the handled object.public abstract class GCUBEHandler<HANDLED> extends Object implements GCUBEIHandler<HANDLED>
GCUBEIHandler.
In particular, a GCUBEHandler:
Lifetime for handlers that manage their own lifetime.
GCUBEHandler implements Lifetime but does not declare it.
Subclasses that commit to invoking those methods should do so. Those
that do not make this commitment define handlers that remain permanently in the State.Created state.
| Modifier and Type | Field and Description |
|---|---|
protected HANDLED |
handled
The handled object.
|
protected GCUBELog |
logger
Object logger.
|
protected GCUBEProducer<Topic,Object> |
producer
Internal event producer.
|
| Constructor and Description |
|---|
GCUBEHandler()
Creates an instance.
|
GCUBEHandler(HANDLED handled)
Creates an instance with a given handled object.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearBlackboard()
Clears the blackboard.
|
Map<String,Object> |
getBlackboard()
Returns the blackboard.
|
HANDLED |
getHandled()
Returns the handled object.
|
String |
getId()
Returns the identifier of the handler.
|
GCUBELog |
getLogger()
Returns the logger.
|
String |
getName()
Returns the name of the handler, by default, the name of its class.
|
GCUBEScopeManager |
getScopeManager()
Returns the scope manager of the handler.
|
GCUBESecurityManager |
getSecurityManager()
Returns the security manager of the handler.
|
State |
getState()
See
Lifetime.getState(). |
protected <TOPIC extends Topic> |
notify(TOPIC topic,
Event<TOPIC,?> e)
|
abstract void |
run()
Executes the task implemented by the handler.
|
void |
setBlackboard(Map<String,Object> state)
Sets the blackboard.
|
void |
setHandled(HANDLED handled)
Sets the handled object.
|
void |
setLogger(GCUBELog logger)
Sets the logger.
|
void |
setName(String name)
Sets the name of the handler.
|
void |
setScopeManager(GCUBEScopeManager manager)
Sets a scope manager for the handler.
|
void |
setSecurityManager(GCUBESecurityManager manager)
Sets a security manager for the handler.
|
void |
setState(State state)
Sets the state of the handler.
|
void |
subscribe(Monitor monitor,
Topic... topics)
|
void |
undo()
Reverts the actions of the handler.
|
void |
unsubscribe(Monitor monitor,
Topic... topics)
|
protected GCUBELog logger
protected HANDLED handled
protected GCUBEProducer<Topic,Object> producer
public GCUBEHandler()
public GCUBEHandler(HANDLED handled)
handled - the handled object.public void setLogger(GCUBELog logger)
setLogger in interface GCUBEIHandler<HANDLED>logger - the logger.public GCUBELog getLogger()
getLogger in interface GCUBEIHandler<HANDLED>public abstract void run()
throws Exception
run in interface GCUBEIHandler<HANDLED>Exception - if the execution of the task does not complete normally.public HANDLED getHandled()
getHandled in interface GCUBEIHandler<HANDLED>public void setHandled(HANDLED handled)
setHandled in interface GCUBEIHandler<HANDLED>handled - the handled object.public Map<String,Object> getBlackboard()
getBlackboard in interface GCUBEIHandler<HANDLED>public void setBlackboard(Map<String,Object> state)
setBlackboard in interface GCUBEIHandler<HANDLED>state - the blackboard.public void clearBlackboard()
clearBlackboard in interface GCUBEIHandler<HANDLED>public String getId()
getId in interface GCUBEIHandler<HANDLED>public String getName()
getName in interface GCUBEIHandler<HANDLED>public void setName(String name)
setName in interface GCUBEIHandler<HANDLED>name - the name.public void undo()
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.undo in interface GCUBEIHandler<HANDLED>public void subscribe(Monitor monitor, Topic... topics)
subscribe in interface GCUBEIHandler<HANDLED>monitor - the monitor.topics - (optional) the topics. If omitted, the monitor is subscribed to Topic.LifetimeTopic.public void unsubscribe(Monitor monitor, Topic... topics)
unsubscribe in interface GCUBEIHandler<HANDLED>monitor - the monitor.topics - (optional) the topics. If omitted, the monitor is subscribed to Topic.LifetimeTopic.protected <TOPIC extends Topic> void notify(TOPIC topic, Event<TOPIC,?> e)
(optional) - the topic.e - the event.public State getState()
Lifetime.getState().public void setState(State state) throws IllegalArgumentException, IllegalStateException
state - the state.IllegalArgumentException - if the state is nullIllegalStateException - if the handler cannot transition to the state from its current state.public void setSecurityManager(GCUBESecurityManager manager)
setSecurityManager in interface GCUBEIHandler<HANDLED>manager - the manager.public void setScopeManager(GCUBEScopeManager manager)
setScopeManager in interface GCUBEIHandler<HANDLED>manager - the manager.public GCUBESecurityManager getSecurityManager()
getSecurityManager in interface GCUBEIHandler<HANDLED>public GCUBEScopeManager getScopeManager()
getScopeManager in interface GCUBEIHandler<HANDLED>Copyright © 2015. All Rights Reserved.