Example #1
0
  ManagedServer(
      final String hostControllerName,
      final String serverName,
      final String authKey,
      final ProcessControllerClient processControllerClient,
      final URI managementURI,
      final TransformationTarget transformationTarget) {

    assert hostControllerName != null : "hostControllerName is null";
    assert serverName != null : "serverName is null";
    assert processControllerClient != null : "processControllerSlave is null";
    assert managementURI != null : "managementURI is null";

    this.hostControllerName = hostControllerName;
    this.serverName = serverName;
    this.serverProcessName = getServerProcessName(serverName);
    this.processControllerClient = processControllerClient;
    this.managementURI = managementURI;

    this.authKey = authKey;

    // Setup the proxy controller
    final PathElement serverPath = PathElement.pathElement(RUNNING_SERVER, serverName);
    final PathAddress address =
        PathAddress.EMPTY_ADDRESS.append(
            PathElement.pathElement(HOST, hostControllerName), serverPath);
    this.protocolClient = new ManagedServerProxy(this);
    this.proxyController =
        TransformingProxyController.Factory.create(
            protocolClient,
            Transformers.Factory.create(transformationTarget),
            address,
            ProxyOperationAddressTranslator.SERVER);
  }
Example #2
0
  private void registerTransformers(SubsystemRegistration subsystem) {
    ResourceTransformationDescriptionBuilder builder =
        TransformationDescriptionBuilder.Factory.createSubsystemInstance();

    GlobalModulesRejecterConverter globalModulesRejecterConverter =
        new GlobalModulesRejecterConverter();

    builder
        .getAttributeBuilder()
        // Deal with https://issues.jboss.org/browse/AS7-4892 on 7.1.2
        .addRejectCheck(
            new JBossDescriptorPropertyReplacementRejectChecker(),
            EeSubsystemRootResource.JBOSS_DESCRIPTOR_PROPERTY_REPLACEMENT)
        // Deal with new attributes added to global-modules elements
        .addRejectCheck(globalModulesRejecterConverter, GlobalModulesDefinition.INSTANCE)
        .setValueConverter(globalModulesRejecterConverter, GlobalModulesDefinition.INSTANCE)
        // Deal with new attribute annotation-property-replacement
        .setDiscard(
            new DiscardAttributeChecker.DiscardAttributeValueChecker(new ModelNode(false)),
            EeSubsystemRootResource.ANNOTATION_PROPERTY_REPLACEMENT)
        .addRejectCheck(
            RejectAttributeChecker.DEFINED,
            EeSubsystemRootResource.ANNOTATION_PROPERTY_REPLACEMENT);
    builder.rejectChildResource(PathElement.pathElement(EESubsystemModel.CONTEXT_SERVICE));
    builder.rejectChildResource(PathElement.pathElement(EESubsystemModel.MANAGED_THREAD_FACTORY));
    builder.rejectChildResource(PathElement.pathElement(EESubsystemModel.MANAGED_EXECUTOR_SERVICE));
    builder.rejectChildResource(
        PathElement.pathElement(EESubsystemModel.MANAGED_SCHEDULED_EXECUTOR_SERVICE));
    builder.discardChildResource(EESubsystemModel.DEFAULT_BINDINGS_PATH);

    TransformationDescription.Tools.register(
        builder.build(), subsystem, ModelVersion.create(1, 0, 0));
  }
