Package org.jboss.msc.service

The service container implementation itself. The service container is what coordinates the registry of services and manages their installation and execution. To create a service container, see ServiceContainer.Factory.create(). To create services, implement the Service interface.

Individual service instances are controlled using the ServiceController interface. Service controllers follow this strict internal state machine:

State machine image

The green boxes represent states; the red boxes below them represent possible transitions. The "When:" condition must be satisfied before a transition is taken; if it is, then the asynchronous tasks listed under "Tasks:" are executed.

The variables are what determine when a transition may occur; any time a variable is changed, the conditions are checked to see if a transition can occur. The variables are as follows:

  • A: The number of currently running asynchronous tasks.
  • R: The number of running children (dependents).
  • D: The number of "demands" from children, used to trigger the start of ON_DEMAND services. If greater than zero, a single "demand" is propagated to the dependency set (parents) of this service.
  • U: The count, from zero, representing the desire of the service to be "up". Only services with a positive "up" count will start.
  • X: The exception produced by the service start() method, if any.
  • MODE: The controller start mode. Values can be one of:
    • ACTIVE - attempt to start immediately, and request all parents (dependencies) to start as well by incrementing their "demand" count (D). Puts a load of +1 on U always.
    • PASSIVE - attempt to start immediately if all dependencies are up. Puts a load of +1 on U always.
    • ON_DEMAND - only start a service if demanded. Puts a load of +1 on U only if D is greater than zero.
    • NEVER - never start. The value of U is not affected and not considered. The value of D is disregarded; if D was greater than zero, then the existing "demand" on the dependency set (parents) is revoked and further "demands" are suppressed until this mode is left.
    • REMOVE - the same as NEVER; in addition, remove the service as soon as it is down. The mode may not be changed again after setting this mode.