@Override
        public ModelNode getModelDescription(Locale locale) {
          final ResourceBundle bundle = getResourceBundle(locale);

          final ModelNode subsystem = new ModelNode();
          subsystem.get(DESCRIPTION).set(bundle.getString("logging"));
          subsystem.get(HEAD_COMMENT_ALLOWED).set(true);
          subsystem.get(TAIL_COMMENT_ALLOWED).set(true);
          subsystem.get(NAMESPACE).set(Namespace.CURRENT.getUriString());

          subsystem.get(OPERATIONS);

          subsystem
              .get(CHILDREN, CommonAttributes.ROOT_LOGGER, DESCRIPTION)
              .set(bundle.getString("root.logger"));
          subsystem
              .get(CHILDREN, CommonAttributes.ASYNC_HANDLER, DESCRIPTION)
              .set(bundle.getString("async.handler"));
          subsystem
              .get(CHILDREN, CommonAttributes.CONSOLE_HANDLER, DESCRIPTION)
              .set(bundle.getString("console.handler"));
          subsystem
              .get(CHILDREN, CommonAttributes.FILE_HANDLER, DESCRIPTION)
              .set(bundle.getString("file.handler"));
          subsystem
              .get(CHILDREN, CommonAttributes.PERIODIC_ROTATING_FILE_HANDLER, DESCRIPTION)
              .set(bundle.getString("periodic.handler"));
          subsystem
              .get(CHILDREN, CommonAttributes.SIZE_ROTATING_FILE_HANDLER, DESCRIPTION)
              .set(bundle.getString("size.periodic.handler"));

          return subsystem;
        }
/** @author <a href="mailto:[email protected]">David M. Lloyd</a> */
public final class PatternFormatterElement
    extends AbstractFormatterElement<PatternFormatterElement> {

  private static final long serialVersionUID = 2260770166892253338L;

  private static final QName ELEMENT_NAME =
      new QName(Namespace.CURRENT.getUriString(), Element.PATTERN_FORMATTER.getLocalName());

  private final String pattern;

  protected PatternFormatterElement(final String pattern) {
    super(ELEMENT_NAME);
    if (pattern == null) {
      throw new IllegalArgumentException("pattern is null");
    }
    this.pattern = pattern;
  }

  protected Formatter createFormatter() {
    return new PatternFormatter(pattern);
  }

  protected Class<PatternFormatterElement> getElementClass() {
    return PatternFormatterElement.class;
  }

  public void writeContent(final XMLExtendedStreamWriter streamWriter) throws XMLStreamException {
    streamWriter.writeAttribute("pattern", pattern);
    streamWriter.writeEndElement();
  }

  public AbstractFormatterSpec getSpecification() {
    return new PatternFormatterSpec(pattern);
  }
}
  /** {@inheritDoc} */
  @Override
  public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context)
      throws XMLStreamException {
    context.startSubsystemElement(Namespace.CURRENT.getUriString(), false);
    final ModelNode model = context.getModelNode();

    writeWorkerThreadPoolIfAttributesSet(writer, model);

    if (model.hasDefined(CONNECTOR)) {
      final ModelNode connector = model.get(CONNECTOR);
      for (String name : connector.keys()) {
        writeConnector(writer, connector.require(name), name);
      }
    }
    if (model.hasDefined(OUTBOUND_CONNECTION)
        || model.hasDefined(REMOTE_OUTBOUND_CONNECTION)
        || model.hasDefined(LOCAL_OUTBOUND_CONNECTION)) {
      // write <outbound-connections> element
      writer.writeStartElement(Element.OUTBOUND_CONNECTIONS.getLocalName());

      if (model.hasDefined(OUTBOUND_CONNECTION)) {
        final List<Property> outboundConnections = model.get(OUTBOUND_CONNECTION).asPropertyList();
        for (Property property : outboundConnections) {
          final String connectionName = property.getName();
          // get the specific outbound-connection
          final ModelNode genericOutboundConnectionModel = property.getValue();
          // process and write outbound connection
          this.writeOutboundConnection(writer, connectionName, genericOutboundConnectionModel);
        }
      }
      if (model.hasDefined(REMOTE_OUTBOUND_CONNECTION)) {
        final List<Property> remoteOutboundConnections =
            model.get(REMOTE_OUTBOUND_CONNECTION).asPropertyList();
        for (Property property : remoteOutboundConnections) {
          final String connectionName = property.getName();
          // get the specific remote outbound connection
          final ModelNode remoteOutboundConnectionModel = property.getValue();
          // process and write remote outbound connection
          this.writeRemoteOutboundConnection(writer, connectionName, remoteOutboundConnectionModel);
        }
      }
      if (model.hasDefined(LOCAL_OUTBOUND_CONNECTION)) {
        final List<Property> localOutboundConnections =
            model.get(LOCAL_OUTBOUND_CONNECTION).asPropertyList();
        for (Property property : localOutboundConnections) {
          final String connectionName = property.getName();
          // get the specific local outbound connection
          final ModelNode localOutboundConnectionModel = property.getValue();
          // process and write local outbound connection
          this.writeLocalOutboundConnection(writer, connectionName, localOutboundConnectionModel);
        }
      }
      // </outbound-connections>
      writer.writeEndElement();
    }

    writer.writeEndElement();
  }
예제 #4
0
    @Override
    public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context)
        throws XMLStreamException {
      context.startSubsystemElement(Namespace.CURRENT.getUriString(), false);
      ModelNode node = context.getModelNode();

      if (has(node, ACTIVATION)) {
        writeAttribute(writer, Attribute.ACTIVATION, node.get(ACTIVATION));
      }

      if (has(node, CONFIGURATION)) {
        ModelNode configuration = node.get(CONFIGURATION);
        writer.writeStartElement(Element.CONFIGURATION.getLocalName());
        writeAttribute(writer, Attribute.PID, configuration.require(PID));
        if (has(configuration, CONFIGURATION_PROPERTIES)) {
          ModelNode configurationProperties = configuration.get(CONFIGURATION_PROPERTIES);
          Set<String> keys = configurationProperties.keys();
          for (String current : keys) {
            String value = configurationProperties.get(current).asString();
            writer.writeStartElement(Element.PROPERTY.getLocalName());
            writer.writeAttribute(Attribute.NAME.getLocalName(), current);
            writer.writeCharacters(value);
            writer.writeEndElement();
          }
        }
        writer.writeEndElement();
      }

      if (has(node, PROPERTIES)) {
        ModelNode properties = node.get(PROPERTIES);
        writer.writeStartElement(Element.PROPERTIES.getLocalName());
        Set<String> keys = properties.keys();
        for (String current : keys) {
          String value = properties.get(current).asString();
          writer.writeStartElement(Element.PROPERTY.getLocalName());
          writer.writeAttribute(Attribute.NAME.getLocalName(), current);
          writer.writeCharacters(value);
          writer.writeEndElement();
        }
        writer.writeEndElement();
      }

      if (has(node, MODULES)) {
        ModelNode modules = node.get(MODULES);
        writer.writeStartElement(Element.MODULES.getLocalName());
        Set<String> keys = modules.keys();
        for (String current : keys) {
          ModelNode currentModule = modules.get(current);
          writer.writeEmptyElement(Element.MODULE.getLocalName());
          writer.writeAttribute(Attribute.IDENTIFIER.getLocalName(), current);
          if (has(currentModule, START)) {
            writeAttribute(writer, Attribute.START, currentModule.require(START));
          }
        }
        writer.writeEndElement();
      }
      writer.writeEndElement();
    }
 /** {@inheritDoc} */
 @Override
 public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context)
     throws XMLStreamException {
   ModelNode model = new ModelNode();
   model
       .get(UndertowRootDefinition.INSTANCE.getPathElement().getKeyValuePair())
       .set(context.getModelNode()); // this is bit of workaround for SPRD to work properly
   xmlDescription.persist(writer, model, Namespace.CURRENT.getUriString());
 }
  /** {@inheritDoc} */
  @Override
  public void writeContent(
      final XMLExtendedStreamWriter writer, final SubsystemMarshallingContext context)
      throws XMLStreamException {
    context.startSubsystemElement(Namespace.CURRENT.getUriString(), false);

    ModelNode node = context.getModelNode();
    writeModClusterConfig(writer, node);
    writer.writeEndElement();
  }
