Search in sources :

Example 6 with Predicate

use of io.undertow.predicate.Predicate in project wildfly by wildfly.

the class ModClusterService method install.

static ServiceController<FilterService> install(String name, ServiceTarget serviceTarget, ModelNode model, OperationContext operationContext) throws OperationFailedException {
    String securityKey = null;
    ModelNode securityKeyNode = ModClusterDefinition.SECURITY_KEY.resolveModelAttribute(operationContext, model);
    if (securityKeyNode.isDefined()) {
        securityKey = securityKeyNode.asString();
    }
    String managementAccessPredicateString = null;
    ModelNode managementAccessPredicateNode = ModClusterDefinition.MANAGEMENT_ACCESS_PREDICATE.resolveModelAttribute(operationContext, model);
    if (managementAccessPredicateNode.isDefined()) {
        managementAccessPredicateString = managementAccessPredicateNode.asString();
    }
    Predicate managementAccessPredicate = null;
    if (managementAccessPredicateString != null) {
        managementAccessPredicate = PredicateParser.parse(managementAccessPredicateString, ModClusterService.class.getClassLoader());
    }
    final ModelNode sslContext = ModClusterDefinition.SSL_CONTEXT.resolveModelAttribute(operationContext, model);
    final ModelNode securityRealm = ModClusterDefinition.SECURITY_REALM.resolveModelAttribute(operationContext, model);
    final ModelNode packetSizeNode = ModClusterDefinition.MAX_AJP_PACKET_SIZE.resolveModelAttribute(operationContext, model);
    OptionMap.Builder builder = OptionMap.builder();
    if (packetSizeNode.isDefined()) {
        builder.set(UndertowOptions.MAX_AJP_PACKET_SIZE, packetSizeNode.asInt());
    }
    builder.set(UndertowOptions.ENABLE_HTTP2, ModClusterDefinition.ENABLE_HTTP2.resolveModelAttribute(operationContext, model).asBoolean());
    ModClusterDefinition.HTTP2_ENABLE_PUSH.resolveOption(operationContext, model, builder);
    ModClusterDefinition.HTTP2_HEADER_TABLE_SIZE.resolveOption(operationContext, model, builder);
    ModClusterDefinition.HTTP2_INITIAL_WINDOW_SIZE.resolveOption(operationContext, model, builder);
    ModClusterDefinition.HTTP2_MAX_CONCURRENT_STREAMS.resolveOption(operationContext, model, builder);
    ModClusterDefinition.HTTP2_MAX_FRAME_SIZE.resolveOption(operationContext, model, builder);
    ModClusterDefinition.HTTP2_MAX_HEADER_LIST_SIZE.resolveOption(operationContext, model, builder);
    ModClusterService service = new ModClusterService(model, ModClusterDefinition.HEALTH_CHECK_INTERVAL.resolveModelAttribute(operationContext, model).asInt(), ModClusterDefinition.MAX_REQUEST_TIME.resolveModelAttribute(operationContext, model).asInt(), ModClusterDefinition.BROKEN_NODE_TIMEOUT.resolveModelAttribute(operationContext, model).asInt(), ModClusterDefinition.ADVERTISE_FREQUENCY.resolveModelAttribute(operationContext, model).asInt(), ModClusterDefinition.ADVERTISE_PATH.resolveModelAttribute(operationContext, model).asString(), ModClusterDefinition.ADVERTISE_PROTOCOL.resolveModelAttribute(operationContext, model).asString(), securityKey, managementAccessPredicate, ModClusterDefinition.CONNECTIONS_PER_THREAD.resolveModelAttribute(operationContext, model).asInt(), ModClusterDefinition.CACHED_CONNECTIONS_PER_THREAD.resolveModelAttribute(operationContext, model).asInt(), ModClusterDefinition.CONNECTION_IDLE_TIMEOUT.resolveModelAttribute(operationContext, model).asInt(), ModClusterDefinition.REQUEST_QUEUE_SIZE.resolveModelAttribute(operationContext, model).asInt(), ModClusterDefinition.USE_ALIAS.resolveModelAttribute(operationContext, model).asBoolean(), ModClusterDefinition.MAX_RETRIES.resolveModelAttribute(operationContext, model).asInt(), Enum.valueOf(FailoverStrategy.class, ModClusterDefinition.FAILOVER_STRATEGY.resolveModelAttribute(operationContext, model).asString()), builder.getMap());
    ServiceBuilder<FilterService> serviceBuilder = serviceTarget.addService(UndertowService.FILTER.append(name), service);
    serviceBuilder.addDependency(SocketBinding.JBOSS_BINDING_NAME.append(ModClusterDefinition.MANAGEMENT_SOCKET_BINDING.resolveModelAttribute(operationContext, model).asString()), SocketBinding.class, service.managementSocketBinding);
    final ModelNode advertiseSocketBinding = ModClusterDefinition.ADVERTISE_SOCKET_BINDING.resolveModelAttribute(operationContext, model);
    if (advertiseSocketBinding.isDefined()) {
        serviceBuilder.addDependency(SocketBinding.JBOSS_BINDING_NAME.append(advertiseSocketBinding.asString()), SocketBinding.class, service.advertiseSocketBinding);
    }
    serviceBuilder.addDependency(IOServices.WORKER.append(ModClusterDefinition.WORKER.resolveModelAttribute(operationContext, model).asString()), XnioWorker.class, service.workerInjectedValue);
    if (sslContext.isDefined()) {
        serviceBuilder.addDependency(operationContext.getCapabilityServiceName(SSL_CONTEXT_CAPABILITY_NAME, sslContext.asString(), SSLContext.class), SSLContext.class, service.sslContext);
    }
    if (securityRealm.isDefined()) {
        SecurityRealm.ServiceUtil.addDependency(serviceBuilder, service.securityRealm, securityRealm.asString(), false);
    }
    return serviceBuilder.install();
}
Also used : OptionMap(org.xnio.OptionMap) SSLContext(javax.net.ssl.SSLContext) ModelNode(org.jboss.dmr.ModelNode) Predicate(io.undertow.predicate.Predicate)

Aggregations

Predicate (io.undertow.predicate.Predicate)6 ModelNode (org.jboss.dmr.ModelNode)2 RequestHeaderAttribute (io.undertow.attribute.RequestHeaderAttribute)1 HandlerWrapper (io.undertow.server.HandlerWrapper)1 HttpHandler (io.undertow.server.HttpHandler)1 HttpServerExchange (io.undertow.server.HttpServerExchange)1 ServletRequestContext (io.undertow.servlet.handlers.ServletRequestContext)1 HttpString (io.undertow.util.HttpString)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 ArrayList (java.util.ArrayList)1 SSLContext (javax.net.ssl.SSLContext)1 PathAddress (org.jboss.as.controller.PathAddress)1 PathManager (org.jboss.as.controller.services.path.PathManager)1 ServiceName (org.jboss.msc.service.ServiceName)1 BeforeClass (org.junit.BeforeClass)1 RunResult (org.wildfly.extension.requestcontroller.RunResult)1 OptionMap (org.xnio.OptionMap)1