Search in sources :

Example 1 with Server

use of org.wildfly.extension.undertow.Server in project wildfly by wildfly.

the class UndertowEngineTestCase method getObfuscatedJvmRoute.

@Test
public void getObfuscatedJvmRoute() {
    // scenario 1, just create a service with obfuscated route but same config as this.service
    final TestUndertowService service1 = new TestUndertowService(null, "default-container", this.serverName, this.hostName, this.route, true, null);
    final Server server1 = new TestServer(this.serverName, this.hostName, service1, this.host, this.listener);
    final Engine engine1 = new UndertowEngine(this.serverName, server1, service1, this.connector);
    assertNotEquals(this.route, engine1.getJvmRoute());
    // after restart, recreate all objects, is the route still the same if config is kept unchanged?
    final Host host2 = new Host(null, null, null, null, null, this.hostName, Collections.emptyList(), "ROOT.war", StatusCodes.NOT_FOUND, false);
    final HttpsListenerService listener2 = new HttpsListenerService(null, PathAddress.pathAddress(Constants.HTTPS_LISTENER, "default"), "https", OptionMap.EMPTY, null, OptionMap.EMPTY, false);
    final UndertowService service2 = new TestUndertowService(null, "default-container", this.serverName, this.hostName, this.route, true, null);
    final Server server2 = new TestServer(this.serverName, this.hostName, service2, host2, listener2);
    final Connector connector2 = mock(Connector.class);
    final Engine engine2 = new UndertowEngine(this.serverName, server2, service2, connector2);
    assertEquals(engine1.getJvmRoute(), engine2.getJvmRoute());
    // with a different route, is the obfuscated route different from previous one?
    final TestUndertowService service3 = new TestUndertowService(null, "default-container", this.serverName, this.hostName, "adifferentroute", true, null);
    final Server server3 = new TestServer(this.serverName, this.hostName, service3, this.host, this.listener);
    final Engine engine3 = new UndertowEngine(this.serverName, server3, service3, this.connector);
    assertNotEquals(engine1.getJvmRoute(), engine3.getJvmRoute());
    // just double check it is obfuscated for engine3 as well
    assertNotEquals("adifferentroute", engine3.getJvmRoute());
    // with a different server name, is the obfuscated route different from previous one?
    final TestUndertowService service4 = new TestUndertowService(null, "default-container", "another.server", this.hostName, "this.route", true, null);
    final Server server4 = new TestServer("another.server", this.hostName, service4, this.host, this.listener);
    final Engine engine4 = new UndertowEngine(this.serverName, server4, service4, this.connector);
    assertNotEquals(engine1.getJvmRoute(), engine4.getJvmRoute());
    // just double check it is obfuscated for engine4 as well
    assertNotEquals(this.route, engine4.getJvmRoute());
}
Also used : Connector(org.jboss.modcluster.container.Connector) Server(org.wildfly.extension.undertow.Server) Host(org.wildfly.extension.undertow.Host) HttpsListenerService(org.wildfly.extension.undertow.HttpsListenerService) Engine(org.jboss.modcluster.container.Engine) UndertowService(org.wildfly.extension.undertow.UndertowService) Test(org.junit.Test)

Example 2 with Server

use of org.wildfly.extension.undertow.Server in project wildfly by wildfly.

the class UndertowDistributableServerRuntimeHandler method execute.

@Override
public void execute(OperationContext context, String serverName) {
    SupplierDependency<RoutingProvider> provider = getRoutingProvider(context, serverName);
    if (provider != null) {
        ServiceTarget target = context.getServiceTarget();
        CapabilityServiceSupport support = context.getCapabilityServiceSupport();
        SupplierDependency<Server> server = new ServiceSupplierDependency<>(UndertowUnaryRequirement.SERVER.getServiceName(context, serverName));
        SupplierDependency<String> route = new FunctionSupplierDependency<>(server, Server::getRoute);
        Consumer<ServiceTarget> installer = new Consumer<ServiceTarget>() {

            @Override
            public void accept(ServiceTarget target) {
                for (CapabilityServiceConfigurator configurator : provider.get().getServiceConfigurators(serverName, route)) {
                    configurator.configure(support).build(target).install();
                }
            }
        };
        ServiceName name = ServiceName.JBOSS.append("clustering", "web", "undertow", "routing", serverName);
        provider.register(target.addService(name)).setInstance(new ChildTargetService(installer)).install();
    }
}
Also used : RoutingProvider(org.wildfly.clustering.web.routing.RoutingProvider) FunctionSupplierDependency(org.wildfly.clustering.service.FunctionSupplierDependency) Server(org.wildfly.extension.undertow.Server) CapabilityServiceConfigurator(org.jboss.as.clustering.controller.CapabilityServiceConfigurator) ChildTargetService(org.wildfly.clustering.service.ChildTargetService) ServiceTarget(org.jboss.msc.service.ServiceTarget) ServiceSupplierDependency(org.wildfly.clustering.service.ServiceSupplierDependency) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport) Consumer(java.util.function.Consumer) ServiceName(org.jboss.msc.service.ServiceName)

Aggregations

Server (org.wildfly.extension.undertow.Server)2 Consumer (java.util.function.Consumer)1 CapabilityServiceConfigurator (org.jboss.as.clustering.controller.CapabilityServiceConfigurator)1 CapabilityServiceSupport (org.jboss.as.controller.capability.CapabilityServiceSupport)1 Connector (org.jboss.modcluster.container.Connector)1 Engine (org.jboss.modcluster.container.Engine)1 ServiceName (org.jboss.msc.service.ServiceName)1 ServiceTarget (org.jboss.msc.service.ServiceTarget)1 Test (org.junit.Test)1 ChildTargetService (org.wildfly.clustering.service.ChildTargetService)1 FunctionSupplierDependency (org.wildfly.clustering.service.FunctionSupplierDependency)1 ServiceSupplierDependency (org.wildfly.clustering.service.ServiceSupplierDependency)1 RoutingProvider (org.wildfly.clustering.web.routing.RoutingProvider)1 Host (org.wildfly.extension.undertow.Host)1 HttpsListenerService (org.wildfly.extension.undertow.HttpsListenerService)1 UndertowService (org.wildfly.extension.undertow.UndertowService)1