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