Search in sources :

Example 71 with PathAddress

use of org.jboss.as.controller.PathAddress 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)

Example 72 with PathAddress

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

the class HandlerChainAdd 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 String protocolBindings = getAttributeValue(operation, PROTOCOL_BINDINGS);
        final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
        final PathElement confElem = address.getElement(address.size() - 2);
        final String configType = confElem.getKey();
        final String configName = confElem.getValue();
        final String handlerChainType = address.getElement(address.size() - 1).getKey();
        final String handlerChainId = address.getElement(address.size() - 1).getValue();
        final ServiceName configServiceName = getConfigServiceName(configType, configName);
        if (context.getServiceRegistry(false).getService(configServiceName) == null) {
            throw WSLogger.ROOT_LOGGER.missingConfig(configName);
        }
        final ServiceName handlerChainServiceName = getHandlerChainServiceName(configServiceName, handlerChainType, handlerChainId);
        final HandlerChainService service = new HandlerChainService(handlerChainType, handlerChainId, protocolBindings);
        final ServiceTarget target = context.getServiceTarget();
        final ServiceBuilder<?> handlerChainServiceBuilder = target.addService(handlerChainServiceName, service);
        for (ServiceName sn : PackageUtils.getServiceNameDependencies(context, handlerChainServiceName, address, HANDLER)) {
            //get a new injector instance each time
            handlerChainServiceBuilder.addDependency(sn, UnifiedHandlerMetaData.class, service.getHandlersInjector());
        }
        handlerChainServiceBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();
    } else {
        context.reloadRequired();
    }
}
Also used : HandlerChainService(org.jboss.as.webservices.service.HandlerChainService) PathElement(org.jboss.as.controller.PathElement) 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)

Example 73 with PathAddress

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

the class WSEndpointMetrics method getEndpointMetricsFragment.

