Search in sources :

Example 66 with PathAddress

use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.

the class AccessLogAdd method performRuntime.

@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
    final PathAddress address = context.getCurrentAddress();
    final PathAddress hostAddress = address.getParent();
    final PathAddress serverAddress = hostAddress.getParent();
    final String worker = AccessLogDefinition.WORKER.resolveModelAttribute(context, model).asString();
    final String pattern = AccessLogDefinition.PATTERN.resolveModelAttribute(context, model).asString();
    final String directory = AccessLogDefinition.DIRECTORY.resolveModelAttribute(context, model).asString();
    final String filePrefix = AccessLogDefinition.PREFIX.resolveModelAttribute(context, model).asString();
    final String fileSuffix = AccessLogDefinition.SUFFIX.resolveModelAttribute(context, model).asString();
    final boolean useServerLog = AccessLogDefinition.USE_SERVER_LOG.resolveModelAttribute(context, model).asBoolean();
    final boolean rotate = AccessLogDefinition.ROTATE.resolveModelAttribute(context, model).asBoolean();
    final boolean extended = AccessLogDefinition.EXTENDED.resolveModelAttribute(context, model).asBoolean();
    final ModelNode relativeToNode = AccessLogDefinition.RELATIVE_TO.resolveModelAttribute(context, model);
    final String relativeTo = relativeToNode.isDefined() ? relativeToNode.asString() : null;
    Predicate predicate = null;
    ModelNode predicateNode = AccessLogDefinition.PREDICATE.resolveModelAttribute(context, model);
    if (predicateNode.isDefined()) {
        predicate = Predicates.parse(predicateNode.asString(), getClass().getClassLoader());
    }
    final AccessLogService service;
    if (useServerLog) {
        service = new AccessLogService(pattern, extended, predicate);
    } else {
        service = new AccessLogService(pattern, directory, relativeTo, filePrefix, fileSuffix, rotate, extended, predicate);
    }
    final String serverName = serverAddress.getLastElement().getValue();
    final String hostName = hostAddress.getLastElement().getValue();
    final ServiceName serviceName = UndertowService.accessLogServiceName(serverName, hostName);
    final ServiceBuilder<AccessLogService> builder = context.getServiceTarget().addService(serviceName, service).addDependency(IOServices.WORKER.append(worker), XnioWorker.class, service.getWorker()).addDependency(PathManagerService.SERVICE_NAME, PathManager.class, service.getPathManager()).addDependency(UndertowService.virtualHostName(serverName, hostName), Host.class, service.getHost());
    builder.setInitialMode(ServiceController.Mode.ACTIVE).install();
}
Also used : PathManager(org.jboss.as.controller.services.path.PathManager) ServiceName(org.jboss.msc.service.ServiceName) PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode) Predicate(io.undertow.predicate.Predicate)

Example 67 with PathAddress

use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.

the class AccessLogRemove method performRuntime.

@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) {
    final PathAddress hostAddress = context.getCurrentAddress().getParent();
    final PathAddress serverAddress = hostAddress.getParent();
    final String hostName = hostAddress.getLastElement().getValue();
    final String serverName = serverAddress.getLastElement().getValue();
    final ServiceName serviceName = UndertowService.accessLogServiceName(serverName, hostName);
    context.removeService(serviceName);
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) PathAddress(org.jboss.as.controller.PathAddress)

Example 68 with PathAddress

use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.

the class BufferCacheAdd 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();
    int bufferSize = BufferCacheDefinition.BUFFER_SIZE.resolveModelAttribute(context, model).asInt();
    int buffersPerRegions = BufferCacheDefinition.BUFFERS_PER_REGION.resolveModelAttribute(context, model).asInt();
    int maxRegions = BufferCacheDefinition.MAX_REGIONS.resolveModelAttribute(context, model).asInt();
    final BufferCacheService service = new BufferCacheService(bufferSize, buffersPerRegions, maxRegions);
    final ServiceTarget target = context.getServiceTarget();
    target.addService(BufferCacheService.SERVICE_NAME.append(name), service).setInitialMode(ServiceController.Mode.ON_DEMAND).install();
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) ServiceTarget(org.jboss.msc.service.ServiceTarget)

Example 69 with PathAddress

use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.

the class FilterDefinitions method registerChildren.

