Search in sources :

Example 56 with ServiceName

use of org.jboss.msc.service.ServiceName in project wildfly by wildfly.

the class WSIntegrationProcessorJAXWS_POJO method processAnnotation.

// @Override
protected void processAnnotation(final DeploymentUnit unit, final EEModuleDescription moduleDescription) throws DeploymentUnitProcessingException {
    if (!DeploymentTypeMarker.isType(DeploymentType.WAR, unit)) {
        return;
    }
    final Map<String, EEModuleClassDescription> classDescriptionMap = new HashMap<String, org.jboss.as.ee.component.EEModuleClassDescription>();
    final CompositeIndex index = unit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
    for (EEModuleClassDescription classDescritpion : moduleDescription.getClassDescriptions()) {
        if (isJaxwsEndpoint(classDescritpion, index) && !exclude(unit, classDescritpion)) {
            classDescriptionMap.put(classDescritpion.getClassName(), classDescritpion);
        }
    }
    final JBossWebMetaData jbossWebMD = getJBossWebMetaData(unit);
    final JAXWSDeployment jaxwsDeployment = getJaxwsDeployment(unit);
    if (jbossWebMD != null) {
        final Set<String> matchedEps = new HashSet<String>();
        for (final ServletMetaData servletMD : getServlets(jbossWebMD)) {
            final String endpointClassName = getEndpointClassName(servletMD);
            final String endpointName = getEndpointName(servletMD);
            if (classDescriptionMap.containsKey(endpointClassName) || matchedEps.contains(endpointClassName)) {
                // creating component description for POJO endpoint
                final ComponentDescription pojoComponent = createComponentDescription(unit, endpointName, endpointClassName, endpointName);
                final ServiceName pojoViewName = registerView(pojoComponent, endpointClassName);
                final String urlPattern = getUrlPattern(endpointName, unit);
                jaxwsDeployment.addEndpoint(new POJOEndpoint(endpointName, endpointClassName, pojoViewName, urlPattern));
                classDescriptionMap.remove(endpointClassName);
                matchedEps.add(endpointClassName);
            } else {
                if (unit.getParent() != null && DeploymentTypeMarker.isType(DeploymentType.EAR, unit.getParent())) {
                    final EEModuleDescription eeModuleDescription = unit.getParent().getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
                    final CompositeIndex parentIndex = unit.getParent().getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
                    for (EEModuleClassDescription classDescription : eeModuleDescription.getClassDescriptions()) {
                        if (classDescription.getClassName().equals(endpointClassName) && isJaxwsEndpoint(classDescription, parentIndex)) {
                            final ComponentDescription pojoComponent = createComponentDescription(unit, endpointName, endpointClassName, endpointName);
                            final ServiceName pojoViewName = registerView(pojoComponent, endpointClassName);
                            final String urlPattern = getUrlPattern(endpointName, unit);
                            jaxwsDeployment.addEndpoint(new POJOEndpoint(endpointName, endpointClassName, pojoViewName, urlPattern));
                        }
                    }
                }
            }
        }
    }
    for (EEModuleClassDescription classDescription : classDescriptionMap.values()) {
        ClassInfo classInfo = null;
        String serviceName = null;
        String urlPattern = null;
        // #1 Override serviceName with the explicit urlPattern from port-component/port-component-uri in jboss-webservices.xml
        EJBEndpoint ejbEndpoint = getWebserviceMetadataEJBEndpoint(jaxwsDeployment, classDescription.getClassName());
        if (ejbEndpoint != null) {
            urlPattern = UrlPatternUtils.getUrlPatternByPortComponentURI(getJBossWebserviceMetaDataPortComponent(unit, ejbEndpoint.getName()));
        }
        // #2 Override serviceName with @WebContext.urlPattern
        if (urlPattern == null) {
            final ClassAnnotationInformation<WebContext, WebContextAnnotationInfo> annotationWebContext = classDescription.getAnnotationInformation(WebContext.class);
            if (annotationWebContext != null) {
                WebContextAnnotationInfo wsInfo = annotationWebContext.getClassLevelAnnotations().get(0);
                if (wsInfo != null && wsInfo.getUrlPattern().length() > 0) {
                    urlPattern = wsInfo.getUrlPattern();
                }
            }
        }
        // #3 use serviceName declared in a class annotation
        if (urlPattern == null) {
            final ClassAnnotationInformation<WebService, WebServiceAnnotationInfo> annotationInfo = classDescription.getAnnotationInformation(WebService.class);
            if (annotationInfo != null) {
                WebServiceAnnotationInfo wsInfo = annotationInfo.getClassLevelAnnotations().get(0);
                serviceName = wsInfo.getServiceName();
                classInfo = (ClassInfo) wsInfo.getTarget();
                urlPattern = UrlPatternUtils.getUrlPattern(classInfo.name().local(), serviceName);
                if (jaxwsDeployment.contains(urlPattern)) {
                    urlPattern = UrlPatternUtils.getUrlPattern(classInfo.name().local(), serviceName, wsInfo.getName());
                }
            }
            final ClassAnnotationInformation<WebServiceProvider, WebServiceProviderAnnotationInfo> annotationProviderInfo = classDescription.getAnnotationInformation(WebServiceProvider.class);
            if (annotationProviderInfo != null) {
                WebServiceProviderAnnotationInfo wsInfo = annotationProviderInfo.getClassLevelAnnotations().get(0);
                serviceName = wsInfo.getServiceName();
                classInfo = (ClassInfo) wsInfo.getTarget();
            }
        }
        if (classInfo != null) {
            final String endpointClassName = classDescription.getClassName();
            final ComponentDescription pojoComponent = createComponentDescription(unit, endpointClassName, endpointClassName, endpointClassName);
            final ServiceName pojoViewName = registerView(pojoComponent, endpointClassName);
            if (urlPattern == null) {
                urlPattern = UrlPatternUtils.getUrlPattern(classInfo.name().local(), serviceName);
            }
            // register POJO endpoint
            jaxwsDeployment.addEndpoint(new POJOEndpoint(endpointClassName, pojoViewName, UrlPatternUtils.getUrlPattern(urlPattern)));
        }
    }
}
Also used : JBossWebMetaData(org.jboss.metadata.web.jboss.JBossWebMetaData) ASHelper.getJBossWebMetaData(org.jboss.as.webservices.util.ASHelper.getJBossWebMetaData) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) WebContext(org.jboss.ws.api.annotation.WebContext) HashMap(java.util.HashMap) WebService(javax.jws.WebService) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) EJBEndpoint(org.jboss.as.webservices.metadata.model.EJBEndpoint) ASHelper.getWebserviceMetadataEJBEndpoint(org.jboss.as.webservices.util.ASHelper.getWebserviceMetadataEJBEndpoint) ServletMetaData(org.jboss.metadata.web.spec.ServletMetaData) HashSet(java.util.HashSet) POJOEndpoint(org.jboss.as.webservices.metadata.model.POJOEndpoint) WebServiceProvider(javax.xml.ws.WebServiceProvider) ServiceName(org.jboss.msc.service.ServiceName) JAXWSDeployment(org.jboss.as.webservices.metadata.model.JAXWSDeployment) EEModuleClassDescription(org.jboss.as.ee.component.EEModuleClassDescription) ClassInfo(org.jboss.jandex.ClassInfo)

