void updatePoolService(final OperationContext context, final ModelNode model)
      throws OperationFailedException {

    final ModelNode poolName = poolAttribute.resolveModelAttribute(context, model);

    final ServiceRegistry serviceRegistry = context.getServiceRegistry(true);
    ServiceController existingDefaultPoolConfigService =
        serviceRegistry.getService(poolConfigServiceName);
    // if a default MDB pool is already installed, then remove it first
    if (existingDefaultPoolConfigService != null) {
      context.removeService(existingDefaultPoolConfigService);
    }

    if (poolName.isDefined()) {
      // now install default pool config service which points to an existing pool config service
      final ValueInjectionService<PoolConfig> newDefaultPoolConfigService =
          new ValueInjectionService<PoolConfig>();
      ServiceController<?> newController =
          context
              .getServiceTarget()
              .addService(poolConfigServiceName, newDefaultPoolConfigService)
              .addDependency(
                  PoolConfigService.EJB_POOL_CONFIG_BASE_SERVICE_NAME.append(poolName.asString()),
                  PoolConfig.class,
                  newDefaultPoolConfigService.getInjector())
              .install();
    }
  }
 @Override
 public void configureDependency(ServiceBuilder<?> serviceBuilder, Service<Component> service)
     throws DeploymentUnitProcessingException {
   final StatelessSessionComponentCreateService statelessSessionComponentService =
       (StatelessSessionComponentCreateService) service;
   final String poolName = this.statelessComponentDescription.getPoolConfigName();
   // if no pool name has been explicitly set, then inject the optional "default slsb pool
   // config"
   if (poolName == null) {
     serviceBuilder.addDependency(
         ServiceBuilder.DependencyType.OPTIONAL,
         PoolConfigService.DEFAULT_SLSB_POOL_CONFIG_SERVICE_NAME,
         PoolConfig.class,
         statelessSessionComponentService.getPoolConfigInjector());
   } else {
     // pool name has been explicitly set so the pool config is a required dependency
     serviceBuilder.addDependency(
         PoolConfigService.EJB_POOL_CONFIG_BASE_SERVICE_NAME.append(poolName),
         PoolConfig.class,
         statelessSessionComponentService.getPoolConfigInjector());
   }
 }