Search in sources :

Example 16 with ServiceTarget

use of org.jboss.msc.service.ServiceTarget in project wildfly by wildfly.

the class TransactionJndiBindingProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    if (moduleDescription == null) {
        return;
    }
    final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
    //if this is a war we need to bind to the modules comp namespace
    if (DeploymentTypeMarker.isType(DeploymentType.WAR, deploymentUnit)) {
        final ServiceName moduleContextServiceName = ContextNames.contextServiceNameOfModule(moduleDescription.getApplicationName(), moduleDescription.getModuleName());
        bindServices(deploymentUnit, serviceTarget, moduleContextServiceName);
    }
    for (ComponentDescription component : moduleDescription.getComponentDescriptions()) {
        if (component.getNamingMode() == ComponentNamingMode.CREATE) {
            final ServiceName compContextServiceName = ContextNames.contextServiceNameOfComponent(moduleDescription.getApplicationName(), moduleDescription.getModuleName(), component.getComponentName());
            bindServices(deploymentUnit, serviceTarget, compContextServiceName);
        }
    }
}
Also used : ComponentDescription(org.jboss.as.ee.component.ComponentDescription) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) ServiceName(org.jboss.msc.service.ServiceName) ServiceTarget(org.jboss.msc.service.ServiceTarget) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 17 with ServiceTarget

use of org.jboss.msc.service.ServiceTarget in project wildfly by wildfly.

the class SharedSessionManagerDeploymentProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    SharedSessionManagerConfig sharedConfig = deploymentUnit.getAttachment(UndertowAttachments.SHARED_SESSION_MANAGER_CONFIG);
    if (sharedConfig == null) {
        return;
    }
    ServiceTarget target = phaseContext.getServiceTarget();
    ServiceName deploymentServiceName = deploymentUnit.getServiceName();
    ServiceName managerServiceName = deploymentServiceName.append(SharedSessionManagerConfig.SHARED_SESSION_MANAGER_SERVICE_NAME);
    DistributableSessionManagerFactoryBuilder builder = new DistributableSessionManagerFactoryBuilderValue().getValue();
    if (builder != null) {
        CapabilityServiceSupport support = deploymentUnit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
        Module module = deploymentUnit.getAttachment(Attachments.MODULE);
        builder.build(support, target, managerServiceName, new SimpleDistributableSessionManagerConfiguration(sharedConfig, deploymentUnit.getName(), module)).setInitialMode(Mode.ON_DEMAND).install();
    } else {
        InMemorySessionManager manager = new InMemorySessionManager(deploymentUnit.getName(), sharedConfig.getMaxActiveSessions());
        if (sharedConfig.getSessionConfig() != null) {
            if (sharedConfig.getSessionConfig().getSessionTimeoutSet()) {
                manager.setDefaultSessionTimeout(sharedConfig.getSessionConfig().getSessionTimeout());
            }
        }
        SessionManagerFactory factory = new ImmediateSessionManagerFactory(manager);
        target.addService(managerServiceName, new ValueService<>(new ImmediateValue<>(factory))).setInitialMode(Mode.ON_DEMAND).install();
    }
    ServiceName codecServiceName = deploymentServiceName.append(SharedSessionManagerConfig.SHARED_SESSION_IDENTIFIER_CODEC_SERVICE_NAME);
    DistributableSessionIdentifierCodecBuilder sessionIdentifierCodecBuilder = new DistributableSessionIdentifierCodecBuilderValue().getValue();
    if (sessionIdentifierCodecBuilder != null) {
        sessionIdentifierCodecBuilder.build(target, codecServiceName, deploymentUnit.getName()).setInitialMode(Mode.ON_DEMAND).install();
    } else {
        // Fallback to simple codec if server does not support clustering
        SimpleSessionIdentifierCodecService.build(target, codecServiceName).setInitialMode(Mode.ON_DEMAND).install();
    }
}
Also used : DistributableSessionIdentifierCodecBuilderValue(org.wildfly.extension.undertow.session.DistributableSessionIdentifierCodecBuilderValue) ServiceTarget(org.jboss.msc.service.ServiceTarget) DistributableSessionManagerFactoryBuilderValue(org.wildfly.extension.undertow.session.DistributableSessionManagerFactoryBuilderValue) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport) ImmediateValue(org.jboss.msc.value.ImmediateValue) DistributableSessionIdentifierCodecBuilder(org.wildfly.extension.undertow.session.DistributableSessionIdentifierCodecBuilder) SharedSessionManagerConfig(org.wildfly.extension.undertow.session.SharedSessionManagerConfig) SimpleDistributableSessionManagerConfiguration(org.wildfly.extension.undertow.session.SimpleDistributableSessionManagerConfiguration) DistributableSessionManagerFactoryBuilder(org.wildfly.extension.undertow.session.DistributableSessionManagerFactoryBuilder) ServiceName(org.jboss.msc.service.ServiceName) SessionManagerFactory(io.undertow.servlet.api.SessionManagerFactory) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) InMemorySessionManager(io.undertow.server.session.InMemorySessionManager)