예제 #7
0
    /** {@inheritDoc} */
    @Override
    public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context)
        throws XMLStreamException {
      context.startSubsystemElement(Namespace.CURRENT.getUriString(), false);
      ModelNode node = context.getModelNode();

      writeArchiveValidation(writer, node);
      writeBeanValidation(writer, node);
      writeDefaultWorkManager(writer, node);
      writeCachedConnectionManager(writer, node);
      writer.writeEndElement();
    }
    /** {@inheritDoc} */
    @Override
    public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context)
        throws XMLStreamException {
      context.startSubsystemElement(Namespace.CURRENT.getUriString(), false);
      ModelNode scanners = context.getModelNode();
      for (final Property list : scanners.asPropertyList()) {
        final ModelNode node = list.getValue();

        for (final Property scanner : node.asPropertyList()) {

          writer.writeEmptyElement(Element.DEPLOYMENT_SCANNER.getLocalName());
          writer.writeAttribute(Attribute.NAME.getLocalName(), scanner.getName());
          ModelNode configuration = scanner.getValue();
          if (configuration.hasDefined(CommonAttributes.PATH)) {
            writer.writeAttribute(
                Attribute.PATH.getLocalName(), configuration.get(CommonAttributes.PATH).asString());
          }
          if (configuration.hasDefined(CommonAttributes.SCAN_ENABLED)) {
            writer.writeAttribute(
                Attribute.SCAN_ENABLED.getLocalName(),
                configuration.get(CommonAttributes.SCAN_ENABLED).asString());
          }
          if (configuration.hasDefined(CommonAttributes.SCAN_INTERVAL)) {
            writer.writeAttribute(
                Attribute.SCAN_INTERVAL.getLocalName(),
                configuration.get(CommonAttributes.SCAN_INTERVAL).asString());
          }
          if (configuration.hasDefined(CommonAttributes.RELATIVE_TO)) {
            writer.writeAttribute(
                Attribute.RELATIVE_TO.getLocalName(),
                configuration.get(CommonAttributes.RELATIVE_TO).asString());
          }
          if (configuration.hasDefined(CommonAttributes.AUTO_DEPLOY_ZIPPED)) {
            if (!configuration.get(CommonAttributes.AUTO_DEPLOY_ZIPPED).asBoolean()) {
              writer.writeAttribute(
                  Attribute.AUTO_DEPLOY_ZIPPED.getLocalName(), Boolean.FALSE.toString());
            }
          }
          if (configuration.hasDefined(CommonAttributes.AUTO_DEPLOY_EXPLODED)) {
            if (configuration.get(CommonAttributes.AUTO_DEPLOY_EXPLODED).asBoolean()) {
              writer.writeAttribute(
                  Attribute.AUTO_DEPLOY_EXPLODED.getLocalName(), Boolean.TRUE.toString());
            }
          }
          if (configuration.hasDefined(CommonAttributes.DEPLOYMENT_TIMEOUT)) {
            writer.writeAttribute(
                Attribute.DEPLOYMENT_TIMEOUT.getLocalName(),
                configuration.get(CommonAttributes.DEPLOYMENT_TIMEOUT).asString());
          }
        }
        writer.writeEndElement();
      }
    }
예제 #9
0
    /** {@inheritDoc} */
    @Override
    public void writeContent(
        final XMLExtendedStreamWriter writer, final SubsystemMarshallingContext context)
        throws XMLStreamException {

      context.startSubsystemElement(Namespace.CURRENT.getUriString(), false);

      ModelNode node = context.getModelNode();

      if (node.hasDefined(THREAD_FACTORY)) {
        for (String name : node.get(THREAD_FACTORY).keys()) {
          final ModelNode child = node.get(THREAD_FACTORY, name);
          if (child.isDefined()) {
            writeThreadFactory(writer, child);
          }
        }
      }
      if (node.hasDefined(BOUNDED_QUEUE_THREAD_POOL)) {
        for (String name : node.get(BOUNDED_QUEUE_THREAD_POOL).keys()) {
          final ModelNode child = node.get(BOUNDED_QUEUE_THREAD_POOL, name);
          if (child.isDefined()) {
            writeBoundedQueueThreadPool(writer, child);
          }
        }
      }
      if (node.hasDefined(QUEUELESS_THREAD_POOL)) {
        for (String name : node.get(QUEUELESS_THREAD_POOL).keys()) {
          final ModelNode child = node.get(QUEUELESS_THREAD_POOL, name);
          if (child.isDefined()) {
            writeQueuelessThreadPool(writer, child);
          }
        }
      }
      if (node.hasDefined(SCHEDULED_THREAD_POOL)) {
        for (String name : node.get(SCHEDULED_THREAD_POOL).keys()) {
          final ModelNode child = node.get(SCHEDULED_THREAD_POOL, name);
          if (child.isDefined()) {
            writeScheduledQueueThreadPool(writer, child);
          }
        }
      }
      if (node.hasDefined(UNBOUNDED_QUEUE_THREAD_POOL)) {
        for (String name : node.get(UNBOUNDED_QUEUE_THREAD_POOL).keys()) {
          final ModelNode child = node.get(UNBOUNDED_QUEUE_THREAD_POOL, name);
          if (child.isDefined()) {
            writeUnboundedQueueThreadPool(writer, child);
          }
        }
      }

      writer.writeEndElement();
    }
예제 #10
0
    /** {@inheritDoc} */
    @Override
    public void writeContent(
        final XMLExtendedStreamWriter writer, final SubsystemMarshallingContext context)
        throws XMLStreamException {

      ModelNode node = context.getModelNode();
      if (node.has(CommonAttributes.DEFAULT_DATASOURCE)) {
        context.startSubsystemElement(Namespace.CURRENT.getUriString(), false);
        writer.writeStartElement(Element.JPA.getLocalName());
        writer.writeAttribute(
            Attribute.DEFAULT_DATASOURCE_NAME.getLocalName(),
            node.get(CommonAttributes.DEFAULT_DATASOURCE).asString());
        writer.writeEndElement();
        writer.writeEndElement();
      } else {
        // TODO seems to be a problem with empty elements cleaning up the queue in
        // FormattingXMLStreamWriter.runAttrQueue
        // context.startSubsystemElement(NewNamingExtension.NAMESPACE, true);
        context.startSubsystemElement(Namespace.CURRENT.getUriString(), false);
        writer.writeEndElement();
      }
    }
 private void parseProperties(
     XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list)
     throws XMLStreamException {
   while (reader.nextTag() != END_ELEMENT) {
     reader.require(
         START_ELEMENT, Namespace.CURRENT.getUriString(), Element.PROPERTY.getLocalName());
     final Property property = readProperty(reader);
     ModelNode propertyOp = new ModelNode();
     propertyOp.get(OP).set(ADD);
     propertyOp.get(OP_ADDR).set(address).add(PROPERTY, property.getName());
     propertyOp.get(VALUE).set(property.getValue());
     list.add(propertyOp);
   }
 }
