Search in sources :

Example 1 with CapabilityServiceBuilder

use of org.jboss.as.controller.CapabilityServiceBuilder in project wildfly by wildfly.

the class HTTPUpgradeService method installService.

@SuppressWarnings("unchecked")
public static void installService(final CapabilityServiceTarget target, String activeMQServerName, final String acceptorName, final String httpListenerName) {
    final CapabilityServiceBuilder sb = target.addCapability(HTTPAcceptorDefinition.CAPABILITY);
    sb.provides(MessagingServices.getHttpUpgradeServiceName(activeMQServerName, acceptorName));
    Supplier<ChannelUpgradeHandler> upgradeSupplier = sb.requiresCapability(HTTP_UPGRADE_REGISTRY_CAPABILITY_NAME, ChannelUpgradeHandler.class, httpListenerName);
    Supplier<ListenerRegistry> listenerRegistrySupplier = sb.requiresCapability(HTTP_LISTENER_REGISTRY_CAPABILITY_NAME, ListenerRegistry.class);
    sb.requires(ActiveMQActivationService.getServiceName(MessagingServices.getActiveMQServiceName(activeMQServerName)));
    final HTTPUpgradeService service = new HTTPUpgradeService(activeMQServerName, acceptorName, httpListenerName, upgradeSupplier, listenerRegistrySupplier);
    sb.setInitialMode(ServiceController.Mode.PASSIVE);
    sb.setInstance(service);
    sb.install();
}
Also used : ListenerRegistry(io.undertow.server.ListenerRegistry) CapabilityServiceBuilder(org.jboss.as.controller.CapabilityServiceBuilder) ChannelUpgradeHandler(io.undertow.server.handlers.ChannelUpgradeHandler)

Example 2 with CapabilityServiceBuilder

use of org.jboss.as.controller.CapabilityServiceBuilder in project wildfly by wildfly.

the class JaegerTracerConfigurationAddHandler method performRuntime.

@Override
@SuppressWarnings("unchecked")
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
    super.performRuntime(context, operation, model);
    CapabilityServiceBuilder builder = context.getCapabilityServiceTarget().addCapability(TRACER_CAPABILITY);
    String outboundSocketBindingName = TracerAttributes.SENDER_BINDING.resolveModelAttribute(context, model).asStringOrNull();
    Supplier<OutboundSocketBinding> outboundSocketBindingSupplier;
    if (outboundSocketBindingName != null) {
        outboundSocketBindingSupplier = builder.requiresCapability(OUTBOUND_SOCKET_BINDING_CAPABILITY_NAME, OutboundSocketBinding.class, outboundSocketBindingName);
    } else {
        outboundSocketBindingSupplier = () -> null;
    }
    TracerConfiguration config = new JaegerTracerConfiguration(context, context.getCurrentAddressValue(), operation, outboundSocketBindingSupplier);
    Consumer<TracerConfiguration> injector = builder.provides(TRACER_CAPABILITY);
    builder.setInstance(new Service() {

        @Override
        public void start(StartContext context) {
            injector.accept(config);
            WildFlyTracerFactory.registerTracer(config.getName()).accept(config);
        }

        @Override
        public void stop(StopContext context) {
            WildFlyTracerFactory.registerTracer(config.getName()).accept(null);
        }
    });
    builder.setInitialMode(ON_DEMAND).install();
}
Also used : JaegerTracerConfiguration(org.wildfly.extension.microprofile.opentracing.resolver.JaegerTracerConfiguration) CapabilityServiceBuilder(org.jboss.as.controller.CapabilityServiceBuilder) StopContext(org.jboss.msc.service.StopContext) StartContext(org.jboss.msc.service.StartContext) OutboundSocketBinding(org.jboss.as.network.OutboundSocketBinding) TracerConfiguration(org.wildfly.microprofile.opentracing.smallrye.TracerConfiguration) JaegerTracerConfiguration(org.wildfly.extension.microprofile.opentracing.resolver.JaegerTracerConfiguration) Service(org.jboss.msc.Service)

Example 3 with CapabilityServiceBuilder

