コード例 #1
0
  /**
   * {@inheritDoc}
   *
   * @see
   *     org.jboss.staxmapper.XMLElementReader#readElement(org.jboss.staxmapper.XMLExtendedStreamReader,
   *     java.lang.Object)
   */
  @Override
  public void readElement(XMLExtendedStreamReader reader, List<ModelNode> operations)
      throws XMLStreamException {

    ModelNode subsystemAddress = new ModelNode();
    subsystemAddress.add(ModelDescriptionConstants.SUBSYSTEM, InfinispanExtension.SUBSYSTEM_NAME);
    subsystemAddress.protect();

    ModelNode subsystem = Util.getEmptyOperation(ModelDescriptionConstants.ADD, subsystemAddress);

    for (int i = 0; i < reader.getAttributeCount(); i++) {
      ParseUtils.requireNoNamespaceAttribute(reader, i);
      String value = reader.getAttributeValue(i);
      Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
      switch (attribute) {
        case DEFAULT_CACHE_CONTAINER:
          {
            subsystem.get(ModelKeys.DEFAULT_CACHE_CONTAINER).set(value);
            break;
          }
        default:
          {
            throw ParseUtils.unexpectedAttribute(reader, i);
          }
      }
    }

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

    // command to add the subsystem
    operations.add(subsystem);

    while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
      switch (Namespace.forUri(reader.getNamespaceURI())) {
        case INFINISPAN_1_0:
        case INFINISPAN_1_1:
          {
            Element element = Element.forName(reader.getLocalName());
            switch (element) {
              case CACHE_CONTAINER:
                {
                  parseContainer(reader, subsystemAddress, operations);
                  break;
                }
              default:
                {
                  throw ParseUtils.unexpectedElement(reader);
                }
            }
            break;
          }
        default:
          {
            throw ParseUtils.unexpectedElement(reader);
          }
      }
    }
  }
コード例 #2
0
    @Override
    public void readElement(final XMLExtendedStreamReader reader, final List<ModelNode> list)
        throws XMLStreamException {

      final ModelNode address = new ModelNode();
      address.add(SUBSYSTEM, SUBSYSTEM_NAME);
      address.protect();

      final ModelNode subsystem = new ModelNode();
      subsystem.get(OP).set(ADD);
      subsystem.get(OP_ADDR).set(address);
      list.add(subsystem);

      // Handle elements
      while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        switch (Namespace.forUri(reader.getNamespaceURI())) {
          case THREADS_1_0:
            {
              final Element element = Element.forName(reader.getLocalName());
              switch (element) {
                case BOUNDED_QUEUE_THREAD_POOL:
                  {
                    parseBoundedQueueThreadPool(reader, address, list);
                    break;
                  }
                case THREAD_FACTORY:
                  {
                    // Add connector updates
                    parseThreadFactory(reader, address, list);
                    break;
                  }
                case QUEUELESS_THREAD_POOL:
                  {
                    parseQueuelessThreadPool(reader, address, list);
                    break;
                  }
                case SCHEDULED_THREAD_POOL:
                  {
                    parseScheduledThreadPool(reader, address, list);
                    break;
                  }
                case UNBOUNDED_QUEUE_THREAD_POOL:
                  {
                    parseUnboundedQueueThreadPool(reader, address, list);
                    break;
                  }
                default:
                  {
                    throw unexpectedElement(reader);
                  }
              }
              break;
            }
          default:
            {
              throw unexpectedElement(reader);
            }
        }
      }
    }