예제 #12
0
    /** {@inheritDoc} */
    @Override
    public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context)
        throws XMLStreamException {

      context.startSubsystemElement(Namespace.CURRENT.getUriString(), false);

      ModelNode node = context.getModelNode();

      if (has(node, CommonAttributes.XTS_ENVIRONMENT)) {
        writer.writeStartElement(Element.XTS_ENVIRONMENT.getLocalName());
        final ModelNode xtsEnv = node.get(CommonAttributes.XTS_ENVIRONMENT);
        if (has(xtsEnv, ModelDescriptionConstants.URL)) {
          writeAttribute(writer, Attribute.URL, xtsEnv.get(ModelDescriptionConstants.URL));
        }
        writer.writeEndElement();
      }
      writer.writeEndElement();
    }
    /** {@inheritDoc} */
    @Override
    public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context)
        throws XMLStreamException {
      ModelNode node = context.getModelNode();
      boolean hasChildren =
          node.hasDefined(RESOURCEADAPTER_NAME)
              && node.get(RESOURCEADAPTER_NAME).asPropertyList().size() > 0;

      context.startSubsystemElement(Namespace.CURRENT.getUriString(), !hasChildren);

      if (hasChildren) {
        writer.writeStartElement(Element.RESOURCE_ADAPTERS.getLocalName());
        for (Property property : node.get(RESOURCEADAPTER_NAME).asPropertyList()) {
          final ModelNode ra = property.getValue();

          writeRaElement(writer, ra);
        }
        writer.writeEndElement();
        // Close the subsystem element
        writer.writeEndElement();
      }
    }
  @Override
  public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context)
      throws XMLStreamException {
    context.startSubsystemElement(Namespace.CURRENT.getUri(), false);
    ModelNode model = context.getModelNode();
    if (model.isDefined()) {
      if (model.hasDefined(ModelKeys.REPOSITORY)) {
        for (Property entry : model.get(ModelKeys.REPOSITORY).asPropertyList()) {
          String repositoryName = entry.getName();
          ModelNode repository = entry.getValue();
          writeRepositoryConfiguration(writer, repository, repositoryName);
        }
      }

      if (model.hasDefined(ModelKeys.WEBAPP)) {
        for (Property entry : model.get(ModelKeys.WEBAPP).asPropertyList()) {
          String webappName = entry.getName();
          ModelNode webapp = entry.getValue();
          writeWebAppConfiguration(writer, webapp, webappName);
        }
      }
    }
    writer.writeEndElement(); // End of subsystem element
  }
예제 #15
0
 public void initializeParsers(ExtensionParsingContext context) {
   context.setSubsystemXmlMapping(
       SUBSYSTEM_NAME, Namespace.CURRENT.getUriString(), JdrReportSubsystemParser.INSTANCE);
 }
