Search in sources :

Example 46 with ServiceName

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

the class AccessLogRemove method performRuntime.

@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) {
    final PathAddress hostAddress = context.getCurrentAddress().getParent();
    final PathAddress serverAddress = hostAddress.getParent();
    final String hostName = hostAddress.getLastElement().getValue();
    final String serverName = serverAddress.getLastElement().getValue();
    final ServiceName serviceName = UndertowService.accessLogServiceName(serverName, hostName);
    context.removeService(serviceName);
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) PathAddress(org.jboss.as.controller.PathAddress)

Example 47 with ServiceName

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

the class HttpsListenerAdd method configureAdditionalDependencies.

@Override
void configureAdditionalDependencies(OperationContext context, ServiceBuilder<? extends UndertowListener> serviceBuilder, ModelNode model, ListenerService service) throws OperationFailedException {
    serviceBuilder.addDependency(HttpListenerAdd.REGISTRY_SERVICE_NAME, ListenerRegistry.class, ((HttpListenerService) service).getHttpListenerRegistry());
    ModelNode sslContextModel = HttpsListenerResourceDefinition.SSL_CONTEXT.resolveModelAttribute(context, model);
    ModelNode securityRealmModel = HttpsListenerResourceDefinition.SECURITY_REALM.resolveModelAttribute(context, model);
    final String sslContextRef = sslContextModel.isDefined() ? sslContextModel.asString() : null;
    final String securityRealmRef = securityRealmModel.isDefined() ? securityRealmModel.asString() : null;
    final InjectedValue<SSLContext> sslContextInjector = new InjectedValue<>();
    final InjectedValue<SecurityRealm> securityRealmInjector = new InjectedValue<>();
    if (securityRealmRef != null) {
        SecurityRealm.ServiceUtil.addDependency(serviceBuilder, securityRealmInjector, securityRealmRef, false);
    }
    if (sslContextRef != null) {
        String runtimeCapability = RuntimeCapability.buildDynamicCapabilityName(SSL_CONTEXT_CAPABILITY, sslContextRef);
        ServiceName sslContextServiceName = context.getCapabilityServiceName(runtimeCapability, SSLContext.class);
        serviceBuilder.addDependency(sslContextServiceName, SSLContext.class, sslContextInjector);
    }
    ((HttpsListenerService) service).setSSLContextSupplier(() -> {
        if (sslContextRef != null) {
            return sslContextInjector.getValue();
        }
        if (securityRealmRef != null) {
            SSLContext sslContext = securityRealmInjector.getValue().getSSLContext();
            if (sslContext == null) {
                throw UndertowLogger.ROOT_LOGGER.noSslContextInSecurityRealm(securityRealmRef);
            }
            return sslContext;
        }
        try {
            return SSLContext.getDefault();
        } catch (Exception e) {
            throw new IllegalStateException(e);
        }
    });
}
Also used : InjectedValue(org.jboss.msc.value.InjectedValue) ServiceName(org.jboss.msc.service.ServiceName) SecurityRealm(org.jboss.as.domain.management.SecurityRealm) SSLContext(javax.net.ssl.SSLContext) ModelNode(org.jboss.dmr.ModelNode) OperationFailedException(org.jboss.as.controller.OperationFailedException)

Example 48 with ServiceName

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

the class AbstractUndertowSubsystemTestCase method testRuntime.

public static void testRuntime(KernelServices mainServices, final String virtualHostName, int flag) throws Exception {
    if (!mainServices.isSuccessfulBoot()) {
        Throwable t = mainServices.getBootError();
        Assert.fail("Boot unsuccessful: " + (t != null ? t.toString() : "no boot error provided"));
    }
    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(virtualHostName, "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());
    if (flag == 1) {
        Assert.assertEquals(3, host.getAllAliases().size());
        Assert.assertEquals("default-alias", new ArrayList<>(host.getAllAliases()).get(1));
    }
    final ServiceName locationServiceName = UndertowService.locationServiceName(virtualHostName, "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(virtualHostName, "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);
}
Also used : HttpHandler(io.undertow.server.HttpHandler) 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)

Example 49 with ServiceName

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

the class AbstractUndertowSubsystemTestCase method testRuntimeLast.

public static void testRuntimeLast(KernelServices mainServices) {
    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 : ServiceName(org.jboss.msc.service.ServiceName) ServiceController(org.jboss.msc.service.ServiceController)

Example 50 with ServiceName

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

the class EndpointPublisherImpl method doPublish.

/**
     * Publish the webapp for the WS deployment unit
     *
     * @param target
     * @param unit
     * @return
     * @throws Exception
     */
protected Context doPublish(ServiceTarget target, DeploymentUnit unit) throws Exception {
    Deployment deployment = unit.getAttachment(WSAttachmentKeys.DEPLOYMENT_KEY);
    List<Endpoint> endpoints = deployment.getService().getEndpoints();
    //otherwise we need to explicitly wait for the endpoint services to be started before creating the webapp.
    if (!runningInService) {
        final ServiceRegistry registry = unit.getServiceRegistry();
        for (Endpoint ep : endpoints) {
            final ServiceName serviceName = EndpointService.getServiceName(unit, ep.getShortName());
            registry.getRequiredService(serviceName).awaitValue();
        }
    }
    //TODO simplify and use findChild later in destroy()/stopWebApp()
    deployment.addAttachment(WebDeploymentController.class, startWebApp(host, unit));
    return new Context(unit.getAttachment(WSAttachmentKeys.JBOSSWEB_METADATA_KEY).getContextRoot(), endpoints);
}
Also used : Context(org.jboss.wsf.spi.publish.Context) Endpoint(org.jboss.wsf.spi.deployment.Endpoint) ServiceName(org.jboss.msc.service.ServiceName) Deployment(org.jboss.wsf.spi.deployment.Deployment) ServiceRegistry(org.jboss.msc.service.ServiceRegistry)

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