use of org.jboss.as.controller.CapabilityServiceBuilder 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;
    final boolean obfuscateSessionRoute = UndertowRootDefinition.OBFUSCATE_SESSION_ROUTE.resolveModelAttribute(context, model).asBoolean();
    // we clear provider on system boot, as on reload it could cause issues.
    DefaultDeploymentMappingProvider.instance().clear();
    final CapabilityServiceBuilder<?> csb = context.getCapabilityServiceTarget().addCapability(UndertowRootDefinition.UNDERTOW_CAPABILITY);
    final Consumer<UndertowService> usConsumer = csb.provides(UndertowRootDefinition.UNDERTOW_CAPABILITY, UndertowService.UNDERTOW);
    csb.setInstance(new UndertowService(usConsumer, defaultContainer, defaultServer, defaultVirtualHost, instanceId, obfuscateSessionRoute, stats));
    csb.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());
            JBossAllXmlParserRegisteringProcessor.Builder builder = JBossAllXmlParserRegisteringProcessor.builder();
            for (SharedSessionConfigSchema schema : EnumSet.allOf(SharedSessionConfigSchema.class)) {
                builder.addParser(schema.getRoot(), SharedSessionManagerConfig.ATTACHMENT_KEY, new SharedSessionConfigParser(schema));
            }
            processorTarget.addDeploymentProcessor(UndertowExtension.SUBSYSTEM_NAME, Phase.STRUCTURE, Phase.STRUCTURE_REGISTER_JBOSS_ALL_UNDERTOW_SHARED_SESSION, builder.build());
            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());
            processorTarget.addDeploymentProcessor(UndertowExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_TLD_DEPLOYMENT, new TldParsingDeploymentProcessor());
            processorTarget.addDeploymentProcessor(UndertowExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_WEB_COMPONENTS, new org.wildfly.extension.undertow.deployment.WebComponentProcessor());
            processorTarget.addDeploymentProcessor(UndertowExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_UNDERTOW_DEFAULT_SECURITY_DOMAIN, new DefaultSecurityDomainProcessor(defaultSecurityDomain));
            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());
            processorTarget.addDeploymentProcessor(UndertowExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EXTERNAL_TAGLIB, new ExternalTldParsingDeploymentProcessor());
            processorTarget.addDeploymentProcessor(UndertowExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_UNDERTOW_SERVLET_CONTAINER_DEPENDENCY, new UndertowServletContainerDependencyProcessor(defaultContainer));
            processorTarget.addDeploymentProcessor(UndertowExtension.SUBSYSTEM_NAME, Phase.INSTALL, Phase.INSTALL_SHARED_SESSION_MANAGER, new SharedSessionManagerDeploymentProcessor(defaultServer));
            processorTarget.addDeploymentProcessor(UndertowExtension.SUBSYSTEM_NAME, Phase.INSTALL, Phase.INSTALL_SERVLET_INIT_DEPLOYMENT, new ServletContainerInitializerDeploymentProcessor());
            processorTarget.addDeploymentProcessor(UndertowExtension.SUBSYSTEM_NAME, Phase.INSTALL, Phase.INSTALL_WEB_RESOLVE_SECURITY_DOMAIN, new SecurityDomainResolvingProcessor(defaultSecurityDomain, knownSecurityDomain));
            processorTarget.addDeploymentProcessor(UndertowExtension.SUBSYSTEM_NAME, Phase.INSTALL, Phase.INSTALL_WAR_DEPLOYMENT, new UndertowDeploymentProcessor(defaultVirtualHost, defaultContainer, defaultServer, knownSecurityDomain));
        }
    }, OperationContext.Stage.RUNTIME);
    context.getCapabilityServiceTarget().addCapability(HTTP_INVOKER_RUNTIME_CAPABILITY).setInstance(new RemoteHttpInvokerService()).install();
}
Also used : UndertowHandlersDeploymentProcessor(org.wildfly.extension.undertow.deployment.UndertowHandlersDeploymentProcessor) SecurityDomainResolvingProcessor(org.wildfly.extension.undertow.deployment.SecurityDomainResolvingProcessor) SharedTldsMetaDataBuilder(org.jboss.as.web.common.SharedTldsMetaDataBuilder) CapabilityServiceBuilder(org.jboss.as.controller.CapabilityServiceBuilder) WebJBossAllParser(org.wildfly.extension.undertow.deployment.WebJBossAllParser) UndertowDeploymentProcessor(org.wildfly.extension.undertow.deployment.UndertowDeploymentProcessor) UndertowServletContainerDependencyProcessor(org.wildfly.extension.undertow.deployment.UndertowServletContainerDependencyProcessor) ServletContainerInitializerDeploymentProcessor(org.wildfly.extension.undertow.deployment.ServletContainerInitializerDeploymentProcessor) DefaultSecurityDomainProcessor(org.wildfly.extension.undertow.deployment.DefaultSecurityDomainProcessor) 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) SharedSessionConfigParser(org.wildfly.extension.undertow.session.SharedSessionConfigParser) WarStructureDeploymentProcessor(org.wildfly.extension.undertow.deployment.WarStructureDeploymentProcessor) JBossAllXmlParserRegisteringProcessor(org.jboss.as.server.deployment.jbossallxml.JBossAllXmlParserRegisteringProcessor) EarContextRootProcessor(org.wildfly.extension.undertow.deployment.EarContextRootProcessor) 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) SharedSessionConfigSchema(org.wildfly.extension.undertow.session.SharedSessionConfigSchema)

