Search in sources :

Example 1 with RoutingProvider

use of org.wildfly.clustering.web.routing.RoutingProvider in project wildfly by wildfly.

the class RoutingProviderServiceConfigurator method build.

@Override
public ServiceBuilder<?> build(ServiceTarget target) {
    ServiceName name = this.getServiceName();
    ServiceBuilder<?> builder = target.addService(name);
    Consumer<RoutingProvider> provider = builder.provides(name);
    Service service = new FunctionalService<>(provider, Function.identity(), this);
    return builder.setInstance(service).setInitialMode(ServiceController.Mode.ON_DEMAND);
}
Also used : RoutingProvider(org.wildfly.clustering.web.routing.RoutingProvider) FunctionalService(org.wildfly.clustering.service.FunctionalService) ServiceName(org.jboss.msc.service.ServiceName) FunctionalService(org.wildfly.clustering.service.FunctionalService) Service(org.jboss.msc.Service)

Example 2 with RoutingProvider

use of org.wildfly.clustering.web.routing.RoutingProvider 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

ServiceName (org.jboss.msc.service.ServiceName)2 RoutingProvider (org.wildfly.clustering.web.routing.RoutingProvider)2 Consumer (java.util.function.Consumer)1 CapabilityServiceConfigurator (org.jboss.as.clustering.controller.CapabilityServiceConfigurator)1 CapabilityServiceSupport (org.jboss.as.controller.capability.CapabilityServiceSupport)1 Service (org.jboss.msc.Service)1 ServiceTarget (org.jboss.msc.service.ServiceTarget)1 ChildTargetService (org.wildfly.clustering.service.ChildTargetService)1 FunctionSupplierDependency (org.wildfly.clustering.service.FunctionSupplierDependency)1 FunctionalService (org.wildfly.clustering.service.FunctionalService)1 ServiceSupplierDependency (org.wildfly.clustering.service.ServiceSupplierDependency)1 Server (org.wildfly.extension.undertow.Server)1