Module org.refcodes.component
Package org.refcodes.component
Class ConfigurableLifecycleAutomatonImpl<CTX>
java.lang.Object
org.refcodes.component.ConfigurableLifecycleAutomatonImpl<CTX>
- Type Parameters:
CTX- the context used to initialize the implementing instance.
- All Implemented Interfaces:
Configurable<CTX>,Configurable.ConfigureAutomaton<CTX>,ConfigurableLifecycleComponent<CTX>,ConfigurableLifecycleComponent.ConfigurableLifecycleAutomaton<CTX>,Destroyable,Destroyable.DestroyAutomaton,InitializedAccessor,LifecycleStatusAccessor,Pausable,Pausable.PauseAutomaton,Resumable,Resumable.ResumeAutomaton,RunningAccessor,Startable,Startable.StartAutomaton,Stoppable,Stoppable.StopAutomaton
public class ConfigurableLifecycleAutomatonImpl<CTX>
extends Object
implements ConfigurableLifecycleComponent.ConfigurableLifecycleAutomaton<CTX>
This class implements a
ConfigurableLifecycleComponent.ConfigurableLifecycleAutomaton.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.refcodes.component.Configurable
Configurable.ConfigureAutomaton<CTX>, Configurable.ConfigureBuilder<CTX,B extends Configurable.ConfigureBuilder<CTX, B>> Nested classes/interfaces inherited from interface org.refcodes.component.ConfigurableLifecycleComponent
ConfigurableLifecycleComponent.ConfigurableLifecycleAutomaton<CTX>Nested classes/interfaces inherited from interface org.refcodes.component.Destroyable
Destroyable.DestroyAutomatonNested classes/interfaces inherited from interface org.refcodes.component.InitializedAccessor
InitializedAccessor.InitializedMutator, InitializedAccessor.InitializedPropertyNested classes/interfaces inherited from interface org.refcodes.component.LifecycleStatusAccessor
LifecycleStatusAccessor.LifecycleStatusBuilder<B extends LifecycleStatusAccessor.LifecycleStatusBuilder<B>>, LifecycleStatusAccessor.LifecycleStatusMutator, LifecycleStatusAccessor.LifecycleStatusPropertyNested classes/interfaces inherited from interface org.refcodes.component.Pausable
Pausable.PauseAutomaton, Pausable.PauseBuilder<B extends Pausable.PauseBuilder<B>>, Pausable.UncheckedPausableNested classes/interfaces inherited from interface org.refcodes.component.Resumable
Resumable.ResumeAutomaton, Resumable.ResumeBuilder<B extends Resumable.ResumeBuilder<B>>, Resumable.UncheckedResumableNested classes/interfaces inherited from interface org.refcodes.component.RunningAccessor
RunningAccessor.RunningMutator, RunningAccessor.RunningPropertyNested classes/interfaces inherited from interface org.refcodes.component.Startable
Startable.StartAutomaton, Startable.StartBuilder<B extends Startable.StartBuilder<B>>, Startable.UncheckedStartableNested classes/interfaces inherited from interface org.refcodes.component.Stoppable
Stoppable.StopAutomaton, Stoppable.StopBuilder<B extends Stoppable.StopBuilder<B>>, Stoppable.UncheckedStoppable -
Constructor Summary
ConstructorsConstructorDescriptionEmpty constructor, suchLifecycleComponent.LifecycleAutomatoncannot do much more than decline the variousLifecycleStatusstates for you.ConfigurableLifecycleAutomatonImpl(ConfigurableLifecycleComponent<CTX> aLifeConfigurableCycleComponent) This constructor uses aLifecycleStatusfor wrapping it inside theConfigurableLifecycleAutomatonImpl, making sure of obeying and guarding the correctLifecycleStatus's order ofLifecycleStatusstates for you. -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()Destroys the component.protected ConfigurableLifecycleComponent<CTX>Provides access to theLifecycleComponentinstance.Retrieves theLifecycleStatusproperty from the property.voidinitialize(CTX aContext) Initializes and configures the component.booleanDetermines whether the component may get destroyed.booleanDetermines whether the component is destroyed.booleanisInitalizable(CTX aContext) Checks if is initalizable.booleanRetrieves the is-initialized property from the initialized property.booleanDetermines whether the component may get paused.booleanisPaused()Determines whether the component is paused.booleanDetermines whether the component may get resumed.booleanRetrieves the is-running property from the running property.booleanDetermines whether the component may get started.booleanDetermines whether the component may get stopped.booleanDetermines whether the component is stopped.voidpause()Pauses the component.voidresume()Resumes the component.voidstart()Starts the component.voidstop()Stops the component.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.refcodes.component.Configurable
initializeUncheckedMethods inherited from interface org.refcodes.component.Pausable
pauseUncheckedMethods inherited from interface org.refcodes.component.Resumable
resumeUncheckedMethods inherited from interface org.refcodes.component.Startable
startUncheckedMethods inherited from interface org.refcodes.component.Stoppable
stopUnchecked
-
Constructor Details
-
ConfigurableLifecycleAutomatonImpl
public ConfigurableLifecycleAutomatonImpl()Empty constructor, suchLifecycleComponent.LifecycleAutomatoncannot do much more than decline the variousLifecycleStatusstates for you. -
ConfigurableLifecycleAutomatonImpl
public ConfigurableLifecycleAutomatonImpl(ConfigurableLifecycleComponent<CTX> aLifeConfigurableCycleComponent) This constructor uses aLifecycleStatusfor wrapping it inside theConfigurableLifecycleAutomatonImpl, making sure of obeying and guarding the correctLifecycleStatus's order ofLifecycleStatusstates for you.- Parameters:
aLifeConfigurableCycleComponent- The component to be guarded regarding the correct declination of theLifecycleStatusstates.
-
-
Method Details
-
getLifecycleStatus
Retrieves theLifecycleStatusproperty from the property. Determines in whichLifecycleStatusstatus a component is in.- Specified by:
getLifecycleStatusin interfaceLifecycleStatusAccessor- Returns:
- Returns the
LifecycleStatusproperty stored by the property.
-
initialize
Initializes and configures the component.- Specified by:
initializein interfaceConfigurable<CTX>- Parameters:
aContext- The context to be passed to the implementing instance.- Throws:
InitializeException- Thrown in case initializing fails.
-
isInitalizable
Checks if is initalizable.- Specified by:
isInitalizablein interfaceConfigurable.ConfigureAutomaton<CTX>- Parameters:
aContext- the context- Returns:
- true, if is initalizable
-
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:
isInitializedin 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:
isStartablein interfaceStartable.StartAutomaton- Returns:
- True if
Startable.start()is possible.
-
start
Starts the component.- Specified by:
startin 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:
isRunningin 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:
isPausablein interfacePausable.PauseAutomaton- Returns:
- True if
Pausable.pause()is possible.
-
pause
Pauses the component.- Specified by:
pausein interfacePausable- Throws:
PauseException- in case pausing fails.
-
isPaused
public boolean isPaused()Determines whether the component is paused.- Specified by:
isPausedin interfacePausable.PauseAutomaton- Returns:
- True in case of being paused, else false.
-
isResumable
public boolean isResumable()Determines whether the component may get resumed.- Specified by:
isResumablein interfaceResumable.ResumeAutomaton- Returns:
- True if
Resumable.resume()is possible.
-
resume
Resumes the component.- Specified by:
resumein interfaceResumable- Throws:
ResumeException- Thrown in case resuming fails.
-
isStoppable
public boolean isStoppable()Determines whether the component may get stopped.- Specified by:
isStoppablein interfaceStoppable.StopAutomaton- Returns:
- True if
Stoppable.stop()is possible.
-
stop
Stops the component.- Specified by:
stopin interfaceStoppable- Throws:
StopException- Thrown in case stopping fails.
-
isStopped
public boolean isStopped()Determines whether the component is stopped.- Specified by:
isStoppedin interfaceStoppable.StopAutomaton- Returns:
- True in case of being stopped, else false.
-
isDestroyable
public boolean isDestroyable()Determines whether the component may get destroyed.- Specified by:
isDestroyablein 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 aComponenthas been destroyed, then invoking any of thatComponentinstance's methods (except theDestroyable.destroy()method) must throw anIllegalStateExceptionas by definition a once destroyedComponentis in the state of being destroyed which is irreversible.- Specified by:
destroyin interfaceDestroyable
-
isDestroyed
public boolean isDestroyed()Determines whether the component is destroyed. In case of being true, then invoking any of thatComponentinstance's methods (except theDestroyable.destroy()method) must throw anIllegalStateExceptionas by definition a once destroyedComponentis in the state of being destroyed which is irreversible.- Specified by:
isDestroyedin interfaceDestroyable.DestroyAutomaton- Returns:
- True in case of being destroyed, else false.
-
getLifecycleComponent
Provides access to theLifecycleComponentinstance.- Returns:
- The
LifecycleComponentinstance being set.
-