Example 4 with CapabilityServiceBuilder

use of org.jboss.as.controller.CapabilityServiceBuilder in project wildfly by wildfly.

the class EJB3RemoteServiceAdd method installRuntimeServices.

void installRuntimeServices(final OperationContext context, final ModelNode model) throws OperationFailedException {
    final String clientMappingsClusterName = EJB3RemoteResourceDefinition.CLIENT_MAPPINGS_CLUSTER_NAME.resolveModelAttribute(context, model).asString();
    final List<ModelNode> connectorNameNodes = EJB3RemoteResourceDefinition.CONNECTORS.resolveModelAttribute(context, model).asList();
    final String threadPoolName = EJB3RemoteResourceDefinition.THREAD_POOL_NAME.resolveModelAttribute(context, model).asString();
    final boolean executeInWorker = EJB3RemoteResourceDefinition.EXECUTE_IN_WORKER.resolveModelAttribute(context, model).asBoolean();
    final ServiceTarget target = context.getServiceTarget();
    // for each connector specified, we need to set up a client-mappings cache
    for (ModelNode connectorNameNode : connectorNameNodes) {
        String connectorName = connectorNameNode.asString();
        // Install the client-mapping service for the remoting connector
        ServiceConfigurator clientMappingsEntryProviderConfigurator = new EJBRemotingConnectorClientMappingsEntryProviderService(clientMappingsClusterName, connectorName).configure(context);
        clientMappingsEntryProviderConfigurator.build(target).setInitialMode(ServiceController.Mode.ON_DEMAND).install();
        if (this.provider != null) {
            // Install the registry for the remoting connector's client mappings
            SupplierDependency<Map.Entry<String, List<ClientMapping>>> registryEntryDependency = new ServiceSupplierDependency<>(clientMappingsEntryProviderConfigurator.getServiceName());
            for (CapabilityServiceConfigurator configurator : this.provider.getServiceConfigurators(clientMappingsClusterName, connectorName, new FunctionSupplierDependency<>(registryEntryDependency, Map.Entry::getValue))) {
                configurator.configure(context).build(target).install();
            }
        }
    }
    final OptionMap channelCreationOptions = this.getChannelCreationOptions(context);
    // Install the Jakarta Enterprise Beans remoting connector service which will listen for client connections on the remoting channel
    // TODO: Externalize (expose via management API if needed) the version and the marshalling strategy
    final EJBRemoteConnectorService ejbRemoteConnectorService = new EJBRemoteConnectorService(channelCreationOptions, FilterSpecClassResolverFilter.getFilterForOperationContext(context));
    CapabilityServiceBuilder<?> builder = (CapabilityServiceBuilder<?>) context.getCapabilityServiceTarget().addCapability(EJB3RemoteResourceDefinition.EJB_REMOTE_CAPABILITY).setInstance(ejbRemoteConnectorService).addCapabilityRequirement(EJB3RemoteResourceDefinition.REMOTING_ENDPOINT_CAPABILITY_NAME, Endpoint.class, ejbRemoteConnectorService.getEndpointInjector());
    if (!executeInWorker) {
        builder.addCapabilityRequirement(EJB3RemoteResourceDefinition.THREAD_POOL_CAPABILITY_NAME, ExecutorService.class, ejbRemoteConnectorService.getExecutorService(), threadPoolName);
    }
    // add rest of the dependencies
    builder.addDependency(AssociationService.SERVICE_NAME, AssociationService.class, ejbRemoteConnectorService.getAssociationServiceInjector()).addCapabilityRequirement(EJB3RemoteResourceDefinition.REMOTE_TRANSACTION_SERVICE_CAPABILITY_NAME, RemotingTransactionService.class, ejbRemoteConnectorService.getRemotingTransactionServiceInjector()).addAliases(EJBRemoteConnectorService.SERVICE_NAME).setInitialMode(ServiceController.Mode.LAZY).install();
}
Also used : CapabilityServiceConfigurator(org.jboss.as.clustering.controller.CapabilityServiceConfigurator) EJBRemotingConnectorClientMappingsEntryProviderService(org.jboss.as.ejb3.remote.EJBRemotingConnectorClientMappingsEntryProviderService) ServiceTarget(org.jboss.msc.service.ServiceTarget) ServiceSupplierDependency(org.wildfly.clustering.service.ServiceSupplierDependency) RemotingTransactionService(org.wildfly.transaction.client.provider.remoting.RemotingTransactionService) CapabilityServiceBuilder(org.jboss.as.controller.CapabilityServiceBuilder) Endpoint(org.jboss.remoting3.Endpoint) EJBRemoteConnectorService(org.jboss.as.ejb3.remote.EJBRemoteConnectorService) OptionMap(org.xnio.OptionMap) ClientMapping(org.jboss.as.network.ClientMapping) ModelNode(org.jboss.dmr.ModelNode) OptionMap(org.xnio.OptionMap) Map(java.util.Map) ServiceConfigurator(org.wildfly.clustering.service.ServiceConfigurator) CapabilityServiceConfigurator(org.jboss.as.clustering.controller.CapabilityServiceConfigurator)

