Search in sources :

Example 1 with RegistryInstallerService

use of org.jboss.as.ejb3.remote.RegistryInstallerService 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 String connectorName = EJB3RemoteResourceDefinition.CONNECTOR_REF.resolveModelAttribute(context, model).asString();
    final ServiceName remotingServerInfoServiceName = RemotingConnectorBindingInfoService.serviceName(connectorName);
    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();
    // Install the client-mapping service for the remoting connector
    new EJBRemotingConnectorClientMappingsEntryProviderService(clientMappingsClusterName, remotingServerInfoServiceName).configure(context).build(target).setInitialMode(ServiceController.Mode.ON_DEMAND).install();
    new RegistryInstallerService(clientMappingsClusterName).configure(context).build(target).setInitialMode(ServiceController.Mode.ON_DEMAND).install();
    // Handle case where no infinispan subsystem exists or does not define an ejb cache-container
    Resource rootResource = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS);
    PathElement infinispanPath = PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, "infinispan");
    if (!rootResource.hasChild(infinispanPath) || !rootResource.getChild(infinispanPath).hasChild(PathElement.pathElement("cache-container", clientMappingsClusterName))) {
        // Install services that would normally be installed by this container/cache
        CapabilityServiceSupport support = context.getCapabilityServiceSupport();
        for (GroupBuilderProvider provider : ServiceLoader.load(LocalGroupBuilderProvider.class, LocalGroupBuilderProvider.class.getClassLoader())) {
            for (CapabilityServiceBuilder<?> builder : provider.getBuilders(requirement -> requirement.getServiceName(support, clientMappingsClusterName), clientMappingsClusterName)) {
                builder.configure(support).build(target).install();
            }
        }
        for (CacheBuilderProvider provider : ServiceLoader.load(LocalCacheBuilderProvider.class, LocalCacheBuilderProvider.class.getClassLoader())) {
            for (CapabilityServiceBuilder<?> builder : provider.getBuilders(requirement -> requirement.getServiceName(support, clientMappingsClusterName, null), clientMappingsClusterName, null)) {
                builder.configure(support).build(target).install();
            }
        }
    }
    final OptionMap channelCreationOptions = this.getChannelCreationOptions(context);
    // Install the EJB 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);
    ServiceBuilder<EJBRemoteConnectorService> builder = target.addService(EJBRemoteConnectorService.SERVICE_NAME, ejbRemoteConnectorService);
    builder.addDependency(RemotingServices.SUBSYSTEM_ENDPOINT, Endpoint.class, ejbRemoteConnectorService.getEndpointInjector()).addDependency(remotingServerInfoServiceName, RemotingConnectorBindingInfoService.RemotingConnectorInfo.class, ejbRemoteConnectorService.getRemotingConnectorInfoInjectedValue()).addDependency(AssociationService.SERVICE_NAME, AssociationService.class, ejbRemoteConnectorService.getAssociationServiceInjector()).addDependency(TxnServices.JBOSS_TXN_REMOTE_TRANSACTION_SERVICE, RemotingTransactionService.class, ejbRemoteConnectorService.getRemotingTransactionServiceInjector()).addDependency(ControlledProcessStateService.SERVICE_NAME, ControlledProcessStateService.class, ejbRemoteConnectorService.getControlledProcessStateServiceInjector()).setInitialMode(ServiceController.Mode.ACTIVE);
    if (!executeInWorker) {
        builder.addDependency(EJB3SubsystemModel.BASE_THREAD_POOL_SERVICE_NAME.append(threadPoolName), ExecutorService.class, ejbRemoteConnectorService.getExecutorService());
    }
    builder.install();
}
Also used : LocalCacheBuilderProvider(org.wildfly.clustering.spi.LocalCacheBuilderProvider) CacheBuilderProvider(org.wildfly.clustering.spi.CacheBuilderProvider) ControlledProcessStateService(org.jboss.as.controller.ControlledProcessStateService) EJBRemotingConnectorClientMappingsEntryProviderService(org.jboss.as.ejb3.remote.EJBRemotingConnectorClientMappingsEntryProviderService) ServiceTarget(org.jboss.msc.service.ServiceTarget) RegistryInstallerService(org.jboss.as.ejb3.remote.RegistryInstallerService) RemotingConnectorBindingInfoService(org.jboss.as.remoting.RemotingConnectorBindingInfoService) Resource(org.jboss.as.controller.registry.Resource) AssociationService(org.jboss.as.ejb3.remote.AssociationService) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport) PathElement(org.jboss.as.controller.PathElement) Endpoint(org.jboss.remoting3.Endpoint) ServiceName(org.jboss.msc.service.ServiceName) EJBRemoteConnectorService(org.jboss.as.ejb3.remote.EJBRemoteConnectorService) GroupBuilderProvider(org.wildfly.clustering.spi.GroupBuilderProvider) LocalGroupBuilderProvider(org.wildfly.clustering.spi.LocalGroupBuilderProvider) OptionMap(org.xnio.OptionMap) LocalCacheBuilderProvider(org.wildfly.clustering.spi.LocalCacheBuilderProvider) LocalGroupBuilderProvider(org.wildfly.clustering.spi.LocalGroupBuilderProvider)

Aggregations

ControlledProcessStateService (org.jboss.as.controller.ControlledProcessStateService)1 PathElement (org.jboss.as.controller.PathElement)1 CapabilityServiceSupport (org.jboss.as.controller.capability.CapabilityServiceSupport)1 Resource (org.jboss.as.controller.registry.Resource)1 AssociationService (org.jboss.as.ejb3.remote.AssociationService)1 EJBRemoteConnectorService (org.jboss.as.ejb3.remote.EJBRemoteConnectorService)1 EJBRemotingConnectorClientMappingsEntryProviderService (org.jboss.as.ejb3.remote.EJBRemotingConnectorClientMappingsEntryProviderService)1 RegistryInstallerService (org.jboss.as.ejb3.remote.RegistryInstallerService)1 RemotingConnectorBindingInfoService (org.jboss.as.remoting.RemotingConnectorBindingInfoService)1 ServiceName (org.jboss.msc.service.ServiceName)1 ServiceTarget (org.jboss.msc.service.ServiceTarget)1 Endpoint (org.jboss.remoting3.Endpoint)1 CacheBuilderProvider (org.wildfly.clustering.spi.CacheBuilderProvider)1 GroupBuilderProvider (org.wildfly.clustering.spi.GroupBuilderProvider)1 LocalCacheBuilderProvider (org.wildfly.clustering.spi.LocalCacheBuilderProvider)1 LocalGroupBuilderProvider (org.wildfly.clustering.spi.LocalGroupBuilderProvider)1 OptionMap (org.xnio.OptionMap)1