Example #3
0
    private void addThreadFactories(final ModelNode result, final ModelNode model) {
      if (model.hasDefined(THREAD_FACTORY)) {
        ModelNode pools = model.get(THREAD_FACTORY);
        for (Property poolProp : pools.asPropertyList()) {
          final ModelNode operation =
              Util.getEmptyOperation(
                  ADD,
                  pathAddress(
                      PathElement.pathElement(SUBSYSTEM, SUBSYSTEM_NAME),
                      PathElement.pathElement(THREAD_FACTORY, poolProp.getName())));
          final ModelNode pool = poolProp.getValue();

          operation.get(NAME).set(pool.require(NAME));
          if (pool.hasDefined(GROUP_NAME)) {
            operation.get(GROUP_NAME).set(pool.get(GROUP_NAME));
          }
          if (pool.hasDefined(THREAD_NAME_PATTERN)) {
            operation.get(THREAD_NAME_PATTERN).set(pool.get(THREAD_NAME_PATTERN));
          }
          if (pool.hasDefined(PRIORITY)) {
            operation.get(PRIORITY).set(pool.get(PRIORITY));
          }
          if (pool.hasDefined(PROPERTIES)) {
            operation.get(PROPERTIES).set(pool.get(PROPERTIES));
          }
          result.add(operation);
        }
      }
    }
  Resource createRootResource() {
    final Resource rootResource = Resource.Factory.create();

    CoreManagementResourceDefinition.registerDomainResource(rootResource);

    final Resource host = Resource.Factory.create();
    final Resource serverOneConfig = Resource.Factory.create();
    final ModelNode serverOneModel = new ModelNode();
    serverOneModel.get(GROUP).set("group-one");
    serverOneModel.get(SOCKET_BINDING_GROUP).set("binding-one");
    serverOneConfig.writeModel(serverOneModel);
    host.registerChild(PathElement.pathElement(SERVER_CONFIG, "server-one"), serverOneConfig);

    final Resource serverTwoConfig = Resource.Factory.create();
    final ModelNode serverTwoModel = new ModelNode();
    serverTwoModel.get(GROUP).set("group-one");
    serverTwoConfig.writeModel(serverTwoModel);
    host.registerChild(PathElement.pathElement(SERVER_CONFIG, "server-two"), serverTwoConfig);

    final Resource serverThreeConfig = Resource.Factory.create();
    final ModelNode serverThreeModel = new ModelNode();
    serverThreeModel.get(GROUP).set("group-two");
    serverThreeConfig.writeModel(serverThreeModel);
    host.registerChild(PathElement.pathElement(SERVER_CONFIG, "server-three"), serverThreeConfig);

    rootResource.registerChild(PathElement.pathElement(HOST, "localhost"), host);

    final Resource serverGroup1 = Resource.Factory.create();
    serverGroup1.getModel().get(PROFILE).set("profile-one");
    serverGroup1.getModel().get(SOCKET_BINDING_GROUP).set("binding-one");
    rootResource.registerChild(PathElement.pathElement(SERVER_GROUP, "group-one"), serverGroup1);

    final Resource serverGroup2 = Resource.Factory.create();
    serverGroup2.getModel().get(PROFILE).set("profile-2");
    serverGroup2.getModel().get(SOCKET_BINDING_GROUP).set("binding-two");
    rootResource.registerChild(PathElement.pathElement(SERVER_GROUP, "group-two"), serverGroup2);

    final Resource profile1 = Resource.Factory.create();
    profile1.getModel().setEmptyObject();
    rootResource.registerChild(PathElement.pathElement(PROFILE, "profile-one"), profile1);
    final Resource profile2 = Resource.Factory.create();
    profile2.getModel().setEmptyObject();
    rootResource.registerChild(PathElement.pathElement(PROFILE, "profile-two"), profile2);

    final Resource binding1 = Resource.Factory.create();
    binding1.getModel().setEmptyObject();
    rootResource.registerChild(
        PathElement.pathElement(SOCKET_BINDING_GROUP, "binding-one"), binding1);
    final Resource binding2 = Resource.Factory.create();
    binding2.getModel().setEmptyObject();
    rootResource.registerChild(
        PathElement.pathElement(SOCKET_BINDING_GROUP, "binding-two"), binding2);

    hack(rootResource, EXTENSION);
    hack(rootResource, PATH);
    hack(rootResource, SYSTEM_PROPERTY);
    hack(rootResource, INTERFACE);
    hack(rootResource, DEPLOYMENT);
    return rootResource;
  }