Example 5 with CapabilityServiceBuilder

use of org.jboss.as.controller.CapabilityServiceBuilder in project wildfly by wildfly.

the class RemotingProfileAdd method installServices.

protected void installServices(final OperationContext context, final PathAddress address, final ModelNode profileNode) throws OperationFailedException {
    try {
        final ModelNode staticEjbDiscoery = StaticEJBDiscoveryDefinition.INSTANCE.resolveModelAttribute(context, profileNode);
        List<StaticEJBDiscoveryDefinition.StaticEjbDiscovery> discoveryList = StaticEJBDiscoveryDefinition.createStaticEjbList(context, staticEjbDiscoery);
        final List<ServiceURL> urls = new ArrayList<>();
        for (StaticEJBDiscoveryDefinition.StaticEjbDiscovery resource : discoveryList) {
            ServiceURL.Builder builder = new ServiceURL.Builder();
            builder.setAbstractType("ejb").setAbstractTypeAuthority("jboss").setUri(new URI(resource.getUrl()));
            String distinctName = resource.getDistinct() == null ? "" : resource.getDistinct();
            String appName = resource.getApp() == null ? "" : resource.getApp();
            String moduleName = resource.getModule();
            if (distinctName.isEmpty()) {
                if (appName.isEmpty()) {
                    builder.addAttribute(EJBClientContext.FILTER_ATTR_EJB_MODULE, AttributeValue.fromString(moduleName));
                } else {
                    builder.addAttribute(EJBClientContext.FILTER_ATTR_EJB_MODULE, AttributeValue.fromString(appName + "/" + moduleName));
                }
            } else {
                if (appName.isEmpty()) {
                    builder.addAttribute(EJBClientContext.FILTER_ATTR_EJB_MODULE_DISTINCT, AttributeValue.fromString(moduleName + "/" + distinctName));
                } else {
                    builder.addAttribute(EJBClientContext.FILTER_ATTR_EJB_MODULE_DISTINCT, AttributeValue.fromString(appName + "/" + moduleName + "/" + distinctName));
                }
            }
            urls.add(builder.create());
        }
        final Map<String, RemotingProfileService.RemotingConnectionSpec> map = new HashMap<>();
        final List<RemotingProfileService.HttpConnectionSpec> httpConnectionSpecs = new ArrayList<>();
        final RemotingProfileService profileService = new RemotingProfileService(urls, map, httpConnectionSpecs);
        // populating the map after the fact is cheating, but it works thanks to the MSC start service "fence"
        final CapabilityServiceBuilder capabilityServiceBuilder = context.getCapabilityServiceTarget().addCapability(RemotingProfileResourceDefinition.REMOTING_PROFILE_CAPABILITY, profileService);
        if (profileNode.hasDefined(EJB3SubsystemModel.REMOTING_EJB_RECEIVER)) {
            for (final Property receiverProperty : profileNode.get(EJB3SubsystemModel.REMOTING_EJB_RECEIVER).asPropertyList()) {
                final ModelNode receiverNode = receiverProperty.getValue();
                final String connectionRef = RemotingEjbReceiverDefinition.OUTBOUND_CONNECTION_REF.resolveModelAttribute(context, receiverNode).asString();
                final long timeout = RemotingEjbReceiverDefinition.CONNECT_TIMEOUT.resolveModelAttribute(context, receiverNode).asLong();
                final InjectedValue<OutboundConnection> connectionInjector = new InjectedValue<>();
                capabilityServiceBuilder.addCapabilityRequirement(OUTBOUND_CONNECTION_CAPABILITY_NAME, OutboundConnection.class, connectionInjector, connectionRef);
                final ModelNode channelCreationOptionsNode = receiverNode.get(EJB3SubsystemModel.CHANNEL_CREATION_OPTIONS);
                OptionMap channelCreationOptions = createChannelOptionMap(context, channelCreationOptionsNode);
                map.put(connectionRef, new RemotingProfileService.RemotingConnectionSpec(connectionRef, connectionInjector, channelCreationOptions, timeout));
            }
        }
        final boolean isLocalReceiverExcluded = RemotingProfileResourceDefinition.EXCLUDE_LOCAL_RECEIVER.resolveModelAttribute(context, profileNode).asBoolean();
        if (profileNode.hasDefined(EJB3SubsystemModel.REMOTE_HTTP_CONNECTION)) {
            for (final Property receiverProperty : profileNode.get(EJB3SubsystemModel.REMOTE_HTTP_CONNECTION).asPropertyList()) {
                final ModelNode receiverNode = receiverProperty.getValue();
                final String uri = RemoteHttpConnectionDefinition.URI.resolveModelAttribute(context, receiverNode).asString();
                httpConnectionSpecs.add(new RemotingProfileService.HttpConnectionSpec(uri));
            }
        }
        // if the local receiver is enabled for this context, then add a dependency on the appropriate LocalEjbReceive service
        if (!isLocalReceiverExcluded) {
            final ModelNode passByValueNode = RemotingProfileResourceDefinition.LOCAL_RECEIVER_PASS_BY_VALUE.resolveModelAttribute(context, profileNode);
            if (passByValueNode.isDefined()) {
                final ServiceName localTransportProviderServiceName = passByValueNode.asBoolean() == true ? LocalTransportProvider.BY_VALUE_SERVICE_NAME : LocalTransportProvider.BY_REFERENCE_SERVICE_NAME;
                capabilityServiceBuilder.addDependency(localTransportProviderServiceName, EJBTransportProvider.class, profileService.getLocalTransportProviderInjector());
            } else {
                // setup a dependency on the default local Jakarta Enterprise Beans receiver service configured at the subsystem level
                capabilityServiceBuilder.addDependency(LocalTransportProvider.DEFAULT_LOCAL_TRANSPORT_PROVIDER_SERVICE_NAME, EJBTransportProvider.class, profileService.getLocalTransportProviderInjector());
            }
        }
        capabilityServiceBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();
    } catch (IllegalArgumentException | URISyntaxException e) {
        throw new OperationFailedException(e.getLocalizedMessage());
    }
}
Also used : InjectedValue(org.jboss.msc.value.InjectedValue) OutboundConnection(org.jboss.as.network.OutboundConnection) HashMap(java.util.HashMap) CapabilityServiceBuilder(org.jboss.as.controller.CapabilityServiceBuilder) ArrayList(java.util.ArrayList) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) ServiceURL(org.wildfly.discovery.ServiceURL) RemotingProfileService(org.jboss.as.ejb3.remote.RemotingProfileService) Property(org.jboss.dmr.Property) OperationFailedException(org.jboss.as.controller.OperationFailedException) CapabilityServiceBuilder(org.jboss.as.controller.CapabilityServiceBuilder) ServiceName(org.jboss.msc.service.ServiceName) OptionMap(org.xnio.OptionMap) ModelNode(org.jboss.dmr.ModelNode)

