Contextual type.
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class |
| Modifier and Type | Field and Description |
|---|---|
| private final ContextPermission | |
| private final AtomicReference | |
| private final String | |
| private final ConcurrentHashMap | |
| private final ThreadLocal | |
| private final Class |
| Access | Constructor and Description |
|---|---|
| public | ContextManager(final Class<C>
the type class of the context object (must not be type)null)Construct a new instance, with a name matching the class name of the given |
| public | ContextManager(final Class<C>
the type class of the context object (must not be type, final String null)the name to use for permission checks (must not be name)null or empty)Construct a new instance. |
| Modifier and Type | Method and Description |
|---|---|
| public C | Returns: the current context, ornull if none is activeImplements java. |
| pack-priv C | |
| public C | Returns: the global default, ornull if none is installed or availablethe class loader classLoader)Get the class loader default instance. |
| public Supplier | Returns: the global default, ornull if none is installed or availablethe class loader classLoader)Get the class loader default supplier.\ |
| public C | Returns: the global default, ornull if none is installed or availableGet the global default context instance. |
| public Supplier | Returns: the global default supplier, ornull if none is installed or availableGet the global default supplier instance. |
| private C | |
| public Supplier | Returns: the privileged supplierGet a privileged supplier for this context manager which returns the currently active context without a permission check. |
| public C | Returns: the per-thread default, ornull if none is installed or availableGet the per-thread default context instance. |
| public Supplier | Returns: the per-thread default supplier, ornull if none is installed or availableGet the per-thread default context instance. |
| pack-priv void | |
| public void | setClassLoaderDefault(final ClassLoader
the class loader (must not be classLoader, final C null)the class loader default value, or classLoaderDefault)null to remove the defaultSet the per-class loader default instance supplier. |
| public void | setClassLoaderDefaultSupplier(final ClassLoader
the class loader (must not be classLoader, final Supplier<C> null)the supplier, or supplier)null to remove the default for this class loaderSet the per-class loader default instance supplier. |
| public void | setGlobalDefault(final C
the global default value, or globalDefault)null to remove the global defaultSet the global default instance. |
| public void | setGlobalDefaultSupplier(final Supplier<C>
the supplier, or supplier)null to remove the global defaultSet the global default instance supplier. |
| public boolean | Returns: true if the supplier was set, false if it was already set to something elsethe supplier supplier (must not be supplierSupplier)null)Set the global default instance supplier, but only if it was not already set. |
| public void | setThreadDefault(final C
the per-thread default value, or threadDefault)null to remove the per-thread defaultSet the per-thread default instance. |
| public void | setThreadDefaultSupplier(final Supplier<C>
the supplier, or supplier)null to remove the per-thread defaultSet the per-thread default instance supplier. |
| getPermission | back to summary |
|---|---|
| private final ContextPermission getPermission | |
| globalDefaultSupplierRef | back to summary |
|---|---|
| private final AtomicReference<Supplier<C>> globalDefaultSupplierRef | |
| name | back to summary |
|---|---|
| private final String name | |
| perClassLoaderDefault | back to summary |
|---|---|
| private final ConcurrentHashMap<ClassLoader, Supplier<C>> perClassLoaderDefault | |
| stateRef | back to summary |
|---|---|
| private final ThreadLocal<ContextManager. | |
| type | back to summary |
|---|---|
| private final Class<C> type | |
| ContextManager | back to summary |
|---|---|
| public ContextManager(final Class<C> type) Construct a new instance, with a name matching the class name of the given
| |
| ContextManager | back to summary |
|---|---|
| public ContextManager(final Class<C> type, final String name) Construct a new instance. | |
| get | back to summary |
|---|---|
| public C get() Implements java. Get the currently active context, possibly examining the per-thread or global defaults.
| |
| getAndSetCurrent | back to summary |
|---|---|
| pack-priv C getAndSetCurrent(Contextual<C> newVal) | |
| getClassLoaderDefault | back to summary |
|---|---|
| public C getClassLoaderDefault(final ClassLoader classLoader) Get the class loader default instance. Note that the class loader default is determined by way of a
| |
| getClassLoaderDefaultSupplier | back to summary |
|---|---|
| public Supplier Get the class loader default supplier.\
| |
| getGlobalDefault | back to summary |
|---|---|
| public C getGlobalDefault() Get the global default context instance. Note that the global default is determined by way of a
| |
| getGlobalDefaultSupplier | back to summary |
|---|---|
| public Supplier Get the global default supplier instance.
| |
| getPrivileged | back to summary |
|---|---|
| private C getPrivileged() | |
| getPrivilegedSupplier | back to summary |
|---|---|
| public Supplier Get a privileged supplier for this context manager which returns the currently active context without a permission check.
| |
| getThreadDefault | back to summary |
|---|---|
| public C getThreadDefault() Get the per-thread default context instance. Note that the per-thread default is determined by way of a
| |
| getThreadDefaultSupplier | back to summary |
|---|---|
| public Supplier Get the per-thread default context instance.
| |
| restoreCurrent | back to summary |
|---|---|
| pack-priv void restoreCurrent(C oldVal) | |
| setClassLoaderDefault | back to summary |
|---|---|
| public void setClassLoaderDefault(final ClassLoader classLoader, final C classLoaderDefault) Set the per-class loader default instance supplier. The supplier, if one is given, should have a reasonable policy such
that callers of
| |
| setClassLoaderDefaultSupplier | back to summary |
|---|---|
| public void setClassLoaderDefaultSupplier(final ClassLoader classLoader, final Supplier<C> supplier) Set the per-class loader default instance supplier. The supplier, if one is given, should have a reasonable policy such
that callers of
| |
| setGlobalDefault | back to summary |
|---|---|
| public void setGlobalDefault(final C globalDefault) Set the global default instance. This instance will be returned from all subsequent calls to
| |
| setGlobalDefaultSupplier | back to summary |
|---|---|
| public void setGlobalDefaultSupplier(final Supplier<C> supplier) Set the global default instance supplier. The supplier, if one is given, should have a reasonable policy such
that callers of
| |
| setGlobalDefaultSupplierIfNotSet | back to summary |
|---|---|
| public boolean setGlobalDefaultSupplierIfNotSet(final Supplier<Supplier<C>> supplierSupplier) Set the global default instance supplier, but only if it was not already set. If no supplier is set, the given supplier supplier is queried to get the new value to set.
| |
| setThreadDefault | back to summary |
|---|---|
| public void setThreadDefault(final C threadDefault) Set the per-thread default instance. This instance will be returned from all subsequent calls to
| |
| setThreadDefaultSupplier | back to summary |
|---|---|
| public void setThreadDefaultSupplier(final Supplier<C> supplier) Set the per-thread default instance supplier. The supplier, if one is given, should have a reasonable policy such
that callers of
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv T | |
| pack-priv Supplier |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| current | back to summary |
|---|---|
| pack-priv T current | |
| defaultSupplier | back to summary |
|---|---|
| pack-priv Supplier<T> defaultSupplier | |
| State | back to summary |
|---|---|
| pack-priv State() | |