|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object cz.cuni.amis.pogamut.base.component.controller.AbstractComponentControllerBase<COMPONENT>
public abstract class AbstractComponentControllerBase<COMPONENT extends IComponent>
Abstract class implementing some methods from IComponentControllerBase
.
Namely:
getComponent()
getComponentControl()
isRunning()
isPaused()
awaitState(ComponentState...)
awaitState(long, ComponentState...)
getState()
inState(ComponentState...)
notInState(ComponentState...)
IComponent
.
getComponent()
getComponentControl()
isRunning()
isPaused()
awaitState(ComponentState...)
awaitState(long, ComponentState...)
getState()
inState(ComponentState...)
notInState(ComponentState...)
Suitable for creating custom IComponentController
s or ISharedComponentController
s.
Nested Class Summary | |
---|---|
protected static class |
AbstractComponentControllerBase.AwaitState
Used for filtering states we're awaiting on. |
Field Summary | |
---|---|
protected boolean |
broadcastingEvents
Tells whether the controller sends events about the state of the component, i.e., whether it should automatically send starting/stopping events or not. |
protected COMPONENT |
component
Component controlled by this controller. |
protected Flag<ComponentState> |
componentState
State of the controlled component. |
protected IComponentControlHelper |
control
Method providing means for direct control of the component . |
protected IToken |
controllerId
Unique (in context of one agent) id of this controller. |
protected java.util.logging.Logger |
log
Log used by the class, is never null. |
Constructor Summary | |
---|---|
AbstractComponentControllerBase(COMPONENT component,
IComponentControlHelper componentControlHelper,
java.util.logging.Logger log)
Initialize the controller. |
|
AbstractComponentControllerBase(IToken componentControllerId,
COMPONENT component,
IComponentControlHelper componentControlHelper,
java.util.logging.Logger log)
Initialize controller with specific componentControllerId. |
Method Summary | |
---|---|
ComponentState |
awaitState(ComponentState... states)
Waits until the component reaches one of 'states' or KILLING / KILLED state is reached. |
ComponentState |
awaitState(long timeoutMillis,
ComponentState... states)
Waits until the component reaches one of 'states' or KILLING / KILLED state is reached. |
COMPONENT |
getComponent()
Returns controlled component instance. |
IComponentControlHelper |
getComponentControl()
Returns component control with lifecycle methods of the component controlled by this instance. |
IToken |
getComponentId()
Unique identification of the component. |
java.util.logging.Logger |
getLog()
|
ImmutableFlag<ComponentState> |
getState()
Returns state of the controlled component (state of the component life-cycle). |
protected java.lang.String |
id(IComponent component)
Returns component id or null. |
boolean |
inState(ComponentState... states)
Whether the component is in one of 'states'. |
boolean |
isBroadcastingEvents()
Tells whether the controller sends events about the state of the component, i.e., whether it should automatically send starting/stopping events or not. |
boolean |
isPaused()
Whether the component is paused (or is pausing/resuming). |
boolean |
isRunning()
Whether the component has been started, is not stopped or killed, may be paused. |
boolean |
notInState(ComponentState... states)
Whether the component is not in any of 'states'. |
void |
setBroadcastingEvents(boolean broadcastingEvents)
Enables (== true) / Disables (== false) sending events about the state of the component, i.e., whether it should automatically send starting/stopping events or not. |
protected void |
setState(ComponentState state)
Changes the componentState to desired state. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface cz.cuni.amis.pogamut.base.component.controller.IComponentControllerBase |
---|
fatalError, fatalError, getFatalError, manualKill, manualPause, manualResume, manualStart, manualStartPaused, manualStop |
Field Detail |
---|
protected IToken controllerId
protected IComponentControlHelper control
component
. This object is passed from the outside
of the controller, usually created by the component itself.
protected COMPONENT extends IComponent component
protected java.util.logging.Logger log
protected Flag<ComponentState> componentState
Use setState(ComponentState)
to alter the value of the flag.
Should not be set manually, use setState(ComponentState)
instead.
protected boolean broadcastingEvents
DEFAULT: TRUE (the controller is broadcasting events as default)
Exception: IComponentControllerBase.fatalError(String)
and IComponentControllerBase.fatalError(String, Throwable)
must always send fatal error!
Constructor Detail |
---|
public AbstractComponentControllerBase(COMPONENT component, IComponentControlHelper componentControlHelper, java.util.logging.Logger log)
controllerId
(adding suffix "-controller" to the IComponent.getComponentId()
.
component
- componentControlHelper
- log
- public AbstractComponentControllerBase(IToken componentControllerId, COMPONENT component, IComponentControlHelper componentControlHelper, java.util.logging.Logger log)
componentControllerId
- component
- componentControlHelper
- log
- Method Detail |
---|
public java.lang.String toString()
toString
in class java.lang.Object
public IToken getComponentId()
IComponent
getComponentId
in interface IComponent
public java.util.logging.Logger getLog()
public COMPONENT getComponent()
IComponentControllerBase
getComponent
in interface IComponentControllerBase<COMPONENT extends IComponent>
public boolean isBroadcastingEvents()
IComponentControllerBase
DEFAULT: TRUE (the controller is broadcasting events as default)
Exception: IComponentControllerBase.fatalError(String)
and IComponentControllerBase.fatalError(String, Throwable)
must always send fatal error!
isBroadcastingEvents
in interface IComponentControllerBase<COMPONENT extends IComponent>
public void setBroadcastingEvents(boolean broadcastingEvents)
IComponentControllerBase
Exception: IComponentControllerBase.fatalError(String)
and IComponentControllerBase.fatalError(String, Throwable)
must always send fatal error!
setBroadcastingEvents
in interface IComponentControllerBase<COMPONENT extends IComponent>
broadcastingEvents
- Enables (== true) / Disables (== false)public IComponentControlHelper getComponentControl()
IComponentControllerBase
IComponentControllerBase.getComponent()
.
IT IS DISCOURAGED TO USE METHODS OF THE IComponentControlHelper
DIRECTLY! IT DEFIES THE PURPOSE OF THE CONTROLLER TOTALLY
AND THE CONTROLLER WILL PROBABLY WON'T COPE WITH SUCH BEHAVIOR.
But what the hell, if it solves your problem, go ahead ;-)
getComponentControl
in interface IComponentControllerBase<COMPONENT extends IComponent>
public boolean isRunning()
IComponentControllerBase
isRunning
in interface IComponentControllerBase<COMPONENT extends IComponent>
public boolean isPaused()
IComponentControllerBase
isPaused
in interface IComponentControllerBase<COMPONENT extends IComponent>
public ImmutableFlag<ComponentState> getState()
IComponentControllerBase
It returns flag - therefore you may use WaitForFlagChange
to synchronize on the flag changes in other threads or use
awaitState() method.
getState
in interface IComponentControllerBase<COMPONENT extends IComponent>
public boolean inState(ComponentState... states)
IComponentControllerBase
inState
in interface IComponentControllerBase<COMPONENT extends IComponent>
public boolean notInState(ComponentState... states)
IComponentControllerBase
notInState
in interface IComponentControllerBase<COMPONENT extends IComponent>
public ComponentState awaitState(ComponentState... states) throws ComponentKilledException
IComponentControllerBase
If KILLING / KILLED state is not among 'states' then reaching of this state will throw ComponentKilledException
exception.
If interrupted, PogamutInterruptedException
is thrown.
awaitState
in interface IComponentControllerBase<COMPONENT extends IComponent>
ComponentKilledException
ComponentKilledException
public ComponentState awaitState(long timeoutMillis, ComponentState... states) throws ComponentKilledException
IComponentControllerBase
If KILLING / KILLED state is not among 'states' then reaching of this state will throw ComponentKilledException
exception.
If interrupted, PogamutInterruptedException
is thrown.
If times out, null is returned.
awaitState
in interface IComponentControllerBase<COMPONENT extends IComponent>
ComponentKilledException
ComponentKilledException
protected java.lang.String id(IComponent component)
component
-
protected void setState(ComponentState state)
componentState
to desired state.
state
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |