Exemplo n.º 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);
   }
 }
Exemplo n.º 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));
  }
Exemplo n.º 3
0
  @Test
  public void testParseSubsystem_1_0() throws Exception {
    String subsystemXml =
        "<subsystem xmlns=\"urn:jboss:domain:jacorb:1.0\">"
            + "    <orb name=\"JBoss\" print-version=\"off\">"
            + "        <connection retries=\"5\" retry-interval=\"500\" client-timeout=\"0\" server-timeout=\"0\"/>"
            + "        <naming root-context=\"JBoss/Naming/root\" export-corbaloc=\"on\"/>"
            + "    </orb>"
            + "    <poa monitoring=\"off\" queue-wait=\"on\" queue-min=\"10\" queue-max=\"100\">"
            + "        <request-processors pool-size=\"10\" max-threads=\"32\"/>"
            + "    </poa>"
            + "    <interop sun=\"on\" comet=\"off\" chunk-custom-rmi-valuetypes=\"on\"/>"
            + "    <security support-ssl=\"off\" use-domain-socket-factory=\"off\" use-domain-server-socket-factory=\"off\"/>"
            + "    <property key=\"a\" value=\"va\"/>"
            + "    <property key=\"b\" value=\"vb\"/>"
            + "    <initializers>security,transactions</initializers>"
            + "</subsystem>";

    List<ModelNode> operations = super.parse(subsystemXml);

    // check that we have the expected number of operations.
    Assert.assertEquals(1, operations.size());
    // check that each operation has the correct content.
    ModelNode addSubsystem = operations.get(0);
    Assert.assertEquals(ADD, addSubsystem.get(OP).asString());
    PathAddress addr = PathAddress.pathAddress(addSubsystem.get(OP_ADDR));
    Assert.assertEquals(1, addr.size());
    PathElement element = addr.getElement(0);
    Assert.assertEquals(SUBSYSTEM, element.getKey());
    Assert.assertEquals(JacORBExtension.SUBSYSTEM_NAME, element.getValue());
  }
Exemplo n.º 4
0
  @Override
  public void execute(OperationContext context, ModelNode operation)
      throws OperationFailedException {

    final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
    final PathElement element = address.getLastElement();
    final String serverName = element.getValue();

    final ModelNode subModel = context.readModel(PathAddress.EMPTY_ADDRESS);
    final boolean isStart;
    if (subModel.hasDefined(AUTO_START)) {
      isStart = subModel.get(AUTO_START).asBoolean();
    } else {
      isStart = true;
    }

    ServerStatus status = serverInventory.determineServerStatus(serverName);

    if (status == ServerStatus.STOPPED) {
      status = isStart ? status : ServerStatus.DISABLED;
    }

    if (status != null) {
      context.getResult().set(status.toString());
      context.completeStep();
    } else {
      throw new OperationFailedException(new ModelNode().set("Failed to get server status"));
    }
  }
Exemplo n.º 5
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);
  }
  @Override
  AttributeAccess getAttributeAccess(
      final ListIterator<PathElement> iterator, final String attributeName) {

    if (iterator.hasNext()) {
      final PathElement next = iterator.next();
      final NodeSubregistry subregistry = children.get(next.getKey());
      if (subregistry == null) {
        return null;
      }
      return subregistry.getAttributeAccess(iterator, next.getValue(), attributeName);
    } else {
      final Map<String, AttributeAccess> snapshot = attributesUpdater.get(this);
      AttributeAccess access = snapshot.get(attributeName);
      if (access == null) {
        // If there is metadata for an attribute but no AttributeAccess, assume RO. Can't
        // be writable without a registered handler. This opens the possibility that out-of-date
        // metadata
        // for attribute "foo" can lead to a read of non-existent-in-model "foo" with
        // an unexpected undefined value returned. But it removes the possibility of a
        // dev forgetting to call registry.registerReadOnlyAttribute("foo", null) resulting
        // in the valid attribute "foo" not being readable
        final ModelNode desc = descriptionProvider.getModelDescription(null);
        if (desc.has(ATTRIBUTES) && desc.get(ATTRIBUTES).keys().contains(attributeName)) {
          access =
              new AttributeAccess(AccessType.READ_ONLY, Storage.CONFIGURATION, null, null, null);
        }
      }
      return access;
    }
  }
  @Override
  void getOperationDescriptions(
      final ListIterator<PathElement> iterator,
      final Map<String, OperationEntry> providers,
      final boolean inherited) {

    if (!iterator.hasNext()) {
      checkPermission();
      providers.putAll(operationsUpdater.get(this));
      if (inherited) {
        getInheritedOperations(providers, true);
      }
      return;
    }
    final PathElement next = iterator.next();
    try {
      final String key = next.getKey();
      final Map<String, NodeSubregistry> snapshot = childrenUpdater.get(this);
      final NodeSubregistry subregistry = snapshot.get(key);
      if (subregistry != null) {
        subregistry.getHandlers(iterator, next.getValue(), providers, inherited);
      }
    } finally {
      iterator.previous();
    }
  }
