Top Inners Fields Constructors Methods
org.glassfish.hk2.runlevel.internal

public Class AsyncRunLevelContext

extends Object
Class Inheritance
Annotations
@Service
@Visibility:LOCAL
Imports
java.security.AccessController, .PrivilegedAction, java.util.HashMap, .HashSet, .LinkedList, .List, .Map, .Timer, java.util.concurrent.Executor, .SynchronousQueue, .ThreadFactory, .ThreadPoolExecutor, .TimeUnit, java.util.concurrent.locks.ReentrantLock, .Condition, java.util.logging.Level, .Logger, jakarta.inject.Inject, org.glassfish.hk2.api.ActiveDescriptor, .Context, .DescriptorVisibility, .MultiException, .ServiceHandle, .ServiceLocator, .Visibility, org.glassfish.hk2.runlevel.CurrentlyRunningException, .RunLevel, .RunLevelController, .RunLevelFuture, org.glassfish.hk2.runlevel.utilities.Utilities, org.jvnet.hk2.annotations.Service

Author
jwells

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class

Field Summary

Modifier and TypeField and Description
private final Map<ActiveDescriptor<?>, Object>
backingMap

The backing maps for this context.

private long
private final HashMap<ActiveDescriptor<?>, Long>
creatingDescriptors

The set of services currently being created

private int
private CurrentTaskFutureWrapper
private static final boolean
private static final String
private static final Executor
private Executor
private final HashSet<ActiveDescriptor<?>>
hardCancelledDescriptors

The set of descriptors that have been hard cancelled

private final Logger
private final Map<ActiveDescriptor<?>, Throwable>
private final ServiceLocator
pack-priv final ReentrantLock
private static final Logger
private int
private Integer
private final Condition
private final LinkedList<ActiveDescriptor<?>>
private RunLevelController.ThreadingPolicy
private static final ThreadFactory
private static final Timer
private boolean

Constructor Summary

AccessConstructor and Description
private
AsyncRunLevelContext(ServiceLocator
The locator to use
locator
)

Constructor for the guy who does the work

Method Summary

Modifier and TypeMethod and Description
pack-priv void
public boolean

Returns:

true if already created, false otherwise
containsKey
(ActiveDescriptor<?>
The descriptor to find
descriptor
)

The Context API for discovering if a descriptor has been created

public void
destroyOne(ActiveDescriptor<?>
The descriptor to destroy
descriptor
)

The Context API.

public <U> U

Returns:

The object created
findOrCreate
(ActiveDescriptor<U>
the descriptor to create
activeDescriptor
,
ServiceHandle<?>
The root descriptor
root
)

This is from the Context API, called by the wrapper

pack-priv long
public RunLevelFuture

Returns:

The current task, may be null if there is no current task
getCurrentFuture
()

Gets the current task

pack-priv int
pack-priv Executor
pack-priv int
pack-priv Integer
pack-priv List<ActiveDescriptor<?>>
pack-priv RunLevelController.ThreadingPolicy
pack-priv void
hardCancelOne(ActiveDescriptor<?>
the non-null descriptor to hard cancel
descriptor
)

No need to lock this, it is called with the lock already held

pack-priv void
pack-priv void
private static String
private static String
public RunLevelFuture

Returns:

A non-null RunLevelFuture that is the handle to give the caller
proceedTo
(int
The level to change to
level
)

This method is called to change the proceedTo level of the system

pack-priv void
setCancelTimeout(long cancelTimeout)

pack-priv void
setCurrentLevel(int currentLevel)

pack-priv void
pack-priv void
setMaximumThreads(int maximum)

pack-priv void
setModeOverride(Integer modeOverride)

pack-priv void
private void
validate(ActiveDescriptor<?>
the descriptor of the service being activated
descriptor
,
int currentLevel)

Verifies that the run level value of the RunLevel annotated service described by the given descriptor is valid for activation.

pack-priv boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

backingMapback to summary
private final Map<ActiveDescriptor<?>, Object> backingMap

The backing maps for this context.

cancelTimeoutback to summary
private long cancelTimeout
creatingDescriptorsback to summary
private final HashMap<ActiveDescriptor<?>, Long> creatingDescriptors

The set of services currently being created

currentLevelback to summary
private int currentLevel
currentTaskback to summary
private CurrentTaskFutureWrapper currentTask
DEBUG_CONTEXTback to summary
private static final boolean DEBUG_CONTEXT
DEBUG_CONTEXT_PROPERTYback to summary
private static final String DEBUG_CONTEXT_PROPERTY
DEFAULT_EXECUTORback to summary
private static final Executor DEFAULT_EXECUTOR
executorback to summary
private Executor executor
hardCancelledDescriptorsback to summary
private final HashSet<ActiveDescriptor<?>> hardCancelledDescriptors

The set of descriptors that have been hard cancelled

hk2Loggerback to summary
private final Logger hk2Logger
levelErrorMapback to summary
private final Map<ActiveDescriptor<?>, Throwable> levelErrorMap
locatorback to summary
private final ServiceLocator locator
lockback to summary
pack-priv final ReentrantLock lock
loggerback to summary
private static final Logger logger
maxThreadsback to summary
private int maxThreads
modeOverrideback to summary
private Integer modeOverride
notEmptyback to summary
private final Condition notEmpty
orderedCreationListback to summary
private final LinkedList<ActiveDescriptor<?>> orderedCreationList
policyback to summary
private RunLevelController.ThreadingPolicy policy
THREAD_FACTORYback to summary
private static final ThreadFactory THREAD_FACTORY
TIMERback to summary
private static final Timer TIMER
wasCancelledback to summary
private boolean wasCancelled

Constructor Detail

AsyncRunLevelContextback to summary
private AsyncRunLevelContext(ServiceLocator locator)

