Search in sources :

Example 1 with FunctionSupplierDependency

use of org.wildfly.clustering.service.FunctionSupplierDependency 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

Consumer (java.util.function.Consumer)1 CapabilityServiceConfigurator (org.jboss.as.clustering.controller.CapabilityServiceConfigurator)1 CapabilityServiceSupport (org.jboss.as.controller.capability.CapabilityServiceSupport)1 ServiceName (org.jboss.msc.service.ServiceName)1 ServiceTarget (org.jboss.msc.service.ServiceTarget)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 Server (org.wildfly.extension.undertow.Server)1