Java Code Examples for org.jboss.as.controller.OperationContext#restartRequired()

The following examples show how to use org.jboss.as.controller.OperationContext#restartRequired() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractDeploymentChainStep.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public final void execute(final OperationContext context, final ModelNode operation) {
    if (context.isBooting()) {
        execute(TARGET);
    } else {
        // WFCORE-1781 We should not be called post-boot as the DUP chain can only be modified in boot
        // Check and see if the OperationDefinition for this op declares reload/restart required and if so
        // trigger that; otherwise fail.
        ImmutableManagementResourceRegistration mrr = context.getResourceRegistration();
        OperationEntry oe = mrr.getOperationEntry(PathAddress.EMPTY_ADDRESS, operation.get(ModelDescriptionConstants.OP).asString());
        Set<OperationEntry.Flag> flags = oe == null ? Collections.emptySet() : oe.getOperationDefinition().getFlags();
        if (flags.contains(OperationEntry.Flag.RESTART_JVM)) {
            context.restartRequired();
            context.completeStep((ctx, op) -> ctx.revertRestartRequired());
        } else if (flags.contains(OperationEntry.Flag.RESTART_ALL_SERVICES)) {
            context.reloadRequired();
            context.completeStep(OperationContext.RollbackHandler.REVERT_RELOAD_REQUIRED_ROLLBACK_HANDLER);
        } else {
            // Coding error we cannot recover from
            throw new IllegalStateException();
        }
    }
}
 
Example 2
Source File: HandlerOperations.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public final void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model, final LogContextConfiguration logContextConfiguration) throws OperationFailedException {
    final String name = context.getCurrentAddressValue();
    final HandlerConfiguration configuration = logContextConfiguration.getHandlerConfiguration(name);
    if (configuration == null) {
        throw createOperationFailure(LoggingLogger.ROOT_LOGGER.handlerConfigurationNotFound(name));
    }
    final AttributeDefinition[] attributes = getAttributes();
    if (attributes != null) {
        boolean restartRequired = false;
        boolean reloadRequired = false;
        for (AttributeDefinition attribute : attributes) {
            // Only update if the attribute is on the operation
            if (operation.has(attribute.getName())) {
                handleProperty(attribute, context, model, logContextConfiguration, configuration);
                restartRequired = restartRequired || Logging.requiresRestart(attribute.getFlags());
                reloadRequired = reloadRequired || Logging.requiresReload(attribute.getFlags());
            }
        }
        if (restartRequired) {
            context.restartRequired();
        } else if (reloadRequired) {
            context.reloadRequired();
        }
    }

    // It's important that properties are written in the correct order, reorder the properties if
    // needed before the commit.
    addOrderPropertiesStep(context, propertySorter, configuration);
}
 
Example 3
Source File: ForceRestartRequiredHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
    context.restartRequired();
}