Aggregations

CapabilityServiceBuilder (org.jboss.as.controller.CapabilityServiceBuilder)10 ModelNode (org.jboss.dmr.ModelNode)6 TimeUnit (java.util.concurrent.TimeUnit)2 AbstractManagedExecutorService (org.glassfish.enterprise.concurrent.AbstractManagedExecutorService)2 ManagedExecutorHungTasksPeriodicTerminationService (org.jboss.as.ee.concurrent.service.ManagedExecutorHungTasksPeriodicTerminationService)2 OptionMap (org.xnio.OptionMap)2 ListenerRegistry (io.undertow.server.ListenerRegistry)1 ChannelUpgradeHandler (io.undertow.server.handlers.ChannelUpgradeHandler)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 CapabilityServiceConfigurator (org.jboss.as.clustering.controller.CapabilityServiceConfigurator)1 CapabilityServiceTarget (org.jboss.as.controller.CapabilityServiceTarget)1 OperationFailedException (org.jboss.as.controller.OperationFailedException)1 DefaultContextSetupProviderImpl (org.jboss.as.ee.concurrent.DefaultContextSetupProviderImpl)1 ContextServiceService (org.jboss.as.ee.concurrent.service.ContextServiceService)1 ManagedExecutorServiceService (org.jboss.as.ee.concurrent.service.ManagedExecutorServiceService)1 ManagedScheduledExecutorServiceService (org.jboss.as.ee.concurrent.service.ManagedScheduledExecutorServiceService)1