Example #5
0
    private void addUnboundedQueueThreadPools(final ModelNode result, final ModelNode model) {
      if (model.hasDefined(UNBOUNDED_QUEUE_THREAD_POOL)) {
        ModelNode pools = model.get(UNBOUNDED_QUEUE_THREAD_POOL);
        for (Property poolProp : pools.asPropertyList()) {
          final ModelNode operation =
              Util.getEmptyOperation(
                  ADD,
                  pathAddress(
                      PathElement.pathElement(SUBSYSTEM, SUBSYSTEM_NAME),
                      PathElement.pathElement(UNBOUNDED_QUEUE_THREAD_POOL, poolProp.getName())));
          final ModelNode pool = poolProp.getValue();

          operation.get(NAME).set(pool.require(NAME));
          if (pool.hasDefined(THREAD_FACTORY)) {
            operation.get(THREAD_FACTORY).set(pool.get(THREAD_FACTORY));
          }
          if (pool.hasDefined(PROPERTIES)) {
            operation.get(PROPERTIES).set(pool.get(PROPERTIES));
          }
          if (pool.hasDefined(MAX_THREADS)) {
            operation.get(MAX_THREADS).set(pool.get(MAX_THREADS));
          }
          if (pool.hasDefined(KEEPALIVE_TIME)) {
            operation.get(KEEPALIVE_TIME).set(pool.get(KEEPALIVE_TIME));
          }
          result.add(operation);
        }
      }
    }
  private void clusteredTo120Test(
      ModelVersion version120, KernelServices mainServices, boolean clustered)
      throws OperationFailedException {

    PathAddress pa =
        PathAddress.pathAddress(
            PathElement.pathElement(SUBSYSTEM, MessagingExtension.SUBSYSTEM_NAME),
            // stuff if the empty hornetq-server defined in empty_subsystem_2_0
            PathElement.pathElement(
                HornetQServerResourceDefinition.HORNETQ_SERVER_PATH.getKey(), "stuff"));

    ModelNode addOp = Util.createAddOperation(pa);
    addOp.get(CommonAttributes.CLUSTERED.getName()).set(clustered);

    OperationTransformer.TransformedOperation transformedOperation =
        mainServices.transformOperation(version120, addOp);
    assertFalse(
        transformedOperation.getTransformedOperation().has(CommonAttributes.CLUSTERED.getName()));

    ModelNode result = new ModelNode();
    result.get(OUTCOME).set(SUCCESS);
    result.get(RESULT);
    assertFalse(transformedOperation.rejectOperation(result));
    assertEquals(result, transformedOperation.transformResult(result));

    ModelNode writeOp = Util.createEmptyOperation(WRITE_ATTRIBUTE_OPERATION, pa);
    writeOp.get(NAME).set(CommonAttributes.CLUSTERED.getName());
    writeOp.get(VALUE).set(clustered);

    transformedOperation = mainServices.transformOperation(version120, writeOp);
    assertNull(transformedOperation.getTransformedOperation());
  }
  public void addDeploymentOverlays(final List<ModelNode> updates) {
    if (domainModel.hasDefined(DEPLOYMENT_OVERLAY)) {

      HostFileRepository remoteRepository = null;
      if (!domainController.getLocalHostInfo().isMasterDomainController()) {
        remoteRepository = domainController.getRemoteFileRepository();
      }

      for (Property deploymentOverlay : domainModel.get(DEPLOYMENT_OVERLAY).asPropertyList()) {
        String name = deploymentOverlay.getName();
        ModelNode details = deploymentOverlay.getValue();

        PathAddress addr =
            PathAddress.pathAddress(PathElement.pathElement(DEPLOYMENT_OVERLAY, name));
        ModelNode addOp = Util.getEmptyOperation(ADD, addr.toModelNode());
        updates.add(addOp);

        if (details.hasDefined(CONTENT)) {

          for (Property content : details.get(CONTENT).asPropertyList()) {
            final String contentName = content.getName();
            final ModelNode contentDetails = content.getValue();
            byte[] hash = contentDetails.require(CONTENT).asBytes();
            File[] files = domainController.getLocalFileRepository().getDeploymentFiles(hash);
            if (files == null || files.length == 0) {
              if (remoteRepository != null) {
                remoteRepository.getDeploymentFiles(hash);
              }
            }
            addr =
                PathAddress.pathAddress(
                    PathElement.pathElement(DEPLOYMENT_OVERLAY, name),
                    PathElement.pathElement(CONTENT, contentName));
            addOp = Util.getEmptyOperation(ADD, addr.toModelNode());
            addOp.get(CONTENT).get(HASH).set(contentDetails.get(CONTENT));
            updates.add(addOp);
          }
        }
        if (serverGroup.hasDefined(DEPLOYMENT_OVERLAY)) {
          final ModelNode groupOverlay = serverGroup.get(DEPLOYMENT_OVERLAY).asObject();
          if (groupOverlay.has(name)) {
            ModelNode deploymentsNode = groupOverlay.get(name);
            if (deploymentsNode.has(DEPLOYMENT)) {
              for (Property content : deploymentsNode.get(DEPLOYMENT).asPropertyList()) {
                final String deploymentName = content.getName();
                final ModelNode deploymentDetails = content.getValue();
                addr =
                    PathAddress.pathAddress(
                        PathElement.pathElement(DEPLOYMENT_OVERLAY, name),
                        PathElement.pathElement(DEPLOYMENT, deploymentName));
                addOp = Util.getEmptyOperation(ADD, addr.toModelNode());
                updates.add(addOp);
              }
            }
          }
        }
      }
    }
  }
 /**
  * EAP 6.3 switched the default behavior for datasource statistics from enabled to a configurable
  * disabled. If a config is being migrated, we want the new behavior, so we don't use the parser
  * to enable statistics when a legacy xsd is found. But the 6.2 slave cannot boot if the config
  * has statistics disabled, so we need to specifically enable them for the mixed domain case.
  */
 private void enableDatasourceStatistics(PathAddress profileAddress, List<ModelNode> ops) {
   PathAddress ds =
       profileAddress.append(
           PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, "datasources"),
           PathElement.pathElement("data-source", "ExampleDS"));
   ModelNode op = Util.getWriteAttributeOperation(ds, "statistics-enabled", true);
   ops.add(op);
 }
  MockOperationContext getOperationContextWithIncludes(final PathAddress operationAddress) {
    final Resource root = createRootResource();
    Resource profileThree = Resource.Factory.create();
    root.registerChild(PathElement.pathElement(PROFILE, "profile-three"), profileThree);

    Resource profileFour = Resource.Factory.create();
    profileFour.getModel().get(INCLUDES).add("profile-three");
    root.registerChild(PathElement.pathElement(PROFILE, "profile-four"), profileFour);
    return new MockOperationContext(root, false, operationAddress, false);
  }
  public static void excludeBadOps_7_1_x(LegacyKernelServicesInitializer initializer) {
    // deployment overlays don't exist in 7.1.x
    initializer.addOperationValidationExclude(
        ADD, PathAddress.pathAddress(PathElement.pathElement(DEPLOYMENT_OVERLAY)));

    initializer.addOperationValidationExclude(
        ADD,
        PathAddress.pathAddress(
            PathElement.pathElement(DEPLOYMENT_OVERLAY), PathElement.pathElement(CONTENT)));
    initializer.addOperationValidationExclude(
        ADD,
        PathAddress.pathAddress(
            PathElement.pathElement(SERVER_GROUP), PathElement.pathElement(DEPLOYMENT_OVERLAY)));

    // Socket binding group/socket-binding has problems if there are expressions in the
    // multicast-port
    initializer.addOperationValidationResolve(
        ADD,
        PathAddress.pathAddress(
            PathElement.pathElement(SOCKET_BINDING_GROUP),
            PathElement.pathElement(SOCKET_BINDING)));

    // Deployment operation validator thinks that content is required
    initializer.addOperationValidationExclude(
        ADD,
        PathAddress.pathAddress(
            PathElement.pathElement(SERVER_GROUP), PathElement.pathElement(DEPLOYMENT)));
  }
 @Override
 public void unregisterRunningServer(String serverName) {
   PathAddress pa =
       PathAddress.pathAddress(
           PathElement.pathElement(HOST, hostControllerInfo.getLocalHostName()));
   PathElement pe = PathElement.pathElement(RUNNING_SERVER, serverName);
   ROOT_LOGGER.unregisteringServer(serverName);
   ManagementResourceRegistration hostRegistration = modelNodeRegistration.getSubModel(pa);
   hostRegistration.unregisterProxyController(pe);
   serverProxies.remove(serverName);
 }
  MockOperationContext getOperationContextForSubsystemIncludes(
      final PathAddress operationAddress, RootResourceInitializer initializer) {
    final Resource root = createRootResource();
    Resource profileThree = Resource.Factory.create();
    root.registerChild(PathElement.pathElement(PROFILE, "profile-three"), profileThree);

    Resource profileFour = Resource.Factory.create();
    root.registerChild(PathElement.pathElement(PROFILE, "profile-four"), profileFour);

    Resource profileFive = Resource.Factory.create();
    root.registerChild(PathElement.pathElement(PROFILE, "profile-five"), profileFive);

    initializer.addAdditionalResources(root);
    return new MockOperationContext(root, false, operationAddress, false);
  }
