示例#1
0
  public static ModifiableResourceAdapter buildResourceAdaptersObject(ModelNode operation)
      throws OperationFailedException {
    Map<String, String> configProperties = new HashMap<String, String>(0);
    List<CommonConnDef> connectionDefinitions = new ArrayList<CommonConnDef>(0);
    List<CommonAdminObject> adminObjects = new ArrayList<CommonAdminObject>(0);
    //        if (operation.hasDefined(CONFIG_PROPERTIES.getName())) {
    //            configProperties = new HashMap<String,
    // String>(operation.get(CONFIG_PROPERTIES.getName()).asList().size());
    //            for (ModelNode property : operation.get(CONFIG_PROPERTIES.getName()).asList()) {
    //                configProperties.put(property.asProperty().getName(),
    // property.asProperty().getValue().asString());
    //            }
    //        }
    String archive = getStringIfSetOrGetDefault(operation, ARCHIVE.getName(), null);
    TransactionSupportEnum transactionSupport =
        operation.hasDefined(TRANSACTIONSUPPORT.getName())
            ? TransactionSupportEnum.valueOf(operation.get(TRANSACTIONSUPPORT.getName()).asString())
            : null;
    String bootstrapContext =
        getStringIfSetOrGetDefault(operation, BOOTSTRAPCONTEXT.getName(), null);
    List<String> beanValidationGroups = null;
    if (operation.hasDefined(BEANVALIDATIONGROUPS.getName())) {
      beanValidationGroups =
          new ArrayList<String>(operation.get(BEANVALIDATIONGROUPS.getName()).asList().size());
      for (ModelNode beanValidtion : operation.get(BEANVALIDATIONGROUPS.getName()).asList()) {
        beanValidationGroups.add(beanValidtion.asString());
      }
    }
    ModifiableResourceAdapter ra;
    ra =
        new ModifiableResourceAdapter(
            archive,
            transactionSupport,
            connectionDefinitions,
            adminObjects,
            configProperties,
            beanValidationGroups,
            bootstrapContext);

    return ra;
  }
    private void writeRaElement(XMLExtendedStreamWriter streamWriter, ModelNode ra)
        throws XMLStreamException {
      streamWriter.writeStartElement(ResourceAdapters.Tag.RESOURCE_ADAPTER.getLocalName());

      ARCHIVE.marshallAsElement(ra, streamWriter);

      if (ra.hasDefined(BEANVALIDATIONGROUPS.getName())) {
        for (ModelNode bvg : ra.get(BEANVALIDATIONGROUPS.getName()).asList()) {
          BEANVALIDATIONGROUPS.marshallAsElement(bvg, streamWriter);
        }
      }

      BOOTSTRAPCONTEXT.marshallAsElement(ra, streamWriter);
      TRANSACTIONSUPPORT.marshallAsElement(ra, streamWriter);
      writeNewConfigProperties(streamWriter, ra);
      TransactionSupportEnum transactionSupport =
          ra.hasDefined(TRANSACTIONSUPPORT.getName())
              ? TransactionSupportEnum.valueOf(ra.get(TRANSACTIONSUPPORT.getName()).asString())
              : null;
      boolean isXa = false;
      if (transactionSupport == TransactionSupportEnum.XATransaction) {
        isXa = true;
      }
      if (ra.hasDefined(CONNECTIONDEFINITIONS_NAME)) {
        streamWriter.writeStartElement(ResourceAdapter.Tag.CONNECTION_DEFINITIONS.getLocalName());
        for (Property conDef : ra.get(CONNECTIONDEFINITIONS_NAME).asPropertyList()) {
          writeConDef(streamWriter, conDef.getValue(), conDef.getName(), isXa);
        }
        streamWriter.writeEndElement();
      }

      if (ra.hasDefined(ADMIN_OBJECTS_NAME)) {
        streamWriter.writeStartElement(ResourceAdapter.Tag.ADMIN_OBJECTS.getLocalName());
        for (Property adminObject : ra.get(ADMIN_OBJECTS_NAME).asPropertyList()) {
          writeAdminObject(streamWriter, adminObject.getValue(), adminObject.getName());
        }
        streamWriter.writeEndElement();
      }
      streamWriter.writeEndElement();
    }