コード例 #1
0
 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);
     }
   }
 }
コード例 #2
0
 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);
       }
     }
   }
 }
コード例 #3
0
 @Override
 void getProxyControllers(ListIterator<PathElement> iterator, Set<ProxyController> controllers) {
   if (iterator.hasNext()) {
     final PathElement next = iterator.next();
     final NodeSubregistry subregistry = children.get(next.getKey());
     if (subregistry == null) {
       return;
     }
     if (next.isWildcard()) {
       subregistry.getProxyControllers(iterator, null, controllers);
     } else if (next.isMultiTarget()) {
       for (final String value : next.getSegments()) {
         subregistry.getProxyControllers(iterator, value, controllers);
       }
     } else {
       subregistry.getProxyControllers(iterator, next.getValue(), controllers);
     }
   } else {
     final Map<String, NodeSubregistry> snapshot = childrenUpdater.get(this);
     for (NodeSubregistry subregistry : snapshot.values()) {
       subregistry.getProxyControllers(iterator, null, controllers);
     }
   }
 }