Example #13
0
  /**
   * Cleans up a module's subsystems from the resource registration model.
   *
   * @param rootResource the model root resource
   * @param moduleName the name of the extension's module. Cannot be {@code null}
   * @throws IllegalStateException if the extension still has subsystems present in {@code
   *     rootResource} or its children
   */
  public void removeExtension(Resource rootResource, String moduleName)
      throws IllegalStateException {

    final ManagementResourceRegistration profileReg = profileRegistration;
    if (profileReg == null) {
      // we've been cleared and haven't re-initialized yet
      return;
    }

    final ManagementResourceRegistration deploymentsReg = deploymentsRegistration;
    ExtensionInfo extension = extensions.remove(moduleName);
    if (extension != null) {
      synchronized (extension) {
        Set<String> subsystemNames = extension.subsystems.keySet();
        for (String subsystem : subsystemNames) {
          if (rootResource.getChild(
                  PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, subsystem))
              != null) {
            // Restore the data
            extensions.put(moduleName, extension);
            throw MESSAGES.removingExtensionWithRegisteredSubsystem(moduleName, subsystem);
          }
        }
        for (Map.Entry<String, SubsystemInformation> entry : extension.subsystems.entrySet()) {
          String subsystem = entry.getKey();
          profileReg.unregisterSubModel(
              PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, subsystem));
          if (deploymentsReg != null) {
            deploymentsReg.unregisterSubModel(
                PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, subsystem));
          }

          if (extension.xmlMapper != null) {
            SubsystemInformationImpl subsystemInformation =
                SubsystemInformationImpl.class.cast(entry.getValue());
            for (String namespace : subsystemInformation.getXMLNamespaces()) {
              extension.xmlMapper.unregisterRootElement(new QName(namespace, SUBSYSTEM));
            }
          }
        }
        if (extension.xmlMapper != null) {
          for (String namespace : extension.unnamedParsers) {
            extension.xmlMapper.unregisterRootElement(new QName(namespace, SUBSYSTEM));
          }
        }
      }
    }
  }
  @Override
  protected void addBootOperations(List<ModelNode> bootOperations) {
    if (enableRbac) {
      for (StandardRole standardRole : EnumSet.allOf(StandardRole.class)) {
        ModelNode addRoleMappingOp =
            Util.createAddOperation(
                PathAddress.pathAddress(
                    CoreManagementResourceDefinition.PATH_ELEMENT,
                    AccessAuthorizationResourceDefinition.PATH_ELEMENT,
                    PathElement.pathElement(
                        RoleMappingResourceDefinition.PATH_KEY, standardRole.getFormalName())));
        bootOperations.add(addRoleMappingOp);

        ModelNode addIncludeUserOp =
            Util.createAddOperation(
                PathAddress.pathAddress(
                    CoreManagementResourceDefinition.PATH_ELEMENT,
                    AccessAuthorizationResourceDefinition.PATH_ELEMENT,
                    PathElement.pathElement(
                        RoleMappingResourceDefinition.PATH_KEY, standardRole.getFormalName()),
                    PathElement.pathElement(
                        ModelDescriptionConstants.INCLUDE,
                        "user-" + roleToUserName(standardRole))));
        addIncludeUserOp
            .get(PrincipalResourceDefinition.NAME.getName())
            .set(roleToUserName(standardRole));
        addIncludeUserOp
            .get(PrincipalResourceDefinition.TYPE.getName())
            .set(PrincipalResourceDefinition.Type.USER.toString());
        bootOperations.add(addIncludeUserOp);
      }

      ModelNode enableRbacOp =
          Util.getWriteAttributeOperation(
              PathAddress.pathAddress(
                  CoreManagementResourceDefinition.PATH_ELEMENT,
                  AccessAuthorizationResourceDefinition.PATH_ELEMENT),
              AccessAuthorizationResourceDefinition.PROVIDER.getName(),
              new ModelNode(AccessAuthorizationResourceDefinition.Provider.RBAC.toString()));
      bootOperations.add(enableRbacOp);
    }

    ModelNode addOp =
        Util.createAddOperation(
            PathAddress.pathAddress(
                ModelDescriptionConstants.SUBSYSTEM, JMXExtension.SUBSYSTEM_NAME));
    bootOperations.add(addOp);
  }
