/** {@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(); }
/** @author Richard Achmatowicz (c) 2011 Red Hat Inc. */ public interface CommonAttributes { SimpleAttributeDefinition DEFAULT_STACK = new SimpleAttributeDefinitionBuilder(ModelKeys.DEFAULT_STACK, ModelType.STRING, false) .setXmlName(Attribute.DEFAULT_STACK.getLocalName()) .setAllowExpression(false) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .build(); SimpleAttributeDefinition NAME = new SimpleAttributeDefinitionBuilder(ModelKeys.NAME, ModelType.STRING, false) .setXmlName(Attribute.NAME.getLocalName()) .setAllowExpression(false) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .build(); SimpleAttributeDefinition TYPE = new SimpleAttributeDefinitionBuilder(ModelKeys.TYPE, ModelType.STRING, false) .setXmlName(Attribute.TYPE.getLocalName()) .setAllowExpression(false) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) // .setValidator(new ProtocolTypeValidator(false)) .build(); SimpleAttributeDefinition SHARED = new SimpleAttributeDefinitionBuilder(ModelKeys.SHARED, ModelType.BOOLEAN, true) .setXmlName(Attribute.SHARED.getLocalName()) .setAllowExpression(false) .setDefaultValue(new ModelNode().set(true)) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .build(); SimpleAttributeDefinition SOCKET_BINDING = new SimpleAttributeDefinitionBuilder(ModelKeys.SOCKET_BINDING, ModelType.STRING, true) .setXmlName(Attribute.SOCKET_BINDING.getLocalName()) .setAllowExpression(false) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .build(); SimpleAttributeDefinition DIAGNOSTICS_SOCKET_BINDING = new SimpleAttributeDefinitionBuilder( ModelKeys.DIAGNOSTICS_SOCKET_BINDING, ModelType.STRING, true) .setXmlName(Attribute.DIAGNOSTICS_SOCKET_BINDING.getLocalName()) .setAllowExpression(false) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .build(); SimpleAttributeDefinition DEFAULT_EXECUTOR = new SimpleAttributeDefinitionBuilder(ModelKeys.DEFAULT_EXECUTOR, ModelType.STRING, true) .setXmlName(Attribute.DEFAULT_EXECUTOR.getLocalName()) .setAllowExpression(false) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .build(); SimpleAttributeDefinition OOB_EXECUTOR = new SimpleAttributeDefinitionBuilder(ModelKeys.OOB_EXECUTOR, ModelType.STRING, true) .setXmlName(Attribute.OOB_EXECUTOR.getLocalName()) .setAllowExpression(false) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .build(); SimpleAttributeDefinition TIMER_EXECUTOR = new SimpleAttributeDefinitionBuilder(ModelKeys.TIMER_EXECUTOR, ModelType.STRING, true) .setXmlName(Attribute.TIMER_EXECUTOR.getLocalName()) .setAllowExpression(false) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .build(); SimpleAttributeDefinition THREAD_FACTORY = new SimpleAttributeDefinitionBuilder(ModelKeys.THREAD_FACTORY, ModelType.STRING, true) .setXmlName(Attribute.THREAD_FACTORY.getLocalName()) .setAllowExpression(false) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .build(); SimpleAttributeDefinition SITE = new SimpleAttributeDefinitionBuilder(ModelKeys.SITE, ModelType.STRING, true) .setXmlName(Attribute.SITE.getLocalName()) .setAllowExpression(true) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .build(); SimpleAttributeDefinition RACK = new SimpleAttributeDefinitionBuilder(ModelKeys.RACK, ModelType.STRING, true) .setXmlName(Attribute.RACK.getLocalName()) .setAllowExpression(true) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .build(); SimpleAttributeDefinition MACHINE = new SimpleAttributeDefinitionBuilder(ModelKeys.MACHINE, ModelType.STRING, true) .setXmlName(Attribute.MACHINE.getLocalName()) .setAllowExpression(true) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .build(); SimpleAttributeDefinition PROPERTY = new SimpleAttributeDefinition(ModelKeys.PROPERTY, ModelType.PROPERTY, true); SimpleListAttributeDefinition PROPERTIES = SimpleListAttributeDefinition.Builder.of(ModelKeys.PROPERTIES, PROPERTY) .setAllowNull(true) .build(); SimpleAttributeDefinition VALUE = new SimpleAttributeDefinitionBuilder("value", ModelType.STRING, false) .setXmlName("value") .setAllowExpression(false) .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) .build(); AttributeDefinition[] TRANSPORT_ATTRIBUTES = { TYPE, SHARED, SOCKET_BINDING, DIAGNOSTICS_SOCKET_BINDING, DEFAULT_EXECUTOR, OOB_EXECUTOR, TIMER_EXECUTOR, THREAD_FACTORY, SITE, RACK, MACHINE, PROPERTIES }; AttributeDefinition[] PROTOCOL_ATTRIBUTES = {TYPE, SOCKET_BINDING, PROPERTIES}; ObjectTypeAttributeDefinition PROTOCOL = ObjectTypeAttributeDefinition.Builder.of(ModelKeys.PROTOCOL, PROTOCOL_ATTRIBUTES) .setAllowNull(true) .setSuffix("protocol") .build(); ObjectTypeAttributeDefinition TRANSPORT = ObjectTypeAttributeDefinition.Builder.of(ModelKeys.TRANSPORT, TRANSPORT_ATTRIBUTES) .setAllowNull(true) .setSuffix("transport") .build(); ObjectListAttributeDefinition PROTOCOLS = ObjectListAttributeDefinition.Builder.of(ModelKeys.PROTOCOLS, PROTOCOL) .setAllowNull(true) .build(); AttributeDefinition[] STACK_ATTRIBUTES = {TRANSPORT, PROTOCOLS}; ObjectTypeAttributeDefinition STACK = ObjectTypeAttributeDefinition.Builder.of(ModelKeys.STACK, STACK_ATTRIBUTES) .setAllowNull(true) .setSuffix("stack") .build(); }