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)));
}
}
}
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;
}
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;
}
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());
}
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);
}
}
Aggregations