Example #15
0
    public void execute(OperationContext context, ModelNode operation)
        throws OperationFailedException {
      final ModelNode add = createEmptyAddOperation();
      final ModelNode model = context.readModel(PathAddress.EMPTY_ADDRESS);

      if (model.hasDefined(BEAN_VALIDATION_ENABLED)) {
        add.get(BEAN_VALIDATION_ENABLED).set(model.get(BEAN_VALIDATION_ENABLED));
      }
      if (model.hasDefined(ARCHIVE_VALIDATION_ENABLED)) {
        add.get(ARCHIVE_VALIDATION_ENABLED).set(model.get(ARCHIVE_VALIDATION_ENABLED));
      }
      if (model.hasDefined(ARCHIVE_VALIDATION_FAIL_ON_ERROR)) {
        add.get(ARCHIVE_VALIDATION_FAIL_ON_ERROR).set(model.get(ARCHIVE_VALIDATION_FAIL_ON_ERROR));
      }
      if (model.hasDefined(ARCHIVE_VALIDATION_FAIL_ON_WARN)) {
        add.get(ARCHIVE_VALIDATION_FAIL_ON_WARN).set(model.get(ARCHIVE_VALIDATION_FAIL_ON_WARN));
      }
      if (model.hasDefined(CACHED_CONNECTION_MANAGER_DEBUG)) {
        add.get(CACHED_CONNECTION_MANAGER_DEBUG).set(model.get(CACHED_CONNECTION_MANAGER_DEBUG));
      }
      if (model.hasDefined(CACHED_CONNECTION_MANAGER_ERROR)) {
        add.get(CACHED_CONNECTION_MANAGER_ERROR).set(model.get(CACHED_CONNECTION_MANAGER_ERROR));
      }

      final ModelNode result = context.getResult();
      result.add(add);

      if (model.hasDefined(THREAD_POOL)) {
        ModelNode pools = model.get(THREAD_POOL);
        for (Property poolProp : pools.asPropertyList()) {
          if (poolProp.getName().equals(LONG_RUNNING_THREADS)) {
            addBoundedQueueThreadPool(
                result,
                poolProp.getValue(),
                PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, SUBSYSTEM_NAME),
                PathElement.pathElement(THREAD_POOL, LONG_RUNNING_THREADS));
          } else if (poolProp.getName().equals(SHORT_RUNNING_THREADS)) {
            addBoundedQueueThreadPool(
                result,
                poolProp.getValue(),
                PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, SUBSYSTEM_NAME),
                PathElement.pathElement(THREAD_POOL, SHORT_RUNNING_THREADS));
          }
        }
      }

      context.completeStep();
    }
 /** Test of authorizeAddress method, of class AuthorizedAddress. */
 @Test
 public void testAccessAuthorizedAddress() {
   ModelNode address =
       PathAddress.pathAddress(
               PathElement.pathElement(DEPLOYMENT, "test.war"),
               PathElement.pathElement(SUBSYSTEM, "Undertow"))
           .toModelNode();
   ModelNode authorizedAddress = address;
   OperationContext context = new AuthorizationOperationContext(authorizedAddress.asString());
   ModelNode operation = new ModelNode();
   operation.get(OP).set(READ_RESOURCE_OPERATION);
   operation.get(OP_ADDR).set(address);
   AuthorizedAddress expResult = new AuthorizedAddress(authorizedAddress, false);
   AuthorizedAddress result = AuthorizedAddress.authorizeAddress(context, operation);
   assertEquals(expResult, result);
 }
 protected void describe(
     final Resource resource,
     final ModelNode address,
     ModelNode result,
     final ImmutableManagementResourceRegistration registration) {
   if (registration.isRemote()
       || registration.isRuntimeOnly()
       || resource.isProxy()
       || resource.isRuntime()) {
     return;
   }
   final Set<PathElement> children = registration.getChildAddresses(PathAddress.EMPTY_ADDRESS);
   result.add(createAddOperation(address, resource.getModel(), children));
   for (final PathElement element : children) {
     if (element.isMultiTarget()) {
       final String childType = element.getKey();
       for (final Resource.ResourceEntry entry : resource.getChildren(childType)) {
         final ImmutableManagementResourceRegistration childRegistration =
             registration.getSubModel(
                 PathAddress.pathAddress(PathElement.pathElement(childType, entry.getName())));
         final ModelNode childAddress = address.clone();
         childAddress.add(childType, entry.getName());
         describe(entry, childAddress, result, childRegistration);
       }
     } else {
       final Resource child = resource.getChild(element);
       final ImmutableManagementResourceRegistration childRegistration =
           registration.getSubModel(PathAddress.pathAddress(element));
       final ModelNode childAddress = address.clone();
       childAddress.add(element.getKey(), element.getValue());
       describe(child, childAddress, result, childRegistration);
     }
   }
 }
  @Override
  public void initialize(ExtensionContext context) {
    log.debug("Initializing Security Extension");

    final SubsystemRegistration subsystem = context.registerSubsystem(SUBSYSTEM_NAME);
    final ModelNodeRegistration registration =
        subsystem.registerSubsystemModel(SecuritySubsystemDescriptions.SUBSYSTEM);
    registration.registerOperationHandler(
        ADD, SecuritySubsystemAdd.INSTANCE, SecuritySubsystemDescriptions.SUBSYSTEM_ADD, false);
    registration.registerOperationHandler(
        DESCRIBE,
        SecurityDescribeHandler.INSTANCE,
        SecuritySubsystemDescriptions.SUBSYSTEM_DESCRIBE,
        false);

    // security domains
    final ModelNodeRegistration securityDomain =
        registration.registerSubModel(
            PathElement.pathElement(CommonAttributes.SECURITY_DOMAIN),
            SecuritySubsystemDescriptions.SECURITY_DOMAIN);
    securityDomain.registerOperationHandler(
        SecurityDomainAdd.OPERATION_NAME,
        SecurityDomainAdd.INSTANCE,
        SecuritySubsystemDescriptions.SECURITY_DOMAIN_ADD,
        false);
    securityDomain.registerOperationHandler(
        SecurityDomainRemove.OPERATION_NAME,
        SecurityDomainRemove.INSTANCE,
        SecuritySubsystemDescriptions.SECURITY_DOMAIN_REMOVE,
        false);

    subsystem.registerXMLElementWriter(PARSER);
  }