Exemplo n.º 8
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);
        }
      }
    }
Exemplo n.º 9
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);
        }
      }
    }
  void launchServices(
      final OperationContext context,
      final PathAddress pathAddress,
      final ModelNode model,
      final ServiceVerificationHandler verificationHandler,
      final List<ServiceController<?>> newControllers)
      throws OperationFailedException {
    Handler newHandler = new Handler();

    newHandler.setClazz(
        HandlerResourceDefinition.CLASS.resolveModelAttribute(context, model).asString());

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

    if (handler.hasDefined(COMMON_HANDLER_PARAMETER.getName())) {
      for (ModelNode handlerParameter : handler.get(COMMON_HANDLER_PARAMETER.getName()).asList()) {
        Property property = handlerParameter.asProperty();
        String paramName = property.getName();
        String paramValue =
            HandlerParameterResourceDefinition.VALUE
                .resolveModelAttribute(context, property.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());

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

    if (newControllers != null) {
      newControllers.add(controller);
    }
  }
  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;
  }
 public void addResource(PathAddress relativeAddress, Resource toAdd) {
   Resource model = root;
   final Iterator<PathElement> i = relativeAddress.iterator();
   while (i.hasNext()) {
     final PathElement element = i.next();
     if (element.isMultiTarget()) {
       throw MESSAGES.cannotWriteTo("*");
     }
     if (!i.hasNext()) {
       if (model.hasChild(element)) {
         throw MESSAGES.duplicateResourceAddress(relativeAddress);
       } else {
         model.registerChild(element, toAdd);
         model = toAdd;
       }
     } else {
       model = model.getChild(element);
       if (model == null) {
         PathAddress ancestor = PathAddress.EMPTY_ADDRESS;
         for (PathElement pe : relativeAddress) {
           ancestor = ancestor.append(pe);
           if (element.equals(pe)) {
             break;
           }
         }
         throw MESSAGES.resourceNotFound(ancestor, relativeAddress);
       }
     }
   }
 }
  /** Tests that the xml is parsed into the correct operations */
  @Test
  public void testParseSubsystem() throws Exception {
    // Parse the subsystem xml into operations
    List<ModelNode> operations = super.parse(getSubsystemXml());

    /*
    // print the operations
    System.out.println("List of operations");
    for (ModelNode op : operations) {
        System.out.println("operation = " + op.toString());
    }
    */

    // Check that we have the expected number of operations
    // one for each resource instance
    Assert.assertEquals(this.operations, operations.size());

    // Check that each operation has the correct content
    ModelNode addSubsystem = operations.get(0);
    Assert.assertEquals(ADD, addSubsystem.get(OP).asString());
    PathAddress addr = PathAddress.pathAddress(addSubsystem.get(OP_ADDR));
    Assert.assertEquals(1, addr.size());
    PathElement element = addr.getElement(0);
    Assert.assertEquals(SUBSYSTEM, element.getKey());
    Assert.assertEquals(getMainSubsystemName(), element.getValue());
  }
  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());
  }
  private static DescribedOp getDescribedOp(
      OperationContext context, String operationName, ModelNode operation, boolean lenient)
      throws OperationFailedException {
    DescribedOp result = null;
    OperationEntry operationEntry;
    // First try to get the current resource registration to give authz a chance to reject this
    // request
    ImmutableManagementResourceRegistration registry = context.getResourceRegistration();
    if (registry != null) {
      operationEntry = registry.getOperationEntry(PathAddress.EMPTY_ADDRESS, operationName);
    } else {
      // We know the user is authorized to read this address.
      // There's no MRR at that address, but see if the MRR tree can resolve an operation entry
      // (e.g. an inherited one)
      operationEntry =
          context
              .getRootResourceRegistration()
              .getOperationEntry(context.getCurrentAddress(), operationName);
    }

    if (operationEntry != null) {
      Locale locale = GlobalOperationHandlers.getLocale(context, operation);
      result = new DescribedOp(operationEntry, locale);
    } else if (lenient) {
      // For wildcard elements, check specific registrations where the same OSH is used
      // for all such registrations
      PathAddress address = context.getCurrentAddress();
      if (address.size() > 0) {
        PathElement pe = address.getLastElement();
        if (pe.isWildcard()) {
          ImmutableManagementResourceRegistration rootRegistration =
              context.getRootResourceRegistration();
          String type = pe.getKey();
          PathAddress parent = address.subAddress(0, address.size() - 1);
          Set<PathElement> children = rootRegistration.getChildAddresses(parent);
          if (children != null) {
            Locale locale = GlobalOperationHandlers.getLocale(context, operation);
            DescribedOp found = null;
            for (PathElement child : children) {
              if (type.equals(child.getKey())) {
                OperationEntry oe =
                    rootRegistration.getOperationEntry(parent.append(child), operationName);
                DescribedOp describedOp = oe == null ? null : new DescribedOp(oe, locale);
                if (describedOp == null || (found != null && !found.equals(describedOp))) {
                  // Not all children have the same handler; give up
                  found = null;
                  break;
                }
                // We have a candidate OSH
                found = describedOp;
              }
            }
            result = found;
          }
        }
      }
    }
    return result;
  }
  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);
              }
            }
          }
        }
      }
    }
  }
 private ModelVersion getSubsystemVersion(PathAddress address) {
   for (PathElement element : address) {
     if (element.getKey().equals(SUBSYSTEM)) {
       return Tools.createModelVersion(versions.get(SUBSYSTEM, element.getValue()));
     }
   }
   throw new IllegalArgumentException("Could not find subsystem version for " + address);
 }
 private void assertOperation(
     final ModelNode operation, final String operationName, final PathElement lastElement) {
   assertEquals(operationName, operation.get(OP).asString());
   final PathAddress addr = PathAddress.pathAddress(operation.get(OP_ADDR));
   final PathElement element = addr.getLastElement();
   assertEquals(lastElement.getKey(), element.getKey());
   assertEquals(lastElement.getValue(), element.getValue());
 }