Example 18 with ServiceTarget

use of org.jboss.msc.service.ServiceTarget in project wildfly by wildfly.

the class UndertowSubsystemAdd method performBoottime.

/**
     * {@inheritDoc}
     */
@Override
protected void performBoottime(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
    try {
        Class.forName("org.apache.jasper.compiler.JspRuntimeContext", true, this.getClass().getClassLoader());
    } catch (ClassNotFoundException e) {
        UndertowLogger.ROOT_LOGGER.couldNotInitJsp(e);
    }
    final ModelNode model = resource.getModel();
    final String defaultVirtualHost = UndertowRootDefinition.DEFAULT_VIRTUAL_HOST.resolveModelAttribute(context, model).asString();
    final String defaultContainer = UndertowRootDefinition.DEFAULT_SERVLET_CONTAINER.resolveModelAttribute(context, model).asString();
    final String defaultServer = UndertowRootDefinition.DEFAULT_SERVER.resolveModelAttribute(context, model).asString();
    final boolean stats = UndertowRootDefinition.STATISTICS_ENABLED.resolveModelAttribute(context, model).asBoolean();
    final String defaultSecurityDomain = UndertowRootDefinition.DEFAULT_SECURITY_DOMAIN.resolveModelAttribute(context, model).asString();
    final ModelNode instanceIdModel = UndertowRootDefinition.INSTANCE_ID.resolveModelAttribute(context, model);
    final String instanceId = instanceIdModel.isDefined() ? instanceIdModel.asString() : null;
    ServiceTarget target = context.getServiceTarget();
    //we clear provider on system boot, as on reload it could cause issues.
    DefaultDeploymentMappingProvider.instance().clear();
    target.addService(UndertowService.UNDERTOW, new UndertowService(defaultContainer, defaultServer, defaultVirtualHost, instanceId, stats)).setInitialMode(ServiceController.Mode.ACTIVE).install();
    context.addStep(new AbstractDeploymentChainStep() {

        @Override
        protected void execute(DeploymentProcessorTarget processorTarget) {
            final SharedTldsMetaDataBuilder sharedTldsBuilder = new SharedTldsMetaDataBuilder(model.clone());
            processorTarget.addDeploymentProcessor(UndertowExtension.SUBSYSTEM_NAME, Phase.STRUCTURE, Phase.STRUCTURE_EXPLODED_MOUNT, new DeploymentRootExplodedMountProcessor());
            processorTarget.addDeploymentProcessor(UndertowExtension.SUBSYSTEM_NAME, Phase.STRUCTURE, Phase.STRUCTURE_REGISTER_JBOSS_ALL_UNDERTOW_SHARED_SESSION, new JBossAllXmlParserRegisteringProcessor<>(SharedSessionConfigParser_1_0.ROOT_ELEMENT, UndertowAttachments.SHARED_SESSION_MANAGER_CONFIG, SharedSessionConfigParser_1_0.INSTANCE));
            processorTarget.addDeploymentProcessor(UndertowExtension.SUBSYSTEM_NAME, Phase.STRUCTURE, Phase.STRUCTURE_REGISTER_JBOSS_ALL_WEB, new JBossAllXmlParserRegisteringProcessor<>(WebJBossAllParser.ROOT_ELEMENT, WebJBossAllParser.ATTACHMENT_KEY, new WebJBossAllParser()));
            processorTarget.addDeploymentProcessor(UndertowExtension.SUBSYSTEM_NAME, Phase.STRUCTURE, Phase.STRUCTURE_WAR_DEPLOYMENT_INIT, new WarDeploymentInitializingProcessor());
            processorTarget.addDeploymentProcessor(UndertowExtension.SUBSYSTEM_NAME, Phase.STRUCTURE, Phase.STRUCTURE_WAR, new WarStructureDeploymentProcessor(sharedTldsBuilder));
            processorTarget.addDeploymentProcessor(UndertowExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_WEB_DEPLOYMENT, new WebParsingDeploymentProcessor());
            processorTarget.addDeploymentProcessor(UndertowExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_WEB_DEPLOYMENT_FRAGMENT, new WebFragmentParsingDeploymentProcessor());
            processorTarget.addDeploymentProcessor(UndertowExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_JBOSS_WEB_DEPLOYMENT, new JBossWebParsingDeploymentProcessor());
            processorTarget.addDeploymentProcessor(UndertowExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_ANNOTATION_WAR, new WarAnnotationDeploymentProcessor());
            processorTarget.addDeploymentProcessor(UndertowExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_EAR_CONTEXT_ROOT, new EarContextRootProcessor());
            processorTarget.addDeploymentProcessor(UndertowExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_WEB_MERGE_METADATA, new WarMetaDataProcessor());
            //todo: fix priority
            processorTarget.addDeploymentProcessor(UndertowExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_WEB_MERGE_METADATA + 1, new TldParsingDeploymentProcessor());
            //todo: fix priority
            processorTarget.addDeploymentProcessor(UndertowExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_WEB_MERGE_METADATA + 2, new org.wildfly.extension.undertow.deployment.WebComponentProcessor());
            processorTarget.addDeploymentProcessor(UndertowExtension.SUBSYSTEM_NAME, Phase.DEPENDENCIES, Phase.DEPENDENCIES_WAR_MODULE, new UndertowDependencyProcessor());
            processorTarget.addDeploymentProcessor(UndertowExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_UNDERTOW_WEBSOCKETS, new UndertowJSRWebSocketDeploymentProcessor());
            processorTarget.addDeploymentProcessor(UndertowExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_UNDERTOW_HANDLERS, new UndertowHandlersDeploymentProcessor());
            //todo: fix priority
            processorTarget.addDeploymentProcessor(UndertowExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_UNDERTOW_HANDLERS + 1, new ExternalTldParsingDeploymentProcessor());
            //todo: fix priority
            processorTarget.addDeploymentProcessor(UndertowExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_UNDERTOW_HANDLERS + 2, new UndertowServletContainerDependencyProcessor(defaultContainer));
            processorTarget.addDeploymentProcessor(UndertowExtension.SUBSYSTEM_NAME, Phase.INSTALL, Phase.INSTALL_SHARED_SESSION_MANAGER, new SharedSessionManagerDeploymentProcessor());
            processorTarget.addDeploymentProcessor(UndertowExtension.SUBSYSTEM_NAME, Phase.INSTALL, Phase.INSTALL_SERVLET_INIT_DEPLOYMENT, new ServletContainerInitializerDeploymentProcessor());
            processorTarget.addDeploymentProcessor(UndertowExtension.SUBSYSTEM_NAME, Phase.INSTALL, Phase.INSTALL_WAR_DEPLOYMENT, new UndertowDeploymentProcessor(defaultVirtualHost, defaultContainer, defaultServer, defaultSecurityDomain, knownSecurityDomain));
        }
    }, OperationContext.Stage.RUNTIME);
    DistributableSessionIdentifierCodecBuilder builder = new DistributableSessionIdentifierCodecBuilderValue().getValue();
    if (builder != null) {
        builder.buildServerDependency(target).setInitialMode(ServiceController.Mode.ON_DEMAND).install();
    }
    RouteValueService.build(target).setInitialMode(ServiceController.Mode.ON_DEMAND).install();
    target.addService(UndertowRootDefinition.HTTP_INVOKER_RUNTIME_CAPABILITY.getCapabilityServiceName(), new RemoteHttpInvokerService()).install();
}
Also used : UndertowHandlersDeploymentProcessor(org.wildfly.extension.undertow.deployment.UndertowHandlersDeploymentProcessor) DistributableSessionIdentifierCodecBuilderValue(org.wildfly.extension.undertow.session.DistributableSessionIdentifierCodecBuilderValue) WebJBossAllParser(org.wildfly.extension.undertow.deployment.WebJBossAllParser) UndertowDeploymentProcessor(org.wildfly.extension.undertow.deployment.UndertowDeploymentProcessor) UndertowServletContainerDependencyProcessor(org.wildfly.extension.undertow.deployment.UndertowServletContainerDependencyProcessor) DistributableSessionIdentifierCodecBuilder(org.wildfly.extension.undertow.session.DistributableSessionIdentifierCodecBuilder) ServletContainerInitializerDeploymentProcessor(org.wildfly.extension.undertow.deployment.ServletContainerInitializerDeploymentProcessor) UndertowJSRWebSocketDeploymentProcessor(org.wildfly.extension.undertow.deployment.UndertowJSRWebSocketDeploymentProcessor) WebParsingDeploymentProcessor(org.wildfly.extension.undertow.deployment.WebParsingDeploymentProcessor) JBossWebParsingDeploymentProcessor(org.wildfly.extension.undertow.deployment.JBossWebParsingDeploymentProcessor) ExternalTldParsingDeploymentProcessor(org.wildfly.extension.undertow.deployment.ExternalTldParsingDeploymentProcessor) TldParsingDeploymentProcessor(org.wildfly.extension.undertow.deployment.TldParsingDeploymentProcessor) SharedTldsMetaDataBuilder(org.jboss.as.web.common.SharedTldsMetaDataBuilder) WarDeploymentInitializingProcessor(org.wildfly.extension.undertow.deployment.WarDeploymentInitializingProcessor) WebFragmentParsingDeploymentProcessor(org.wildfly.extension.undertow.deployment.WebFragmentParsingDeploymentProcessor) WarStructureDeploymentProcessor(org.wildfly.extension.undertow.deployment.WarStructureDeploymentProcessor) JBossAllXmlParserRegisteringProcessor(org.jboss.as.server.deployment.jbossallxml.JBossAllXmlParserRegisteringProcessor) EarContextRootProcessor(org.wildfly.extension.undertow.deployment.EarContextRootProcessor) ServiceTarget(org.jboss.msc.service.ServiceTarget) WarAnnotationDeploymentProcessor(org.wildfly.extension.undertow.deployment.WarAnnotationDeploymentProcessor) SharedSessionManagerDeploymentProcessor(org.wildfly.extension.undertow.deployment.SharedSessionManagerDeploymentProcessor) DeploymentProcessorTarget(org.jboss.as.server.DeploymentProcessorTarget) ExternalTldParsingDeploymentProcessor(org.wildfly.extension.undertow.deployment.ExternalTldParsingDeploymentProcessor) DeploymentRootExplodedMountProcessor(org.wildfly.extension.undertow.deployment.DeploymentRootExplodedMountProcessor) WarMetaDataProcessor(org.wildfly.extension.undertow.deployment.WarMetaDataProcessor) UndertowDependencyProcessor(org.wildfly.extension.undertow.deployment.UndertowDependencyProcessor) JBossWebParsingDeploymentProcessor(org.wildfly.extension.undertow.deployment.JBossWebParsingDeploymentProcessor) AbstractDeploymentChainStep(org.jboss.as.server.AbstractDeploymentChainStep) ModelNode(org.jboss.dmr.ModelNode)