Example #19
0
  private ModelNode removeServerGroups(final DomainClient client) throws Exception {
    final ModelNode op =
        Util.createEmptyOperation(
            READ_RESOURCE_OPERATION,
            PathAddress.pathAddress(PathElement.pathElement(SERVER_GROUP)));
    final ModelNode results = executeForResult(op, client);
    ModelNode group = null;
    for (ModelNode result : results.asList()) {
      String groupName = PathAddress.pathAddress(result.get(ADDRESS)).getLastElement().getValue();
      if (groupName.equals(OTHER_SERVER_GROUP)) {
        group = result.get(RESULT);
      } else {
        ModelNode remove = Util.createRemoveOperation(PathAddress.pathAddress(result.get(ADDRESS)));
        executeForResult(remove, client);
      }
    }
    Assert.assertNotNull(group);

    // Add main-server-group as a copy of other-server-group (cuts down on the amount of profiles
    // needed)
    final ModelNode addMain = group.clone();
    final PathAddress mainServerGroupAddress =
        PathAddress.pathAddress(SERVER_GROUP, MAIN_SERVER_GROUP);
    addMain.get(OP).set(ADD);
    addMain.get(OP_ADDR).set(mainServerGroupAddress.toModelNode());
    executeForResult(addMain, client);

    return group;
  }
  /**
   * Starts a controller with the given subsystem xml and then checks that a second controller
   * started with the operations from its describe action results in the same model
   */
  @Test
  public void testDescribeHandler() throws Exception {
    KernelServicesBuilder builderA =
        createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT);

    // Parse the subsystem xml and install into the first controller
    String subsystemXml = "subsystem.xml";

    builderA.setSubsystemXmlResource(subsystemXml);
    KernelServices servicesA = builderA.build();

    // Get the model and the describe operations from the first controller
    ModelNode modelA = servicesA.readWholeModel();
    ModelNode describeOp = new ModelNode();
    describeOp.get(OP).set(DESCRIBE);
    describeOp
        .get(OP_ADDR)
        .set(
            PathAddress.pathAddress(
                    PathElement.pathElement(SUBSYSTEM, ZooKeeperExtension.SUBSYSTEM_NAME))
                .toModelNode());
    List<ModelNode> operations =
        super.checkResultAndGetContents(servicesA.executeOperation(describeOp)).asList();

    // Install the describe options from the first controller into a second
    // controller
    KernelServicesBuilder builderB =
        createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT);
    builderB.setBootOperations(operations);
    KernelServices servicesB = builderB.build();
    ModelNode modelB = servicesB.readWholeModel();

    // Make sure the models from the two controllers are identical
    super.compare(modelA, modelB);
  }