예제 #16
0
  /** {@inheritDoc} */
  @Override
  public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context)
      throws XMLStreamException {

    context.startSubsystemElement(Namespace.CURRENT.getUriString(), false);

    ModelNode node = context.getModelNode();

    writeAttribute(writer, Attribute.NATIVE.getLocalName(), node);
    writeAttribute(writer, Attribute.DEFAULT_VIRTUAL_SERVER.getLocalName(), node);
    writeAttribute(writer, Attribute.INSTANCE_ID.getLocalName(), node);
    if (node.hasDefined(CONTAINER_CONFIG)) {
      writeContainerConfig(writer, node.get(CONTAINER_CONFIG));
    }
    if (node.hasDefined(CONNECTOR)) {
      for (final Property connector : node.get(CONNECTOR).asPropertyList()) {
        final ModelNode config = connector.getValue();
        writer.writeStartElement(Element.CONNECTOR.getLocalName());
        writer.writeAttribute(NAME, connector.getName());
        writeAttribute(writer, Attribute.PROTOCOL.getLocalName(), config);
        writeAttribute(writer, Attribute.SOCKET_BINDING.getLocalName(), config);
        writeAttribute(writer, Attribute.SCHEME.getLocalName(), config);
        writeAttribute(writer, Attribute.ENABLED.getLocalName(), config);
        writeAttribute(writer, Attribute.ENABLE_LOOKUPS.getLocalName(), config);
        writeAttribute(writer, Attribute.PROXY_NAME.getLocalName(), config);
        writeAttribute(writer, Attribute.PROXY_PORT.getLocalName(), config);
        writeAttribute(writer, Attribute.SECURE.getLocalName(), config);
        writeAttribute(writer, Attribute.EXECUTOR.getLocalName(), config);
        writeAttribute(writer, Attribute.MAX_POST_SIZE.getLocalName(), config);
        writeAttribute(writer, Attribute.MAX_SAVE_POST_SIZE.getLocalName(), config);
        writeAttribute(writer, Attribute.MAX_CONNECTIONS.getLocalName(), config);
        writeAttribute(writer, Attribute.REDIRECT_PORT.getLocalName(), config);

        if (config.get(SSL).isDefined() && config.get(SSL).has("configuration")) {
          ModelNode sslConfig = config.get(SSL).get("configuration");
          writer.writeStartElement(Element.SSL.getLocalName());
          writeAttribute(writer, Attribute.NAME.getLocalName(), sslConfig);
          writeAttribute(writer, Attribute.KEY_ALIAS.getLocalName(), sslConfig);
          writeAttribute(writer, Attribute.PASSWORD.getLocalName(), sslConfig);
          writeAttribute(writer, Attribute.CERTIFICATE_KEY_FILE.getLocalName(), sslConfig);
          writeAttribute(writer, Attribute.CIPHER_SUITE.getLocalName(), sslConfig);
          writeAttribute(writer, Attribute.PROTOCOL.getLocalName(), sslConfig);
          writeAttribute(writer, Attribute.VERIFY_CLIENT.getLocalName(), sslConfig);
          writeAttribute(writer, Attribute.VERIFY_DEPTH.getLocalName(), sslConfig);
          writeAttribute(writer, Attribute.CERTIFICATE_FILE.getLocalName(), sslConfig);
          writeAttribute(writer, Attribute.CA_CERTIFICATE_FILE.getLocalName(), sslConfig);
          writeAttribute(writer, Attribute.CA_REVOCATION_URL.getLocalName(), sslConfig);
          writeAttribute(writer, Attribute.SESSION_CACHE_SIZE.getLocalName(), sslConfig);
          writeAttribute(writer, Attribute.SESSION_TIMEOUT.getLocalName(), sslConfig);
          writer.writeEndElement();
        }
        if (config.hasDefined(VIRTUAL_SERVER)) {
          for (final ModelNode virtualServer : config.get(VIRTUAL_SERVER).asList()) {
            writer.writeEmptyElement(VIRTUAL_SERVER);
            writer.writeAttribute(NAME, virtualServer.asString());
          }
        }

        writer.writeEndElement();
      }
    }
    if (node.hasDefined(VIRTUAL_SERVER)) {
      for (final Property host : node.get(VIRTUAL_SERVER).asPropertyList()) {
        final ModelNode config = host.getValue();
        writer.writeStartElement(Element.VIRTUAL_SERVER.getLocalName());
        writer.writeAttribute(NAME, host.getName());
        writeAttribute(writer, Attribute.DEFAULT_WEB_MODULE.getLocalName(), config);
        if (config.hasDefined(ENABLE_WELCOME_ROOT) && config.get(ENABLE_WELCOME_ROOT).asBoolean())
          writer.writeAttribute(ENABLE_WELCOME_ROOT, "true");

        if (config.hasDefined(ALIAS)) {
          for (final ModelNode alias : config.get(ALIAS).asList()) {
            writer.writeEmptyElement(ALIAS);
            writer.writeAttribute(NAME, alias.asString());
          }
        }

        if (config.get(ACCESS_LOG).isDefined() && config.get(ACCESS_LOG).has("configuration")) {
          ModelNode accessLog = config.get(ACCESS_LOG).get("configuration");
          writer.writeStartElement(Element.ACCESS_LOG.getLocalName());
          writeAttribute(writer, Attribute.PATTERN.getLocalName(), accessLog);
          writeAttribute(writer, Attribute.RESOLVE_HOSTS.getLocalName(), accessLog);
          writeAttribute(writer, Attribute.EXTENDED.getLocalName(), accessLog);
          writeAttribute(writer, Attribute.PREFIX.getLocalName(), accessLog);
          writeAttribute(writer, Attribute.ROTATE.getLocalName(), accessLog);

          if (accessLog.has(DIRECTORY) && accessLog.get(DIRECTORY).has("configuration")) {
            ModelNode directory = accessLog.get(DIRECTORY).get("configuration");
            String name = Element.DIRECTORY.getLocalName();
            boolean startwritten = false;
            startwritten =
                writeAttribute(
                    writer, Attribute.PATH.getLocalName(), directory, startwritten, name);
            startwritten =
                writeAttribute(
                    writer, Attribute.RELATIVE_TO.getLocalName(), directory, startwritten, name);
            if (startwritten) writer.writeEndElement();
          }
          writer.writeEndElement();
        }

        if (config.hasDefined(REWRITE)) {
          for (final ModelNode rewritenode : config.get(REWRITE).asList()) {
            String name = getAddedRule(rewritenode);
            ModelNode rewrite;
            if (rewritenode.hasDefined(name)) rewrite = rewritenode.get(name);
            else rewrite = rewritenode;
            writer.writeStartElement(REWRITE);
            writeAttribute(writer, Attribute.PATTERN.getLocalName(), rewrite);
            writeAttribute(writer, Attribute.SUBSTITUTION.getLocalName(), rewrite);
            writeAttribute(writer, Attribute.FLAGS.getLocalName(), rewrite);

            if (rewrite.hasDefined(CONDITION)) {
              for (final ModelNode conditionnode : rewrite.get(CONDITION).asList()) {
                String condname = getAddedConditionName(conditionnode);
                ModelNode condition;
                if (conditionnode.hasDefined(condname)) condition = conditionnode.get(condname);
                else condition = conditionnode;
                writer.writeStartElement(CONDITION);
                writeAttribute(writer, Attribute.TEST.getLocalName(), condition);
                writeAttribute(writer, Attribute.PATTERN.getLocalName(), condition);
                writeAttribute(writer, Attribute.FLAGS.getLocalName(), condition);
                writer.writeEndElement();
              }
            }
            writer.writeEndElement();
          }
        }

        if (config.hasDefined(SSO) && config.get(SSO).has("configuration")) {
          final ModelNode sso;
          sso = config.get(SSO).get("configuration");
          writer.writeStartElement(SSO);
          writeAttribute(writer, Attribute.CACHE_CONTAINER.getLocalName(), sso);
          writeAttribute(writer, Attribute.CACHE_NAME.getLocalName(), sso);
          writeAttribute(writer, Attribute.DOMAIN.getLocalName(), sso);
          writeAttribute(writer, Attribute.REAUTHENTICATE.getLocalName(), sso);
          writer.writeEndElement();
        }

        // End of the VIRTUAL_SERVER
        writer.writeEndElement();
      }
    }
    writer.writeEndElement();
  }
예제 #17
0
/** @author Tomaz Cerar (c) 2015 Red Hat Inc. */
public class ThreadsParser2_0 extends PersistentResourceXMLParser {
  static final ThreadsParser2_0 INSTANCE = new ThreadsParser2_0();

  public static final PersistentResourceXMLBuilder THREAD_FACTORY_PARSER =
      getThreadFactoryParser(ThreadFactoryResourceDefinition.DEFAULT_INSTANCE);

  @SuppressWarnings("deprecation")
  private static final PersistentResourceXMLDescription xmlDescription =
      builder(new ThreadSubsystemResourceDefinition(false), Namespace.CURRENT.getUriString())
          .addChild(THREAD_FACTORY_PARSER)
          .addChild(
              getUnboundedQueueThreadPoolParser(
                  UnboundedQueueThreadPoolResourceDefinition.create(false)))
          .addChild(
              getBoundedQueueThreadPoolParser(
                  BoundedQueueThreadPoolResourceDefinition.create(false, false)))
          .addChild(
              getBoundedQueueThreadPoolParser(
                  BoundedQueueThreadPoolResourceDefinition.create(true, false)))
          .addChild(
              getQueuelessThreadPoolParser(
                  QueuelessThreadPoolResourceDefinition.create(false, false)))
          .addChild(
              getQueuelessThreadPoolParser(
                  QueuelessThreadPoolResourceDefinition.create(true, false)))
          .addChild(
              getScheduledThreadPoolParser(ScheduledThreadPoolResourceDefinition.create(false)))
          .build();

  @Override
  public PersistentResourceXMLDescription getParserDescription() {
    return xmlDescription;
  }

  public static PersistentResourceXMLBuilder getThreadFactoryParser(
      ThreadFactoryResourceDefinition factoryResourceDefinition) {
    return builder(factoryResourceDefinition)
        .addAttributes(
            PoolAttributeDefinitions.GROUP_NAME,
            PoolAttributeDefinitions.THREAD_NAME_PATTERN,
            PoolAttributeDefinitions.PRIORITY);
  }

  public static PersistentResourceXMLBuilder getUnboundedQueueThreadPoolParser(
      UnboundedQueueThreadPoolResourceDefinition resourceDefinition) {
    return builder(resourceDefinition)
        .addAttributes(
            PoolAttributeDefinitions.KEEPALIVE_TIME,
            PoolAttributeDefinitions.MAX_THREADS,
            PoolAttributeDefinitions.THREAD_FACTORY);
  }

  public static PersistentResourceXMLBuilder getScheduledThreadPoolParser(
      ScheduledThreadPoolResourceDefinition resourceDefinition) {
    return builder(resourceDefinition)
        .addAttributes(
            PoolAttributeDefinitions.KEEPALIVE_TIME,
            PoolAttributeDefinitions.MAX_THREADS,
            PoolAttributeDefinitions.THREAD_FACTORY);
  }