@Override
public void registerChildren(ManagementResourceRegistration resourceRegistration) {
    super.registerChildren(resourceRegistration);
    PathElement targetPe = RequestLimitHandler.INSTANCE.getPathElement();
    AliasEntry aliasEntry = new AliasEntry(resourceRegistration.getSubModel(PathAddress.pathAddress(targetPe))) {

        @Override
        public PathAddress convertToTargetAddress(PathAddress aliasAddress, AliasContext aliasContext) {
            PathElement pe = aliasAddress.getLastElement();
            return aliasAddress.getParent().append(PathElement.pathElement(targetPe.getKey(), pe.getValue()));
        }
    };
    resourceRegistration.registerAlias(PathElement.pathElement("connection-limit"), aliasEntry);
}
Also used : PathElement(org.jboss.as.controller.PathElement) PathAddress(org.jboss.as.controller.PathAddress) AliasEntry(org.jboss.as.controller.registry.AliasEntry)

Example 70 with PathAddress

use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.

the class EndpointConfigAdd method performRuntime.

@Override
protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException {
    //modify the runtime if we're booting, otherwise set reload required and leave the runtime unchanged
    if (context.isBooting()) {
        final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
        final String name = address.getLastElement().getValue();
        //get the server config object from the ServerConfigService (service installed but not started yet, but the object is fine for our needs here)
        final ServerConfig serverConfig = ASHelper.getMSCService(WSServices.CONFIG_SERVICE, ServerConfig.class, context);
        if (serverConfig == null) {
            throw WSLogger.ROOT_LOGGER.serviceNotAvailable(WSServices.CONFIG_SERVICE.getCanonicalName());
        }
        final ServiceName serviceName = getEndpointConfigServiceName(name);
        final ConfigService endpointConfigService = new ConfigService(serverConfig, name, false);
        final ServiceTarget target = context.getServiceTarget();
        final ServiceBuilder<?> serviceBuilder = target.addService(serviceName, endpointConfigService);
        for (ServiceName sn : PackageUtils.getServiceNameDependencies(context, serviceName, address, Constants.PROPERTY)) {
            //get a new injector instance each time
            serviceBuilder.addDependency(sn, PropertyService.class, endpointConfigService.getPropertiesInjector());
        }
        for (ServiceName sn : PackageUtils.getServiceNameDependencies(context, serviceName, address, Constants.PRE_HANDLER_CHAIN)) {
            //get a new injector instance each time
            serviceBuilder.addDependency(sn, UnifiedHandlerChainMetaData.class, endpointConfigService.getPreHandlerChainsInjector());
        }
        for (ServiceName sn : PackageUtils.getServiceNameDependencies(context, serviceName, address, Constants.POST_HANDLER_CHAIN)) {
            //get a new injector instance each time
            serviceBuilder.addDependency(sn, UnifiedHandlerChainMetaData.class, endpointConfigService.getPostHandlerChainsInjector());
        }
        serviceBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();
    } else {
        context.reloadRequired();
    }
}
Also used : ServerConfig(org.jboss.wsf.spi.management.ServerConfig) ConfigService(org.jboss.as.webservices.service.ConfigService) ServiceName(org.jboss.msc.service.ServiceName) PackageUtils.getEndpointConfigServiceName(org.jboss.as.webservices.dmr.PackageUtils.getEndpointConfigServiceName) PathAddress(org.jboss.as.controller.PathAddress) ServiceTarget(org.jboss.msc.service.ServiceTarget)

Aggregations

PathAddress (org.jboss.as.controller.PathAddress)473 ModelNode (org.jboss.dmr.ModelNode)345 PathElement (org.jboss.as.controller.PathElement)54 Resource (org.jboss.as.controller.registry.Resource)53 ServiceName (org.jboss.msc.service.ServiceName)53 OperationFailedException (org.jboss.as.controller.OperationFailedException)48 Test (org.junit.Test)36 ServiceTarget (org.jboss.msc.service.ServiceTarget)32 ParseUtils.unexpectedElement (org.jboss.as.controller.parsing.ParseUtils.unexpectedElement)29 OperationContext (org.jboss.as.controller.OperationContext)28 ResourceTransformationDescriptionBuilder (org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder)25 KernelServices (org.jboss.as.subsystem.test.KernelServices)24 ParseUtils.requireNoNamespaceAttribute (org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute)23 ParseUtils.unexpectedAttribute (org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute)23 Map (java.util.Map)22 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)19 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)19 ArrayList (java.util.ArrayList)18 TransformationContext (org.jboss.as.controller.transform.TransformationContext)17 FailedOperationTransformationConfig (org.jboss.as.model.test.FailedOperationTransformationConfig)15