Class ObservableLifecycleStatusMachine<SRC>
java.lang.Object
org.refcodes.component.LifecycleMachine
org.refcodes.component.ext.observer.ObservableLifecycleStatusMachine<SRC>
- Type Parameters:
SRC
- The source of the events consumed by theLifecycleStatusObserver
.
- All Implemented Interfaces:
org.refcodes.component.Destroyable
,org.refcodes.component.Destroyable.DestroyAutomaton
,org.refcodes.component.Initializable
,org.refcodes.component.Initializable.InitializeAutomaton
,org.refcodes.component.InitializedAccessor
,org.refcodes.component.LifecycleComponent
,org.refcodes.component.LifecycleComponent.LifecycleAutomaton
,org.refcodes.component.LifecycleStatusAccessor
,org.refcodes.component.Pausable
,org.refcodes.component.Pausable.PauseAutomaton
,org.refcodes.component.Resumable
,org.refcodes.component.Resumable.ResumeAutomaton
,org.refcodes.component.RunningAccessor
,org.refcodes.component.Startable
,org.refcodes.component.Startable.StartAutomaton
,org.refcodes.component.Stoppable
,org.refcodes.component.Stoppable.StopAutomaton
,org.refcodes.observer.Observable<LifecycleStatusObserver<InitializeAccomplishedEvent<SRC>,
StartAccomplishedEvent<SRC>, ResumeAccomplishedEvent<SRC>, PauseAccomplishedEvent<SRC>, StopAccomplishedEvent<SRC>, DestroyAccomplishedEvent<SRC>, org.refcodes.observer.EventMetaData, SRC>>
public class ObservableLifecycleStatusMachine<SRC>
extends org.refcodes.component.LifecycleMachine
implements org.refcodes.observer.Observable<LifecycleStatusObserver<InitializeAccomplishedEvent<SRC>,StartAccomplishedEvent<SRC>,ResumeAccomplishedEvent<SRC>,PauseAccomplishedEvent<SRC>,StopAccomplishedEvent<SRC>,DestroyAccomplishedEvent<SRC>,org.refcodes.observer.EventMetaData,SRC>>
The
ObservableLifecycleStatusMachine
extends the
LifecycleMachine
with life-cycle ActionEvent
functionality
which can be vetoed, such running through several stages from getting started
till being destroyed. The valid state changes are mainly as follows:
"start" - "pause" - "resume" - "stop" - "destroy"
For example:
"start" - "pause" - "resume" - "pause" - "resume" - "stop" - "start" -
"pause" - "resume" - "stop" - "destroy"
The implementation is suffixed with "Machine" instead of "Automaton" for
differentiation with any interface of similar (same) name.-
Nested Class Summary
Nested classes/interfaces inherited from class org.refcodes.component.LifecycleMachine
org.refcodes.component.LifecycleMachine.ManualLifecycleMachine
Nested classes/interfaces inherited from interface org.refcodes.component.Destroyable
org.refcodes.component.Destroyable.DestroyAutomaton
Nested classes/interfaces inherited from interface org.refcodes.component.Initializable
org.refcodes.component.Initializable.InitializeAutomaton, org.refcodes.component.Initializable.InitializeBuilder<B extends org.refcodes.component.Initializable.InitializeBuilder<B>>, org.refcodes.component.Initializable.UncheckedInitializable
Nested classes/interfaces inherited from interface org.refcodes.component.InitializedAccessor
org.refcodes.component.InitializedAccessor.InitializedMutator, org.refcodes.component.InitializedAccessor.InitializedProperty
Nested classes/interfaces inherited from interface org.refcodes.component.LifecycleComponent
org.refcodes.component.LifecycleComponent.LifecycleAutomaton, org.refcodes.component.LifecycleComponent.UncheckedLifecycleComponent
Nested classes/interfaces inherited from interface org.refcodes.component.LifecycleStatusAccessor
org.refcodes.component.LifecycleStatusAccessor.LifecycleStatusBuilder<B extends org.refcodes.component.LifecycleStatusAccessor.LifecycleStatusBuilder<B>>, org.refcodes.component.LifecycleStatusAccessor.LifecycleStatusMutator, org.refcodes.component.LifecycleStatusAccessor.LifecycleStatusProperty
Nested classes/interfaces inherited from interface org.refcodes.component.Pausable
org.refcodes.component.Pausable.PauseAutomaton, org.refcodes.component.Pausable.PauseBuilder<B extends org.refcodes.component.Pausable.PauseBuilder<B>>, org.refcodes.component.Pausable.UncheckedPausable
Nested classes/interfaces inherited from interface org.refcodes.component.Resumable
org.refcodes.component.Resumable.ResumeAutomaton, org.refcodes.component.Resumable.ResumeBuilder<B extends org.refcodes.component.Resumable.ResumeBuilder<B>>, org.refcodes.component.Resumable.UncheckedResumable
Nested classes/interfaces inherited from interface org.refcodes.component.RunningAccessor
org.refcodes.component.RunningAccessor.RunningMutator, org.refcodes.component.RunningAccessor.RunningProperty
Nested classes/interfaces inherited from interface org.refcodes.component.Startable
org.refcodes.component.Startable.StartAutomaton, org.refcodes.component.Startable.StartBuilder<B extends org.refcodes.component.Startable.StartBuilder<B>>, org.refcodes.component.Startable.UncheckedStartable
Nested classes/interfaces inherited from interface org.refcodes.component.Stoppable
org.refcodes.component.Stoppable.StopAutomaton, org.refcodes.component.Stoppable.StopBuilder<B extends org.refcodes.component.Stoppable.StopBuilder<B>>, org.refcodes.component.Stoppable.UncheckedStoppable
-
Constructor Summary
ConstructorDescriptionInstantiates a newObservableLifecycleStatusMachine
.ObservableLifecycleStatusMachine
(ExecutorService aExecutorService, org.refcodes.controlflow.ExecutionStrategy aExecutionStrategy) Instantiates a newObservableLifecycleStatusMachine
.ObservableLifecycleStatusMachine
(org.refcodes.component.LifecycleComponent aLifecycleComponent) Instantiates a newObservableLifecycleStatusMachine
.ObservableLifecycleStatusMachine
(org.refcodes.component.LifecycleComponent aLifecycleComponent, ExecutorService aExecutorService, org.refcodes.controlflow.ExecutionStrategy aExecutionStrategy) Instantiates a newObservableLifecycleStatusMachine
.ObservableLifecycleStatusMachine
(org.refcodes.component.LifecycleComponent aLifecycleComponent, org.refcodes.observer.EventMetaData aEventMetaData) Instantiates a newObservableLifecycleStatusMachine
.ObservableLifecycleStatusMachine
(org.refcodes.component.LifecycleComponent aLifecycleComponent, org.refcodes.observer.EventMetaData aEventMetaData, ExecutorService aExecutorService, org.refcodes.controlflow.ExecutionStrategy aExecutionStrategy) Instantiates a newObservableLifecycleStatusMachine
.ObservableLifecycleStatusMachine
(org.refcodes.component.LifecycleComponent aLifecycleComponent, org.refcodes.observer.EventMetaData aEventMetaData, SRC aSource) Instantiates a newObservableLifecycleStatusMachine
.ObservableLifecycleStatusMachine
(org.refcodes.component.LifecycleComponent aLifecycleComponent, org.refcodes.observer.EventMetaData aEventMetaData, SRC aSource, ExecutorService aExecutorService, org.refcodes.controlflow.ExecutionStrategy aExecutionStrategy) Instantiates a newObservableLifecycleStatusMachine
.ObservableLifecycleStatusMachine
(org.refcodes.component.LifecycleComponent aLifecycleComponent, SRC aSource) Instantiates a newObservableLifecycleStatusMachine
.ObservableLifecycleStatusMachine
(org.refcodes.component.LifecycleComponent aLifecycleComponent, SRC aSource, ExecutorService aExecutorService, org.refcodes.controlflow.ExecutionStrategy aExecutionStrategy) Instantiates a newObservableLifecycleStatusMachine
.ObservableLifecycleStatusMachine
(org.refcodes.observer.EventMetaData aEventMetaData) Instantiates a newObservableLifecycleStatusMachine
.ObservableLifecycleStatusMachine
(org.refcodes.observer.EventMetaData aEventMetaData, ExecutorService aExecutorService, org.refcodes.controlflow.ExecutionStrategy aExecutionStrategy) Instantiates a newObservableLifecycleStatusMachine
.ObservableLifecycleStatusMachine
(org.refcodes.observer.EventMetaData aEventMetaData, SRC aSource) Instantiates a newObservableLifecycleStatusMachine
.ObservableLifecycleStatusMachine
(org.refcodes.observer.EventMetaData aEventMetaData, SRC aSource, ExecutorService aExecutorService, org.refcodes.controlflow.ExecutionStrategy aExecutionStrategy) Instantiates a newObservableLifecycleStatusMachine
.ObservableLifecycleStatusMachine
(SRC aSource) Instantiates a newObservableLifecycleStatusMachine
.ObservableLifecycleStatusMachine
(SRC aSource, ExecutorService aExecutorService, org.refcodes.controlflow.ExecutionStrategy aExecutionStrategy) Instantiates a newObservableLifecycleStatusMachine
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy()
boolean
hasObserver
(LifecycleStatusObserver<InitializeAccomplishedEvent<SRC>, StartAccomplishedEvent<SRC>, ResumeAccomplishedEvent<SRC>, PauseAccomplishedEvent<SRC>, StopAccomplishedEvent<SRC>, DestroyAccomplishedEvent<SRC>, org.refcodes.observer.EventMetaData, SRC> aObserver) void
void
pause()
void
resume()
void
start()
void
stop()
boolean
subscribeObserver
(LifecycleStatusObserver<InitializeAccomplishedEvent<SRC>, StartAccomplishedEvent<SRC>, ResumeAccomplishedEvent<SRC>, PauseAccomplishedEvent<SRC>, StopAccomplishedEvent<SRC>, DestroyAccomplishedEvent<SRC>, org.refcodes.observer.EventMetaData, SRC> aObserver) boolean
unsubscribeObserver
(LifecycleStatusObserver<InitializeAccomplishedEvent<SRC>, StartAccomplishedEvent<SRC>, ResumeAccomplishedEvent<SRC>, PauseAccomplishedEvent<SRC>, StopAccomplishedEvent<SRC>, DestroyAccomplishedEvent<SRC>, org.refcodes.observer.EventMetaData, SRC> aObserver) Methods inherited from class org.refcodes.component.LifecycleMachine
getLifecycleComponent, getLifecycleStatus, isDestroyable, isDestroyed, isInitalizable, isInitialized, isPausable, isPaused, isResumable, isRunning, isStartable, isStoppable, isStopped, setLifecycleStatus
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.refcodes.component.Initializable
initializeUnchecked
Methods inherited from interface org.refcodes.component.Pausable
pauseUnchecked
Methods inherited from interface org.refcodes.component.Resumable
resumeUnchecked
Methods inherited from interface org.refcodes.component.Startable
startUnchecked
Methods inherited from interface org.refcodes.component.Stoppable
stopUnchecked
-
Constructor Details
-
ObservableLifecycleStatusMachine
public ObservableLifecycleStatusMachine()Instantiates a newObservableLifecycleStatusMachine
. -
ObservableLifecycleStatusMachine
Instantiates a newObservableLifecycleStatusMachine
.- Parameters:
aSource
- The source instance to be used when firing events in case the source is to be different from this class' instance.
-
ObservableLifecycleStatusMachine
public ObservableLifecycleStatusMachine(org.refcodes.observer.EventMetaData aEventMetaData) Instantiates a newObservableLifecycleStatusMachine
.- Parameters:
aEventMetaData
- TheEventMetaData
to be used when firing events in case theEventMetaData
is to be different from the auto-generatedEventMetaData
.
-
ObservableLifecycleStatusMachine
public ObservableLifecycleStatusMachine(org.refcodes.observer.EventMetaData aEventMetaData, SRC aSource) Instantiates a newObservableLifecycleStatusMachine
.- Parameters:
aEventMetaData
- TheEventMetaData
to be used when firing events in case theEventMetaData
is to be different from the auto-generatedEventMetaData
.aSource
- The source instance to be used when firing events in case the source is to be different from this class' instance.
-
ObservableLifecycleStatusMachine
public ObservableLifecycleStatusMachine(org.refcodes.component.LifecycleComponent aLifecycleComponent) Instantiates a newObservableLifecycleStatusMachine
.- Parameters:
aLifecycleComponent
- TheLifecycleComponent
to which the life-cycle method calls are to be delegated to.
-
ObservableLifecycleStatusMachine
public ObservableLifecycleStatusMachine(org.refcodes.component.LifecycleComponent aLifecycleComponent, SRC aSource) Instantiates a newObservableLifecycleStatusMachine
.- Parameters:
aLifecycleComponent
- TheLifecycleComponent
to which the life-cycle method calls are to be delegated to.aSource
- The source instance to be used when firing events in case the source is to be different from this class' instance.
-
ObservableLifecycleStatusMachine
public ObservableLifecycleStatusMachine(org.refcodes.component.LifecycleComponent aLifecycleComponent, org.refcodes.observer.EventMetaData aEventMetaData) Instantiates a newObservableLifecycleStatusMachine
.- Parameters:
aLifecycleComponent
- TheLifecycleComponent
to which the life-cycle method calls are to be delegated to.aEventMetaData
- TheEventMetaData
to be used when firing events in case theEventMetaData
is to be different from the auto-generatedEventMetaData
.
-
ObservableLifecycleStatusMachine
public ObservableLifecycleStatusMachine(org.refcodes.component.LifecycleComponent aLifecycleComponent, org.refcodes.observer.EventMetaData aEventMetaData, SRC aSource) Instantiates a newObservableLifecycleStatusMachine
.- Parameters:
aLifecycleComponent
- TheLifecycleComponent
to which the life-cycle method calls are to be delegated to.aEventMetaData
- TheEventMetaData
to be used when firing events in case theEventMetaData
is to be different from the auto-generatedEventMetaData
.aSource
- The source instance to be used when firing events in case the source is to be different from this class' instance.
-
ObservableLifecycleStatusMachine
public ObservableLifecycleStatusMachine(ExecutorService aExecutorService, org.refcodes.controlflow.ExecutionStrategy aExecutionStrategy) Instantiates a newObservableLifecycleStatusMachine
.- Parameters:
aExecutorService
- The executor service to be used when firingActionEvent
instances in multiple threads (if null then a default one is used).aExecutionStrategy
- TheExecutionStrategy
to be used when firingActionEvent
instance (if null then the defaultExecutionStrategy.SEQUENTIAL
is used).
-
ObservableLifecycleStatusMachine
public ObservableLifecycleStatusMachine(SRC aSource, ExecutorService aExecutorService, org.refcodes.controlflow.ExecutionStrategy aExecutionStrategy) Instantiates a newObservableLifecycleStatusMachine
.- Parameters:
aSource
- The source instance to be used when firing events in case the source is to be different from this class' instance.aExecutorService
- The executor service to be used when firingActionEvent
instances in multiple threads (if null then a default one is used).aExecutionStrategy
- TheExecutionStrategy
to be used when firingActionEvent
instance (if null then the defaultExecutionStrategy.SEQUENTIAL
is used).
-
ObservableLifecycleStatusMachine
public ObservableLifecycleStatusMachine(org.refcodes.observer.EventMetaData aEventMetaData, ExecutorService aExecutorService, org.refcodes.controlflow.ExecutionStrategy aExecutionStrategy) Instantiates a newObservableLifecycleStatusMachine
.- Parameters:
aEventMetaData
- TheEventMetaData
to be used when firing events in case theEventMetaData
is to be different from the auto-generatedEventMetaData
.aExecutorService
- The executor service to be used when firingActionEvent
instances in multiple threads (if null then a default one is used).aExecutionStrategy
- TheExecutionStrategy
to be used when firingActionEvent
instance (if null then the defaultExecutionStrategy.SEQUENTIAL
is used).
-
ObservableLifecycleStatusMachine
public ObservableLifecycleStatusMachine(org.refcodes.observer.EventMetaData aEventMetaData, SRC aSource, ExecutorService aExecutorService, org.refcodes.controlflow.ExecutionStrategy aExecutionStrategy) Instantiates a newObservableLifecycleStatusMachine
.- Parameters:
aEventMetaData
- TheEventMetaData
to be used when firing events in case theEventMetaData
is to be different from the auto-generatedEventMetaData
.aSource
- The source instance to be used when firing events in case the source is to be different from this class' instance.aExecutorService
- The executor service to be used when firingActionEvent
instances in multiple threads (if null then a default one is used).aExecutionStrategy
- TheExecutionStrategy
to be used when firingActionEvent
instance (if null then the defaultExecutionStrategy.SEQUENTIAL
is used).
-
ObservableLifecycleStatusMachine
public ObservableLifecycleStatusMachine(org.refcodes.component.LifecycleComponent aLifecycleComponent, ExecutorService aExecutorService, org.refcodes.controlflow.ExecutionStrategy aExecutionStrategy) Instantiates a newObservableLifecycleStatusMachine
.- Parameters:
aLifecycleComponent
- TheLifecycleComponent
to which the life-cycle method calls are to be delegated to.aExecutorService
- The executor service to be used when firingActionEvent
instances in multiple threads (if null then a default one is used).aExecutionStrategy
- TheExecutionStrategy
to be used when firingActionEvent
instance (if null then the defaultExecutionStrategy.SEQUENTIAL
is used).
-
ObservableLifecycleStatusMachine
public ObservableLifecycleStatusMachine(org.refcodes.component.LifecycleComponent aLifecycleComponent, SRC aSource, ExecutorService aExecutorService, org.refcodes.controlflow.ExecutionStrategy aExecutionStrategy) Instantiates a newObservableLifecycleStatusMachine
.- Parameters:
aLifecycleComponent
- TheLifecycleComponent
to which the life-cycle method calls are to be delegated to.aSource
- The source instance to be used when firing events in case the source is to be different from this class' instance.aExecutorService
- The executor service to be used when firingActionEvent
instances in multiple threads (if null then a default one is used).aExecutionStrategy
- TheExecutionStrategy
to be used when firingActionEvent
instance (if null then the defaultExecutionStrategy.SEQUENTIAL
is used).
-
ObservableLifecycleStatusMachine
public ObservableLifecycleStatusMachine(org.refcodes.component.LifecycleComponent aLifecycleComponent, org.refcodes.observer.EventMetaData aEventMetaData, ExecutorService aExecutorService, org.refcodes.controlflow.ExecutionStrategy aExecutionStrategy) Instantiates a newObservableLifecycleStatusMachine
.- Parameters:
aLifecycleComponent
- TheLifecycleComponent
to which the life-cycle method calls are to be delegated to.aEventMetaData
- TheEventMetaData
to be used when firing events in case theEventMetaData
is to be different from the auto-generatedEventMetaData
.aExecutorService
- The executor service to be used when firingActionEvent
instances in multiple threads (if null then a default one is used).aExecutionStrategy
- TheExecutionStrategy
to be used when firingActionEvent
instance (if null then the defaultExecutionStrategy.SEQUENTIAL
is used).
-
ObservableLifecycleStatusMachine
public ObservableLifecycleStatusMachine(org.refcodes.component.LifecycleComponent aLifecycleComponent, org.refcodes.observer.EventMetaData aEventMetaData, SRC aSource, ExecutorService aExecutorService, org.refcodes.controlflow.ExecutionStrategy aExecutionStrategy) Instantiates a newObservableLifecycleStatusMachine
.- Parameters:
aLifecycleComponent
- TheLifecycleComponent
to which the life-cycle method calls are to be delegated to.aEventMetaData
- TheEventMetaData
to be used when firing events in case theEventMetaData
is to be different from the auto-generatedEventMetaData
.aSource
- The source instance to be used when firing events in case the source is to be different from this class' instance.aExecutorService
- The executor service to be used when firingActionEvent
instances in multiple threads (if null then a default one is used).aExecutionStrategy
- TheExecutionStrategy
to be used when firingActionEvent
instance (if null then the defaultExecutionStrategy.SEQUENTIAL
is used).
-
-
Method Details
-
hasObserver
public boolean hasObserver(LifecycleStatusObserver<InitializeAccomplishedEvent<SRC>, StartAccomplishedEvent<SRC>, ResumeAccomplishedEvent<SRC>, PauseAccomplishedEvent<SRC>, StopAccomplishedEvent<SRC>, DestroyAccomplishedEvent<SRC>, org.refcodes.observer.EventMetaData, SRC> aObserver) - Specified by:
hasObserver
in interfaceorg.refcodes.observer.Observable<SRC>
-
subscribeObserver
public boolean subscribeObserver(LifecycleStatusObserver<InitializeAccomplishedEvent<SRC>, StartAccomplishedEvent<SRC>, ResumeAccomplishedEvent<SRC>, PauseAccomplishedEvent<SRC>, StopAccomplishedEvent<SRC>, DestroyAccomplishedEvent<SRC>, org.refcodes.observer.EventMetaData, SRC> aObserver) - Specified by:
subscribeObserver
in interfaceorg.refcodes.observer.Observable<SRC>
-
unsubscribeObserver
public boolean unsubscribeObserver(LifecycleStatusObserver<InitializeAccomplishedEvent<SRC>, StartAccomplishedEvent<SRC>, ResumeAccomplishedEvent<SRC>, PauseAccomplishedEvent<SRC>, StopAccomplishedEvent<SRC>, DestroyAccomplishedEvent<SRC>, org.refcodes.observer.EventMetaData, SRC> aObserver) - Specified by:
unsubscribeObserver
in interfaceorg.refcodes.observer.Observable<SRC>
-
initialize
public void initialize() throws org.refcodes.component.InitializeException- Specified by:
initialize
in interfaceorg.refcodes.component.Initializable
- Overrides:
initialize
in classorg.refcodes.component.LifecycleMachine
- Throws:
org.refcodes.component.InitializeException
-
start
public void start() throws org.refcodes.component.StartException- Specified by:
start
in interfaceorg.refcodes.component.Startable
- Overrides:
start
in classorg.refcodes.component.LifecycleMachine
- Throws:
org.refcodes.component.StartException
-
pause
public void pause() throws org.refcodes.component.PauseException- Specified by:
pause
in interfaceorg.refcodes.component.Pausable
- Overrides:
pause
in classorg.refcodes.component.LifecycleMachine
- Throws:
org.refcodes.component.PauseException
-
resume
public void resume() throws org.refcodes.component.ResumeException- Specified by:
resume
in interfaceorg.refcodes.component.Resumable
- Overrides:
resume
in classorg.refcodes.component.LifecycleMachine
- Throws:
org.refcodes.component.ResumeException
-
stop
public void stop() throws org.refcodes.component.StopException- Specified by:
stop
in interfaceorg.refcodes.component.Stoppable
- Overrides:
stop
in classorg.refcodes.component.LifecycleMachine
- Throws:
org.refcodes.component.StopException
-
destroy
public void destroy()- Specified by:
destroy
in interfaceorg.refcodes.component.Destroyable
- Overrides:
destroy
in classorg.refcodes.component.LifecycleMachine
-