예제 #1
0
/*      */   public String getString(String name, String defaultValue)
/*      */   {
/*  832 */     XMLAttribute attr = findAttribute(name);
/*  833 */     if (attr == null) {
/*  834 */       return defaultValue;
/*      */     }
/*  836 */     return attr.getValue();
/*      */   }
 private static String require(XMLExtendedStreamReader reader, XMLAttribute attribute)
     throws XMLStreamException {
   String value = reader.getAttributeValue(null, attribute.getLocalName());
   if (value == null) {
     throw ParseUtils.missingRequired(reader, attribute.getLocalName());
   }
   return value;
 }
예제 #3
0
/*      */   public void remove(String name)
/*      */   {
/* 1177 */     for (int i = 0; i < this.attributes.size(); i++) {
/* 1178 */       XMLAttribute attr = (XMLAttribute)this.attributes.elementAt(i);
/* 1179 */       if (attr.getName().equals(name)) {
/* 1180 */         this.attributes.removeElementAt(i);
/* 1181 */         return;
/*      */       }
/*      */     }
/*      */   }
예제 #4
0
/*      */   public void setString(String name, String value)
/*      */   {
/* 1119 */     XMLAttribute attr = findAttribute(name);
/* 1120 */     if (attr == null) {
/* 1121 */       attr = new XMLAttribute(name, name, null, value, "CDATA");
/* 1122 */       this.attributes.addElement(attr);
/*      */     } else {
/* 1124 */       attr.setValue(value);
/*      */     }
/*      */   }
예제 #5
0
/*      */   private XMLAttribute findAttribute(String fullName)
/*      */   {
/*  685 */     Enumeration<XMLAttribute> en = this.attributes.elements();
/*  686 */     while (en.hasMoreElements()) {
/*  687 */       XMLAttribute attr = (XMLAttribute)en.nextElement();
/*  688 */       if (attr.getName().equals(fullName)) {
/*  689 */         return attr;
/*      */       }
/*      */     }
/*  692 */     return null;
/*      */   }
예제 #6
0
 public String toString() {
   if (_next != null) {
     return _name + "=\"" + _value + "\" " + _next.toString();
   } else {
     return _name + "=\"" + _value + "\"";
   }
 }
  private void parseThreadPool(
      ThreadPoolResourceDefinition pool,
      XMLExtendedStreamReader reader,
      PathAddress parentAddress,
      Map<PathAddress, ModelNode> operations)
      throws XMLStreamException {
    PathAddress address = parentAddress.append(pool.getPathElement());
    ModelNode operation = Util.createAddOperation(address);
    operations.put(address, operation);

    for (int i = 0; i < reader.getAttributeCount(); i++) {
      XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i));
      switch (attribute) {
        case MIN_THREADS:
          readAttribute(reader, i, operation, pool.getMinThreads());
          break;
        case MAX_THREADS:
          readAttribute(reader, i, operation, pool.getMaxThreads());
          break;
        case QUEUE_LENGTH:
          readAttribute(reader, i, operation, pool.getQueueLength());
          break;
        case KEEPALIVE_TIME:
          readAttribute(reader, i, operation, pool.getKeepAliveTime());
          break;
        default:
          throw ParseUtils.unexpectedAttribute(reader, i);
      }
    }

    ParseUtils.requireNoContent(reader);
  }
 private void parseProtocolAttribute(
     XMLExtendedStreamReader reader, int index, ModelNode operation) throws XMLStreamException {
   XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(index));
   switch (attribute) {
     case TYPE:
       {
         // Already parsed
         break;
       }
     case SOCKET_BINDING:
       {
         readAttribute(
             reader, index, operation, ProtocolResourceDefinition.Attribute.SOCKET_BINDING);
         break;
       }
     case MODULE:
       {
         if (this.schema.since(JGroupsSchema.VERSION_3_0)) {
           readAttribute(reader, index, operation, ProtocolResourceDefinition.Attribute.MODULE);
           break;
         }
       }
     default:
       {
         throw ParseUtils.unexpectedAttribute(reader, index);
       }
   }
 }