Constructor for the guy who does the work

Parameters
locator:ServiceLocator

The locator to use

Annotations
@Inject

Method Detail

clearErrorsback to summary
pack-priv void clearErrors()
containsKeyback to summary
public boolean containsKey(ActiveDescriptor<?> descriptor)

The Context API for discovering if a descriptor has been created

Parameters
descriptor:ActiveDescriptor<?>

The descriptor to find

Returns:boolean

true if already created, false otherwise

destroyOneback to summary
public void destroyOne(ActiveDescriptor<?> descriptor)

The Context API. Removes a descriptor from the set

Parameters
descriptor:ActiveDescriptor<?>

The descriptor to destroy

Annotations
@SuppressWarnings:unchecked
findOrCreateback to summary
public <U> U findOrCreate(ActiveDescriptor<U> activeDescriptor, ServiceHandle<?> root)

This is from the Context API, called by the wrapper

Parameters
activeDescriptor:ActiveDescriptor<U>

the descriptor to create

root:ServiceHandle<?>

The root descriptor

Returns:U

The object created

Annotations
@SuppressWarnings:unchecked
getCancelTimeoutback to summary
pack-priv long getCancelTimeout()
getCurrentFutureback to summary
public RunLevelFuture getCurrentFuture()

Gets the current task

Returns:RunLevelFuture

The current task, may be null if there is no current task

getCurrentLevelback to summary
pack-priv int getCurrentLevel()
getExecutorback to summary
pack-priv Executor getExecutor()
getMaximumThreadsback to summary
pack-priv int getMaximumThreads()
getModeOverrideback to summary
pack-priv Integer getModeOverride()
getOrderedListOfServicesAtLevelback to summary
pack-priv List<ActiveDescriptor<?>> getOrderedListOfServicesAtLevel(int level)
getPolicyback to summary
pack-priv RunLevelController.ThreadingPolicy getPolicy()
hardCancelOneback to summary
pack-priv void hardCancelOne(ActiveDescriptor<?> descriptor)

No need to lock this, it is called with the lock already held

Parameters
descriptor:ActiveDescriptor<?>

the non-null descriptor to hard cancel

jobDoneback to summary
pack-priv void jobDone()
levelCancelledback to summary
pack-priv void levelCancelled()
oneLineDescriptorback to summary
private static String oneLineDescriptor(ActiveDescriptor<?> descriptor)
oneLineRootback to summary
private static String oneLineRoot(ServiceHandle<?> root)
proceedToback to summary
public RunLevelFuture proceedTo(int level) throws CurrentlyRunningException

This method is called to change the proceedTo level of the system

Parameters
level:int

The level to change to

Returns:RunLevelFuture

A non-null RunLevelFuture that is the handle to give the caller

Exceptions
CurrentlyRunningException:
If there is already a running job
setCancelTimeoutback to summary
pack-priv void setCancelTimeout(long cancelTimeout)
setCurrentLevelback to summary
pack-priv void setCurrentLevel(int currentLevel)
setExecutorback to summary
pack-priv void setExecutor(Executor executor)
setMaximumThreadsback to summary
pack-priv void setMaximumThreads(int maximum)
setModeOverrideback to summary
pack-priv void setModeOverride(Integer modeOverride)
setPolicyback to summary
pack-priv void setPolicy(RunLevelController.ThreadingPolicy policy)
validateback to summary
private void validate(ActiveDescriptor<?> descriptor, int currentLevel) throws 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 org.glassfish.hk2.runlevel.RunLevelController.

Parameters
descriptor:ActiveDescriptor<?>

the descriptor of the service being activated

Exceptions
RunLevelException:
if the validation fails
wouldBlockRightNowback to summary
pack-priv boolean wouldBlockRightNow(ActiveDescriptor<?> desc)
org.glassfish.hk2.runlevel.internal back to summary

private Class AsyncRunLevelContext.RunLevelControllerThread

extends Thread
Class Inheritance

Field Summary

Inherited from java.lang.Thread:
MAX_PRIORITYMIN_PRIORITYNORM_PRIORITY

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Thread:
activeCountcheckAccessclonecurrentThreaddumpStackenumerategetAllStackTracesgetContextClassLoadergetDefaultUncaughtExceptionHandlergetIdgetNamegetPrioritygetStackTracegetStategetThreadGroupgetUncaughtExceptionHandlerholdsLockinterruptinterruptedisAliveisDaemonisInterruptedisVirtualjoinjoinjoinjoinofPlatformofVirtualonSpinWaitrunsetContextClassLoadersetDaemonsetDefaultUncaughtExceptionHandlersetNamesetPrioritysetUncaughtExceptionHandlersleepsleepsleepstartstartVirtualThreadthreadIdtoStringyield

Constructor Detail

RunLevelControllerThreadback to summary
private RunLevelControllerThread(Runnable r)
org.glassfish.hk2.runlevel.internal back to summary

private Class AsyncRunLevelContext.RunLevelThreadFactory

extends Object
implements ThreadFactory
Class Inheritance
  • java.lang.Object
  • org.glassfish.hk2.runlevel.internal.AsyncRunLevelContext.RunLevelThreadFactory
All Implemented Interfaces
java.util.concurrent.ThreadFactory

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public Thread
newThread(Runnable runnable)

Implements java.util.concurrent.ThreadFactory.newThread.

Constructs a new unstarted Thread to run the given runnable.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

RunLevelThreadFactoryback to summary
private RunLevelThreadFactory()

Method Detail

newThreadback to summary
public Thread newThread(Runnable runnable)

Implements java.util.concurrent.ThreadFactory.newThread.

Doc from java.util.concurrent.ThreadFactory.newThread.

Constructs a new unstarted Thread to run the given runnable.

Annotations
@Override