(The source code version in this article is JBoss-as-Final 6.1.0)
The JBoss service status is defined in the lifecyclestate class.
There are eight statuses in total: instreceivated, pre_init, initialized, idle, starting, started, stopping, stopped
The following are explanations:
I. instancated
The most primitive status of a service, only once. After entering another status, it will no longer return to this status.
This status is set in the last line of the constructor of abstractserver.
This. State = lifecyclestate. instancated;
The initialize () method is executed after the constructor. Therefore, the service is not initialized yet.
This status is often seen in many JBoss errors.
The literal meaning of this word is easily understood:InstantiatedIn fact, he means: Your service is stillOriginalIs not started!
Ii. pre_init
Preparation status before initialization: Pre-Initialize. When the abstractserver executes the initialize () method, it sets the status to pre_init. This status is only once.
After the status is set, call the doinitialize () method.
Between instancated ------> pre_init, the configuration is null. At this time, the configuration is a newly instantiated basicjbossasserverconfig object.
Different from instancated, The pre_init status is set to use
This. setstate (lifecyclestate. pre_init );
In addition to setting the state, the lifecycle change event is also triggered:
This. State = State; final set <lifecycleeventhandler> handlers = This. gethandlersforevent (State); For (final lifecycleeventhandler handler: handlers) {handler. handleevent (State );}
In the abstractjbossasserverbase doinitialize () method, the start and stop events are registered:
Final lifecycleeventhandler starthandler = new handler (this); Final lifecycleeventhandler stophandler = new kernelstopeventlifecycleeventhandler (this); this. registereventhandler (starthandler, lifecyclestate. started); this. registereventhandler (stophandler, lifecyclestate. stopping );
Iii. initialized
Initialization is complete. The doinitialize () method of abstractserver and its subclass is fully executed. After returning to initialize (), the pre_init state is changed to initialized. This status is only once.
Also used
This. setstate (lifecyclestate. initialized );
Iv. idle
Idle, indicating that the instance is not started or is waiting for startup. The initial status is set with the initialized status:
This. setstate (lifecyclestate. initialized); this. setstate (lifecyclestate. idle );
Another State that changes to idle is stoped:
This. setstate (lifecyclestate. Stopped); this. setstate (lifecyclestate. idle );
V. Starting
The instance is being started and has not been started yet.
The starting status is set in startservertask of abstractserver:
Setstate (lifecyclestate.Starting);
VI,Started
The startup is complete and is in the service status.
This status is set after the startservertask of abstractserver completes the dostart () and other methods.
At the same time, kernelstarteventlifecycleeventhandler event processing is triggered!
This is a parallel processing mechanism.
Started can be converted to stopping.
VII. Stopping
Stopping. Not finished yet.
At the same time, the kernelstopeventlifecycleeventhandler event processing is also triggered!
This status is switched to stopped.
VIII. Stopped
Stopped. Then switch to the idle status.
The preceding status is onlyInstancated,Idle,The started and stopped statuses are stable,We often see only the four stable states.
Other States will change to a stable State during program execution, so these unstable States cannot be obtained.
JBoss as6 service status description