Example 57 with ServiceName

use of org.jboss.msc.service.ServiceName in project wildfly by wildfly.

the class AbstractIntegrationProcessorJAXWS method createComponentDescription.

static ComponentDescription createComponentDescription(final DeploymentUnit unit, final String componentName, final String componentClassName, final String dependsOnEndpointClassName) {
    final EEModuleDescription moduleDescription = getRequiredAttachment(unit, EE_MODULE_DESCRIPTION);
    // JBoss WEB processors may install fake components for WS endpoints - removing them forcibly
    moduleDescription.removeComponent(componentName, componentClassName);
    // register WS component
    ComponentDescription componentDescription = new WSComponentDescription(componentName, componentClassName, moduleDescription, unit.getServiceName());
    moduleDescription.addComponent(componentDescription);
    // register WS dependency
    final ServiceName endpointServiceName = EndpointService.getServiceName(unit, dependsOnEndpointClassName);
    componentDescription.addDependency(endpointServiceName, ServiceBuilder.DependencyType.REQUIRED);
    return componentDescription;
}
Also used : WSComponentDescription(org.jboss.as.webservices.injection.WSComponentDescription) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) ServiceName(org.jboss.msc.service.ServiceName) WSComponentDescription(org.jboss.as.webservices.injection.WSComponentDescription)