  public static PersistentResourceXMLBuilder getQueuelessThreadPoolParser(
      QueuelessThreadPoolResourceDefinition definition) {
    PersistentResourceXMLBuilder builder =
        builder(definition)
            .addAttributes(
                PoolAttributeDefinitions.KEEPALIVE_TIME,
                PoolAttributeDefinitions.MAX_THREADS,
                PoolAttributeDefinitions.THREAD_FACTORY);

    if (!definition.isBlocking()) {
      builder.addAttribute(PoolAttributeDefinitions.HANDOFF_EXECUTOR);
    }
    return builder;
  }

  public static PersistentResourceXMLBuilder getBoundedQueueThreadPoolParser(
      BoundedQueueThreadPoolResourceDefinition definition) {
    PersistentResourceXMLBuilder builder =
        builder(definition)
            .addAttributes(
                PoolAttributeDefinitions.KEEPALIVE_TIME,
                PoolAttributeDefinitions.MAX_THREADS,
                PoolAttributeDefinitions.THREAD_FACTORY,
                PoolAttributeDefinitions.CORE_THREADS,
                PoolAttributeDefinitions.QUEUE_LENGTH,
                PoolAttributeDefinitions.ALLOW_CORE_TIMEOUT);

    if (!definition.isBlocking()) {
      builder.addAttribute(PoolAttributeDefinitions.HANDOFF_EXECUTOR);
    }
    return builder;
  }
}
  /**
   * {@inheritDoc}
   *
   * @see
   *     org.jboss.staxmapper.XMLElementWriter#writeContent(org.jboss.staxmapper.XMLExtendedStreamWriter,
   *     java.lang.Object)
   */
  @Override
  public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context)
      throws XMLStreamException {
    context.startSubsystemElement(Namespace.CURRENT.getUri(), false);
    ModelNode model = context.getModelNode();
    if (model.isDefined()) {
      for (Property entry : model.get(ModelKeys.CACHE_CONTAINER).asPropertyList()) {

        String containerName = entry.getName();
        ModelNode container = entry.getValue();

        writer.writeStartElement(Element.CACHE_CONTAINER.getLocalName());
        writer.writeAttribute(Attribute.NAME.getLocalName(), containerName);
        // AS7-3488 make default-cache a non required attribute
        // this.writeRequired(writer, Attribute.DEFAULT_CACHE, container, ModelKeys.DEFAULT_CACHE);
        this.writeListAsAttribute(writer, Attribute.ALIASES, container, ModelKeys.ALIASES);
        this.writeOptional(writer, Attribute.ASYNC_EXECUTOR, container, ModelKeys.ASYNC_EXECUTOR);
        this.writeOptional(writer, Attribute.DEFAULT_CACHE, container, ModelKeys.DEFAULT_CACHE);
        this.writeOptional(
            writer, Attribute.EVICTION_EXECUTOR, container, ModelKeys.EVICTION_EXECUTOR);
        this.writeOptional(writer, Attribute.JNDI_NAME, container, ModelKeys.JNDI_NAME);
        this.writeOptional(
            writer, Attribute.LISTENER_EXECUTOR, container, ModelKeys.LISTENER_EXECUTOR);
        this.writeOptional(
            writer,
            Attribute.REPLICATION_QUEUE_EXECUTOR,
            container,
            ModelKeys.REPLICATION_QUEUE_EXECUTOR);
        this.writeOptional(
            writer,
            Attribute.STATE_TRANSFER_EXECUTOR,
            container,
            ModelKeys.STATE_TRANSFER_EXECUTOR);
        this.writeOptional(writer, Attribute.START, container, ModelKeys.START);
        this.writeOptional(writer, Attribute.MODULE, container, ModelKeys.MODULE);
        this.writeOptional(writer, Attribute.STATISTICS, container, ModelKeys.STATISTICS);

        if (container.hasDefined(ModelKeys.TRANSPORT)) {
          writer.writeStartElement(Element.TRANSPORT.getLocalName());
          ModelNode transport = container.get(ModelKeys.TRANSPORT, ModelKeys.TRANSPORT_NAME);
          this.writeOptional(writer, Attribute.STACK, transport, ModelKeys.STACK);
          this.writeOptional(writer, Attribute.CLUSTER, transport, ModelKeys.CLUSTER);
          this.writeOptional(writer, Attribute.EXECUTOR, transport, ModelKeys.EXECUTOR);
          this.writeOptional(writer, Attribute.LOCK_TIMEOUT, transport, ModelKeys.LOCK_TIMEOUT);
          this.writeOptional(
              writer,
              Attribute.REMOTE_COMMAND_EXECUTOR,
              transport,
              ModelKeys.REMOTE_COMMAND_EXECUTOR);
          this.writeOptional(
              writer, Attribute.STRICT_PEER_TO_PEER, transport, ModelKeys.STRICT_PEER_TO_PEER);
          this.writeOptional(
              writer, Attribute.TOTAL_ORDER_EXECUTOR, transport, ModelKeys.TOTAL_ORDER_EXECUTOR);
          writer.writeEndElement();
        }

        if (container.hasDefined(ModelKeys.SECURITY)) {
          writer.writeStartElement(Element.SECURITY.getLocalName());
          ModelNode security = container.get(ModelKeys.SECURITY, ModelKeys.SECURITY_NAME);
          if (security.hasDefined(ModelKeys.AUTHORIZATION)) {
            writer.writeStartElement(Element.AUTHORIZATION.getLocalName());
            ModelNode authorization =
                security.get(ModelKeys.AUTHORIZATION, ModelKeys.AUTHORIZATION_NAME);
            if (authorization.hasDefined(ModelKeys.MAPPER)) {
              String mapper = authorization.get(ModelKeys.MAPPER).asString();
              if (CommonNameRoleMapper.class.getName().equals(mapper)) {
                writer.writeEmptyElement(Element.COMMON_NAME_ROLE_MAPPER.getLocalName());
              } else if (ClusterRoleMapper.class.getName().equals(mapper)) {
                writer.writeEmptyElement(Element.CLUSTER_ROLE_MAPPER.getLocalName());
              } else if (IdentityRoleMapper.class.getName().equals(mapper)) {
                writer.writeEmptyElement(Element.IDENTITY_ROLE_MAPPER.getLocalName());
              } else {
                writer.writeStartElement(Element.CUSTOM_ROLE_MAPPER.getLocalName());
                writer.writeAttribute(Attribute.CLASS.getLocalName(), mapper);
                writer.writeEndElement();
              }
            }

            ModelNode roles = authorization.get(ModelKeys.ROLE);
            for (ModelNode roleNode : roles.asList()) {
              ModelNode role = roleNode.get(0);
              writer.writeStartElement(Element.ROLE.getLocalName());
              AuthorizationRoleResource.NAME.marshallAsAttribute(role, writer);
              this.writeListAsAttribute(writer, Attribute.PERMISSIONS, role, ModelKeys.PERMISSIONS);
              writer.writeEndElement();
            }

            writer.writeEndElement();
          }

          writer.writeEndElement();
        }

        // write any existent cache types
        if (container.get(ModelKeys.LOCAL_CACHE).isDefined()) {
          for (Property localCacheEntry : container.get(ModelKeys.LOCAL_CACHE).asPropertyList()) {
            String localCacheName = localCacheEntry.getName();
            ModelNode localCache = localCacheEntry.getValue();

            writer.writeStartElement(Element.LOCAL_CACHE.getLocalName());
            // write identifier before other attributes
            writer.writeAttribute(Attribute.NAME.getLocalName(), localCacheName);

            processCommonCacheAttributesElements(writer, localCache);

            writer.writeEndElement();
          }
        }

        if (container.get(ModelKeys.INVALIDATION_CACHE).isDefined()) {
          for (Property invalidationCacheEntry :
              container.get(ModelKeys.INVALIDATION_CACHE).asPropertyList()) {
            String invalidationCacheName = invalidationCacheEntry.getName();
            ModelNode invalidationCache = invalidationCacheEntry.getValue();

            writer.writeStartElement(Element.INVALIDATION_CACHE.getLocalName());
            // write identifier before other attributes
            writer.writeAttribute(Attribute.NAME.getLocalName(), invalidationCacheName);

            processCommonClusteredCacheAttributes(writer, invalidationCache);
            processCommonCacheAttributesElements(writer, invalidationCache);

            writer.writeEndElement();
          }
        }

        if (container.get(ModelKeys.REPLICATED_CACHE).isDefined()) {
          for (Property replicatedCacheEntry :
              container.get(ModelKeys.REPLICATED_CACHE).asPropertyList()) {
            String replicatedCacheName = replicatedCacheEntry.getName();
            ModelNode replicatedCache = replicatedCacheEntry.getValue();

            writer.writeStartElement(Element.REPLICATED_CACHE.getLocalName());
            // write identifier before other attributes
            writer.writeAttribute(Attribute.NAME.getLocalName(), replicatedCacheName);

            processCommonClusteredCacheAttributes(writer, replicatedCache);
            processCommonCacheAttributesElements(writer, replicatedCache);

            writer.writeEndElement();
          }
        }

        if (container.get(ModelKeys.DISTRIBUTED_CACHE).isDefined()) {
          for (Property distributedCacheEntry :
              container.get(ModelKeys.DISTRIBUTED_CACHE).asPropertyList()) {
            String distributedCacheName = distributedCacheEntry.getName();
            ModelNode distributedCache = distributedCacheEntry.getValue();

            writer.writeStartElement(Element.DISTRIBUTED_CACHE.getLocalName());
            // write identifier before other attributes
            writer.writeAttribute(Attribute.NAME.getLocalName(), distributedCacheName);
            // distributed cache attributes
            this.writeOptional(writer, Attribute.OWNERS, distributedCache, ModelKeys.OWNERS);
            this.writeOptional(writer, Attribute.SEGMENTS, distributedCache, ModelKeys.SEGMENTS);
            this.writeOptional(
                writer, Attribute.CAPACITY_FACTOR, distributedCache, ModelKeys.CAPACITY_FACTOR);
            this.writeOptional(
                writer, Attribute.L1_LIFESPAN, distributedCache, ModelKeys.L1_LIFESPAN);

            processCommonClusteredCacheAttributes(writer, distributedCache);
            processCommonCacheAttributesElements(writer, distributedCache);

            writer.writeEndElement();
          }
        }
        writer.writeEndElement();
      }
    }
    writer.writeEndElement();
  }
