Пример #1
0
 @Override
 protected void performRuntime(
     final OperationContext context, final ModelNode operation, final ModelNode model)
     throws OperationFailedException {
   final ServerConfig config = getServerConfig(context);
   if (config != null) {
     final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
     final PathElement confElem = address.getElement(address.size() - 2);
     final String configType = confElem.getKey();
     final String configName = confElem.getValue();
     final String handlerChainType = address.getElement(address.size() - 1).getKey();
     final String handlerChainId = address.getElement(address.size() - 1).getValue();
     for (final CommonConfig commonConfig : getConfigs(config, configType)) {
       if (configName.equals(commonConfig.getConfigName())) {
         final List<UnifiedHandlerChainMetaData> handlerChains;
         if (PRE_HANDLER_CHAIN.equals(handlerChainType)) {
           handlerChains = commonConfig.getPreHandlerChains();
         } else if (POST_HANDLER_CHAIN.equals(handlerChainType)) {
           handlerChains = commonConfig.getPostHandlerChains();
         } else {
           throw MESSAGES.wrongHandlerChainType(
               handlerChainType, PRE_HANDLER_CHAIN, POST_HANDLER_CHAIN);
         }
         final UnifiedHandlerChainMetaData handlerChain = getChain(handlerChains, handlerChainId);
         if (handlerChain == null) {
           throw MESSAGES.missingHandlerChain(configName, handlerChainType, handlerChainId);
         }
         handlerChains.remove(handlerChain);
         context.reloadRequired();
         return;
       }
     }
     throw MESSAGES.missingConfig(configName);
   }
 }
Пример #2
0
  @Override
  protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model)
      throws OperationFailedException {

    ServiceRegistry registry = context.getServiceRegistry(false);
    final ServiceName serviceName =
        MessagingServices.getActiveMQServiceName(
            PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
    ServiceController<?> service = registry.getService(serviceName);
    if (service != null) {
      context.reloadRequired();
    } else {
      final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
      final String name = address.getLastElement().getValue();

      final ServiceTarget target = context.getServiceTarget();
      if (model.hasDefined(JGROUPS_CHANNEL.getName())) {
        // nothing to do, in that case, the clustering.jgroups subsystem will have setup the stack
      } else if (model.hasDefined(RemoteTransportDefinition.SOCKET_BINDING.getName())) {
        final GroupBindingService bindingService = new GroupBindingService();
        target
            .addService(
                GroupBindingService.getBroadcastBaseServiceName(serviceName).append(name),
                bindingService)
            .addDependency(
                SocketBinding.JBOSS_BINDING_NAME.append(model.get(SOCKET_BINDING).asString()),
                SocketBinding.class,
                bindingService.getBindingRef())
            .install();
      }
    }
  }
Пример #3
0
 @Override
 protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model)
     throws OperationFailedException {
   if (context.isResourceServiceRestartAllowed()) {
     removeRuntimeService(context, operation);
   } else {
     context.reloadRequired();
   }
 }
 protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) {
   if (isRemoveService(context)) {
     // Since so many things can depend on this, only remove if the user set the
     // ALLOW_RESOURCE_SERVICE_RESTART operation header
     context.removeService(MBeanServerService.SERVICE_NAME);
   } else {
     context.reloadRequired();
   }
 }
Пример #5
0
  @Override
  protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model)
      throws OperationFailedException {

    final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
    final String name = address.getLastElement().getValue();

    context.removeService(WSServices.CLIENT_CONFIG_SERVICE.append(name));
    context.reloadRequired();
  }