@SuppressWarnings("unchecked")
private ModelNode getEndpointMetricsFragment(final ModelNode operation, final ServiceRegistry registry) throws OperationFailedException {
    final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
    String endpointId;
    try {
        endpointId = URLDecoder.decode(address.getLastElement().getValue(), "UTF-8");
    } catch (final UnsupportedEncodingException e) {
        throw new RuntimeException(e);
    }
    final String metricName = operation.require(NAME).asString();
    final String webContext = endpointId.substring(0, endpointId.indexOf(":"));
    final String endpointName = endpointId.substring(endpointId.indexOf(":") + 1);
    ServiceName endpointServiceName = WSServices.ENDPOINT_SERVICE.append("context=" + webContext).append(endpointName);
    ServiceController<Endpoint> service = (ServiceController<Endpoint>) currentServiceContainer().getService(endpointServiceName);
    Endpoint endpoint = service.getValue();
    if (endpoint == null) {
        throw new OperationFailedException(WSLogger.ROOT_LOGGER.noMetricsAvailable());
    }
    final ModelNode result = new ModelNode();
    final EndpointMetrics endpointMetrics = endpoint.getEndpointMetrics();
    if (MIN_PROCESSING_TIME.getName().equals(metricName)) {
        result.set(endpointMetrics.getMinProcessingTime());
    } else if (MAX_PROCESSING_TIME.getName().equals(metricName)) {
        result.set(endpointMetrics.getMaxProcessingTime());
    } else if (AVERAGE_PROCESSING_TIME.getName().equals(metricName)) {
        result.set(endpointMetrics.getAverageProcessingTime());
    } else if (TOTAL_PROCESSING_TIME.getName().equals(metricName)) {
        result.set(endpointMetrics.getTotalProcessingTime());
    } else if (REQUEST_COUNT.getName().equals(metricName)) {
        result.set(endpointMetrics.getRequestCount());
    } else if (RESPONSE_COUNT.getName().equals(metricName)) {
        result.set(endpointMetrics.getResponseCount());
    } else if (FAULT_COUNT.getName().equals(metricName)) {
        result.set(endpointMetrics.getFaultCount());
    }
    return result;
}
Also used : Endpoint(org.jboss.wsf.spi.deployment.Endpoint) ServiceName(org.jboss.msc.service.ServiceName) PathAddress(org.jboss.as.controller.PathAddress) OperationFailedException(org.jboss.as.controller.OperationFailedException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ServiceController(org.jboss.msc.service.ServiceController) ModelNode(org.jboss.dmr.ModelNode) EndpointMetrics(org.jboss.wsf.spi.management.EndpointMetrics)

Example 74 with PathAddress

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

the class WSSubsystem11Reader method readElement.

@Override
public void readElement(final XMLExtendedStreamReader reader, final List<ModelNode> list) throws XMLStreamException {
    final PathAddress address = PathAddress.pathAddress(WSExtension.SUBSYSTEM_PATH);
    final ModelNode subsystem = Util.createAddOperation(address);
    list.add(subsystem);
    readAttributes(reader, subsystem);
    // elements
    final EnumSet<Element> encountered = EnumSet.noneOf(Element.class);
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        final Element element = Element.forName(reader.getLocalName());
        switch(element) {
            case MODIFY_WSDL_ADDRESS:
                {
                    if (!encountered.add(element)) {
                        throw unexpectedElement(reader);
                    }
                    final String value = parseElementNoAttributes(reader);
                    Attributes.MODIFY_WSDL_ADDRESS.parseAndSetParameter(value, subsystem, reader);
                    break;
                }
            case WSDL_HOST:
                {
                    if (!encountered.add(element)) {
                        throw unexpectedElement(reader);
                    }
                    final String value = parseElementNoAttributes(reader);
                    Attributes.WSDL_HOST.parseAndSetParameter(value, subsystem, reader);
                    break;
                }
            case WSDL_PORT:
                {
                    if (!encountered.add(element)) {
                        throw unexpectedElement(reader);
                    }
                    final String value = parseElementNoAttributes(reader);
                    Attributes.WSDL_PORT.parseAndSetParameter(value, subsystem, reader);
                    break;
                }
            case WSDL_SECURE_PORT:
                {
                    if (!encountered.add(element)) {
                        throw unexpectedElement(reader);
                    }
                    final String value = parseElementNoAttributes(reader);
                    Attributes.WSDL_SECURE_PORT.parseAndSetParameter(value, subsystem, reader);
                    break;
                }
            case ENDPOINT_CONFIG:
                {
                    List<ModelNode> configs = readConfig(reader, address, false);
                    list.addAll(configs);
                    break;
                }
            default:
                {
                    handleUnknownElement(reader, address, element, list, encountered);
                }
        }
    }
//TODOļ¼šcheck required element
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) ParseUtils.unexpectedElement(org.jboss.as.controller.parsing.ParseUtils.unexpectedElement) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList) ModelNode(org.jboss.dmr.ModelNode)

Example 75 with PathAddress

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

the class XTSExtension method registerTransformers1x.

private void registerTransformers1x(SubsystemRegistration subsystem) {
    ResourceTransformationDescriptionBuilder builder = TransformationDescriptionBuilder.Factory.createSubsystemInstance();
    builder.getAttributeBuilder().setDiscard(new DiscardAttributeChecker.DefaultDiscardAttributeChecker() {

        @Override
        protected boolean isValueDiscardable(PathAddress address, String attributeName, ModelNode attributeValue, TransformationContext context) {
            return attributeValue.isDefined() && attributeValue.equals(XTSSubsystemDefinition.HOST_NAME.getDefaultValue());
        }
    }, XTSSubsystemDefinition.HOST_NAME).setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(new ModelNode(false)), XTSSubsystemDefinition.DEFAULT_CONTEXT_PROPAGATION).addRejectCheck(RejectAttributeChecker.DEFINED, XTSSubsystemDefinition.HOST_NAME, XTSSubsystemDefinition.DEFAULT_CONTEXT_PROPAGATION).end();
    TransformationDescription.Tools.register(builder.build(), subsystem, ModelVersion.create(1, 1, 0));
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) ResourceTransformationDescriptionBuilder(org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder) ModelNode(org.jboss.dmr.ModelNode) TransformationContext(org.jboss.as.controller.transform.TransformationContext) DiscardAttributeChecker(org.jboss.as.controller.transform.description.DiscardAttributeChecker)

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