コード例 #3
0
  private void parseRehashing(
      XMLExtendedStreamReader reader, ModelNode cache, List<ModelNode> operations)
      throws XMLStreamException {

    // ModelNode for the rehashing add operation
    ModelNode rehashingAddress = cache.get(ModelDescriptionConstants.OP_ADDR).clone();
    rehashingAddress.add(ModelKeys.STATE_TRANSFER, ModelKeys.STATE_TRANSFER_NAME);
    rehashingAddress.protect();
    ModelNode rehashing = Util.getEmptyOperation(ModelDescriptionConstants.ADD, rehashingAddress);

    for (int i = 0; i < reader.getAttributeCount(); i++) {
      String value = reader.getAttributeValue(i);
      Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
      switch (attribute) {
        case ENABLED:
          {
            CommonAttributes.ENABLED.parseAndSetParameter(value, rehashing, reader);
            break;
          }
        case TIMEOUT:
          {
            CommonAttributes.TIMEOUT.parseAndSetParameter(value, rehashing, reader);
            break;
          }
        default:
          {
            throw ParseUtils.unexpectedAttribute(reader, i);
          }
      }
    }
    ParseUtils.requireNoContent(reader);
    operations.add(rehashing);
  }
コード例 #4
0
  @Test
  public void testReadResourceResources() throws Exception {

    final ModelNode address = new ModelNode();
    address.add("subsystem", "datasources");
    address.protect();

    final ModelNode operation = new ModelNode();
    operation.get(OP).set("read-resource-description");

    operation.get(OP_ADDR).set(address);

    final ModelNode result = executeOperation(operation);
    final Map<String, ModelNode> children =
        getChildren(result.get("attributes").get("installed-drivers").get("value-type"));
    Assert.assertFalse(children.isEmpty());

    HashSet<String> keys = new HashSet<String>();
    for (final Entry<String, ModelNode> child : children.entrySet()) {
      Assert.assertTrue(child.getKey() != null);
      keys.add(child.getKey());
    }
    Assert.assertTrue(keys.contains("driver-xa-datasource-class-name"));
    Assert.assertTrue(keys.contains("module-slot"));
    Assert.assertTrue(keys.contains("driver-name"));
  }
コード例 #5
0
 @Override
 protected ModelNode getDataSourceAddress(Datasource datasource) {
   ModelNode address =
       new ModelNode().add(SUBSYSTEM, "datasources").add("data-source", datasource.getName());
   address.protect();
   return address;
 }
コード例 #6
0
  private void parseEviction(
      XMLExtendedStreamReader reader, ModelNode cache, List<ModelNode> operations)
      throws XMLStreamException {
    // ModelNode for the eviction add operation
    ModelNode evictionAddress = cache.get(ModelDescriptionConstants.OP_ADDR).clone();
    evictionAddress.add(ModelKeys.EVICTION, ModelKeys.EVICTION_NAME);
    evictionAddress.protect();
    ModelNode eviction = Util.getEmptyOperation(ModelDescriptionConstants.ADD, evictionAddress);

    for (int i = 0; i < reader.getAttributeCount(); i++) {
      String value = reader.getAttributeValue(i);
      Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
      switch (attribute) {
        case STRATEGY:
          {
            EvictionResource.EVICTION_STRATEGY.parseAndSetParameter(value, eviction, reader);
            break;
          }
        case MAX_ENTRIES:
          {
            EvictionResource.MAX_ENTRIES.parseAndSetParameter(value, eviction, reader);
            break;
          }
        default:
          {
            throw ParseUtils.unexpectedAttribute(reader, i);
          }
      }
    }
    ParseUtils.requireNoContent(reader);
    operations.add(eviction);
  }
コード例 #7
0
  private void parseCustomStore(
      XMLExtendedStreamReader reader, ModelNode cache, List<ModelNode> operations)
      throws XMLStreamException {
    // ModelNode for the store add operation
    ModelNode storeAddress = cache.get(ModelDescriptionConstants.OP_ADDR).clone();
    storeAddress.add(ModelKeys.STORE, ModelKeys.STORE_NAME);
    storeAddress.protect();
    ModelNode store = Util.getEmptyOperation(ModelDescriptionConstants.ADD, storeAddress);

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

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

    this.parseStoreProperties(reader, store);
    operations.add(store);
  }