Example 58 with ServiceName

use of org.jboss.msc.service.ServiceName 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 59 with ServiceName

use of org.jboss.msc.service.ServiceName in project wildfly by wildfly.

the class UndertowSubsystem31TestCase method testRuntime.

@Test
public void testRuntime() throws Exception {
    System.setProperty("server.data.dir", System.getProperty("java.io.tmpdir"));
    System.setProperty("jboss.home.dir", System.getProperty("java.io.tmpdir"));
    System.setProperty("jboss.home.dir", System.getProperty("java.io.tmpdir"));
    System.setProperty("jboss.server.server.dir", System.getProperty("java.io.tmpdir"));
    KernelServicesBuilder builder = createKernelServicesBuilder(RUNTIME).setSubsystemXml(getSubsystemXml());
    KernelServices mainServices = builder.build();
    if (!mainServices.isSuccessfulBoot()) {
        Assert.fail(mainServices.getBootError().toString());
    }
    ServiceController<FilterService> connectionLimiter = (ServiceController<FilterService>) mainServices.getContainer().getService(UndertowService.FILTER.append("limit-connections"));
    connectionLimiter.setMode(ServiceController.Mode.ACTIVE);
    FilterService connectionLimiterService = connectionLimiter.getService().getValue();
    HttpHandler result = connectionLimiterService.createHttpHandler(Predicates.truePredicate(), new PathHandler());
    Assert.assertNotNull("handler should have been created", result);
    ServiceController<FilterService> headersFilter = (ServiceController<FilterService>) mainServices.getContainer().getService(UndertowService.FILTER.append("headers"));
    headersFilter.setMode(ServiceController.Mode.ACTIVE);
    FilterService headersService = headersFilter.getService().getValue();
    HttpHandler headerHandler = headersService.createHttpHandler(Predicates.truePredicate(), new PathHandler());
    Assert.assertNotNull("handler should have been created", headerHandler);
    final ServiceName hostServiceName = UndertowService.virtualHostName("some-server", "other-host");
    ServiceController<Host> hostSC = (ServiceController<Host>) mainServices.getContainer().getService(hostServiceName);
    Assert.assertNotNull(hostSC);
    hostSC.setMode(ServiceController.Mode.ACTIVE);
    Host host = hostSC.getValue();
    Assert.assertEquals(1, host.getFilters().size());
    Assert.assertEquals(3, host.getAllAliases().size());
    Assert.assertEquals("default-alias", new ArrayList<>(host.getAllAliases()).get(1));
    final ServiceName locationServiceName = UndertowService.locationServiceName("some-server", "default-host", "/");
    ServiceController<LocationService> locationSC = (ServiceController<LocationService>) mainServices.getContainer().getService(locationServiceName);
    Assert.assertNotNull(locationSC);
    locationSC.setMode(ServiceController.Mode.ACTIVE);
    LocationService locationService = locationSC.getValue();
    Assert.assertNotNull(locationService);
    connectionLimiter.setMode(ServiceController.Mode.REMOVE);
    final ServiceName jspServiceName = UndertowService.SERVLET_CONTAINER.append("myContainer");
    ServiceController<ServletContainerService> jspServiceServiceController = (ServiceController<ServletContainerService>) mainServices.getContainer().getService(jspServiceName);
    Assert.assertNotNull(jspServiceServiceController);
    JSPConfig jspConfig = jspServiceServiceController.getService().getValue().getJspConfig();
    Assert.assertNotNull(jspConfig);
    Assert.assertNotNull(jspConfig.createJSPServletInfo());
    final ServiceName filterRefName = UndertowService.filterRefName("some-server", "other-host", "/", "static-gzip");
    ServiceController<FilterRef> gzipFilterController = (ServiceController<FilterRef>) mainServices.getContainer().getService(filterRefName);
    gzipFilterController.setMode(ServiceController.Mode.ACTIVE);
    FilterRef gzipFilterRef = gzipFilterController.getService().getValue();
    HttpHandler gzipHandler = gzipFilterRef.createHttpHandler(new PathHandler());
    Assert.assertNotNull("handler should have been created", gzipHandler);
    //testCustomFilters(mainServices);
    ServiceController<Host> defaultHostSC = (ServiceController<Host>) mainServices.getContainer().getService(UndertowService.DEFAULT_HOST);
    defaultHostSC.setMode(ServiceController.Mode.ACTIVE);
    Host defaultHost = defaultHostSC.getValue();
    Assert.assertNotNull("Default host should exist", defaultHost);
    ServiceController<Server> defaultServerSC = (ServiceController<Server>) mainServices.getContainer().getService(UndertowService.DEFAULT_SERVER);
    defaultServerSC.setMode(ServiceController.Mode.ACTIVE);
    Server defaultServer = defaultServerSC.getValue();
    Assert.assertNotNull("Default host should exist", defaultServer);
    final ServiceName accessLogServiceName = UndertowService.accessLogServiceName("some-server", "default-host");
    ServiceController<AccessLogService> accessLogSC = (ServiceController<AccessLogService>) mainServices.getContainer().getService(accessLogServiceName);
    Assert.assertNotNull(accessLogSC);
    accessLogSC.setMode(ServiceController.Mode.ACTIVE);
    AccessLogService accessLogService = accessLogSC.getValue();
    Assert.assertNotNull(accessLogService);
    Assert.assertFalse(accessLogService.isRotate());
}
Also used : HttpHandler(io.undertow.server.HttpHandler) KernelServices(org.jboss.as.subsystem.test.KernelServices) FilterService(org.wildfly.extension.undertow.filters.FilterService) ArrayList(java.util.ArrayList) PathHandler(io.undertow.server.handlers.PathHandler) FilterRef(org.wildfly.extension.undertow.filters.FilterRef) ServiceName(org.jboss.msc.service.ServiceName) ServiceController(org.jboss.msc.service.ServiceController) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder) AbstractSubsystemBaseTest(org.jboss.as.subsystem.test.AbstractSubsystemBaseTest) Test(org.junit.Test)