Example #21
0
 private ConnectorResource() {
   super(
       PathElement.pathElement(CommonAttributes.CONNECTOR),
       RemotingExtension.getResourceDescriptionResolver(CONNECTOR),
       ConnectorAdd.INSTANCE,
       ConnectorRemove.INSTANCE);
 }
  public static class Tls extends Tcp {
    public static final PathElement PATH_ELEMENT =
        PathElement.pathElement(ModelDescriptionConstants.PROTOCOL, ModelDescriptionConstants.TLS);

    private static final AttributeDefinition[] ATTRIBUTES =
        new AttributeDefinition[] {HOST, PORT, MESSAGE_TRANSFER};

    Tls(
        ManagedAuditLogger auditLogger,
        PathManagerService pathManager,
        EnvironmentNameReader environmentReader) {
      super(
          auditLogger,
          pathManager,
          ATTRIBUTES,
          PATH_ELEMENT,
          DomainManagementResolver.getResolver("core.management.syslog-tls"),
          environmentReader);
    }

    @Override
    public void registerChildren(ManagementResourceRegistration resourceRegistration) {
      resourceRegistration.registerSubModel(
          TlsKeyStore.createTrustStore(auditLogger, pathManager, environmentReader));
      resourceRegistration.registerSubModel(
          TlsKeyStore.createClientCertStore(auditLogger, pathManager, environmentReader));
    }
  }
  public static class Udp extends SyslogAuditLogProtocolResourceDefinition {
    public static final PathElement PATH_ELEMENT =
        PathElement.pathElement(ModelDescriptionConstants.PROTOCOL, ModelDescriptionConstants.UDP);

    private static final AttributeDefinition[] ATTRIBUTES = new AttributeDefinition[] {HOST, PORT};

    Udp(
        ManagedAuditLogger auditLogger,
        PathManagerService pathManager,
        EnvironmentNameReader environmentReader) {
      super(
          auditLogger,
          pathManager,
          ATTRIBUTES,
          PATH_ELEMENT,
          DomainManagementResolver.getResolver("core.management.syslog-udp"),
          environmentReader);
    }

    Udp(
        ManagedAuditLogger auditLogger,
        PathManagerService pathManager,
        AttributeDefinition[] attributes,
        PathElement pathElement,
        ResourceDescriptionResolver resolver,
        EnvironmentNameReader environmentReader) {
      super(auditLogger, pathManager, attributes, pathElement, resolver, environmentReader);
    }
  }
/**
 * @author Bob McWhirter
 * @author Lance Ball
 */
public class MessagingConfiguration extends AbstractServerConfiguration<MessagingFraction> {

  private PathAddress address =
      PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, "messaging-activemq"));

  public MessagingConfiguration() {
    super(MessagingFraction.class);
  }

  @Override
  public MessagingFraction defaultFraction() {
    return MessagingFraction.createDefaultFraction();
  }

  @Override
  public void prepareArchive(Archive a) {
    a.as(JARArchive.class).addModule("javax.jms.api");
  }

  @Override
  public List<ModelNode> getList(MessagingFraction fraction) throws Exception {
    List<ModelNode> list = new ArrayList<>();

    ModelNode node = new ModelNode();
    node.get(OP_ADDR).set(EXTENSION, "org.wildfly.extension.messaging-activemq");
    node.get(OP).set(ADD);
    list.add(node);

    list.addAll(Marshaller.marshal(fraction));

    return list;
  }
}
  @Override
  public ManagementResourceRegistration registerOverrideModel(
      String name, OverrideDescriptionProvider descriptionProvider) {
    Assert.checkNotNullParam("name", name);
    Assert.checkNotNullParam("descriptionProvider", descriptionProvider);

    if (parent == null) {
      throw ControllerLogger.ROOT_LOGGER.cannotOverrideRootRegistration();
    }

    if (!PathElement.WILDCARD_VALUE.equals(valueString)) {
      throw ControllerLogger.ROOT_LOGGER.cannotOverrideNonWildCardRegistration(valueString);
    }
    PathElement pe = PathElement.pathElement(parent.getKeyName(), name);

    final SimpleResourceDefinition rd =
        new SimpleResourceDefinition(
            pe,
            new OverrideDescriptionCombiner(
                getModelDescription(PathAddress.EMPTY_ADDRESS), descriptionProvider)) {

          @Override
          public List<AccessConstraintDefinition> getAccessConstraints() {
            return AbstractResourceRegistration.this.getAccessConstraints();
          }
        };
    return parent.getParent().registerSubModel(rd);
  }
