Class AsyncRunLevelContext

    • Field Detail

      • DEBUG_CONTEXT_PROPERTY

        private static final java.lang.String DEBUG_CONTEXT_PROPERTY
        See Also:
        Constant Field Values
      • DEBUG_CONTEXT

        private static final boolean DEBUG_CONTEXT
      • logger

        private static final java.util.logging.Logger logger
      • timer

        private static final java.util.Timer timer
      • THREAD_FACTORY

        private static final java.util.concurrent.ThreadFactory THREAD_FACTORY
      • hk2Logger

        private final Logger hk2Logger
      • currentLevel

        private int currentLevel
      • DEFAULT_EXECUTOR

        private static final java.util.concurrent.Executor DEFAULT_EXECUTOR
      • backingMap

        private final java.util.Map<ActiveDescriptor<?>,​java.lang.Object> backingMap
        The backing maps for this context.
      • levelErrorMap

        private final java.util.Map<ActiveDescriptor<?>,​java.lang.Throwable> levelErrorMap
      • wasCancelled

        private boolean wasCancelled
      • creatingDescriptors

        private final java.util.HashMap<ActiveDescriptor<?>,​java.lang.Long> creatingDescriptors
        The set of services currently being created
      • hardCancelledDescriptors

        private final java.util.HashSet<ActiveDescriptor<?>> hardCancelledDescriptors
        The set of descriptors that have been hard cancelled
      • orderedCreationList

        private final java.util.LinkedList<ActiveDescriptor<?>> orderedCreationList
      • executor

        private java.util.concurrent.Executor executor
      • maxThreads

        private int maxThreads
      • cancelTimeout

        private long cancelTimeout
      • modeOverride

        private java.lang.Integer modeOverride
    • Constructor Detail

      • AsyncRunLevelContext

        @Inject
        private AsyncRunLevelContext​(ServiceLocator locator)
        Constructor for the guy who does the work
        Parameters:
        locator - The locator to use
    • Method Detail

      • findOrCreate

        public <U> U findOrCreate​(ActiveDescriptor<U> activeDescriptor,
                                  ServiceHandle<?> root)
        This is from the Context API, called by the wrapper
        Parameters:
        activeDescriptor - the descriptor to create
        root - The root descriptor
        Returns:
        The object created
      • containsKey

        public boolean containsKey​(ActiveDescriptor<?> descriptor)
        The Context API for discovering if a descriptor has been created
        Parameters:
        descriptor - The descriptor to find
        Returns:
        true if already created, false otherwise
      • hardCancelOne

        void hardCancelOne​(ActiveDescriptor<?> descriptor)
        No need to lock this, it is called with the lock already held
        Parameters:
        descriptor - the non-null descriptor to hard cancel
      • destroyOne

        public void destroyOne​(ActiveDescriptor<?> descriptor)
        The Context API. Removes a descriptor from the set
        Parameters:
        descriptor - The descriptor to destroy
      • validate

        private void validate​(ActiveDescriptor<?> descriptor,
                              int currentLevel)
                       throws java.lang.IllegalStateException
        Verifies that the run level value of the RunLevel annotated service described by the given descriptor is valid for activation. Valid means that the run level value is less than or equal to the current or planned run level of the given RunLevelController.
        Parameters:
        descriptor - the descriptor of the service being activated
        service - the run level service
        Throws:
        RunLevelException - if the validation fails
        java.lang.IllegalStateException
      • getCurrentLevel

        int getCurrentLevel()
      • levelCancelled

        void levelCancelled()
      • setCurrentLevel

        void setCurrentLevel​(int currentLevel)
      • setExecutor

        void setExecutor​(java.util.concurrent.Executor executor)
      • getExecutor

        java.util.concurrent.Executor getExecutor()
      • getOrderedListOfServicesAtLevel

        java.util.List<ActiveDescriptor<?>> getOrderedListOfServicesAtLevel​(int level)
      • proceedTo

        public RunLevelFuture proceedTo​(int level)
                                 throws CurrentlyRunningException
        This method is called to change the proceedTo level of the system
        Parameters:
        level - The level to change to
        Returns:
        A non-null RunLevelFuture that is the handle to give the caller
        Throws:
        CurrentlyRunningException - If there is already a running job
      • jobDone

        void jobDone()
      • getCurrentFuture

        public RunLevelFuture getCurrentFuture()
        Gets the current task
        Returns:
        The current task, may be null if there is no current task
      • setMaximumThreads

        void setMaximumThreads​(int maximum)
      • getMaximumThreads

        int getMaximumThreads()
      • clearErrors

        void clearErrors()
      • setCancelTimeout

        void setCancelTimeout​(long cancelTimeout)
      • getCancelTimeout

        long getCancelTimeout()
      • getModeOverride

        java.lang.Integer getModeOverride()
      • setModeOverride

        void setModeOverride​(java.lang.Integer modeOverride)
      • oneLineDescriptor

        private static java.lang.String oneLineDescriptor​(ActiveDescriptor<?> descriptor)
      • oneLineRoot

        private static java.lang.String oneLineRoot​(ServiceHandle<?> root)