Exemplo n.º 19
0
 /**
  * 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);
 }
 @Override
 public void unregisterAlias(PathElement address) {
   final Map<String, NodeSubregistry> snapshot = childrenUpdater.get(this);
   final NodeSubregistry subregistry = snapshot.get(address.getKey());
   if (subregistry != null) {
     subregistry.unregisterAlias(address.getValue());
   }
 }
 public void unregisterSubModel(final PathElement address) throws IllegalArgumentException {
   final Map<String, NodeSubregistry> snapshot = childrenUpdater.get(this);
   final NodeSubregistry subregistry = snapshot.get(address.getKey());
   if (subregistry != null) {
     subregistry.unregisterSubModel(address.getValue());
   }
   unregisterAccessConstraints(address);
 }
 @Override
 public void unregisterProxyController(final PathElement address) throws IllegalArgumentException {
   final Map<String, NodeSubregistry> snapshot = childrenUpdater.get(this);
   final NodeSubregistry subregistry = snapshot.get(address.getKey());
   if (subregistry != null) {
     subregistry.unregisterProxyController(address.getValue());
   }
 }
 private static String findSubsystemName(PathAddress pathAddress) {
   for (PathElement element : pathAddress) {
     if (element.getKey().equals(SUBSYSTEM)) {
       return element.getValue();
     }
   }
   return null;
 }
Exemplo n.º 24
0
 /** {@inheritDoc} */
 public void convertAttribute(
     PathAddress address,
     String name,
     ModelNode attributeValue,
     TransformationContext context) {
   PathElement element = address.getLastElement();
   attributeValue.set(element.getValue());
 }
  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);
  }
Exemplo n.º 26
0
  public static PathAddress getParentAddressByKey(PathAddress address, String parentKey) {
    for (int i = address.size() - 1; i >= 0; i--) {
      PathElement pe = address.getElement(i);
      if (parentKey.equals(pe.getKey())) {
        return address.subAddress(0, i + 1);
      }
    }

    return null;
  }
  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);
 }
 @Override
 public void registerProxyController(final PathElement address, final ProxyController controller)
     throws IllegalArgumentException {
   final AbstractResourceRegistration existing =
       getSubRegistration(PathAddress.pathAddress(address));
   if (existing != null && existing.getValueString().equals(address.getValue())) {
     throw ControllerLogger.ROOT_LOGGER.nodeAlreadyRegistered(existing.getLocationString());
   }
   getOrCreateSubregistry(address.getKey())
       .registerProxyController(address.getValue(), controller);
 }
 @Override
 ProxyController getProxyController(ListIterator<PathElement> iterator) {
   if (iterator.hasNext()) {
     final PathElement next = iterator.next();
     final NodeSubregistry subregistry = children.get(next.getKey());
     if (subregistry == null) {
       return null;
     }
     return subregistry.getProxyController(iterator, next.getValue());
   } else {
     return null;
   }
 }