예제 #19
0
 @Override
 public void initializeParsers(final ExtensionParsingContext context) {
   context.setSubsystemXmlMapping(
       Namespace.CURRENT.getUriString(), NewThreadsSubsystemParser.INSTANCE);
 }
예제 #20
0
  /**
   * {@inheritDoc}
   *
   * @see org.jboss.as.controller.Extension#initialize(org.jboss.as.controller.ExtensionContext)
   */
  @Override
  public void initialize(ExtensionContext context) {
    SubsystemRegistration subsystem =
        context.registerSubsystem(
            SUBSYSTEM_NAME,
            Namespace.CURRENT.getMajorVersion(),
            Namespace.CURRENT.getMinorVersion());
    subsystem.registerXMLElementWriter(Namespace.CURRENT.getWriter());

    ManagementResourceRegistration registration =
        subsystem.registerSubsystemModel(InfinispanSubsystemProviders.SUBSYSTEM);
    registration.registerOperationHandler(
        ADD, InfinispanSubsystemAdd.INSTANCE, InfinispanSubsystemProviders.SUBSYSTEM_ADD, false);
    registration.registerOperationHandler(
        DESCRIBE,
        InfinispanSubsystemDescribe.INSTANCE,
        InfinispanSubsystemProviders.SUBSYSTEM_DESCRIBE,
        false,
        EntryType.PRIVATE);
    registration.registerOperationHandler(
        REMOVE,
        ReloadRequiredRemoveStepHandler.INSTANCE,
        InfinispanSubsystemProviders.SUBSYSTEM_REMOVE,
        false);

    ManagementResourceRegistration container =
        registration.registerSubModel(containerPath, InfinispanSubsystemProviders.CACHE_CONTAINER);
    container.registerOperationHandler(
        ADD, CacheContainerAdd.INSTANCE, InfinispanSubsystemProviders.CACHE_CONTAINER_ADD, false);
    container.registerOperationHandler(
        REMOVE,
        CacheContainerRemove.INSTANCE,
        InfinispanSubsystemProviders.CACHE_CONTAINER_REMOVE,
        false);
    container.registerOperationHandler(
        "add-alias", AddAliasCommand.INSTANCE, InfinispanSubsystemProviders.ADD_ALIAS, false);
    container.registerOperationHandler(
        "remove-alias",
        RemoveAliasCommand.INSTANCE,
        InfinispanSubsystemProviders.REMOVE_ALIAS,
        false);
    CacheContainerWriteAttributeHandler.INSTANCE.registerAttributes(container);

    // add /subsystem=infinispan/cache-container=*/singleton=transport:write-attribute
    final ManagementResourceRegistration transport =
        container.registerSubModel(transportPath, InfinispanSubsystemProviders.TRANSPORT);
    transport.registerOperationHandler(
        ADD, TransportAdd.INSTANCE, InfinispanSubsystemProviders.TRANSPORT_ADD, false);
    transport.registerOperationHandler(
        REMOVE, TransportRemove.INSTANCE, InfinispanSubsystemProviders.TRANSPORT_REMOVE, false);
    TransportWriteAttributeHandler.INSTANCE.registerAttributes(transport);

    // add /subsystem=infinispan/cache-container=*/local-cache=*
    ManagementResourceRegistration local =
        container.registerSubModel(localCachePath, InfinispanSubsystemProviders.LOCAL_CACHE);
    local.registerOperationHandler(
        ADD, LocalCacheAdd.INSTANCE, InfinispanSubsystemProviders.LOCAL_CACHE_ADD, false);
    local.registerOperationHandler(
        REMOVE, CacheRemove.INSTANCE, InfinispanSubsystemProviders.CACHE_REMOVE, false);
    registerCommonCacheAttributeHandlers(local);

    // add /subsystem=infinispan/cache-container=*/invalidation-cache=*
    ManagementResourceRegistration invalidation =
        container.registerSubModel(
            invalidationCachePath, InfinispanSubsystemProviders.INVALIDATION_CACHE);
    invalidation.registerOperationHandler(
        ADD,
        InvalidationCacheAdd.INSTANCE,
        InfinispanSubsystemProviders.INVALIDATION_CACHE_ADD,
        false);
    invalidation.registerOperationHandler(
        REMOVE, CacheRemove.INSTANCE, InfinispanSubsystemProviders.CACHE_REMOVE, false);
    registerCommonCacheAttributeHandlers(invalidation);

    // add /subsystem=infinispan/cache-container=*/replicated-cache=*
    ManagementResourceRegistration replicated =
        container.registerSubModel(
            replicatedCachePath, InfinispanSubsystemProviders.REPLICATED_CACHE);
    replicated.registerOperationHandler(
        ADD, ReplicatedCacheAdd.INSTANCE, InfinispanSubsystemProviders.REPLICATED_CACHE_ADD, false);
    replicated.registerOperationHandler(
        REMOVE, CacheRemove.INSTANCE, InfinispanSubsystemProviders.CACHE_REMOVE, false);
    registerCommonCacheAttributeHandlers(replicated);

    // add /subsystem=infinispan/cache-container=*/distributed-cache=*
    ManagementResourceRegistration distributed =
        container.registerSubModel(
            distributedCachePath, InfinispanSubsystemProviders.DISTRIBUTED_CACHE);
    distributed.registerOperationHandler(
        ADD,
        DistributedCacheAdd.INSTANCE,
        InfinispanSubsystemProviders.DISTRIBUTED_CACHE_ADD,
        false);
    distributed.registerOperationHandler(
        REMOVE, CacheRemove.INSTANCE, InfinispanSubsystemProviders.CACHE_REMOVE, false);
    registerCommonCacheAttributeHandlers(distributed);
  }
