Package org.jboss.as.controller
Class AbstractControllerService
- java.lang.Object
-
- org.jboss.as.controller.AbstractControllerService
-
- All Implemented Interfaces:
org.jboss.msc.Service
,org.jboss.msc.service.Service<ModelController>
,org.jboss.msc.value.Value<ModelController>
public abstract class AbstractControllerService extends Object implements org.jboss.msc.service.Service<ModelController>
A base class for controller services.- Author:
- David M. Lloyd, Richard Opalka
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
AbstractControllerService.ControllerInstabilityListener
Listener for notifications that theModelController
is unstable and a process restart is necessary.protected static class
AbstractControllerService.ModelControllerServiceInitializationParams
Parameters for initializingModelControllerServiceInitialization
instancesprotected static interface
AbstractControllerService.PartialModelIndicator
Tracks whether the controller is working with a complete model or just a partial one.
-
Field Summary
Fields Modifier and Type Field Description protected DelegatingConfigurableAuthorizer
authorizer
static String
BOOT_STACK_SIZE_PROPERTY
Name of the system property to set to control the stack size for the thread used to process boot operations.protected static RuntimeCapability<Void>
CLIENT_FACTORY_CAPABILITY
Capability in-vm users of the controller use to create clientsstatic int
DEFAULT_BOOT_STACK_SIZE
The default stack size for the thread used to process boot operations.static RuntimeCapability<Void>
EXECUTOR_CAPABILITY
Capability users of the controller use to perform asynchronous management tasks.protected static RuntimeCapability<Void>
NOTIFICATION_REGISTRY_CAPABILITY
Capability in-vm users of the controller use to register notification handlersstatic RuntimeCapability<Void>
PATH_MANAGER_CAPABILITY
Capability users of the controller use to coordinate changes to paths.protected static RuntimeCapability<Void>
PROCESS_STATE_NOTIFIER_CAPABILITY
Capability users of the controller use to read process state and get notification of state changes.protected ProcessType
processType
protected ManagementSecurityIdentitySupplier
securityIdentitySupplier
-
Constructor Summary
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
acquireReadLock(int operationId)
protected boolean
boot(List<org.jboss.dmr.ModelNode> bootOperations, boolean rollbackOnRuntimeFailure)
Boot with the given operations, performing full model and capability registry validation.protected boolean
boot(List<org.jboss.dmr.ModelNode> bootOperations, boolean rollbackOnRuntimeFailure, boolean skipModelValidation)
Boot with the given operations, optionally disabling model and capability registry validation.protected boolean
boot(List<org.jboss.dmr.ModelNode> bootOperations, boolean rollbackOnRuntimeFailure, boolean skipModelValidation, MutableRootResourceRegistrationProvider parallelBootRootResourceRegistrationProvider)
Boot, optionally disabling model and capability registry validation, using the given provider for the rootManagementResourceRegistration
.protected void
boot(BootContext context)
Boot the controller.protected void
bootThreadDone()
protected void
clearBootingReadOnlyFlag()
protected OperationStepHandler
createExtraValidationStepHandler()
protected void
executeAdditionalCliBootScript()
protected org.jboss.dmr.ModelNode
executeReadOnlyOperation(org.jboss.dmr.ModelNode operation, OperationMessageHandler handler, ModelController.OperationTransactionControl control, OperationStepHandler prepareStep, int lockPermit)
protected org.jboss.dmr.ModelNode
executeReadOnlyOperation(org.jboss.dmr.ModelNode operation, ModelController.OperationTransactionControl control, OperationStepHandler prepareStep)
protected org.jboss.dmr.ModelNode
executeReadOnlyOperation(org.jboss.dmr.ModelNode operation, Resource model, ModelController.OperationTransactionControl control, OperationStepHandler prepareStep)
protected void
finishBoot()
protected void
finishBoot(boolean readOnly)
protected ManagedAuditLogger
getAuditLogger()
protected BootErrorCollector
getBootErrorCollector()
protected ExecutorService
getExecutorService()
protected ModelControllerClientFactory
getModelControllerClientFactory()
protected AbstractControllerService.ModelControllerServiceInitializationParams
getModelControllerServiceInitializationParams()
Override to return aAbstractControllerService.ModelControllerServiceInitializationParams
.protected MutableRootResourceRegistrationProvider
getMutableRootResourceRegistrationProvider()
protected NotificationSupport
getNotificationSupport()
protected AbstractControllerService.PartialModelIndicator
getPartialModelIndicator()
ModelController
getValue()
protected abstract void
initModel(ManagementModel managementModel, Resource modelControllerResource)
protected OperationResponse
internalExecute(Operation operation, OperationMessageHandler handler, ModelController.OperationTransactionControl control, OperationStepHandler prepareStep)
protected OperationResponse
internalExecute(Operation operation, OperationMessageHandler handler, ModelController.OperationTransactionControl control, OperationStepHandler prepareStep, boolean attemptLock)
protected OperationResponse
internalExecute(Operation operation, OperationMessageHandler handler, ModelController.OperationTransactionControl control, OperationStepHandler prepareStep, boolean attemptLock, boolean partialModel)
protected boolean
isExposingClientServicesAllowed()
Gets whether this controller service should install aModelControllerClientFactory
and aNotificationHandlerRegistry
as a service.protected void
postBoot()
protected org.jboss.dmr.ModelNode
registerModelControllerServiceInitializationBootStep(BootContext context)
Used to add the operation used to initialise the ModelControllerServiceInitialization instances.protected void
releaseReadLock(int operationId)
protected void
setConfigurationPersister(ConfigurationPersister persister)
void
start(org.jboss.msc.service.StartContext context)
void
stop(org.jboss.msc.service.StopContext context)
protected void
stopAsynchronous(org.jboss.msc.service.StopContext context)
Hook for subclasses to perform work during the asynchronous task started bystop(org.jboss.msc.service.StopContext)
.
-
-
-
Field Detail
-
BOOT_STACK_SIZE_PROPERTY
public static final String BOOT_STACK_SIZE_PROPERTY
Name of the system property to set to control the stack size for the thread used to process boot operations. The boot sequence can have a very deep stack, so if needed setting this property can be used to create a larger memory area for storing data on the stack.- See Also:
DEFAULT_BOOT_STACK_SIZE
, Constant Field Values
-
DEFAULT_BOOT_STACK_SIZE
public static final int DEFAULT_BOOT_STACK_SIZE
The default stack size for the thread used to process boot operations.- See Also:
BOOT_STACK_SIZE_PROPERTY
, Constant Field Values
-
CLIENT_FACTORY_CAPABILITY
protected static final RuntimeCapability<Void> CLIENT_FACTORY_CAPABILITY
Capability in-vm users of the controller use to create clients
-
NOTIFICATION_REGISTRY_CAPABILITY
protected static final RuntimeCapability<Void> NOTIFICATION_REGISTRY_CAPABILITY
Capability in-vm users of the controller use to register notification handlers
-
PATH_MANAGER_CAPABILITY
public static final RuntimeCapability<Void> PATH_MANAGER_CAPABILITY
Capability users of the controller use to coordinate changes to paths. This capability isn't necessarily directly related to this class but we declare it here as it's as good a place as any at this time.
-
EXECUTOR_CAPABILITY
public static final RuntimeCapability<Void> EXECUTOR_CAPABILITY
Capability users of the controller use to perform asynchronous management tasks. This capability isn't necessarily directly related to this class but we declare it here as it's as good a place as any at this time.
-
PROCESS_STATE_NOTIFIER_CAPABILITY
protected static final RuntimeCapability<Void> PROCESS_STATE_NOTIFIER_CAPABILITY
Capability users of the controller use to read process state and get notification of state changes. This capability isn't necessarily directly related to this class but we declare it here as it's as good a place as any at this time.
-
processType
protected final ProcessType processType
-
authorizer
protected final DelegatingConfigurableAuthorizer authorizer
-
securityIdentitySupplier
protected final ManagementSecurityIdentitySupplier securityIdentitySupplier
-
-
Constructor Detail
-
AbstractControllerService
@Deprecated protected AbstractControllerService(ProcessType processType, RunningModeControl runningModeControl, ConfigurationPersister configurationPersister, ControlledProcessState processState, ResourceDefinition rootResourceDefinition, OperationStepHandler prepareStep, ExpressionResolver expressionResolver, ManagedAuditLogger auditLogger, DelegatingConfigurableAuthorizer authorizer, ManagementSecurityIdentitySupplier securityIdentitySupplier, CapabilityRegistry capabilityRegistry)
Deprecated.Construct a new instance.- Parameters:
processType
- the type of process being controlledrunningModeControl
- the controller of the process' running modeconfigurationPersister
- the configuration persisterprocessState
- the controlled process staterootResourceDefinition
- the root resource definitionprepareStep
- the prepare step to prepend to operation executionexpressionResolver
- the expression resolverauditLogger
- the audit loggerauthorizer
- handles authorizationcapabilityRegistry
- the capability registry
-
AbstractControllerService
protected AbstractControllerService(Supplier<ExecutorService> executorService, Supplier<AbstractControllerService.ControllerInstabilityListener> instabilityListener, ProcessType processType, RunningModeControl runningModeControl, ConfigurationPersister configurationPersister, ControlledProcessState processState, ResourceDefinition rootResourceDefinition, OperationStepHandler prepareStep, ExpressionResolver expressionResolver, ManagedAuditLogger auditLogger, DelegatingConfigurableAuthorizer authorizer, ManagementSecurityIdentitySupplier securityIdentitySupplier, CapabilityRegistry capabilityRegistry, ConfigurationExtension configExtension)
Construct a new instance.- Parameters:
processType
- the type of process being controlledrunningModeControl
- the controller of the process' running modeconfigurationPersister
- the configuration persisterprocessState
- the controlled process staterootResourceDefinition
- the root resource definitionprepareStep
- the prepare step to prepend to operation executionexpressionResolver
- the expression resolverauditLogger
- the audit loggerauthorizer
- handles authorizationcapabilityRegistry
- the capability registry
-
-
Method Detail
-
start
public void start(org.jboss.msc.service.StartContext context) throws org.jboss.msc.service.StartException
- Specified by:
start
in interfaceorg.jboss.msc.Service
- Throws:
org.jboss.msc.service.StartException
-
isExposingClientServicesAllowed
protected boolean isExposingClientServicesAllowed()
Gets whether this controller service should install aModelControllerClientFactory
and aNotificationHandlerRegistry
as a service. Default istrue
; this method allows test infrastructure subclasses to turn this off.- Returns:
true
if a service should be installed
-
boot
protected void boot(BootContext context) throws ConfigurationPersistenceException
Boot the controller. Called during service start.- Parameters:
context
- the boot context- Throws:
ConfigurationPersistenceException
- if the configuration failed to be loaded
-
boot
protected boolean boot(List<org.jboss.dmr.ModelNode> bootOperations, boolean rollbackOnRuntimeFailure) throws ConfigurationPersistenceException
Boot with the given operations, performing full model and capability registry validation.- Parameters:
bootOperations
- the operations. Cannot benull
rollbackOnRuntimeFailure
-true
if the boot should fail if operations fail in the runtime stage- Returns:
true
if boot was successful- Throws:
ConfigurationPersistenceException
-
boot
protected boolean boot(List<org.jboss.dmr.ModelNode> bootOperations, boolean rollbackOnRuntimeFailure, boolean skipModelValidation) throws ConfigurationPersistenceException
Boot with the given operations, optionally disabling model and capability registry validation.- Parameters:
bootOperations
- the operations. Cannot benull
rollbackOnRuntimeFailure
-true
if the boot should fail if operations fail in the runtime stageskipModelValidation
-true
if model and capability validation should be skipped.- Returns:
true
if boot was successful- Throws:
ConfigurationPersistenceException
-
boot
protected boolean boot(List<org.jboss.dmr.ModelNode> bootOperations, boolean rollbackOnRuntimeFailure, boolean skipModelValidation, MutableRootResourceRegistrationProvider parallelBootRootResourceRegistrationProvider) throws ConfigurationPersistenceException
Boot, optionally disabling model and capability registry validation, using the given provider for the rootManagementResourceRegistration
.- Parameters:
bootOperations
- the operations. Cannot benull
rollbackOnRuntimeFailure
-true
if the boot should fail if operations fail in the runtime stageskipModelValidation
-true
if model and capability validation should be skipped.parallelBootRootResourceRegistrationProvider
- provider of the root resource registration- Returns:
true
if boot was successful- Throws:
ConfigurationPersistenceException
-
internalExecute
protected OperationResponse internalExecute(Operation operation, OperationMessageHandler handler, ModelController.OperationTransactionControl control, OperationStepHandler prepareStep)
-
internalExecute
protected OperationResponse internalExecute(Operation operation, OperationMessageHandler handler, ModelController.OperationTransactionControl control, OperationStepHandler prepareStep, boolean attemptLock)
-
internalExecute
protected OperationResponse internalExecute(Operation operation, OperationMessageHandler handler, ModelController.OperationTransactionControl control, OperationStepHandler prepareStep, boolean attemptLock, boolean partialModel)
-
executeReadOnlyOperation
protected final org.jboss.dmr.ModelNode executeReadOnlyOperation(org.jboss.dmr.ModelNode operation, OperationMessageHandler handler, ModelController.OperationTransactionControl control, OperationStepHandler prepareStep, int lockPermit)
-
executeReadOnlyOperation
protected final org.jboss.dmr.ModelNode executeReadOnlyOperation(org.jboss.dmr.ModelNode operation, ModelController.OperationTransactionControl control, OperationStepHandler prepareStep)
-
executeReadOnlyOperation
protected final org.jboss.dmr.ModelNode executeReadOnlyOperation(org.jboss.dmr.ModelNode operation, Resource model, ModelController.OperationTransactionControl control, OperationStepHandler prepareStep)
-
finishBoot
protected void finishBoot() throws ConfigurationPersistenceException
-
finishBoot
protected void finishBoot(boolean readOnly) throws ConfigurationPersistenceException
-
clearBootingReadOnlyFlag
protected void clearBootingReadOnlyFlag()
-
bootThreadDone
protected void bootThreadDone()
-
postBoot
protected void postBoot()
-
getNotificationSupport
protected NotificationSupport getNotificationSupport()
-
getMutableRootResourceRegistrationProvider
protected final MutableRootResourceRegistrationProvider getMutableRootResourceRegistrationProvider()
-
getPartialModelIndicator
protected AbstractControllerService.PartialModelIndicator getPartialModelIndicator()
-
stop
public void stop(org.jboss.msc.service.StopContext context)
- Specified by:
stop
in interfaceorg.jboss.msc.Service
-
stopAsynchronous
protected void stopAsynchronous(org.jboss.msc.service.StopContext context)
Hook for subclasses to perform work during the asynchronous task started bystop(org.jboss.msc.service.StopContext)
. This base method does nothing.Subclasses must not invoke
LifecycleContext.complete()
- Parameters:
context
- the stop context
-
getValue
public ModelController getValue() throws IllegalStateException, IllegalArgumentException
- Specified by:
getValue
in interfaceorg.jboss.msc.value.Value<ModelController>
- Throws:
SecurityException
- if the caller does not haveModelController.ACCESS_PERMISSION
IllegalStateException
IllegalArgumentException
-
getExecutorService
protected ExecutorService getExecutorService()
-
setConfigurationPersister
protected void setConfigurationPersister(ConfigurationPersister persister)
-
initModel
protected abstract void initModel(ManagementModel managementModel, Resource modelControllerResource)
-
getAuditLogger
protected ManagedAuditLogger getAuditLogger()
-
getBootErrorCollector
protected BootErrorCollector getBootErrorCollector()
-
createExtraValidationStepHandler
protected OperationStepHandler createExtraValidationStepHandler()
-
acquireReadLock
protected void acquireReadLock(int operationId) throws InterruptedException
- Throws:
InterruptedException
-
releaseReadLock
protected void releaseReadLock(int operationId)
-
registerModelControllerServiceInitializationBootStep
protected final org.jboss.dmr.ModelNode registerModelControllerServiceInitializationBootStep(BootContext context)
Used to add the operation used to initialise the ModelControllerServiceInitialization instances. The operation will only be registered, and called if the implementing class overrides and returns a nonnull
value fromgetModelControllerServiceInitializationParams()
- Parameters:
context
- the boot context
-
getModelControllerServiceInitializationParams
protected AbstractControllerService.ModelControllerServiceInitializationParams getModelControllerServiceInitializationParams()
Override to return aAbstractControllerService.ModelControllerServiceInitializationParams
. Ifnull
is returned,registerModelControllerServiceInitializationBootStep(BootContext)
will not perform any initialization ofModelControllerServiceInitialization
instances.- Returns:
- the context to use for registering
ModelControllerServiceInitialization
instances
-
getModelControllerClientFactory
protected ModelControllerClientFactory getModelControllerClientFactory()
-
executeAdditionalCliBootScript
protected void executeAdditionalCliBootScript()
-
-