Interface ExtensionContext
-
public interface ExtensionContext
The context for registering a new extension.- Author:
- David M. Lloyd, David Bosschaert, Brian Stansberry (c) 2011 Red Hat Inc.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
ExtensionContext.ContextType
The various types of contexts in which anExtension
can be asked to initialize.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description PathManager
getPathManager()
ProcessType
getProcessType()
Gets the type of the current process.RunningMode
getRunningMode()
Gets the current running mode of the process.ExtensionContext.ContextType
getType()
Gets the type of this context.boolean
isRuntimeOnlyRegistrationValid()
Gets whether it is valid for the extension to register resources, attributes or operations that do not involve the persistent configuration, but rather only involve runtime services.default void
registerExpressionResolverExtension(Supplier<ExpressionResolverExtension> supplier, Pattern expressionPattern, boolean requiresRuntimeResolution)
Registers that the extension may provide anExpressionResolverExtension
if one of its subsystems is appropriately configured.SubsystemRegistration
registerSubsystem(String name, ModelVersion version)
Convenience variant ofregisterSubsystem(String, ModelVersion, boolean)
that usesfalse
as thedeprecated
value.SubsystemRegistration
registerSubsystem(String name, ModelVersion version, boolean deprecated)
Register a new subsystem type.
-
-
-
Method Detail
-
registerSubsystem
SubsystemRegistration registerSubsystem(String name, ModelVersion version)
Convenience variant ofregisterSubsystem(String, ModelVersion, boolean)
that usesfalse
as thedeprecated
value.- Parameters:
name
- the name of the subsystemversion
- the version of the subsystem's management interface.- Returns:
- the
SubsystemRegistration
- Throws:
IllegalStateException
- if the subsystem name has already been registered
-
registerSubsystem
SubsystemRegistration registerSubsystem(String name, ModelVersion version, boolean deprecated)
Register a new subsystem type. The returned registration object should be used to configure XML parsers, operation handlers, and other subsystem-specific constructs for the new subsystem. If the subsystem registration is deemed invalid by the time the extension registration is complete, the subsystem registration will be ignored, and an error message will be logged.The new subsystem registration must register a handler and description for the
add
operation at its root address. The new subsystem registration must register aremove
operation at its root address.- Parameters:
name
- the name of the subsystemversion
- the version of the subsystem's management interface.deprecated
- iftrue
, mark this extension as deprecated- Returns:
- the
SubsystemRegistration
- Throws:
IllegalStateException
- if the subsystem name has already been registered
-
registerExpressionResolverExtension
default void registerExpressionResolverExtension(Supplier<ExpressionResolverExtension> supplier, Pattern expressionPattern, boolean requiresRuntimeResolution)
Registers that the extension may provide anExpressionResolverExtension
if one of its subsystems is appropriately configured. Calling this informs the management kernel that the resolver extension may be installed at some point and provides a supplier via which the resolver extension can be obtained. It also instructs the management kernel as to how to handle expression strings that might be of interest to the resolver extension if it were configured.Once this is invoked, the kernel expression resolver will begin calling the given
supplier
whenever it needs to resolve an expression string. If it returns a non-null value, the returnedExpressionResolverExtension
will be invoked to ensure it isinitialized
and to try andresolve the expression string.
If the given
supplier
returns [@code null}, that indicates the resolver extension has not yet been configured (and perhaps never will be.) The management kernel resolver will however continue to account for the resolver extension in the following ways:- It will check if any unresolved expression string matches the provided
expressionPatterns
. If not no further action is taken with respect to this resolver extension. - If it does match, and the expression resolution is occurring in
OperationContext.Stage.MODEL
, an exception will be thrown. The effect of this is calling this method disablesStage.MODEL
resolution of expressions that match the pattern. Resolving in Stage.MODEL is generally an anti-pattern though, although there are cases where it is attempted, particular withsystem-property
resources. - If it does match and the expression resolution is occurring after
OperationContext.Stage.MODEL
, the behavior depends on the providedrequiresRuntimeResolution
parameter. Iftrue
, an exception will be thrown, as the required resolution could not be performed. Iffalse
, no resolution will be attempted and the overall resolution will continue on. Setting this to false allows expressions that match the pattern but which aren't definitely meant for handling by the resolver extension to still be processed.
Note that if multiple callers register resolver extensions, the management kernel will apply the above logic to each in turn until one provides a resolved string or all have been given an opportunity to try. Only when all have been given an opportunity to try will any exception resulting from one of the attempts be propagated. If none provide a resolved string, but none throw an exception, the expression resolution will move on to trying the core management kernel expression resolution mechanism.
- Parameters:
supplier
- function to be checked during expression resolution to determine if the resolver extension is available. Supplier should returnnull
if the resolver extension isn't actually configured by a subsystem. The supplier itself cannot benull
.expressionPattern
- if thesupplier
returnsnull
, the pattern the kernel expression resolver should use to determine if a given expression string would be of interest to the resolver extension if it was available.requiresRuntimeResolution
-true
if the kernel resolver should throw an expression resolution exception if thesupplier
returnsnull
, the expression string to resolves matches the givenexpressionPattern
, and the resolution is occuring outside ofOperationContext.Stage.MODEL
.
- It will check if any unresolved expression string matches the provided
-
getType
ExtensionContext.ContextType getType()
Gets the type of this context.- Returns:
- the context type. Will not be
null
-
getProcessType
ProcessType getProcessType()
Gets the type of the current process.- Returns:
- the current process type. Will not be
null
-
getRunningMode
RunningMode getRunningMode()
Gets the current running mode of the process.- Returns:
- the current running mode. Will not be
null
-
isRuntimeOnlyRegistrationValid
boolean isRuntimeOnlyRegistrationValid()
Gets whether it is valid for the extension to register resources, attributes or operations that do not involve the persistent configuration, but rather only involve runtime services. Extensions should use this method before registering such "runtime only" resources, attributes or operations. This method is intended to avoid registering resources, attributes or operations on process types that can not install runtime services.- Returns:
- whether it is valid to register runtime resources, attributes, or operations.
-
getPathManager
PathManager getPathManager()
- Returns:
- the path manager. Will not return
null
- Throws:
IllegalStateException
- if the process is not aserver
-
-