Exemplo n.º 1
0
    static {
      // shared cache attributes
      sharedAttributeResolver.put(CacheResource.BATCHING.getName(), "cache");
      sharedAttributeResolver.put(CacheResource.CACHE_MODULE.getName(), "cache");
      sharedAttributeResolver.put(CacheResource.INDEXING.getName(), "cache");
      sharedAttributeResolver.put(CacheResource.INDEXING_PROPERTIES.getName(), "cache");
      sharedAttributeResolver.put(CacheResource.JNDI_NAME.getName(), "cache");
      sharedAttributeResolver.put(CacheResource.NAME.getName(), "cache");
      sharedAttributeResolver.put(CacheResource.START.getName(), "cache");

      sharedAttributeResolver.put(
          ClusteredCacheResource.ASYNC_MARSHALLING.getName(), "clustered-cache");
      sharedAttributeResolver.put(ClusteredCacheResource.MODE.getName(), "clustered-cache");
      sharedAttributeResolver.put(
          ClusteredCacheResource.QUEUE_FLUSH_INTERVAL.getName(), "clustered-cache");
      sharedAttributeResolver.put(ClusteredCacheResource.QUEUE_SIZE.getName(), "clustered-cache");
      sharedAttributeResolver.put(
          ClusteredCacheResource.REMOTE_TIMEOUT.getName(), "clustered-cache");

      sharedAttributeResolver.put(BaseStoreResource.FETCH_STATE.getName(), "store");
      sharedAttributeResolver.put(BaseStoreResource.PASSIVATION.getName(), "store");
      sharedAttributeResolver.put(BaseStoreResource.PRELOAD.getName(), "store");
      sharedAttributeResolver.put(BaseStoreResource.PURGE.getName(), "store");
      sharedAttributeResolver.put(BaseStoreResource.SHARED.getName(), "store");
      sharedAttributeResolver.put(BaseStoreResource.SINGLETON.getName(), "store");
      sharedAttributeResolver.put(BaseStoreResource.PROPERTY.getName(), "store");
      sharedAttributeResolver.put(BaseStoreResource.PROPERTIES.getName(), "store");

      sharedAttributeResolver.put(BaseJDBCStoreResource.DATA_SOURCE.getName(), "jdbc-store");
      sharedAttributeResolver.put(BaseJDBCStoreResource.BATCH_SIZE.getName(), "jdbc-store");
      sharedAttributeResolver.put(BaseJDBCStoreResource.FETCH_SIZE.getName(), "jdbc-store");
      sharedAttributeResolver.put(BaseJDBCStoreResource.PREFIX.getName(), "jdbc-store");
      sharedAttributeResolver.put(
          BaseJDBCStoreResource.ID_COLUMN.getName() + ".column", "jdbc-store");
      sharedAttributeResolver.put(
          BaseJDBCStoreResource.DATA_COLUMN.getName() + ".column", "jdbc-store");
      sharedAttributeResolver.put(
          BaseJDBCStoreResource.TIMESTAMP_COLUMN.getName() + ".column", "jdbc-store");
      sharedAttributeResolver.put(
          BaseJDBCStoreResource.ENTRY_TABLE.getName() + "table", "jdbc-store");
      sharedAttributeResolver.put(
          BaseJDBCStoreResource.BUCKET_TABLE.getName() + "table", "jdbc-store");

      // shared children - this avoids having to describe the children for each parent resource
      sharedAttributeResolver.put(ModelKeys.TRANSPORT, null);
      sharedAttributeResolver.put(ModelKeys.LOCKING, null);
      sharedAttributeResolver.put(ModelKeys.TRANSACTION, null);
      sharedAttributeResolver.put(ModelKeys.EVICTION, null);
      sharedAttributeResolver.put(ModelKeys.EXPIRATION, null);
      sharedAttributeResolver.put(ModelKeys.STATE_TRANSFER, null);
      sharedAttributeResolver.put(ModelKeys.STORE, null);
      sharedAttributeResolver.put(ModelKeys.FILE_STORE, null);
      sharedAttributeResolver.put(ModelKeys.REMOTE_STORE, null);
      sharedAttributeResolver.put(ModelKeys.STRING_KEYED_JDBC_STORE, null);
      sharedAttributeResolver.put(ModelKeys.BINARY_KEYED_JDBC_STORE, null);
      sharedAttributeResolver.put(ModelKeys.MIXED_KEYED_JDBC_STORE, null);
      sharedAttributeResolver.put(ModelKeys.WRITE_BEHIND, null);
      sharedAttributeResolver.put(ModelKeys.PROPERTY, null);
    }
  private void parseBinaryKeyedJDBCStore(
      XMLExtendedStreamReader reader, ModelNode cache, List<ModelNode> operations)
      throws XMLStreamException {

    PathAddress storeAddress =
        PathAddress.pathAddress(cache.get(OP_ADDR))
            .append(ModelKeys.BINARY_KEYED_JDBC_STORE, ModelKeys.BINARY_KEYED_JDBC_STORE_NAME);
    ModelNode store = Util.createAddOperation(storeAddress);

    List<ModelNode> additionalConfigurationOperations = new ArrayList<ModelNode>();

    for (int i = 0; i < reader.getAttributeCount(); i++) {
      String value = reader.getAttributeValue(i);
      Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
      switch (attribute) {
        case DATASOURCE:
          {
            BaseJDBCStoreResource.DATA_SOURCE.parseAndSetParameter(value, store, reader);
            break;
          }
        default:
          {
            this.parseStoreAttribute(reader, i, attribute, value, store);
          }
      }
    }

    if (!store.hasDefined(ModelKeys.DATASOURCE)) {
      throw ParseUtils.missingRequired(reader, EnumSet.of(Attribute.DATASOURCE));
    }

    while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
      Element element = Element.forName(reader.getLocalName());
      switch (element) {
        case BINARY_KEYED_TABLE:
          {
            this.parseJDBCStoreTable(
                reader, store.get(ModelKeys.BINARY_KEYED_TABLE).setEmptyObject());
            break;
          }
        case WRITE_BEHIND:
          {
            parseStoreWriteBehind(reader, store, additionalConfigurationOperations);
            break;
          }
        default:
          {
            this.parseStoreProperty(reader, store, additionalConfigurationOperations);
          }
      }
    }
    operations.add(store);
    operations.addAll(additionalConfigurationOperations);
  }