Example 19 with ServiceTarget

use of org.jboss.msc.service.ServiceTarget in project wildfly by wildfly.

the class TransactionSubsystemAdd method performObjectStoreBoottime.

private void performObjectStoreBoottime(OperationContext context, ModelNode model) throws OperationFailedException {
    boolean useJournalStore = model.hasDefined(USE_JOURNAL_STORE) && model.get(USE_JOURNAL_STORE).asBoolean();
    final boolean enableAsyncIO = TransactionSubsystemRootResourceDefinition.JOURNAL_STORE_ENABLE_ASYNC_IO.resolveModelAttribute(context, model).asBoolean();
    final String objectStorePathRef = TransactionSubsystemRootResourceDefinition.OBJECT_STORE_RELATIVE_TO.resolveModelAttribute(context, model).isDefined() ? TransactionSubsystemRootResourceDefinition.OBJECT_STORE_RELATIVE_TO.resolveModelAttribute(context, model).asString() : null;
    final String objectStorePath = TransactionSubsystemRootResourceDefinition.OBJECT_STORE_PATH.resolveModelAttribute(context, model).asString();
    final boolean useJdbcStore = model.hasDefined(USE_JDBC_STORE) && model.get(USE_JDBC_STORE).asBoolean();
    final String dataSourceJndiName = TransactionSubsystemRootResourceDefinition.JDBC_STORE_DATASOURCE.resolveModelAttribute(context, model).asString();
    ArjunaObjectStoreEnvironmentService.JdbcStoreConfigBulder confiBuilder = new ArjunaObjectStoreEnvironmentService.JdbcStoreConfigBulder();
    confiBuilder.setActionDropTable(TransactionSubsystemRootResourceDefinition.JDBC_ACTION_STORE_DROP_TABLE.resolveModelAttribute(context, model).asBoolean()).setStateDropTable(TransactionSubsystemRootResourceDefinition.JDBC_STATE_STORE_DROP_TABLE.resolveModelAttribute(context, model).asBoolean()).setCommunicationDropTable(TransactionSubsystemRootResourceDefinition.JDBC_COMMUNICATION_STORE_DROP_TABLE.resolveModelAttribute(context, model).asBoolean());
    if (model.hasDefined(TransactionSubsystemRootResourceDefinition.JDBC_ACTION_STORE_TABLE_PREFIX.getName()))
        confiBuilder.setActionTablePrefix(TransactionSubsystemRootResourceDefinition.JDBC_ACTION_STORE_TABLE_PREFIX.resolveModelAttribute(context, model).asString());
    if (model.hasDefined(TransactionSubsystemRootResourceDefinition.JDBC_STATE_STORE_TABLE_PREFIX.getName()))
        confiBuilder.setStateTablePrefix(TransactionSubsystemRootResourceDefinition.JDBC_STATE_STORE_TABLE_PREFIX.resolveModelAttribute(context, model).asString());
    if (model.hasDefined(TransactionSubsystemRootResourceDefinition.JDBC_COMMUNICATION_STORE_TABLE_PREFIX.getName()))
        confiBuilder.setCommunicationTablePrefix(TransactionSubsystemRootResourceDefinition.JDBC_COMMUNICATION_STORE_TABLE_PREFIX.resolveModelAttribute(context, model).asString());
    TransactionLogger.ROOT_LOGGER.debugf("objectStorePathRef=%s, objectStorePath=%s%n", objectStorePathRef, objectStorePath);
    ServiceTarget target = context.getServiceTarget();
    // Configure the ObjectStoreEnvironmentBeans
    final ArjunaObjectStoreEnvironmentService objStoreEnvironmentService = new ArjunaObjectStoreEnvironmentService(useJournalStore, enableAsyncIO, objectStorePath, objectStorePathRef, useJdbcStore, dataSourceJndiName, confiBuilder.build());
    ServiceBuilder<Void> builder = target.addService(TxnServices.JBOSS_TXN_ARJUNA_OBJECTSTORE_ENVIRONMENT, objStoreEnvironmentService).addDependency(PathManagerService.SERVICE_NAME, PathManager.class, objStoreEnvironmentService.getPathManagerInjector()).addDependency(TxnServices.JBOSS_TXN_CORE_ENVIRONMENT);
    if (useJdbcStore) {
        final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(dataSourceJndiName);
        builder.addDependency(bindInfo.getBinderServiceName());
    }
    builder.setInitialMode(ServiceController.Mode.ACTIVE).install();
    TransactionManagerService.addService(target);
    UserTransactionService.addService(target);
    target.addService(TxnServices.JBOSS_TXN_USER_TRANSACTION_REGISTRY, new UserTransactionRegistryService()).setInitialMode(ServiceController.Mode.ACTIVE).install();
    TransactionSynchronizationRegistryService.addService(target);
}
Also used : PathManager(org.jboss.as.controller.services.path.PathManager) UserTransactionRegistryService(org.jboss.as.txn.service.UserTransactionRegistryService) ArjunaObjectStoreEnvironmentService(org.jboss.as.txn.service.ArjunaObjectStoreEnvironmentService) ServiceTarget(org.jboss.msc.service.ServiceTarget) ContextNames(org.jboss.as.naming.deployment.ContextNames)

