Package org.refcodes.component
Class LifeCycleAutomatonImpl
- java.lang.Object
-
- org.refcodes.component.LifeCycleAutomatonImpl
-
- All Implemented Interfaces:
Destroyable
,Destroyable.DestroyAutomaton
,Initializable
,Initializable.InitializeAutomaton
,InitializedAccessor
,LifeCycleComponent
,LifeCycleComponent.LifeCycleAutomaton
,LifeCycleStatusAccessor
,Pausable
,Pausable.PauseAutomaton
,Resumable
,Resumable.ResumeAutomaton
,RunningAccessor
,Startable
,Startable.StartAutomaton
,Stoppable
,Stoppable.StopAutomaton
- Direct Known Subclasses:
LifeCycleAutomatonImpl.ManualLifeCycleAutomatonImpl
public class LifeCycleAutomatonImpl extends java.lang.Object implements LifeCycleComponent.LifeCycleAutomaton
This class implements aLifeCycleComponent.LifeCycleAutomaton
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LifeCycleAutomatonImpl.ManualLifeCycleAutomatonImpl
Opens the otherwise protectedLifeCycleAutomatonImpl.ManualLifeCycleAutomatonImpl.setLifeCycleStatus(LifeCycleStatus)
to be public in order to force any lifecycle status to be set.-
Nested classes/interfaces inherited from interface org.refcodes.component.Destroyable
Destroyable.DestroyAutomaton
-
Nested classes/interfaces inherited from interface org.refcodes.component.Initializable
Initializable.InitializeAutomaton, Initializable.InitializeBuilder<B extends Initializable.InitializeBuilder<B>>, Initializable.UncheckedInitializable
-
Nested classes/interfaces inherited from interface org.refcodes.component.InitializedAccessor
InitializedAccessor.InitializedMutator, InitializedAccessor.InitializedProperty
-
Nested classes/interfaces inherited from interface org.refcodes.component.LifeCycleComponent
LifeCycleComponent.LifeCycleAutomaton, LifeCycleComponent.UncheckedLifeCycleComponent
-
Nested classes/interfaces inherited from interface org.refcodes.component.LifeCycleStatusAccessor
LifeCycleStatusAccessor.LifeCycleStatusBuilder<B extends LifeCycleStatusAccessor.LifeCycleStatusBuilder<B>>, LifeCycleStatusAccessor.LifeCycleStatusMutator, LifeCycleStatusAccessor.LifeCycleStatusProperty
-
Nested classes/interfaces inherited from interface org.refcodes.component.Pausable
Pausable.PauseAutomaton, Pausable.PauseBuilder<B extends Pausable.PauseBuilder<B>>, Pausable.UncheckedPausable
-
Nested classes/interfaces inherited from interface org.refcodes.component.Resumable
Resumable.ResumeAutomaton, Resumable.ResumeBuilder<B extends Resumable.ResumeBuilder<B>>, Resumable.UncheckedResumable
-
Nested classes/interfaces inherited from interface org.refcodes.component.RunningAccessor
RunningAccessor.RunningMutator, RunningAccessor.RunningProperty
-
Nested classes/interfaces inherited from interface org.refcodes.component.Startable
Startable.StartAutomaton, Startable.StartBuilder<B extends Startable.StartBuilder<B>>, Startable.UncheckedStartable
-
Nested classes/interfaces inherited from interface org.refcodes.component.Stoppable
Stoppable.StopAutomaton, Stoppable.StopBuilder<B extends Stoppable.StopBuilder<B>>, Stoppable.UncheckedStoppable
-
-
Constructor Summary
Constructors Constructor Description LifeCycleAutomatonImpl()
Empty constructor, suchLifeCycleComponent.LifeCycleAutomaton
cannot do much more than decline the variousLifeCycleStatus
states for you.LifeCycleAutomatonImpl(LifeCycleComponent aLifeCycleComponent)
This constructor uses aLifeCycleStatus
for wrapping it inside theLifeCycleAutomatonImpl
, making sure of obeying and guarding the correctLifeCycleStatus
's order ofLifeCycleStatus
states for you.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
destroy()
Destroys the component.protected LifeCycleComponent
getLifeCycleComponent()
Provides access to theLifeCycleComponent
instance.LifeCycleStatus
getLifeCycleStatus()
Retrieves theLifeCycleStatus
property from the property.void
initialize()
Initialize the component.boolean
isDestroyable()
Determines whether the component may get destroyed.boolean
isDestroyed()
Determines whether the component is destroyed.boolean
isInitalizable()
Determines whether the component may get initialized.boolean
isInitialized()
Retrieves the is-initialized property from the initialized property.boolean
isPausable()
Determines whether the component may get paused.boolean
isPaused()
Determines whether the component is paused.boolean
isResumable()
Determines whether the component may get resumed.boolean
isRunning()
Retrieves the is-running property from the running property.boolean
isStartable()
Determines whether the component may get started.boolean
isStoppable()
Determines whether the component may get stopped.boolean
isStopped()
Determines whether the component is stopped.void
pause()
Pauses the component.void
resume()
Resumes the component.protected void
setLifeCycleStatus(LifeCycleStatus aStatus)
Provides means to set theLifeCycleStatus
manually.void
start()
Starts the component.void
stop()
Stops the component.-
Methods inherited from interface org.refcodes.component.Initializable
initializeUnchecked
-
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.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 Detail
-
LifeCycleAutomatonImpl
public LifeCycleAutomatonImpl()
Empty constructor, suchLifeCycleComponent.LifeCycleAutomaton
cannot do much more than decline the variousLifeCycleStatus
states for you.
-
LifeCycleAutomatonImpl
public LifeCycleAutomatonImpl(LifeCycleComponent aLifeCycleComponent)
This constructor uses aLifeCycleStatus
for wrapping it inside theLifeCycleAutomatonImpl
, making sure of obeying and guarding the correctLifeCycleStatus
's order ofLifeCycleStatus
states for you.- Parameters:
aLifeCycleComponent
- The component to be guarded regarding the correct declination of theLifeCycleStatus
states.
-
-
Method Detail
-
getLifeCycleStatus
public LifeCycleStatus getLifeCycleStatus()
Retrieves theLifeCycleStatus
property from the property. Determines in whichLifeCycleStatus
status a component is in.- Specified by:
getLifeCycleStatus
in interfaceLifeCycleStatusAccessor
- Returns:
- Returns the
LifeCycleStatus
property stored by the property.
-
initialize
public void initialize() throws InitializeException
Initialize the component.- Specified by:
initialize
in interfaceInitializable
- Throws:
InitializeException
- Thrown in case initializing fails.
-
isInitalizable
public boolean isInitalizable()
Determines whether the component may get initialized.- Specified by:
isInitalizable
in interfaceInitializable.InitializeAutomaton
- Returns:
- True if
Initializable.initialize()
is possible.
-
isInitialized
public boolean isInitialized()
Retrieves the is-initialized property from the initialized property. Determines whether the component is initialized. A component is initialized after being initialized as ofInitializable.initialize()
orConfigurable.initialize(Object)
.- Specified by:
isInitialized
in interfaceInitializedAccessor
- Returns:
- True in case of being initialized (returns the is-initialized property stored by the initialized property).
-
isStartable
public boolean isStartable()
Determines whether the component may get started.- Specified by:
isStartable
in interfaceStartable.StartAutomaton
- Returns:
- True if
Startable.start()
is possible.
-
start
public void start() throws StartException
Starts the component.- Specified by:
start
in interfaceStartable
- Throws:
StartException
- Thrown in case starting fails.
-
isRunning
public boolean isRunning()
Retrieves the is-running property from the running property. Determines whether the component is running. A component is running after being started or being resumed as ofStartable.start()
orResumable.resume()
.- Specified by:
isRunning
in interfaceRunningAccessor
- Returns:
- True in case of being resumed or started (returns the is-running property stored by the running property).
-
isPausable
public boolean isPausable()
Determines whether the component may get paused.- Specified by:
isPausable
in interfacePausable.PauseAutomaton
- Returns:
- True if
Pausable.pause()
is possible.
-
pause
public void pause() throws PauseException
Pauses the component.- Specified by:
pause
in interfacePausable
- Throws:
PauseException
- in case pausing fails.
-
isPaused
public boolean isPaused()
Determines whether the component is paused.- Specified by:
isPaused
in interfacePausable.PauseAutomaton
- Returns:
- True in case of being paused, else false.
-
isResumable
public boolean isResumable()
Determines whether the component may get resumed.- Specified by:
isResumable
in interfaceResumable.ResumeAutomaton
- Returns:
- True if
Resumable.resume()
is possible.
-
resume
public void resume() throws ResumeException
Resumes the component.- Specified by:
resume
in interfaceResumable
- Throws:
ResumeException
- Thrown in case resuming fails.
-
isStoppable
public boolean isStoppable()
Determines whether the component may get stopped.- Specified by:
isStoppable
in interfaceStoppable.StopAutomaton
- Returns:
- True if
Stoppable.stop()
is possible.
-
stop
public void stop() throws StopException
Stops the component.- Specified by:
stop
in interfaceStoppable
- Throws:
StopException
- Thrown in case stopping fails.
-
isStopped
public boolean isStopped()
Determines whether the component is stopped.- Specified by:
isStopped
in interfaceStoppable.StopAutomaton
- Returns:
- True in case of being stopped, else false.
-
isDestroyable
public boolean isDestroyable()
Determines whether the component may get destroyed.- Specified by:
isDestroyable
in interfaceDestroyable.DestroyAutomaton
- Returns:
- True if
Destroyable.destroy()
is possible.
-
destroy
public void destroy()
Destroys the component. External resources might stay untouched! This should always be possible and must not throw any exception. In case aComponent
has been destroyed, then invoking any of thatComponent
instance's methods (except theDestroyable.destroy()
method) must throw anIllegalStateException
as by definition a once destroyedComponent
is in the state of being destroyed which is irreversible.- Specified by:
destroy
in interfaceDestroyable
-
isDestroyed
public boolean isDestroyed()
Determines whether the component is destroyed. In case of being true, then invoking any of thatComponent
instance's methods (except theDestroyable.destroy()
method) must throw anIllegalStateException
as by definition a once destroyedComponent
is in the state of being destroyed which is irreversible.- Specified by:
isDestroyed
in interfaceDestroyable.DestroyAutomaton
- Returns:
- True in case of being destroyed, else false.
-
getLifeCycleComponent
protected LifeCycleComponent getLifeCycleComponent()
Provides access to theLifeCycleComponent
instance.- Returns:
- The
LifeCycleComponent
instance being set.
-
setLifeCycleStatus
protected void setLifeCycleStatus(LifeCycleStatus aStatus)
Provides means to set theLifeCycleStatus
manually.- Parameters:
aStatus
- TheLifeCycleStatus
to be set.
-
-