コード例 #8
0
  private void parseFileStore(
      XMLExtendedStreamReader reader, ModelNode cache, List<ModelNode> operations)
      throws XMLStreamException {
    // ModelNode for the store add operation
    ModelNode storeAddress = cache.get(ModelDescriptionConstants.OP_ADDR).clone();
    storeAddress.add(ModelKeys.FILE_STORE, ModelKeys.FILE_STORE_NAME);
    storeAddress.protect();
    ModelNode store = Util.getEmptyOperation(ModelDescriptionConstants.ADD, storeAddress);

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

    this.parseStoreProperties(reader, store);
    operations.add(store);
  }
コード例 #9
0
  private void parseTransport(
      XMLExtendedStreamReader reader, ModelNode containerAddress, List<ModelNode> operations)
      throws XMLStreamException {

    // ModelNode for the transport add operation
    ModelNode transport = Util.getEmptyOperation(ModelDescriptionConstants.ADD, null);

    for (int i = 0; i < reader.getAttributeCount(); i++) {
      String value = reader.getAttributeValue(i);
      Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
      switch (attribute) {
        case STACK:
          {
            transport.get(ModelKeys.STACK).set(value);
            break;
          }
        case EXECUTOR:
          {
            transport.get(ModelKeys.EXECUTOR).set(value);
            break;
          }
        case LOCK_TIMEOUT:
          {
            transport.get(ModelKeys.LOCK_TIMEOUT).set(Long.parseLong(value));
            break;
          }
        case SITE:
          {
            transport.get(ModelKeys.SITE).set(value);
            break;
          }
        case RACK:
          {
            transport.get(ModelKeys.RACK).set(value);
            break;
          }
        case MACHINE:
          {
            transport.get(ModelKeys.MACHINE).set(value);
            break;
          }
        default:
          {
            throw ParseUtils.unexpectedAttribute(reader, i);
          }
      }
    }
    ParseUtils.requireNoContent(reader);

    // setup the transport address
    ModelNode transportAddress = containerAddress.clone();
    transportAddress.add(ModelKeys.SINGLETON, ModelKeys.TRANSPORT);
    transportAddress.protect();
    transport.get(ModelDescriptionConstants.OP_ADDR).set(transportAddress);

    operations.add(transport);
  }
コード例 #10
0
  /**
   * Creates the root subsystem's root address.
   *
   * @return
   */
  private ModelNode createSubsystemRoot() {
    ModelNode subsystemAddress = new ModelNode();

    subsystemAddress.add(ModelDescriptionConstants.SUBSYSTEM, IDMExtension.SUBSYSTEM_NAME);

    subsystemAddress.protect();

    return Util.getEmptyOperation(ADD, subsystemAddress);
  }
コード例 #11
0
ファイル: JcaExtension.java プロジェクト: jswordfish/jboss-as
  private static ModelNode createEmptyAddOperation() {
    final ModelNode address = new ModelNode();
    address.add(ModelDescriptionConstants.SUBSYSTEM, JCA);
    address.protect();

    final ModelNode subsystem = new ModelNode();
    subsystem.get(OP).set(ADD);
    subsystem.get(OP_ADDR).set(address);
    return subsystem;
  }
コード例 #12
0
ファイル: PureTestCase.java プロジェクト: ringerc/jboss-as
    @Override
    public void tearDown(final ManagementClient managementClient, final String containerId)
        throws Exception {

      final ModelNode address = new ModelNode();
      address.add("subsystem", "resource-adapters");
      address.add("resource-adapter", "pure.rar");
      address.protect();
      remove(address);
    }