Example #26
0
  @Override
  public void initialize(final ExtensionContext context) {
    log.debugf("Initializing Connector Extension");
    // Register the connector subsystem
    final SubsystemRegistration registration = context.registerSubsystem(JCA);

    registration.registerXMLElementWriter(NewConnectorSubsystemParser.INSTANCE);

    // Connector subsystem description and operation handlers
    final ManagementResourceRegistration subsystem = registration.registerSubsystemModel(SUBSYSTEM);
    subsystem.registerOperationHandler(ADD, JcaSubsystemAdd.INSTANCE, SUBSYSTEM_ADD_DESC, false);
    subsystem.registerOperationHandler(
        REMOVE, JcaSubSystemRemove.INSTANCE, SUBSYSTEM_REMOVE_DESC, false);
    subsystem.registerOperationHandler(
        DESCRIBE,
        ConnectorSubsystemDescribeHandler.INSTANCE,
        ConnectorSubsystemDescribeHandler.INSTANCE,
        false,
        OperationEntry.EntryType.PRIVATE);

    final ManagementResourceRegistration threadPools =
        subsystem.registerSubModel(
            PathElement.pathElement(THREAD_POOL), BOUNDED_QUEUE_THREAD_POOL_DESC);
    threadPools.registerOperationHandler(
        ADD, BoundedQueueThreadPoolAdd.INSTANCE, BoundedQueueThreadPoolAdd.INSTANCE, false);
    threadPools.registerOperationHandler(
        REMOVE,
        BoundedQueueThreadPoolRemove.INSTANCE,
        BoundedQueueThreadPoolRemove.INSTANCE,
        false);
  }
  private void compareChildren(CompareContext context) {
    Set<String> legacyChildTypes = context.getLegacyDefinition().getChildTypes();
    Set<String> currentChildTypes = context.getCurrentDefinition().getChildTypes();

    compareSetsAndRemoveMissing(context, "child types", currentChildTypes, legacyChildTypes);

    for (String type : legacyChildTypes) {
      Map<String, ModelNode> legacyChildren = context.getLegacyDefinition().getChildren(type);
      Map<String, ModelNode> currentChildren = context.getCurrentDefinition().getChildren(type);

      compareKeySetsAndRemoveMissing(
          context, "child names for type=" + type, currentChildren, legacyChildren);

      for (Map.Entry<String, ModelNode> legacyChildEntry : legacyChildren.entrySet()) {
        String name = legacyChildEntry.getKey();
        ModelNode legacyChildDescription = legacyChildEntry.getValue();
        ModelNode currentChildDescription = currentChildren.get(name);

        CompareContext childContext;
        try {
          childContext =
              new CompareContext(
                  context.getRootAddress(),
                  context.getPathAddress().append(PathElement.pathElement(type, name)),
                  context.isCore(),
                  new ResourceDefinition(currentChildDescription, currentModelVersions),
                  new ResourceDefinition(legacyChildDescription, legacyModelVersions));
        } catch (RuntimeException e) {
          System.out.println(context.getPathAddress() + " + " + type + "=" + name);
          throw e;
        }
        compareModel(childContext);
      }
    }
  }
  private void compareSubsystemModels() {
    System.out.println("====== Comparing subsystem models ======");
    ResourceDefinition rootCurrentDefinition =
        new ResourceDefinition(trimNonSubsystem(currentResourceDefinitions), currentModelVersions);
    ResourceDefinition rootLegacyDefinition =
        new ResourceDefinition(trimNonSubsystem(legacyResourceDefinitions), legacyModelVersions);
    Map<String, ModelNode> currentSubsystems = rootCurrentDefinition.getChildren(SUBSYSTEM);
    Map<String, ModelNode> legacySubsystems = rootLegacyDefinition.getChildren(SUBSYSTEM);

    CompareContext context =
        new CompareContext(
            PathAddress.EMPTY_ADDRESS,
            PathAddress.EMPTY_ADDRESS,
            true,
            rootCurrentDefinition,
            rootLegacyDefinition);
    compareKeySetsAndRemoveMissing(context, "subsystems", currentSubsystems, legacySubsystems);

    for (Map.Entry<String, ModelNode> legacyEntry : legacySubsystems.entrySet()) {
      PathAddress subsystemAddress =
          PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, legacyEntry.getKey()));
      ResourceDefinition currentDefinition =
          new ResourceDefinition(currentSubsystems.get(legacyEntry.getKey()), currentModelVersions);
      ResourceDefinition legacyDefinition =
          new ResourceDefinition(legacyEntry.getValue(), legacyModelVersions);
      context =
          new CompareContext(
              subsystemAddress, subsystemAddress, false, currentDefinition, legacyDefinition);
      if (!context.continuteWithCheck()) {
        continue;
      }
      compareModel(context);
    }
  }
  /**
   * Starts a controller with the given subsystem xml and then checks that a second controller
   * started with the operations from its describe action results in the same model
   */
  @Test
  public void testDescribeHandler() throws Exception {
    // Parse the subsystem xml and install into the first controller
    KernelServices servicesA =
        createKernelServicesBuilder(AdditionalInitialization.MANAGEMENT)
            .setSubsystemXml(getSubsystemXml())
            .build();
    // Get the model and the describe operations from the first controller
    ModelNode modelA = servicesA.readWholeModel();
    ModelNode describeOp = new ModelNode();
    describeOp.get(OP).set(DESCRIBE);
    describeOp
        .get(OP_ADDR)
        .set(
            PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, getMainSubsystemName()))
                .toModelNode());
    List<ModelNode> operations =
        checkResultAndGetContents(servicesA.executeOperation(describeOp)).asList();

    // Install the describe options from the first controller into a second controller
    KernelServices servicesB =
        createKernelServicesBuilder(null).setBootOperations(operations).build();
    ModelNode modelB = servicesB.readWholeModel();

    // Make sure the models from the two controllers are identical
    super.compare(modelA, modelB);
  }
Example #30
0
 @Override
 @SuppressWarnings("deprecation")
 public ManagementResourceRegistration registerSubsystemModel(
     final DescriptionProvider descriptionProvider) {
   assert descriptionProvider != null : "descriptionProvider is null";
   PathElement pathElement = PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, name);
   return registerSubsystemModel(new SimpleResourceDefinition(pathElement, descriptionProvider));
 }