Example 60 with ServiceName

use of org.jboss.msc.service.ServiceName in project wildfly by wildfly.

the class WSSubsystemAdd method readConfigServiceNames.

private static void readConfigServiceNames(List<ServiceName> serviceNames, Resource subsystemResource, String configType) {
    for (ResourceEntry re : subsystemResource.getChildren(configType)) {
        ServiceName configServiceName = Constants.CLIENT_CONFIG.equals(configType) ? PackageUtils.getClientConfigServiceName(re.getName()) : PackageUtils.getEndpointConfigServiceName(re.getName());
        serviceNames.add(configServiceName);
    }
}
Also used : ResourceEntry(org.jboss.as.controller.registry.Resource.ResourceEntry) ServiceName(org.jboss.msc.service.ServiceName)

Aggregations

ServiceName (org.jboss.msc.service.ServiceName)323 ServiceTarget (org.jboss.msc.service.ServiceTarget)62 PathAddress (org.jboss.as.controller.PathAddress)57 ModelNode (org.jboss.dmr.ModelNode)53 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)47 ServiceRegistry (org.jboss.msc.service.ServiceRegistry)45 OperationFailedException (org.jboss.as.controller.OperationFailedException)35 ServiceController (org.jboss.msc.service.ServiceController)26 Module (org.jboss.modules.Module)24 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)22 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)22 ContextNames (org.jboss.as.naming.deployment.ContextNames)21 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)20 BinderService (org.jboss.as.naming.service.BinderService)20 ArrayList (java.util.ArrayList)17 HashSet (java.util.HashSet)17 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)16 HashMap (java.util.HashMap)14 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)14 OperationContext (org.jboss.as.controller.OperationContext)12