コード例 #13
0
  private void parseRemoteStore(
      XMLExtendedStreamReader reader, ModelNode cache, List<ModelNode> operations)
      throws XMLStreamException {
    // ModelNode for the store add operation
    ModelNode storeAddress = cache.get(ModelDescriptionConstants.OP_ADDR).clone();
    storeAddress.add(ModelKeys.REMOTE_STORE, ModelKeys.REMOTE_STORE_NAME);
    storeAddress.protect();
    ModelNode store = Util.getEmptyOperation(ModelDescriptionConstants.ADD, storeAddress);

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

    while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
      Element element = Element.forName(reader.getLocalName());
      switch (element) {
        case REMOTE_SERVER:
          {
            this.parseRemoteServer(reader, store.get(ModelKeys.REMOTE_SERVERS).add());
            break;
          }
        default:
          {
            this.parseStoreProperty(reader, store);
          }
      }
    }

    if (!store.hasDefined(ModelKeys.REMOTE_SERVERS)) {
      throw ParseUtils.missingRequired(reader, Collections.singleton(Element.REMOTE_SERVER));
    }
    operations.add(store);
  }
コード例 #14
0
  @AfterClass
  public static void tearDown() throws Exception {

    final ModelNode address = new ModelNode();
    address.add("subsystem", "resource-adapters");
    address.add("resource-adapter", "as7_1452.rar");
    address.protect();

    remove(address);
    closeModelControllerClient();
  }
コード例 #15
0
 /**
  * Tests connection in pool
  *
  * @throws Exception in case of error
  */
 @Test
 @RunAsClient
 public void testConnection2() throws Exception {
   final ModelNode address1 = ModuleAcDeploymentTestCaseSetup.address1.clone();
   address1.add("connection-definitions", cf1);
   address1.protect();
   final ModelNode operation1 = new ModelNode();
   operation1.get(OP).set("test-connection-in-pool");
   operation1.get(OP_ADDR).set(address1);
   executeOperation(operation1);
 }
コード例 #16
0
  private void parseStringKeyedJDBCStore(
      XMLExtendedStreamReader reader, ModelNode cache, List<ModelNode> operations)
      throws XMLStreamException {
    // ModelNode for the string-keyed jdbc store add operation
    ModelNode storeAddress = cache.get(ModelDescriptionConstants.OP_ADDR).clone();
    storeAddress.add(ModelKeys.STRING_KEYED_JDBC_STORE, ModelKeys.STRING_KEYED_JDBC_STORE_NAME);
    storeAddress.protect();
    ModelNode store = Util.getEmptyOperation(ModelDescriptionConstants.ADD, 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 STRING_KEYED_TABLE:
          {
            this.parseJDBCStoreTable(
                reader, store.get(ModelKeys.STRING_KEYED_TABLE).setEmptyObject());
            break;
          }
        case WRITE_BEHIND:
          {
            parseStoreWriteBehind(reader, store, additionalConfigurationOperations);
            break;
          }
        default:
          {
            this.parseStoreProperty(reader, store);
          }
      }
    }
    operations.add(store);
    operations.addAll(additionalConfigurationOperations);
  }
コード例 #17
0
  private void addCacheNameToAddress(
      ModelNode cache, ModelNode containerAddress, String cacheType) {

    String name = cache.get(ModelKeys.NAME).asString();
    // setup the cache address
    ModelNode cacheAddress = containerAddress.clone();
    cacheAddress.add(cacheType, name);
    cacheAddress.protect();
    cache.get(ModelDescriptionConstants.OP_ADDR).set(cacheAddress);

    // get rid of NAME now that we are finished with it
    cache.remove(ModelKeys.NAME);
  }
