Search in sources :

Example 1 with HandlerService

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

the class HandlerAdd 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 PathElement confElem = address.getElement(address.size() - 3);
        final String configType = confElem.getKey();
        final String configName = confElem.getValue();
        final String handlerChainType = address.getElement(address.size() - 2).getKey();
        final String handlerChainId = address.getElement(address.size() - 2).getValue();
        final String handlerName = address.getElement(address.size() - 1).getValue();
        final String handlerClass = operation.require(CLASS).asString();
        final HandlerService service = new HandlerService(handlerName, handlerClass, counter.incrementAndGet());
        final ServiceTarget target = context.getServiceTarget();
        final ServiceName configServiceName = getConfigServiceName(configType, configName);
        final ServiceRegistry registry = context.getServiceRegistry(false);
        if (registry.getService(configServiceName) == null) {
            throw WSLogger.ROOT_LOGGER.missingConfig(configName);
        }
        final ServiceName handlerChainServiceName = getHandlerChainServiceName(configServiceName, handlerChainType, handlerChainId);
        if (registry.getService(handlerChainServiceName) == null) {
            throw WSLogger.ROOT_LOGGER.missingHandlerChain(configName, handlerChainType, handlerChainId);
        }
        final ServiceName handlerServiceName = getHandlerServiceName(handlerChainServiceName, handlerName);
        final ServiceBuilder<?> handlerServiceBuilder = target.addService(handlerServiceName, service);
        ServiceController<?> controller = handlerServiceBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();
    } else {
        context.reloadRequired();
    }
}
Also used : PathElement(org.jboss.as.controller.PathElement) HandlerService(org.jboss.as.webservices.service.HandlerService) PackageUtils.getHandlerServiceName(org.jboss.as.webservices.dmr.PackageUtils.getHandlerServiceName) PackageUtils.getConfigServiceName(org.jboss.as.webservices.dmr.PackageUtils.getConfigServiceName) PackageUtils.getHandlerChainServiceName(org.jboss.as.webservices.dmr.PackageUtils.getHandlerChainServiceName) ServiceName(org.jboss.msc.service.ServiceName) PathAddress(org.jboss.as.controller.PathAddress) ServiceTarget(org.jboss.msc.service.ServiceTarget) ServiceRegistry(org.jboss.msc.service.ServiceRegistry)

Aggregations

PathAddress (org.jboss.as.controller.PathAddress)1 PathElement (org.jboss.as.controller.PathElement)1 PackageUtils.getConfigServiceName (org.jboss.as.webservices.dmr.PackageUtils.getConfigServiceName)1 PackageUtils.getHandlerChainServiceName (org.jboss.as.webservices.dmr.PackageUtils.getHandlerChainServiceName)1 PackageUtils.getHandlerServiceName (org.jboss.as.webservices.dmr.PackageUtils.getHandlerServiceName)1 HandlerService (org.jboss.as.webservices.service.HandlerService)1 ServiceName (org.jboss.msc.service.ServiceName)1 ServiceRegistry (org.jboss.msc.service.ServiceRegistry)1 ServiceTarget (org.jboss.msc.service.ServiceTarget)1