Search in sources :

Example 1 with ConfigService

use of org.jboss.as.webservices.service.ConfigService 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)

Example 2 with ConfigService

use of org.jboss.as.webservices.service.ConfigService in project wildfly by wildfly.

the class ClientConfigAdd 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 and 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 = getClientConfigServiceName(name);
        final ConfigService clientConfigService = new ConfigService(serverConfig, name, true);
        final ServiceTarget target = context.getServiceTarget();
        final ServiceBuilder<?> clientServiceBuilder = target.addService(serviceName, clientConfigService);
        for (ServiceName sn : PackageUtils.getServiceNameDependencies(context, serviceName, address, Constants.PROPERTY)) {
            //get a new injector instance each time
            clientServiceBuilder.addDependency(sn, PropertyService.class, clientConfigService.getPropertiesInjector());
        }
        for (ServiceName sn : PackageUtils.getServiceNameDependencies(context, serviceName, address, Constants.PRE_HANDLER_CHAIN)) {
            //get a new injector instance each time
            clientServiceBuilder.addDependency(sn, UnifiedHandlerChainMetaData.class, clientConfigService.getPreHandlerChainsInjector());
        }
        for (ServiceName sn : PackageUtils.getServiceNameDependencies(context, serviceName, address, Constants.POST_HANDLER_CHAIN)) {
            //get a new injector instance each time
            clientServiceBuilder.addDependency(sn, UnifiedHandlerChainMetaData.class, clientConfigService.getPostHandlerChainsInjector());
        }
        clientServiceBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();
    } else {
        context.reloadRequired();
    }
}
Also used : ServerConfig(org.jboss.wsf.spi.management.ServerConfig) ConfigService(org.jboss.as.webservices.service.ConfigService) PackageUtils.getClientConfigServiceName(org.jboss.as.webservices.dmr.PackageUtils.getClientConfigServiceName) ServiceName(org.jboss.msc.service.ServiceName) PathAddress(org.jboss.as.controller.PathAddress) ServiceTarget(org.jboss.msc.service.ServiceTarget)

Aggregations

PathAddress (org.jboss.as.controller.PathAddress)2 ConfigService (org.jboss.as.webservices.service.ConfigService)2 ServiceName (org.jboss.msc.service.ServiceName)2 ServiceTarget (org.jboss.msc.service.ServiceTarget)2 ServerConfig (org.jboss.wsf.spi.management.ServerConfig)2 PackageUtils.getClientConfigServiceName (org.jboss.as.webservices.dmr.PackageUtils.getClientConfigServiceName)1 PackageUtils.getEndpointConfigServiceName (org.jboss.as.webservices.dmr.PackageUtils.getEndpointConfigServiceName)1