コード例 #18
0
    /**
     * Creates data source and return its node address
     *
     * @param xa - should be data source XA?
     * @param jndiName of data source
     * @return ModelNode - address of data source node
     * @throws Exception
     */
    private ModelNode createDataSource(boolean xa, String jndiName) throws Exception {
      ModelNode address = new ModelNode();
      address.add(SUBSYSTEM, "datasources");
      address.add((xa ? "xa-" : "") + "data-source", jndiName);
      address.protect();

      ModelNode operation = new ModelNode();
      operation.get(OP).set(ADD);
      operation.get(OP_ADDR).set(address);
      operation.get("jndi-name").set(jndiName);
      operation.get("driver-name").set("h2");
      if (!xa) operation.get("connection-url").set("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1");
      operation.get("prepared-statements-cache-size").set(3);
      operation.get("user-name").set("sa");
      operation.get("password").set("sa");

      executeOperation(operation);

      if (xa) {
        final ModelNode xaDatasourcePropertiesAddress = address.clone();
        xaDatasourcePropertiesAddress.add("xa-datasource-properties", "URL");
        xaDatasourcePropertiesAddress.protect();
        final ModelNode xaDatasourcePropertyOperation = new ModelNode();
        xaDatasourcePropertyOperation.get(OP).set("add");
        xaDatasourcePropertyOperation.get(OP_ADDR).set(xaDatasourcePropertiesAddress);
        xaDatasourcePropertyOperation.get("value").set("jdbc:h2:mem:test");

        executeOperation(xaDatasourcePropertyOperation);
      }

      operation = new ModelNode();
      operation.get(OP).set("enable");
      operation.get(OP_ADDR).set(address);

      executeOperation(operation);

      return address;
    }
コード例 #19
0
  @Test
  public void testUndefinedTypeEmptyConverter() {
    TypeConverter converter = getConverter(new ModelNode());
    Assert.assertEquals(SimpleType.STRING, converter.getOpenType());

    ModelNode node = new ModelNode();
    node.get("abc");
    node.get("def");
    node.protect();

    String json = assertCast(String.class, converter.fromModelNode(node));
    Assert.assertEquals(node.resolve(), ModelNode.fromJSONString(json));
    Assert.assertEquals(json, assertCast(String.class, converter.fromModelNode(node)));
    assertToArray(converter, json);
  }
コード例 #20
0
  @Test
  public void testUndefinedTypeExpressionConverter() throws Exception {
    ModelNode description = new ModelNode();
    description.get(EXPRESSIONS_ALLOWED).set(true);
    TypeConverter converter = getConverter(description);

    ModelNode node = new ModelNode();
    node.get("abc").setExpression("${this.should.not.exist.!!!!!:10}");
    node.get("def").setExpression("${this.should.not.exist.!!!!!:false}");
    node.protect();

    String json = assertCast(String.class, converter.fromModelNode(node));
    Assert.assertEquals(node, ModelNode.fromJSONString(json));
    assertToArray(converter, json, null);
  }
コード例 #21
0
  @Test
  public void testPropertyValueTypeConverter() {
    ModelNode description = createDescription(ModelType.PROPERTY, ModelType.INT);
    TypeConverter converter = getConverter(description);

    ModelNode node = new ModelNode();
    node.set("name", 1);
    node.protect();

    Assert.assertEquals(SimpleType.STRING, converter.getOpenType());
    String dmr = assertCast(String.class, converter.fromModelNode(node));
    Assert.assertEquals(node, ModelNode.fromString(dmr));
    Assert.assertEquals(dmr, assertCast(String.class, converter.fromModelNode(node)));
    assertToArray(converter, dmr);
  }
コード例 #22
0
  private void parseTransport(
      XMLExtendedStreamReader reader, ModelNode containerAddress, List<ModelNode> operations)
      throws XMLStreamException {

    // ModelNode for the transport add operation
    ModelNode transport = Util.getEmptyOperation(ModelDescriptionConstants.ADD, null);

    for (int i = 0; i < reader.getAttributeCount(); i++) {
      String value = reader.getAttributeValue(i);
      Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
      switch (attribute) {
        case STACK:
          {
            TransportResource.STACK.parseAndSetParameter(value, transport, reader);
            break;
          }
        case CLUSTER:
          {
            TransportResource.CLUSTER.parseAndSetParameter(value, transport, reader);
            break;
          }
        case EXECUTOR:
          {
            TransportResource.EXECUTOR.parseAndSetParameter(value, transport, reader);
            break;
          }
        case LOCK_TIMEOUT:
          {
            TransportResource.LOCK_TIMEOUT.parseAndSetParameter(value, transport, reader);
            break;
          }
        default:
          {
            throw ParseUtils.unexpectedAttribute(reader, i);
          }
      }
    }
    ParseUtils.requireNoContent(reader);

    // setup the transport address
    ModelNode transportAddress = containerAddress.clone();
    transportAddress.add(ModelKeys.TRANSPORT, ModelKeys.TRANSPORT_NAME);
    transportAddress.protect();
    transport.get(ModelDescriptionConstants.OP_ADDR).set(transportAddress);

    operations.add(transport);
  }
