|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IComponentControllerBase<COMPONENT extends IComponent>
Base interface for component controllers, be it IComponentController
or ISharedComponentController
.
The component controller base interface is meant to provide a gateway for starting/stopping/pausing/resuming the component and
querying the component current ComponentState
.
Use AbstractComponentControllerBase
abstraction for the implementation of custom controllers.
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. |
void |
fatalError(java.lang.String message)
Broadcasts fatal error with controlled component as source. |
void |
fatalError(java.lang.String message,
java.lang.Throwable e)
Broadcasts fatal error with controlled component as source. |
COMPONENT |
getComponent()
Returns controlled component instance. |
IComponentControlHelper |
getComponentControl()
Returns component control with lifecycle methods of the component controlled by this instance. |
IFatalErrorEvent |
getFatalError()
Returns last fatal error event that has triggered the system failure. |
ImmutableFlag<ComponentState> |
getState()
Returns state of the controlled component (state of the component life-cycle). |
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. |
void |
manualKill(java.lang.String reason)
Provides the way to kill the component (constructor of this controller). |
void |
manualPause(java.lang.String reason)
Provides the way to pause the component (constructor of this controller). |
void |
manualResume(java.lang.String reason)
Provides the way to pause the component (constructor of this controller). |
void |
manualStart(java.lang.String reason)
Provides the way to manually start the component. |
void |
manualStartPaused(java.lang.String reason)
Provides the way to manually start the component into paused state. |
void |
manualStop(java.lang.String reason)
Provides the way to stop the component (constructor of this controller). |
boolean |
notInState(ComponentState... states)
Whether the component is not in any of 'states'. |
void |
setBroadcastingEvents(boolean broadcastEvents)
Enables (== true) / Disables (== false) sending events about the state of the component, i.e., whether it should automatically send starting/stopping events or not. |
Methods inherited from interface cz.cuni.amis.pogamut.base.component.IComponent |
---|
getComponentId |
Method Detail |
---|
IFatalErrorEvent getFatalError()
boolean isRunning()
boolean isPaused()
ImmutableFlag<ComponentState> getState()
It returns flag - therefore you may use WaitForFlagChange
to synchronize on the flag changes in other threads or use
awaitState() method.
boolean inState(ComponentState... states)
states
-
boolean notInState(ComponentState... states)
states
-
ComponentState awaitState(ComponentState... states)
If KILLING / KILLED state is not among 'states' then reaching of this state will throw ComponentKilledException
exception.
If interrupted, PogamutInterruptedException
is thrown.
state
-
ComponentKilledException
ComponentState awaitState(long timeoutMillis, ComponentState... states)
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.
millis
- state
-
ComponentKilledException
void manualStart(java.lang.String reason)
void manualStartPaused(java.lang.String reason)
void manualStop(java.lang.String reason)
Note that you should not use IComponentControlHelper
.stop() alone to stop your component
as it won't produce IStoppingEvent
and IStoppedEvent
.
If you require your component to stop prematurely - call this method.
reason
- why the component is stoppingvoid manualKill(java.lang.String reason)
Note that you should not use IComponentControlHelper
.kill() alone to stop your component
as it won't produce IFatalErrorEvent
.
If you require your component to stop prematurely - call this method.
reason
- why the component is stoppingvoid manualPause(java.lang.String reason)
Note that you should not use IComponentControlHelper
.pause() alone to stop your component
as it won't produce IPausingEvent
and IPausedEvent
.
reason
- why the component is pausingvoid manualResume(java.lang.String reason)
Note that you should not use IComponentControlHelper
.pause() alone to stop your component
as it won't produce IPausingEvent
and IPausedEvent
.
reason
- why the component is pausingvoid fatalError(java.lang.String message)
Sets state to KILLING, broadcasts IFatalErrorEvent
and then sets the state to KILLED.
WARNING: Note that the ComponentController assumes that you will kill your component yourself before or after you call this method. Therefore the components kill() method won't be called. That's because whenever fatal error occurs, the component is in undefined state and you have to decide what to do based on that fatal error.
message
- void fatalError(java.lang.String message, java.lang.Throwable e)
Sets state to KILLING, broadcasts IFatalErrorEvent
and then sets the state to KILLED.
WARNING: Note that the ComponentController assumes that you will kill your component yourself before or after you call this method. Therefore the components kill() method won't be called. That's because whenever fatal error occurs, the component is in undefined state and you have to decide what to do based on that fatal error.
message
- e
- COMPONENT getComponent()
IComponentControlHelper getComponentControl()
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 ;-)
boolean isBroadcastingEvents()
DEFAULT: TRUE (the controller is broadcasting events as default)
Exception: fatalError(String)
and fatalError(String, Throwable)
must always send fatal error!
void setBroadcastingEvents(boolean broadcastEvents)
Exception: fatalError(String)
and fatalError(String, Throwable)
must always send fatal error!
broadcastEvents
- Enables (== true) / Disables (== false)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |