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

The following examples show how to use org.jboss.as.controller.OperationContext#getCurrentStage() . 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: Transformers.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Obtains a set of {@code TransformationInputs} from the given operation context. If the
 * context's {@link OperationContext#getCurrentStage() current stage} is
 * {@link org.jboss.as.controller.OperationContext.Stage#DOMAIN} any inputs cached with
 * the context as an attachment will be used, and if none are cached, then the created inputs
 * will be cached.
 *
 * @param context the operation context. Cannot be {@code null}
 * @return the inputs. Will not be {@code null}
 */
public static TransformationInputs getOrCreate(OperationContext context) {
    TransformationInputs result;
    if (context.getCurrentStage() == OperationContext.Stage.DOMAIN) {
        // Stage.DOMAIN means the model is not going to change, so we can safely cache.
        // We want to cache because reading the entire model is expensive, so we don't
        // want to do it for every process we need to interact with in a domain roll out.
        result = context.getAttachment(KEY);
        if (result == null) {
            result = new TransformationInputs(context);
            context.attach(KEY, result);
        }
    } else {
        result = new TransformationInputs(context);
    }
    return result;
}
 
Example 2
Source File: IsCallerInRoleOperation.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
    String roleName = RoleMappingResourceDefinition.getRoleName(operation);

    if (context.getCurrentStage() == Stage.MODEL) {
        context.addStep(this, Stage.RUNTIME);
    } else {
        ModelNode result = context.getResult();
        Set<String> operationHeaderRoles = RunAsRoleMapper.getOperationHeaderRoles(operation);
        result.set(isCallerInRole(roleName, context.getCaller(), context.getCallEnvironment(), operationHeaderRoles));
    }
}
 
Example 3
Source File: DomainModelControllerService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public HostControllerInfo getHostControllerInfo(OperationContext context) throws OperationFailedException {
    if (context.isBooting() && context.getCurrentStage() == OperationContext.Stage.MODEL) {
        throw ControllerLogger.ROOT_LOGGER.onlyAccessHostControllerInfoInRuntimeStage();
    }
    return new HostControllerInfo() {
        public boolean isMasterHc() {
            return hostControllerInfo.isMasterDomainController();
        }
    };
}
 
Example 4
Source File: LocalPatchOperationStepHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException {
    if (context.getCurrentStage() == OperationContext.Stage.MODEL) {
        context.addStep(this::executeRuntime, OperationContext.Stage.RUNTIME);
    } else {
        executeRuntime(context, operation);
    }
}
 
Example 5
Source File: PatchStreamResourceOperationStepHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
    if (context.getCurrentStage() == OperationContext.Stage.MODEL) {
        context.addStep(this::executeRuntime, OperationContext.Stage.RUNTIME);
    } else {
        executeRuntime(context, operation);
    }
}