Collection<ServiceController<?>> installChannelServices(
      ServiceTarget target,
      String containerName,
      String cluster,
      String stack,
      ServiceVerificationHandler verificationHandler) {

    ServiceName name = ChannelService.getServiceName(containerName);
    ContextNames.BindInfo bindInfo = createChannelBinding(containerName);
    BinderService binder = new BinderService(bindInfo.getBindName());
    ServiceController<?> binderService =
        target
            .addService(bindInfo.getBinderServiceName(), binder)
            .addAliases(ContextNames.JAVA_CONTEXT_SERVICE_NAME.append(bindInfo.getBindName()))
            .addDependency(
                name,
                Channel.class,
                new ManagedReferenceInjector<Channel>(binder.getManagedObjectInjector()))
            .addDependency(
                bindInfo.getParentContextServiceName(),
                ServiceBasedNamingStore.class,
                binder.getNamingStoreInjector())
            .setInitialMode(ServiceController.Mode.PASSIVE)
            .install();

    InjectedValue<ChannelFactory> channelFactory = new InjectedValue<>();
    ServiceController<?> channelService =
        AsynchronousService.addService(target, name, new ChannelService(cluster, channelFactory))
            .addDependency(
                ChannelFactoryService.getServiceName(stack), ChannelFactory.class, channelFactory)
            .setInitialMode(ServiceController.Mode.ON_DEMAND)
            .install();

    return Arrays.asList(binderService, channelService);
  }
 ServiceController<?> installKeyAffinityServiceFactoryService(
     ServiceTarget target, String containerName, ServiceVerificationHandler verificationHandler) {
   return AsynchronousService.addService(
           target,
           KeyAffinityServiceFactoryService.getServiceName(containerName),
           new KeyAffinityServiceFactoryService(10),
           false,
           true)
       .setInitialMode(ServiceController.Mode.ON_DEMAND)
       .install();
 }
Esempio n. 3
0
  ServiceController<?> installCacheService(
      ServiceTarget target,
      String containerName,
      String cacheName,
      String defaultCache,
      ServiceController.Mode initialMode,
      Configuration config,
      ServiceVerificationHandler verificationHandler) {

    final InjectedValue<EmbeddedCacheManager> container = new InjectedValue<EmbeddedCacheManager>();
    final CacheDependencies cacheDependencies = new CacheDependencies(container);
    final Service<Cache<Object, Object>> service =
        new CacheService<Object, Object>(cacheName, cacheDependencies);
    final ServiceBuilder<?> builder =
        AsynchronousService.addService(
                target, CacheService.getServiceName(containerName, cacheName), service)
            .addDependency(CacheConfigurationService.getServiceName(containerName, cacheName))
            .addDependency(
                EmbeddedCacheManagerService.getServiceName(containerName),
                EmbeddedCacheManager.class,
                container)
            .addDependency(
                config.clustering().cacheMode().isClustered()
                    ? DependencyType.REQUIRED
                    : DependencyType.OPTIONAL,
                ChannelService.getServiceName(containerName))
            .setInitialMode(initialMode);
    if (config.transaction().recovery().enabled()) {
      builder.addDependency(
          TxnServices.JBOSS_TXN_ARJUNA_RECOVERY_MANAGER,
          XAResourceRecoveryRegistry.class,
          cacheDependencies.getRecoveryRegistryInjector());
    }

    // add an alias for the default cache
    if (cacheName.equals(defaultCache)) {
      builder.addAliases(CacheService.getServiceName(containerName, null));
    }

    if (initialMode == ServiceController.Mode.ACTIVE) {
      builder.addListener(verificationHandler);
    }

    return builder.install();
  }
 ServiceController<?> installGlobalComponentRegistryService(
     ServiceTarget target,
     String containerName,
     Transport transport,
     ServiceVerificationHandler verificationHandler) {
   InjectedValue<CacheContainer> container = new InjectedValue<>();
   ServiceBuilder<?> builder =
       AsynchronousService.addService(
               target,
               GlobalComponentRegistryService.getServiceName(containerName),
               new GlobalComponentRegistryService(container))
           .addDependency(
               EmbeddedCacheManagerService.getServiceName(containerName),
               CacheContainer.class,
               container)
           .setInitialMode(ServiceController.Mode.ON_DEMAND);
   if (transport != null) {
     builder.addDependency(ChannelService.getServiceName(containerName));
   }
   return builder.install();
 }