Example 20 with ServiceTarget

use of org.jboss.msc.service.ServiceTarget in project wildfly by wildfly.

the class ServletContainerAdd method installRuntimeServices.

public void installRuntimeServices(OperationContext context, ModelNode model, String name) throws OperationFailedException {
    final ModelNode fullModel = Resource.Tools.readModel(context.readResource(PathAddress.EMPTY_ADDRESS), 2);
    final SessionCookieConfig config = SessionCookieDefinition.INSTANCE.getConfig(context, fullModel.get(SessionCookieDefinition.INSTANCE.getPathElement().getKeyValuePair()));
    final CrawlerSessionManagerConfig crawlerSessionManagerConfig = CrawlerSessionManagementDefinition.INSTANCE.getConfig(context, fullModel.get(CrawlerSessionManagementDefinition.INSTANCE.getPathElement().getKeyValuePair()));
    final boolean persistentSessions = PersistentSessionsDefinition.isEnabled(context, fullModel.get(PersistentSessionsDefinition.INSTANCE.getPathElement().getKeyValuePair()));
    final boolean allowNonStandardWrappers = ServletContainerDefinition.ALLOW_NON_STANDARD_WRAPPERS.resolveModelAttribute(context, model).asBoolean();
    final boolean proactiveAuth = ServletContainerDefinition.PROACTIVE_AUTHENTICATION.resolveModelAttribute(context, model).asBoolean();
    final String bufferCache = ServletContainerDefinition.DEFAULT_BUFFER_CACHE.resolveModelAttribute(context, model).asString();
    final boolean disableFileWatchService = ServletContainerDefinition.DISABLE_FILE_WATCH_SERVICE.resolveModelAttribute(context, model).asBoolean();
    JSPConfig jspConfig = JspDefinition.INSTANCE.getConfig(context, fullModel.get(JspDefinition.INSTANCE.getPathElement().getKeyValuePair()));
    final String stackTracesString = ServletContainerDefinition.STACK_TRACE_ON_ERROR.resolveModelAttribute(context, model).asString();
    final ModelNode defaultEncodingValue = ServletContainerDefinition.DEFAULT_ENCODING.resolveModelAttribute(context, model);
    final String defaultEncoding = defaultEncodingValue.isDefined() ? defaultEncodingValue.asString() : null;
    final boolean useListenerEncoding = ServletContainerDefinition.USE_LISTENER_ENCODING.resolveModelAttribute(context, model).asBoolean();
    final boolean ignoreFlush = ServletContainerDefinition.IGNORE_FLUSH.resolveModelAttribute(context, model).asBoolean();
    final boolean eagerFilterInit = ServletContainerDefinition.EAGER_FILTER_INIT.resolveModelAttribute(context, model).asBoolean();
    final boolean disableCachingForSecuredPages = ServletContainerDefinition.DISABLE_CACHING_FOR_SECURED_PAGES.resolveModelAttribute(context, model).asBoolean();
    final int sessionIdLength = ServletContainerDefinition.SESSION_ID_LENGTH.resolveModelAttribute(context, model).asInt();
    Boolean directoryListingEnabled = null;
    if (model.hasDefined(Constants.DIRECTORY_LISTING)) {
        directoryListingEnabled = ServletContainerDefinition.DIRECTORY_LISTING.resolveModelAttribute(context, model).asBoolean();
    }
    Integer maxSessions = null;
    if (model.hasDefined(Constants.MAX_SESSIONS)) {
        maxSessions = ServletContainerDefinition.MAX_SESSIONS.resolveModelAttribute(context, model).asInt();
    }
    final int sessionTimeout = ServletContainerDefinition.DEFAULT_SESSION_TIMEOUT.resolveModelAttribute(context, model).asInt();
    WebsocketsDefinition.WebSocketInfo webSocketInfo = WebsocketsDefinition.INSTANCE.getConfig(context, fullModel.get(WebsocketsDefinition.INSTANCE.getPathElement().getKeyValuePair()));
    final Map<String, String> mimeMappings = new HashMap<>();
    if (fullModel.hasDefined(Constants.MIME_MAPPING)) {
        for (final Property mapping : fullModel.get(Constants.MIME_MAPPING).asPropertyList()) {
            mimeMappings.put(mapping.getName(), MimeMappingDefinition.VALUE.resolveModelAttribute(context, mapping.getValue()).asString());
        }
    }
    List<String> welcomeFiles = new ArrayList<>();
    if (fullModel.hasDefined(Constants.WELCOME_FILE)) {
        for (final Property welcome : fullModel.get(Constants.WELCOME_FILE).asPropertyList()) {
            welcomeFiles.add(welcome.getName());
        }
    }
    // WFLY-2553 Adding default WildFly specific mechanisms here - subsequently we could enhance the servlet-container
    // config to override / add mechanisms.
    Map<String, AuthenticationMechanismFactory> authenticationMechanisms = new HashMap<>();
    authenticationMechanisms.put("SPNEGO", new NegotiationMechanismFactory());
    authenticationMechanisms.put(HttpServletRequest.DIGEST_AUTH, DigestAuthenticationMechanismFactory.FACTORY);
    final ServletContainerService container = new ServletContainerService(allowNonStandardWrappers, ServletStackTraces.valueOf(stackTracesString.toUpperCase().replace('-', '_')), config, jspConfig, defaultEncoding, useListenerEncoding, ignoreFlush, eagerFilterInit, sessionTimeout, disableCachingForSecuredPages, webSocketInfo != null, webSocketInfo != null && webSocketInfo.isDispatchToWorker(), webSocketInfo != null && webSocketInfo.isPerMessageDeflate(), webSocketInfo == null ? -1 : webSocketInfo.getDeflaterLevel(), mimeMappings, welcomeFiles, directoryListingEnabled, proactiveAuth, sessionIdLength, authenticationMechanisms, maxSessions, crawlerSessionManagerConfig, disableFileWatchService);
    final ServiceTarget target = context.getServiceTarget();
    final ServiceBuilder<ServletContainerService> builder = target.addService(UndertowService.SERVLET_CONTAINER.append(name), container);
    if (bufferCache != null) {
        builder.addDependency(BufferCacheService.SERVICE_NAME.append(bufferCache), DirectBufferCache.class, container.getBufferCacheInjectedValue());
    }
    if (persistentSessions) {
        builder.addDependency(AbstractPersistentSessionManager.SERVICE_NAME, SessionPersistenceManager.class, container.getSessionPersistenceManagerInjectedValue());
    }
    if (webSocketInfo != null) {
        builder.addDependency(IOServices.WORKER.append(webSocketInfo.getWorker()), XnioWorker.class, container.getWebsocketsWorker());
        builder.addDependency(IOServices.BUFFER_POOL.append(webSocketInfo.getBufferPool()), Pool.class, (InjectedValue) container.getWebsocketsBufferPool());
    }
    builder.setInitialMode(ServiceController.Mode.ON_DEMAND).install();
}
Also used : NegotiationMechanismFactory(org.jboss.security.negotiation.NegotiationMechanismFactory) HashMap(java.util.HashMap) ServiceTarget(org.jboss.msc.service.ServiceTarget) ArrayList(java.util.ArrayList) CrawlerSessionManagerConfig(io.undertow.servlet.api.CrawlerSessionManagerConfig) ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property) AuthenticationMechanismFactory(io.undertow.security.api.AuthenticationMechanismFactory) DigestAuthenticationMechanismFactory(org.wildfly.extension.undertow.security.digest.DigestAuthenticationMechanismFactory)

Aggregations

ServiceTarget (org.jboss.msc.service.ServiceTarget)108 ServiceName (org.jboss.msc.service.ServiceName)57 PathAddress (org.jboss.as.controller.PathAddress)30 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)26 ModelNode (org.jboss.dmr.ModelNode)26 Module (org.jboss.modules.Module)18 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)15 OperationFailedException (org.jboss.as.controller.OperationFailedException)12 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)11 ContextNames (org.jboss.as.naming.deployment.ContextNames)11 Resource (org.jboss.as.controller.registry.Resource)10 BinderService (org.jboss.as.naming.service.BinderService)10 AbstractDeploymentChainStep (org.jboss.as.server.AbstractDeploymentChainStep)10 DeploymentProcessorTarget (org.jboss.as.server.DeploymentProcessorTarget)10 PathElement (org.jboss.as.controller.PathElement)9 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)9 ServiceRegistry (org.jboss.msc.service.ServiceRegistry)9 ServiceController (org.jboss.msc.service.ServiceController)8 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5