예제 #21
0
 @Override
 public void initializeParsers(ExtensionParsingContext context) {
   context.setSubsystemXmlMapping(Namespace.CURRENT.getUriString(), PARSER);
 }
  /**
   * {@inheritDoc}
   *
   * @see
   *     org.jboss.staxmapper.XMLElementWriter#writeContent(org.jboss.staxmapper.XMLExtendedStreamWriter,
   *     java.lang.Object)
   */
  @Override
  public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context)
      throws XMLStreamException {
    context.startSubsystemElement(Namespace.CURRENT.getUri(), false);
    ModelNode model = context.getModelNode();
    if (model.isDefined()) {
      writer.writeAttribute(
          Attribute.DEFAULT_CACHE_CONTAINER.getLocalName(),
          model.require(ModelKeys.DEFAULT_CACHE_CONTAINER).asString());
      for (Property entry : model.get(ModelKeys.CACHE_CONTAINER).asPropertyList()) {

        String containerName = entry.getName();
        ModelNode container = entry.getValue();

        writer.writeStartElement(Element.CACHE_CONTAINER.getLocalName());
        writer.writeAttribute(Attribute.NAME.getLocalName(), containerName);
        this.writeRequired(writer, Attribute.DEFAULT_CACHE, container, ModelKeys.DEFAULT_CACHE);
        this.writeOptional(writer, Attribute.JNDI_NAME, container, ModelKeys.JNDI_NAME);
        this.writeOptional(
            writer, Attribute.LISTENER_EXECUTOR, container, ModelKeys.LISTENER_EXECUTOR);
        this.writeOptional(
            writer, Attribute.EVICTION_EXECUTOR, container, ModelKeys.EVICTION_EXECUTOR);
        this.writeOptional(
            writer,
            Attribute.REPLICATION_QUEUE_EXECUTOR,
            container,
            ModelKeys.REPLICATION_QUEUE_EXECUTOR);

        if (container.hasDefined(ModelKeys.ALIAS)) {
          for (ModelNode alias : container.get(ModelKeys.ALIAS).asList()) {
            writer.writeStartElement(Element.ALIAS.getLocalName());
            writer.writeCharacters(alias.asString());
            writer.writeEndElement();
          }
        }

        if (container.hasDefined(ModelKeys.SINGLETON)) {
          writer.writeStartElement(Element.TRANSPORT.getLocalName());
          ModelNode transport = container.get(ModelKeys.SINGLETON, ModelKeys.TRANSPORT);
          this.writeOptional(writer, Attribute.STACK, transport, ModelKeys.STACK);
          this.writeOptional(writer, Attribute.EXECUTOR, transport, ModelKeys.EXECUTOR);
          this.writeOptional(writer, Attribute.LOCK_TIMEOUT, transport, ModelKeys.LOCK_TIMEOUT);
          this.writeOptional(writer, Attribute.SITE, transport, ModelKeys.SITE);
          this.writeOptional(writer, Attribute.RACK, transport, ModelKeys.RACK);
          this.writeOptional(writer, Attribute.MACHINE, transport, ModelKeys.MACHINE);
          writer.writeEndElement();
        }

        // create a list of all caches in the model
        List<Property> cachesPL = new ArrayList<Property>();
        String[] cacheTypes = {
          ModelKeys.LOCAL_CACHE,
          ModelKeys.INVALIDATION_CACHE,
          ModelKeys.REPLICATED_CACHE,
          ModelKeys.DISTRIBUTED_CACHE
        };
        for (String cacheType : cacheTypes) {
          List<Property> cachesOfAType = getCachesAsPropertyList(model, containerName, cacheType);
          if (cachesOfAType != null) cachesPL.addAll(cachesOfAType);
        }

        List<ModelNode> caches = new ArrayList<ModelNode>();
        for (Property cacheEntry : cachesPL) {
          caches.add(cacheEntry.getValue());
        }

        // for (ModelNode cache: container.get(ModelKeys.CACHE).asList()) {
        for (ModelNode cache : caches) {
          Configuration.CacheMode mode =
              Configuration.CacheMode.valueOf(cache.get(ModelKeys.CACHE_MODE).asString());
          if (mode.isClustered()) {
            if (mode.isDistributed()) {
              writer.writeStartElement(Element.DISTRIBUTED_CACHE.getLocalName());
              this.writeOptional(writer, Attribute.OWNERS, cache, ModelKeys.OWNERS);
              this.writeOptional(writer, Attribute.VIRTUAL_NODES, cache, ModelKeys.VIRTUAL_NODES);
              this.writeOptional(writer, Attribute.L1_LIFESPAN, cache, ModelKeys.L1_LIFESPAN);
            } else if (mode.isInvalidation()) {
              writer.writeStartElement(Element.INVALIDATION_CACHE.getLocalName());
            } else {
              writer.writeStartElement(Element.REPLICATED_CACHE.getLocalName());
            }
            writer.writeAttribute(Attribute.MODE.getLocalName(), Mode.forCacheMode(mode).name());
            this.writeOptional(writer, Attribute.QUEUE_SIZE, cache, ModelKeys.QUEUE_SIZE);
            this.writeOptional(
                writer, Attribute.QUEUE_FLUSH_INTERVAL, cache, ModelKeys.QUEUE_FLUSH_INTERVAL);
            this.writeOptional(writer, Attribute.REMOTE_TIMEOUT, cache, ModelKeys.REMOTE_TIMEOUT);
          } else {
            writer.writeStartElement(Element.LOCAL_CACHE.getLocalName());
          }
          this.writeRequired(writer, Attribute.NAME, cache, ModelKeys.NAME);
          this.writeOptional(writer, Attribute.START, cache, ModelKeys.START);
          this.writeOptional(writer, Attribute.BATCHING, cache, ModelKeys.BATCHING);
          this.writeOptional(writer, Attribute.INDEXING, cache, ModelKeys.INDEXING);
          if (cache.hasDefined(ModelKeys.LOCKING)) {
            writer.writeStartElement(Element.LOCKING.getLocalName());
            ModelNode locking = cache.get(ModelKeys.LOCKING);
            this.writeOptional(writer, Attribute.ISOLATION, locking, ModelKeys.ISOLATION);
            this.writeOptional(writer, Attribute.STRIPING, locking, ModelKeys.STRIPING);
            this.writeOptional(
                writer, Attribute.ACQUIRE_TIMEOUT, locking, ModelKeys.ACQUIRE_TIMEOUT);
            this.writeOptional(
                writer, Attribute.CONCURRENCY_LEVEL, locking, ModelKeys.CONCURRENCY_LEVEL);
            writer.writeEndElement();
          }

          if (cache.hasDefined(ModelKeys.TRANSACTION)) {
            writer.writeStartElement(Element.TRANSACTION.getLocalName());
            ModelNode transaction = cache.get(ModelKeys.TRANSACTION);
            this.writeOptional(writer, Attribute.STOP_TIMEOUT, transaction, ModelKeys.STOP_TIMEOUT);
            this.writeOptional(writer, Attribute.MODE, transaction, ModelKeys.MODE);
            this.writeOptional(writer, Attribute.LOCKING, transaction, ModelKeys.LOCKING);
            writer.writeEndElement();
          }

          if (cache.hasDefined(ModelKeys.EVICTION)) {
            writer.writeStartElement(Element.EVICTION.getLocalName());
            ModelNode eviction = cache.get(ModelKeys.EVICTION);
            this.writeOptional(writer, Attribute.STRATEGY, eviction, ModelKeys.STRATEGY);
            this.writeOptional(writer, Attribute.MAX_ENTRIES, eviction, ModelKeys.MAX_ENTRIES);
            writer.writeEndElement();
          }

          if (cache.hasDefined(ModelKeys.EXPIRATION)) {
            writer.writeStartElement(Element.EXPIRATION.getLocalName());
            ModelNode expiration = cache.get(ModelKeys.EXPIRATION);
            this.writeOptional(writer, Attribute.MAX_IDLE, expiration, ModelKeys.MAX_IDLE);
            this.writeOptional(writer, Attribute.LIFESPAN, expiration, ModelKeys.LIFESPAN);
            this.writeOptional(writer, Attribute.INTERVAL, expiration, ModelKeys.INTERVAL);
            writer.writeEndElement();
          }

          if (cache.hasDefined(ModelKeys.STORE)) {
            ModelNode store = cache.get(ModelKeys.STORE);
            writer.writeStartElement(Element.STORE.getLocalName());
            this.writeRequired(writer, Attribute.CLASS, store, ModelKeys.CLASS);
            this.writeStoreAttributes(writer, store);
            this.writeStoreProperties(writer, store);
            writer.writeEndElement();
          }

          if (cache.hasDefined(ModelKeys.FILE_STORE)) {
            ModelNode store = cache.get(ModelKeys.FILE_STORE);
            writer.writeStartElement(Element.FILE_STORE.getLocalName());
            this.writeOptional(writer, Attribute.RELATIVE_TO, store, ModelKeys.RELATIVE_TO);
            this.writeOptional(writer, Attribute.PATH, store, ModelKeys.PATH);
            this.writeStoreAttributes(writer, store);
            this.writeStoreProperties(writer, store);
            writer.writeEndElement();
          }

          if (cache.hasDefined(ModelKeys.JDBC_STORE)) {
            ModelNode store = cache.get(ModelKeys.JDBC_STORE);
            writer.writeStartElement(Element.JDBC_STORE.getLocalName());
            this.writeRequired(writer, Attribute.DATASOURCE, store, ModelKeys.DATASOURCE);
            this.writeStoreAttributes(writer, store);
            this.writeJDBCStoreTable(writer, Element.ENTRY_TABLE, store, ModelKeys.ENTRY_TABLE);
            this.writeJDBCStoreTable(writer, Element.BUCKET_TABLE, store, ModelKeys.BUCKET_TABLE);
            this.writeStoreProperties(writer, store);
            writer.writeEndElement();
          }

          if (cache.hasDefined(ModelKeys.REMOTE_STORE)) {
            ModelNode store = cache.get(ModelKeys.REMOTE_STORE);
            writer.writeStartElement(Element.REMOTE_STORE.getLocalName());
            this.writeOptional(writer, Attribute.CACHE, store, ModelKeys.CACHE);
            this.writeOptional(writer, Attribute.SOCKET_TIMEOUT, store, ModelKeys.SOCKET_TIMEOUT);
            this.writeOptional(writer, Attribute.TCP_NO_DELAY, store, ModelKeys.TCP_NO_DELAY);
            this.writeStoreAttributes(writer, store);
            for (ModelNode remoteServer : store.get(ModelKeys.REMOTE_SERVER).asList()) {
              writer.writeStartElement(Element.REMOTE_SERVER.getLocalName());
              writer.writeAttribute(
                  Attribute.OUTBOUND_SOCKET_BINDING.getLocalName(),
                  remoteServer.get(ModelKeys.OUTBOUND_SOCKET_BINDING).asString());
              writer.writeEndElement();
            }
            this.writeStoreProperties(writer, store);
            writer.writeEndElement();
          }

          if (cache.hasDefined(ModelKeys.STATE_TRANSFER)) {
            ModelNode stateTransfer = cache.get(ModelKeys.STATE_TRANSFER);
            writer.writeStartElement(Element.STATE_TRANSFER.getLocalName());
            this.writeOptional(writer, Attribute.ENABLED, stateTransfer, ModelKeys.ENABLED);
            this.writeOptional(writer, Attribute.TIMEOUT, stateTransfer, ModelKeys.TIMEOUT);
            this.writeOptional(
                writer, Attribute.FLUSH_TIMEOUT, stateTransfer, ModelKeys.FLUSH_TIMEOUT);
            writer.writeEndElement();
          }

          if (cache.hasDefined(ModelKeys.REHASHING)) {
            ModelNode rehashing = cache.get(ModelKeys.REHASHING);
            writer.writeStartElement(Element.REHASHING.getLocalName());
            this.writeOptional(writer, Attribute.ENABLED, rehashing, ModelKeys.ENABLED);
            this.writeOptional(writer, Attribute.TIMEOUT, rehashing, ModelKeys.TIMEOUT);
            this.writeOptional(writer, Attribute.WAIT, rehashing, ModelKeys.WAIT);
            writer.writeEndElement();
          }

          writer.writeEndElement();
        }

        writer.writeEndElement();
      }
    }
    writer.writeEndElement();
  }
예제 #23
0
 public DataSourcesSubsystemElement() {
   super(Namespace.CURRENT.getUriString());
 }
예제 #24
0
 @Override
 public void initializeParsers(ExtensionParsingContext context) {
   context.setSubsystemXmlMapping(SUBSYSTEM_NAME, Namespace.CURRENT.getUriString(), parser);
 }