예제 #9
0
/*      */   public boolean equals(Object object)
/*      */   {
/* 1350 */     if (!(object instanceof XMLElement)) {
/* 1351 */       return false;
/*      */     }
/* 1353 */     XMLElement rawElement = (XMLElement)object;
/*      */     
/* 1355 */     if (!this.name.equals(rawElement.getLocalName())) {
/* 1356 */       return false;
/*      */     }
/* 1358 */     if (this.attributes.size() != rawElement.getAttributeCount()) {
/* 1359 */       return false;
/*      */     }
/* 1361 */     Enumeration<XMLAttribute> en = this.attributes.elements();
/* 1362 */     while (en.hasMoreElements()) {
/* 1363 */       XMLAttribute attr = (XMLAttribute)en.nextElement();
/*      */       
/* 1365 */       if (!rawElement.hasAttribute(attr.getName())) {
/* 1366 */         return false;
/*      */       }
/*      */       
/*      */ 
/*      */ 
/* 1371 */       String value = rawElement.getString(attr.getName(), null);
/* 1372 */       if (!attr.getValue().equals(value)) {
/* 1373 */         return false;
/*      */       }
/*      */     }
/*      */     
/*      */ 
/*      */ 
/*      */ 
/*      */ 
/* 1381 */     if (this.children.size() != rawElement.getChildCount()) {
/* 1382 */       return false;
/*      */     }
/* 1384 */     for (int i = 0; i < this.children.size(); i++) {
/* 1385 */       XMLElement child1 = getChild(i);
/* 1386 */       XMLElement child2 = rawElement.getChild(i);
/*      */       
/* 1388 */       if (!child1.equals(child2)) {
/* 1389 */         return false;
/*      */       }
/*      */     }
/* 1392 */     return true;
/*      */   }
  private void parseChannel(
      XMLExtendedStreamReader reader,
      PathAddress subsystemAddress,
      Map<PathAddress, ModelNode> operations)
      throws XMLStreamException {
    String name = require(reader, XMLAttribute.NAME);
    PathAddress address = subsystemAddress.append(ChannelResourceDefinition.pathElement(name));
    ModelNode operation = Util.createAddOperation(address);
    operations.put(address, operation);

    for (int i = 0; i < reader.getAttributeCount(); i++) {
      ParseUtils.requireNoNamespaceAttribute(reader, i);
      XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i));
      switch (attribute) {
        case NAME:
          {
            // Already parsed
            break;
          }
        case STACK:
          {
            readAttribute(reader, i, operation, ChannelResourceDefinition.Attribute.STACK);
            break;
          }
        case MODULE:
          {
            readAttribute(reader, i, operation, ChannelResourceDefinition.Attribute.MODULE);
            break;
          }
        default:
          {
            throw ParseUtils.unexpectedAttribute(reader, i);
          }
      }
    }

    while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
      XMLElement element = XMLElement.forName(reader.getLocalName());
      switch (element) {
        case FORK:
          {
            this.parseFork(reader, address, operations);
            break;
          }
        default:
          {
            throw ParseUtils.unexpectedElement(reader);
          }
      }
    }
  }
  private void parseRelay(
      XMLExtendedStreamReader reader,
      PathAddress stackAddress,
      Map<PathAddress, ModelNode> operations)
      throws XMLStreamException {
    PathAddress address = stackAddress.append(RelayResourceDefinition.PATH);
    ModelNode operation = Util.createAddOperation(address);
    operations.put(address, operation);

    for (int i = 0; i < reader.getAttributeCount(); i++) {
      XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i));
      switch (attribute) {
        case SITE:
          {
            readAttribute(reader, i, operation, RelayResourceDefinition.Attribute.SITE);
            break;
          }
        default:
          {
            throw ParseUtils.unexpectedAttribute(reader, i);
          }
      }
    }

    if (!operation.hasDefined(RelayResourceDefinition.Attribute.SITE.getDefinition().getName())) {
      throw ParseUtils.missingRequired(reader, EnumSet.of(XMLAttribute.SITE));
    }

    while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
      XMLElement element = XMLElement.forName(reader.getLocalName());
      switch (element) {
        case REMOTE_SITE:
          {
            this.parseRemoteSite(reader, address, operations);
            break;
          }
        case PROPERTY:
          {
            this.parseProperty(reader, address, operations);
            break;
          }
        default:
          {
            throw ParseUtils.unexpectedElement(reader);
          }
      }
    }
  }
  @SuppressWarnings("deprecation")
  private void parseStacks(
      XMLExtendedStreamReader reader, PathAddress address, Map<PathAddress, ModelNode> operations)
      throws XMLStreamException {

    ModelNode operation = operations.get(address);

    for (int i = 0; i < reader.getAttributeCount(); i++) {
      ParseUtils.requireNoNamespaceAttribute(reader, i);
      XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i));
      switch (attribute) {
        case DEFAULT:
          {
            readAttribute(
                reader, i, operation, JGroupsSubsystemResourceDefinition.Attribute.DEFAULT_STACK);
            break;
          }
        default:
          {
            throw ParseUtils.unexpectedAttribute(reader, i);
          }
      }
    }

    while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
      XMLElement element = XMLElement.forName(reader.getLocalName());
      switch (element) {
        case STACK:
          {
            this.parseStack(reader, address, operations);
            break;
          }
        default:
          {
            throw ParseUtils.unexpectedElement(reader);
          }
      }
    }
  }
  private void parseRemoteSite(
      XMLExtendedStreamReader reader,
      PathAddress relayAddress,
      Map<PathAddress, ModelNode> operations)
      throws XMLStreamException {
    String site = require(reader, XMLAttribute.NAME);
    PathAddress address = relayAddress.append(RemoteSiteResourceDefinition.pathElement(site));
    ModelNode operation = Util.createAddOperation(address);
    operations.put(address, operation);

    String cluster = null;

    for (int i = 0; i < reader.getAttributeCount(); i++) {
      String value = reader.getAttributeValue(i);
      XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i));
      switch (attribute) {
        case NAME:
          {
            // Already parsed
            break;
          }
        case STACK:
          {
            if (this.schema.since(JGroupsSchema.VERSION_3_0)) {
              throw ParseUtils.unexpectedAttribute(reader, i);
            }
            readAttribute(
                reader, i, operation, RemoteSiteResourceDefinition.DeprecatedAttribute.STACK);
            break;
          }
        case CLUSTER:
          {
            if (this.schema.since(JGroupsSchema.VERSION_3_0)) {
              throw ParseUtils.unexpectedAttribute(reader, i);
            }
            cluster = value;
            break;
          }
        case CHANNEL:
          {
            if (this.schema.since(JGroupsSchema.VERSION_3_0)) {
              readAttribute(reader, i, operation, RemoteSiteResourceDefinition.Attribute.CHANNEL);

              // We need to populate the deprecated STACK attribute so that we have enough context
              // for transforming the add operation
              PathAddress subsystemAddress =
                  PathAddress.pathAddress(JGroupsSubsystemResourceDefinition.PATH);
              PathAddress channelAddress =
                  subsystemAddress.append(ChannelResourceDefinition.pathElement(value));
              ModelNode channelOperation = operations.get(channelAddress);
              if (channelOperation != null) {
                String stack;
                if (channelOperation.hasDefined(
                    ChannelResourceDefinition.Attribute.STACK.getDefinition().getName())) {
                  stack =
                      channelOperation
                          .get(ChannelResourceDefinition.Attribute.STACK.getDefinition().getName())
                          .asString();
                } else {
                  stack =
                      operations
                          .get(subsystemAddress)
                          .get(
                              JGroupsSubsystemResourceDefinition.Attribute.DEFAULT_STACK
                                  .getDefinition()
                                  .getName())
                          .asString();
                }
                setAttribute(
                    reader,
                    stack,
                    operation,
                    RemoteSiteResourceDefinition.DeprecatedAttribute.STACK);
              }
              break;
            }
          }
        default:
          {
            throw ParseUtils.unexpectedAttribute(reader, i);
          }
      }
    }

    if (this.schema.since(JGroupsSchema.VERSION_3_0)) {
      if (!operation.hasDefined(
          RemoteSiteResourceDefinition.Attribute.CHANNEL.getDefinition().getName())) {
        throw ParseUtils.missingRequired(reader, EnumSet.of(XMLAttribute.CHANNEL));
      }
    } else {
      if (!operation.hasDefined(
          RemoteSiteResourceDefinition.DeprecatedAttribute.STACK.getDefinition().getName())) {
        throw ParseUtils.missingRequired(reader, EnumSet.of(XMLAttribute.STACK));
      }
      String channel = (cluster != null) ? cluster : site;
      setAttribute(reader, channel, operation, RemoteSiteResourceDefinition.Attribute.CHANNEL);

      // We need to create a corresponding channel add operation
      PathAddress subsystemAddress =
          PathAddress.pathAddress(JGroupsSubsystemResourceDefinition.PATH);
      PathAddress channelAddress =
          subsystemAddress.append(ChannelResourceDefinition.pathElement(channel));
      ModelNode channelOperation = Util.createAddOperation(channelAddress);
      String stack =
          operation
              .get(RemoteSiteResourceDefinition.DeprecatedAttribute.STACK.getDefinition().getName())
              .asString();
      setAttribute(reader, stack, channelOperation, ChannelResourceDefinition.Attribute.STACK);
      operations.put(channelAddress, channelOperation);
    }

    ParseUtils.requireNoContent(reader);
  }
  private void parseTransport(
      XMLExtendedStreamReader reader,
      PathAddress stackAddress,
      Map<PathAddress, ModelNode> operations)
      throws XMLStreamException {

    String type = require(reader, XMLAttribute.TYPE);
    PathAddress address = stackAddress.append(TransportResourceDefinition.pathElement(type));
    ModelNode operation = Util.createAddOperation(address);
    operations.put(address, operation);

    for (int i = 0; i < reader.getAttributeCount(); i++) {
      XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i));
      switch (attribute) {
        case SHARED:
          {
            readAttribute(reader, i, operation, TransportResourceDefinition.Attribute.SHARED);
            break;
          }
        case DIAGNOSTICS_SOCKET_BINDING:
          {
            readAttribute(
                reader,
                i,
                operation,
                TransportResourceDefinition.Attribute.DIAGNOSTICS_SOCKET_BINDING);
            break;
          }
        case DEFAULT_EXECUTOR:
          {
            readAttribute(
                reader,
                i,
                operation,
                TransportResourceDefinition.ThreadingAttribute.DEFAULT_EXECUTOR);
            break;
          }
        case OOB_EXECUTOR:
          {
            readAttribute(
                reader, i, operation, TransportResourceDefinition.ThreadingAttribute.OOB_EXECUTOR);
            break;
          }
        case TIMER_EXECUTOR:
          {
            readAttribute(
                reader,
                i,
                operation,
                TransportResourceDefinition.ThreadingAttribute.TIMER_EXECUTOR);
            break;
          }
        case THREAD_FACTORY:
          {
            readAttribute(
                reader,
                i,
                operation,
                TransportResourceDefinition.ThreadingAttribute.THREAD_FACTORY);
            break;
          }
        case SITE:
          {
            if (this.schema.since(JGroupsSchema.VERSION_1_1)) {
              readAttribute(reader, i, operation, TransportResourceDefinition.Attribute.SITE);
              break;
            }
          }
        case RACK:
          {
            if (this.schema.since(JGroupsSchema.VERSION_1_1)) {
              readAttribute(reader, i, operation, TransportResourceDefinition.Attribute.RACK);
              break;
            }
          }
        case MACHINE:
          {
            if (this.schema.since(JGroupsSchema.VERSION_1_1)) {
              readAttribute(reader, i, operation, TransportResourceDefinition.Attribute.MACHINE);
              break;
            }
          }
        default:
          {
            this.parseProtocolAttribute(reader, i, operation);
          }
      }
    }

    while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
      this.parseProtocolElement(reader, address, operations);
    }
  }