Пример #6
0
  @Override
  protected void performRuntime(
      OperationContext context,
      ModelNode operation,
      ModelNode model,
      ServiceVerificationHandler verificationHandler,
      List<ServiceController<?>> newControllers)
      throws OperationFailedException {

    ServiceRegistry registry = context.getServiceRegistry(false);
    final ServiceName hqServiceName =
        MessagingServices.getHornetQServiceName(
            PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
    ServiceController<?> hqService = registry.getService(hqServiceName);
    if (hqService != null) {
      context.reloadRequired();
    }
    // else MessagingSubsystemAdd will add a handler that calls addConnectorServiceConfigs
  }
 @Override
 public void execute(final OperationContext context, final ModelNode operation)
     throws OperationFailedException {
   final Resource resource = context.readResourceForUpdate(PathAddress.EMPTY_ADDRESS);
   final ModelNode model = resource.getModel();
   final String name = operation.require(ModelDescriptionConstants.NAME).asString();
   final AttributeDefinition def = ATTRIBUTES.get(name);
   if (def == null) {
     throw new OperationFailedException(new ModelNode().set(MESSAGES.unknownAttribute(name)));
   }
   final ModelNode value = operation.get(ModelDescriptionConstants.VALUE);
   def.getValidator().validateParameter(name, value);
   model.get(name).set(value);
   context.reloadRequired();
   // Verify the model in a later step
   context.addStep(VERIFY_HANDLER, OperationContext.Stage.VERIFY);
   if (context.completeStep() != OperationContext.ResultAction.KEEP) {
     context.revertReloadRequired();
   }
 }
Пример #8
0
  static void launchServices(
      final OperationContext context,
      final PathAddress pathAddress,
      final ModelNode model,
      final ServiceVerificationHandler verificationHandler,
      final List<ServiceController<?>> newControllers)
      throws OperationFailedException {
    Handler newHandler = new Handler();

    ModelNode classNameNode = HandlerResourceDefinition.CLASS.resolveModelAttribute(context, model);
    ModelNode codeNode = HandlerResourceDefinition.CODE.resolveModelAttribute(context, model);
    String typeName;

    if (classNameNode.isDefined()) {
      typeName = classNameNode.asString();
    } else if (codeNode.isDefined()) {
      typeName = HandlerTypeEnum.forType(codeNode.asString());
    } else {
      throw PicketLinkLogger.ROOT_LOGGER.federationHandlerTypeNotProvided();
    }

    newHandler.setClazz(typeName);

    ModelNode handler = Resource.Tools.readModel(context.readResourceFromRoot(pathAddress));

    if (handler.hasDefined(COMMON_HANDLER_PARAMETER.getName())) {
      for (Property handlerParameter :
          handler.get(COMMON_HANDLER_PARAMETER.getName()).asPropertyList()) {
        String paramName = handlerParameter.getName();
        String paramValue =
            HandlerParameterResourceDefinition.VALUE
                .resolveModelAttribute(context, handlerParameter.getValue())
                .asString();

        KeyValueType kv = new KeyValueType();

        kv.setKey(paramName);
        kv.setValue(paramValue);

        newHandler.add(kv);
      }
    }

    SAMLHandlerService service = new SAMLHandlerService(newHandler);
    PathElement providerAlias = pathAddress.subAddress(0, pathAddress.size() - 1).getLastElement();

    ServiceTarget serviceTarget = context.getServiceTarget();
    ServiceBuilder<SAMLHandlerService> serviceBuilder =
        serviceTarget.addService(
            createServiceName(providerAlias.getValue(), newHandler.getClazz()), service);
    ServiceName serviceName;

    if (providerAlias.getKey().equals(IDENTITY_PROVIDER.getName())) {
      serviceName = IdentityProviderService.createServiceName(providerAlias.getValue());
    } else {
      serviceName = ServiceProviderService.createServiceName(providerAlias.getValue());
    }

    serviceBuilder.addDependency(
        serviceName, EntityProviderService.class, service.getEntityProviderService());

    if (verificationHandler != null) {
      serviceBuilder.addListener(verificationHandler);
    }

    ServiceController<SAMLHandlerService> controller =
        serviceBuilder.setInitialMode(ServiceController.Mode.PASSIVE).install();

    if (newControllers != null) {
      newControllers.add(controller);
    }

    if (!context.isBooting()) {
      // a reload is required to get the chain properly updated with the domain model state.
      context.reloadRequired();
    }
  }
  /** {@inheritDoc */
  public void execute(final OperationContext context, final ModelNode operation)
      throws OperationFailedException {

    final Resource resource = context.createResource(PathAddress.EMPTY_ADDRESS);
    final ModelNode model = resource.getModel();

    for (AttributeDefinition attr : ServerGroupResourceDefinition.ADD_ATTRIBUTES) {
      attr.validateAndSet(operation, model);
    }

    // Validate the profile reference.

    // Future proofing: We resolve the profile in Stage.MODEL even though system properties may not
    // be available yet
    // solely because currently the attribute doesn't support expressions. In the future if system
    // properties
    // can safely be resolved in stage model, this profile attribute can be changed and this will
    // still work.
    boolean reloadRequired = false;
    final String profile = PROFILE.resolveModelAttribute(context, model).asString();
    try {
      context.readResourceFromRoot(
          PathAddress.pathAddress(PathElement.pathElement(PROFILE.getName(), profile)));
    } catch (Exception e) {
      if (master) {
        throw DomainControllerLogger.ROOT_LOGGER.noProfileCalled(profile);
      } else {
        // We are a slave HC and we don't have the socket-binding-group required, so put the slave
        // into reload-required
        reloadRequired = true;
        context.reloadRequired();
      }
    }

    final String socketBindingGroup;
    if (operation.hasDefined(SOCKET_BINDING_GROUP.getName())) {
      socketBindingGroup = SOCKET_BINDING_GROUP.resolveModelAttribute(context, model).asString();
      try {
        context.readResourceFromRoot(
            PathAddress.pathAddress(
                PathElement.pathElement(SOCKET_BINDING_GROUP.getName(), socketBindingGroup)));
      } catch (NoSuchElementException e) {
        if (master) {
          throw new OperationFailedException(
              DomainControllerLogger.ROOT_LOGGER.unknown(
                  SOCKET_BINDING_GROUP.getName(), socketBindingGroup));
        } else {
          // We are a slave HC and we don't have the socket-binding-group required, so put the slave
          // into reload-required
          reloadRequired = true;
          context.reloadRequired();
        }
      }
    } else {
      socketBindingGroup = null;
    }

    final boolean revertReloadRequiredOnRollback = reloadRequired;
    context.completeStep(
        new OperationContext.ResultHandler() {
          @Override
          public void handleResult(
              ResultAction resultAction, OperationContext context, ModelNode operation) {
            if (resultAction == ResultAction.ROLLBACK) {
              if (revertReloadRequiredOnRollback) {
                context.revertReloadRequired();
              }
            }
          }
        });
  }