コード例 #23
0
  private void parseInvalidationCache(
      XMLExtendedStreamReader reader, ModelNode containerAddress, List<ModelNode> operations)
      throws XMLStreamException {

    // ModelNode for the cache add operation
    ModelNode cache = Util.getEmptyOperation(ModelDescriptionConstants.ADD, null);

    for (int i = 0; i < reader.getAttributeCount(); i++) {
      String value = reader.getAttributeValue(i);
      Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
      this.parseClusteredCacheAttribute(reader, i, attribute, value, cache);
    }

    if (!cache.hasDefined(ModelKeys.NAME)) {
      throw ParseUtils.missingRequired(reader, EnumSet.of(Attribute.NAME));
    }
    if (!cache.hasDefined(ModelKeys.MODE)) {
      throw ParseUtils.missingRequired(reader, EnumSet.of(Attribute.MODE));
    }

    while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
      Element element = Element.forName(reader.getLocalName());
      switch (element) {
        case STATE_TRANSFER:
          {
            this.parseStateTransfer(reader, cache.get(ModelKeys.STATE_TRANSFER).setEmptyObject());
            break;
          }
        default:
          {
            this.parseCacheElement(reader, element, cache);
          }
      }
    }
    String name = cache.get(ModelKeys.NAME).asString();
    // setup the cache address
    ModelNode cacheAddress = containerAddress.clone();
    cacheAddress.add(ModelKeys.INVALIDATION_CACHE, name);
    cacheAddress.protect();
    cache.get(ModelDescriptionConstants.OP_ADDR).set(cacheAddress);

    // get rid of NAME now that we are finished with it
    cache.remove(ModelKeys.NAME);

    operations.add(cache);
  }
コード例 #24
0
  @Test
  public void testPropertyValueTypeExpressionConverter() throws Exception {
    ModelNode description = createDescription(ModelType.PROPERTY, ModelType.INT);
    TypeConverter converter = getConverter(description);

    ModelNode node = new ModelNode();
    node.set("name", "${this.should.not.exist.!!!!!:1}");
    node.protect();

    ModelNode expected = node.clone().resolve();

    Assert.assertEquals(SimpleType.STRING, converter.getOpenType());
    String dmr = assertCast(String.class, converter.fromModelNode(node));
    Assert.assertEquals(expected, ModelNode.fromString(dmr));
    Assert.assertEquals(dmr, assertCast(String.class, converter.fromModelNode(expected)));
    assertToArray(converter, dmr);
  }
