Search in sources :

Example 1 with RuntimeCapability

use of org.jboss.as.controller.capability.RuntimeCapability in project wildfly by wildfly.

the class CachedConnectionManagerRemove method execute.

@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
    // This is an odd case where we do not actually do a remove; we just reset state to
    // what it would be following parsing if the xml element does not exist.
    // See discussion on PR with fix for WFLY-2640 .
    ModelNode model = context.readResourceForUpdate(PathAddress.EMPTY_ADDRESS).getModel();
    for (JcaCachedConnectionManagerDefinition.CcmParameters param : JcaCachedConnectionManagerDefinition.CcmParameters.values()) {
        AttributeDefinition ad = param.getAttribute();
        if (param == INSTALL || param == DEBUG || param == ERROR || param == IGNORE_UNKNOWN_CONNECTIONS) {
            model.get(ad.getName()).clear();
        } else {
            // Someone added a new param since wFLY-2640/WFLY-8141 and did not account for it above
            throw new IllegalStateException();
        }
    }
    // At the time of WFLY-2640 there were no capabilities associated with this resource,
    // but if anyone adds one, part of the task is to deal with deregistration.
    // So here's an assert to ensure that is considered
    Set<RuntimeCapability> capabilitySet = context.getResourceRegistration().getCapabilities();
    assert capabilitySet.isEmpty();
    if (context.isDefaultRequiresRuntime()) {
        context.addStep(new OperationStepHandler() {

            @Override
            public void execute(OperationContext operationContext, ModelNode modelNode) throws OperationFailedException {
                context.reloadRequired();
                context.completeStep(new OperationContext.RollbackHandler() {

                    @Override
                    public void handleRollback(OperationContext operationContext, ModelNode modelNode) {
                        context.revertReloadRequired();
                    }
                });
            }
        }, OperationContext.Stage.RUNTIME);
    }
}
Also used : OperationContext(org.jboss.as.controller.OperationContext) RuntimeCapability(org.jboss.as.controller.capability.RuntimeCapability) OperationStepHandler(org.jboss.as.controller.OperationStepHandler) OperationFailedException(org.jboss.as.controller.OperationFailedException) AttributeDefinition(org.jboss.as.controller.AttributeDefinition) ModelNode(org.jboss.dmr.ModelNode)

Example 2 with RuntimeCapability

use of org.jboss.as.controller.capability.RuntimeCapability in project wildfly by wildfly.

the class HandlerAdd method performRuntime.

@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
    final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR));
    final String name = address.getLastElement().getValue();
    final HandlerService service = new HandlerService(handler.createHandler(context, model), name);
    final ServiceTarget target = context.getServiceTarget();
    ServiceBuilder<HttpHandler> builder = target.addService(UndertowService.HANDLER.append(name), service).setInitialMode(ServiceController.Mode.ON_DEMAND);
    final RuntimeCapability newCapability = Handler.CAPABILITY.fromBaseCapability(name);
    if (context.hasOptionalCapability(Handler.REQUEST_CONTROLLER, newCapability.getName(), null)) {
        builder.addDependency(RequestController.SERVICE_NAME, RequestController.class, service.getRequestControllerInjectedValue());
    }
    builder.install();
}
Also used : HttpHandler(io.undertow.server.HttpHandler) RuntimeCapability(org.jboss.as.controller.capability.RuntimeCapability) PathAddress(org.jboss.as.controller.PathAddress) ServiceTarget(org.jboss.msc.service.ServiceTarget)

Aggregations

RuntimeCapability (org.jboss.as.controller.capability.RuntimeCapability)2 HttpHandler (io.undertow.server.HttpHandler)1 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)1 OperationContext (org.jboss.as.controller.OperationContext)1 OperationFailedException (org.jboss.as.controller.OperationFailedException)1 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)1 PathAddress (org.jboss.as.controller.PathAddress)1 ModelNode (org.jboss.dmr.ModelNode)1 ServiceTarget (org.jboss.msc.service.ServiceTarget)1