Class AsyncRunLevelContext
- java.lang.Object
-
- org.glassfish.hk2.runlevel.internal.AsyncRunLevelContext
-
@Service @Visibility(LOCAL) public class AsyncRunLevelContext extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classAsyncRunLevelContext.RunLevelControllerThreadprivate static classAsyncRunLevelContext.RunLevelThreadFactory
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<ActiveDescriptor<?>,java.lang.Object>backingMapThe backing maps for this context.private longcancelTimeoutprivate java.util.HashMap<ActiveDescriptor<?>,java.lang.Long>creatingDescriptorsThe set of services currently being createdprivate intcurrentLevelprivate CurrentTaskFutureWrappercurrentTaskprivate static booleanDEBUG_CONTEXTprivate static java.lang.StringDEBUG_CONTEXT_PROPERTYprivate static java.util.concurrent.ExecutorDEFAULT_EXECUTORprivate java.util.concurrent.Executorexecutorprivate java.util.HashSet<ActiveDescriptor<?>>hardCancelledDescriptorsThe set of descriptors that have been hard cancelledprivate Loggerhk2Loggerprivate java.util.Map<ActiveDescriptor<?>,java.lang.Throwable>levelErrorMapprivate ServiceLocatorlocatorprivate static java.util.logging.Loggerloggerprivate intmaxThreadsprivate java.lang.IntegermodeOverrideprivate java.util.LinkedList<ActiveDescriptor<?>>orderedCreationListprivate RunLevelController.ThreadingPolicypolicyprivate static java.util.concurrent.ThreadFactoryTHREAD_FACTORYprivate static java.util.Timertimerprivate booleanwasCancelled
-
Constructor Summary
Constructors Modifier Constructor Description privateAsyncRunLevelContext(ServiceLocator locator)Constructor for the guy who does the work
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidclearErrors()booleancontainsKey(ActiveDescriptor<?> descriptor)TheContextAPI for discovering if a descriptor has been createdvoiddestroyOne(ActiveDescriptor<?> descriptor)TheContextAPI.<U> UfindOrCreate(ActiveDescriptor<U> activeDescriptor, ServiceHandle<?> root)This is from theContextAPI, called by the wrapper(package private) longgetCancelTimeout()RunLevelFuturegetCurrentFuture()Gets the current task(package private) intgetCurrentLevel()(package private) java.util.concurrent.ExecutorgetExecutor()(package private) intgetMaximumThreads()(package private) java.lang.IntegergetModeOverride()(package private) java.util.List<ActiveDescriptor<?>>getOrderedListOfServicesAtLevel(int level)(package private) RunLevelController.ThreadingPolicygetPolicy()(package private) voidhardCancelOne(ActiveDescriptor<?> descriptor)No need to lock this, it is called with the lock already held(package private) voidjobDone()(package private) voidlevelCancelled()private static java.lang.StringoneLineDescriptor(ActiveDescriptor<?> descriptor)private static java.lang.StringoneLineRoot(ServiceHandle<?> root)RunLevelFutureproceedTo(int level)This method is called to change the proceedTo level of the system(package private) voidsetCancelTimeout(long cancelTimeout)(package private) voidsetCurrentLevel(int currentLevel)(package private) voidsetExecutor(java.util.concurrent.Executor executor)(package private) voidsetMaximumThreads(int maximum)(package private) voidsetModeOverride(java.lang.Integer modeOverride)(package private) voidsetPolicy(RunLevelController.ThreadingPolicy policy)private voidvalidate(ActiveDescriptor<?> descriptor, int currentLevel)Verifies that the run level value of theRunLevelannotated service described by the given descriptor is valid for activation.(package private) booleanwouldBlockRightNow(ActiveDescriptor<?> desc)
-
-
-
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
-
currentTask
private CurrentTaskFutureWrapper currentTask
-
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
-
locator
private final ServiceLocator locator
-
maxThreads
private int maxThreads
-
policy
private RunLevelController.ThreadingPolicy policy
-
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 theContextAPI, called by the wrapper- Parameters:
activeDescriptor- the descriptor to createroot- The root descriptor- Returns:
- The object created
-
containsKey
public boolean containsKey(ActiveDescriptor<?> descriptor)
TheContextAPI for discovering if a descriptor has been created- Parameters:
descriptor- The descriptor to find- Returns:
- true if already created, false otherwise
-
wouldBlockRightNow
boolean wouldBlockRightNow(ActiveDescriptor<?> desc)
-
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)
TheContextAPI. 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 theRunLevelannotated 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 givenRunLevelController.- Parameters:
descriptor- the descriptor of the service being activatedservice- the run level service- Throws:
RunLevelException- if the validation failsjava.lang.IllegalStateException
-
getCurrentLevel
int getCurrentLevel()
-
levelCancelled
void levelCancelled()
-
setCurrentLevel
void setCurrentLevel(int currentLevel)
-
setPolicy
void setPolicy(RunLevelController.ThreadingPolicy policy)
-
setExecutor
void setExecutor(java.util.concurrent.Executor executor)
-
getExecutor
java.util.concurrent.Executor getExecutor()
-
getPolicy
RunLevelController.ThreadingPolicy getPolicy()
-
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)
-
-