コード例 #25
0
  private void parseStoreWriteBehind(
      XMLExtendedStreamReader reader, ModelNode store, List<ModelNode> operations)
      throws XMLStreamException {
    // ModelNode for the write-behind add operation
    ModelNode writeBehindAddress = store.get(ModelDescriptionConstants.OP_ADDR).clone();
    writeBehindAddress.add(ModelKeys.WRITE_BEHIND, ModelKeys.WRITE_BEHIND_NAME);
    writeBehindAddress.protect();
    ModelNode writeBehind =
        Util.getEmptyOperation(ModelDescriptionConstants.ADD, writeBehindAddress);

    for (int i = 0; i < reader.getAttributeCount(); i++) {
      String value = reader.getAttributeValue(i);
      Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
      switch (attribute) {
        case FLUSH_LOCK_TIMEOUT:
          {
            StoreWriteBehindResource.FLUSH_LOCK_TIMEOUT.parseAndSetParameter(
                value, writeBehind, reader);
            break;
          }
        case MODIFICATION_QUEUE_SIZE:
          {
            StoreWriteBehindResource.MODIFICATION_QUEUE_SIZE.parseAndSetParameter(
                value, writeBehind, reader);
            break;
          }
        case SHUTDOWN_TIMEOUT:
          {
            StoreWriteBehindResource.SHUTDOWN_TIMEOUT.parseAndSetParameter(
                value, writeBehind, reader);
            break;
          }
        case THREAD_POOL_SIZE:
          {
            StoreWriteBehindResource.THREAD_POOL_SIZE.parseAndSetParameter(
                value, writeBehind, reader);
            break;
          }
        default:
          throw ParseUtils.unexpectedAttribute(reader, i);
      }
    }
    ParseUtils.requireNoContent(reader);
    operations.add(writeBehind);
  }
コード例 #26
0
  /**
   * {@inheritDoc}
   *
   * @see
   *     org.jboss.staxmapper.XMLElementReader#readElement(org.jboss.staxmapper.XMLExtendedStreamReader,
   *     java.lang.Object)
   */
  @SuppressWarnings("deprecation")
  @Override
  public void readElement(XMLExtendedStreamReader reader, List<ModelNode> operations)
      throws XMLStreamException {

    ModelNode subsystemAddress = new ModelNode();
    subsystemAddress.add(ModelDescriptionConstants.SUBSYSTEM, InfinispanExtension.SUBSYSTEM_NAME);
    subsystemAddress.protect();

    ModelNode subsystem = Util.getEmptyOperation(ModelDescriptionConstants.ADD, subsystemAddress);

    for (int i = 0; i < reader.getAttributeCount(); i++) {
      ParseUtils.requireNoNamespaceAttribute(reader, i);
      Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
      switch (attribute) {
        case DEFAULT_CACHE_CONTAINER:
          {
            // Ignore
            break;
          }
        default:
          {
            throw ParseUtils.unexpectedAttribute(reader, i);
          }
      }
    }

    // command to add the subsystem
    operations.add(subsystem);

    while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
      Element element = Element.forName(reader.getLocalName());
      switch (element) {
        case CACHE_CONTAINER:
          {
            parseContainer(reader, subsystemAddress, operations);
            break;
          }
        default:
          {
            throw ParseUtils.unexpectedElement(reader);
          }
      }
    }
  }
コード例 #27
0
  @SuppressWarnings("deprecation")
  private void parseTransaction(
      XMLExtendedStreamReader reader, ModelNode cache, List<ModelNode> operations)
      throws XMLStreamException {

    // ModelNode for the transaction add operation
    ModelNode transactionAddress = cache.get(ModelDescriptionConstants.OP_ADDR).clone();
    transactionAddress.add(ModelKeys.TRANSACTION, ModelKeys.TRANSACTION_NAME);
    transactionAddress.protect();
    ModelNode transaction =
        Util.getEmptyOperation(ModelDescriptionConstants.ADD, transactionAddress);

    for (int i = 0; i < reader.getAttributeCount(); i++) {
      String value = reader.getAttributeValue(i);
      Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
      switch (attribute) {
        case STOP_TIMEOUT:
          {
            CommonAttributes.STOP_TIMEOUT.parseAndSetParameter(value, transaction, reader);
            break;
          }
        case MODE:
          {
            CommonAttributes.MODE.parseAndSetParameter(value, transaction, reader);
            break;
          }
        case LOCKING:
          {
            CommonAttributes.LOCKING.parseAndSetParameter(value, transaction, reader);
            break;
          }
        case EAGER_LOCKING:
          {
            ROOT_LOGGER.eagerAttributeDeprecated();
            break;
          }
        default:
          {
            throw ParseUtils.unexpectedAttribute(reader, i);
          }
      }
    }
    ParseUtils.requireNoContent(reader);
    operations.add(transaction);
  }
コード例 #28
0
  private void parseLocking(
      XMLExtendedStreamReader reader, ModelNode cache, List<ModelNode> operations)
      throws XMLStreamException {

    // ModelNode for the cache add operation
    ModelNode lockingAddress = cache.get(ModelDescriptionConstants.OP_ADDR).clone();
    lockingAddress.add(ModelKeys.LOCKING, ModelKeys.LOCKING_NAME);
    lockingAddress.protect();
    ModelNode locking = Util.getEmptyOperation(ModelDescriptionConstants.ADD, lockingAddress);

    for (int i = 0; i < reader.getAttributeCount(); i++) {
      String value = reader.getAttributeValue(i);
      Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
      switch (attribute) {
        case ISOLATION:
          {
            CommonAttributes.ISOLATION.parseAndSetParameter(value, locking, reader);
            break;
          }
        case STRIPING:
          {
            CommonAttributes.STRIPING.parseAndSetParameter(value, locking, reader);
            break;
          }
        case ACQUIRE_TIMEOUT:
          {
            CommonAttributes.ACQUIRE_TIMEOUT.parseAndSetParameter(value, locking, reader);
            break;
          }
        case CONCURRENCY_LEVEL:
          {
            CommonAttributes.CONCURRENCY_LEVEL.parseAndSetParameter(value, locking, reader);
            break;
          }
        default:
          {
            throw ParseUtils.unexpectedAttribute(reader, i);
          }
      }
    }
    ParseUtils.requireNoContent(reader);
    operations.add(locking);
  }
コード例 #29
0
  @Test
  public void testUndefinedTypeConverter() {
    TypeConverter converter = getConverter(new ModelNode());
    Assert.assertEquals(SimpleType.STRING, converter.getOpenType());

    ModelNode node = new ModelNode();
    // BES 2013/01/10 This uses BigInteger; I'm not sure why. But use a value > Long.MAX_VALUE
    // so the json parser won't convert it down to a long or int resulting in a different value
    // See AS7-4913
    // Likely BigInteger was used *because of* the problem discussed in AS7-4913
    node.get("abc").set(new BigInteger(String.valueOf(Long.MAX_VALUE) + "0"));
    node.get("def").set(false);
    node.protect();

    String json = assertCast(String.class, converter.fromModelNode(node));
    Assert.assertEquals(node, ModelNode.fromJSONString(json));
    Assert.assertEquals(json, assertCast(String.class, converter.fromModelNode(node)));
    assertToArray(converter, json);
  }
コード例 #30
0
  @Override
  public void readElement(XMLExtendedStreamReader reader, List<ModelNode> list)
      throws XMLStreamException {

    final ModelNode address = new ModelNode();
    address.add(SUBSYSTEM, RemotingExtension.SUBSYSTEM_NAME);
    address.protect();
    final ModelNode subsystem = Util.getEmptyOperation(ADD, address);
    list.add(subsystem);

    requireNoAttributes(reader);

    // Handle elements
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
      boolean doneWorkerThreadPool = false;
      final Element element = Element.forName(reader.getLocalName());
      switch (element) {
        case WORKER_THREAD_POOL:
          if (doneWorkerThreadPool) {
            throw duplicateNamedElement(reader, Element.WORKER_THREAD_POOL.getLocalName());
          }
          doneWorkerThreadPool = true;
          parseWorkerThreadPool(reader, subsystem);
          break;
        case CONNECTOR:
          {
            // Add connector updates
            parseConnector(reader, address, list);
            break;
          }
        case OUTBOUND_CONNECTIONS:
          {
            // parse the outbound-connections
            this.parseOutboundConnections(reader, address, list);
            break;
          }
        default:
          {
            throw unexpectedElement(reader);
          }
      }
    }
  }