use of org.jboss.as.controller.SimpleAttributeDefinition in project wildfly by wildfly.
the class JaxrsSubsystemParser_2_0 method handleSimpleElement.
protected void handleSimpleElement(final XMLExtendedStreamReader reader, final EnumSet<JaxrsElement> encountered, final ModelNode subsystem, final JaxrsElement element) throws XMLStreamException {
if (!encountered.add(element)) {
throw unexpectedElement(reader);
}
final String name = element.getLocalName();
final String value = parseElementNoAttributes(reader);
final SimpleAttributeDefinition attribute = (SimpleAttributeDefinition) JaxrsConstants.nameToAttributeMap.get(name);
attribute.parseAndSetParameter(value, subsystem, reader);
}
use of org.jboss.as.controller.SimpleAttributeDefinition in project wildfly by wildfly.
the class WebSubsystemParser method writeContent.
/**
* {@inheritDoc}
*/
@Override
public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context) throws XMLStreamException {
context.startSubsystemElement(Namespace.CURRENT.getUriString(), false);
ModelNode node = context.getModelNode();
WebDefinition.DEFAULT_VIRTUAL_SERVER.marshallAsAttribute(node, true, writer);
WebDefinition.INSTANCE_ID.marshallAsAttribute(node, false, writer);
WebDefinition.NATIVE.marshallAsAttribute(node, true, writer);
WebDefinition.DEFAULT_SESSION_TIMEOUT.marshallAsAttribute(node, false, writer);
if (node.hasDefined(CONFIGURATION)) {
writeContainerConfig(writer, node.get(CONFIGURATION));
}
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());
List<AttributeDefinition> connectorAttributes = new ArrayList<>(Arrays.asList(WebConnectorDefinition.CONNECTOR_ATTRIBUTES));
if (config.hasDefined(Constants.PROXY_BINDING)) {
connectorAttributes.remove(WebConnectorDefinition.PROXY_PORT);
connectorAttributes.remove(WebConnectorDefinition.PROXY_NAME);
} else {
connectorAttributes.remove(WebConnectorDefinition.PROXY_BINDING);
}
if (config.hasDefined(Constants.REDIRECT_BINDING)) {
connectorAttributes.remove(WebConnectorDefinition.REDIRECT_PORT);
} else {
connectorAttributes.remove(WebConnectorDefinition.REDIRECT_BINDING);
}
for (AttributeDefinition attr : connectorAttributes) {
if (attr instanceof SimpleAttributeDefinition) {
((SimpleAttributeDefinition) attr).marshallAsAttribute(config, true, writer);
}
}
if (config.get(SSL_PATH.getKey(), SSL_PATH.getValue()).isDefined()) {
ModelNode sslConfig = config.get(SSL_PATH.getKey(), SSL_PATH.getValue());
writer.writeStartElement(Element.SSL.getLocalName());
WebSSLDefinition.NAME.marshallAsAttribute(sslConfig, writer);
for (SimpleAttributeDefinition attr : WebSSLDefinition.SSL_ATTRIBUTES) {
attr.marshallAsAttribute(sslConfig, false, writer);
}
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());
WebVirtualHostDefinition.ENABLE_WELCOME_ROOT.marshallAsAttribute(config, true, writer);
WebVirtualHostDefinition.DEFAULT_WEB_MODULE.marshallAsAttribute(config, true, writer);
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_PATH.getKey(), ACCESS_LOG_PATH.getValue()).isDefined()) {
ModelNode accessLog = config.get(ACCESS_LOG_PATH.getKey(), ACCESS_LOG_PATH.getValue());
writer.writeStartElement(Element.ACCESS_LOG.getLocalName());
for (SimpleAttributeDefinition attr : WebAccessLogDefinition.ACCESS_LOG_ATTRIBUTES) {
attr.marshallAsAttribute(accessLog, false, writer);
}
if (accessLog.get(DIRECTORY_PATH.getKey(), DIRECTORY_PATH.getValue()).isDefined()) {
ModelNode directory = accessLog.get(DIRECTORY_PATH.getKey(), DIRECTORY_PATH.getValue());
String name = Element.DIRECTORY.getLocalName();
boolean startwritten = false;
startwritten = writeAttribute(writer, WebAccessLogDirectoryDefinition.PATH, directory, startwritten, name);
startwritten = writeAttribute(writer, WebAccessLogDirectoryDefinition.RELATIVE_TO, directory, startwritten, name);
if (startwritten) {
writer.writeEndElement();
}
}
writer.writeEndElement();
}
if (config.hasDefined(REWRITE)) {
for (final ModelNode rewritenode : config.get(REWRITE).asList()) {
Property prop = rewritenode.asProperty();
ModelNode rewrite = prop.getValue();
writer.writeStartElement(REWRITE);
writer.writeAttribute(NAME, prop.getName());
WebReWriteDefinition.PATTERN.marshallAsAttribute(rewrite, false, writer);
WebReWriteDefinition.SUBSTITUTION.marshallAsAttribute(rewrite, false, writer);
WebReWriteDefinition.FLAGS.marshallAsAttribute(rewrite, false, writer);
if (rewrite.hasDefined(CONDITION)) {
for (final ModelNode conditionnode : rewrite.get(CONDITION).asList()) {
Property conditionProp = conditionnode.asProperty();
ModelNode condition = conditionProp.getValue();
writer.writeStartElement(CONDITION);
writer.writeAttribute(NAME, conditionProp.getName());
WebReWriteConditionDefinition.TEST.marshallAsAttribute(condition, false, writer);
WebReWriteConditionDefinition.PATTERN.marshallAsAttribute(condition, false, writer);
WebReWriteConditionDefinition.FLAGS.marshallAsAttribute(condition, false, writer);
writer.writeEndElement();
}
}
writer.writeEndElement();
}
}
if (config.get(SSO_PATH.getKey(), SSO_PATH.getValue()).isDefined()) {
final ModelNode sso;
sso = config.get(SSO_PATH.getKey(), SSO_PATH.getValue());
writer.writeStartElement(SSO);
for (SimpleAttributeDefinition attr : WebSSODefinition.SSO_ATTRIBUTES) {
attr.marshallAsAttribute(sso, false, writer);
}
writer.writeEndElement();
}
// End of the VIRTUAL_SERVER
writer.writeEndElement();
}
if (node.hasDefined(VALVE)) {
for (final Property valve : node.get(VALVE).asPropertyList()) {
final ModelNode config = valve.getValue();
writer.writeStartElement(Element.VALVE.getLocalName());
writer.writeAttribute(NAME, valve.getName());
for (AttributeDefinition attr : WebValveDefinition.ATTRIBUTES) {
if (attr instanceof SimpleAttributeDefinition) {
((SimpleAttributeDefinition) attr).marshallAsAttribute(config, false, writer);
}
}
if (config.hasDefined(PARAM)) {
for (final Property entry : config.get(PARAM).asPropertyList()) {
writer.writeEmptyElement(Element.PARAM.getLocalName());
writer.writeAttribute(Attribute.PARAM_NAME.getLocalName(), entry.getName());
writer.writeAttribute(Attribute.PARAM_VALUE.getLocalName(), entry.getValue().asString());
}
}
writer.writeEndElement();
}
}
}
writer.writeEndElement();
}
use of org.jboss.as.controller.SimpleAttributeDefinition in project wildfly by wildfly.
the class AbstractFederationSubsystemReader method parseConfig.
/**
* Reads a element from the stream considering the parameters.
*
* @param reader XMLExtendedStreamReader instance from which the elements are read.
* @param xmlElement Name of the Model Element to be parsed.
* @param key Name of the attribute to be used to as the key for the model.
* @param addOperations List of operations.
* @param lastNode Parent ModelNode instance.
* @param attributes AttributeDefinition instances to be used to extract the attributes and populate the resulting model.
*
* @return A ModelNode instance populated.
*
* @throws javax.xml.stream.XMLStreamException
*/
protected ModelNode parseConfig(XMLExtendedStreamReader reader, ModelElement xmlElement, String key, ModelNode lastNode, List<SimpleAttributeDefinition> attributes, List<ModelNode> addOperations) throws XMLStreamException {
if (!reader.getLocalName().equals(xmlElement.getName())) {
return null;
}
ModelNode modelNode = Util.getEmptyOperation(ADD, null);
int attributeCount = reader.getAttributeCount();
for (int i = 0; i < attributeCount; i++) {
String attributeLocalName = reader.getAttributeLocalName(i);
if (ModelElement.forName(attributeLocalName) == null) {
throw unexpectedAttribute(reader, i);
}
}
for (SimpleAttributeDefinition simpleAttributeDefinition : attributes) {
String attributeValue = reader.getAttributeValue("", simpleAttributeDefinition.getXmlName());
simpleAttributeDefinition.parseAndSetParameter(attributeValue, modelNode, reader);
}
String name = xmlElement.getName();
if (key != null) {
name = key;
if (modelNode.hasDefined(key)) {
name = modelNode.get(key).asString();
} else {
String attributeValue = reader.getAttributeValue("", key);
if (attributeValue != null) {
name = attributeValue;
}
}
}
modelNode.get(ModelDescriptionConstants.OP_ADDR).set(lastNode.clone().get(OP_ADDR).add(xmlElement.getName(), name));
addOperations.add(modelNode);
return modelNode;
}
use of org.jboss.as.controller.SimpleAttributeDefinition in project wildfly by wildfly.
the class AbstractIDMSubsystemReader method parseConfig.
/**
* Reads a element from the stream considering the parameters.
*
* @param reader XMLExtendedStreamReader instance from which the elements are read.
* @param xmlElement Name of the Model Element to be parsed.
* @param key Name of the attribute to be used to as the key for the model.
* @param addOperations List of operations.
* @param lastNode Parent ModelNode instance.
* @param attributes AttributeDefinition instances to be used to extract the attributes and populate the resulting model.
*
* @return A ModelNode instance populated.
*
* @throws javax.xml.stream.XMLStreamException
*/
protected ModelNode parseConfig(XMLExtendedStreamReader reader, ModelElement xmlElement, String key, ModelNode lastNode, List<SimpleAttributeDefinition> attributes, List<ModelNode> addOperations) throws XMLStreamException {
if (!reader.getLocalName().equals(xmlElement.getName())) {
return null;
}
ModelNode modelNode = Util.getEmptyOperation(ADD, null);
int attributeCount = reader.getAttributeCount();
for (int i = 0; i < attributeCount; i++) {
String attributeLocalName = reader.getAttributeLocalName(i);
if (ModelElement.forName(attributeLocalName) == null) {
throw unexpectedAttribute(reader, i);
}
}
for (SimpleAttributeDefinition simpleAttributeDefinition : attributes) {
simpleAttributeDefinition.parseAndSetParameter(reader.getAttributeValue("", simpleAttributeDefinition.getXmlName()), modelNode, reader);
}
String name = xmlElement.getName();
if (key != null) {
name = key;
if (modelNode.hasDefined(key)) {
name = modelNode.get(key).asString();
} else {
String attributeValue = reader.getAttributeValue("", key);
if (attributeValue != null) {
name = attributeValue;
}
}
}
modelNode.get(ModelDescriptionConstants.OP_ADDR).set(lastNode.clone().get(OP_ADDR).add(xmlElement.getName(), name));
addOperations.add(modelNode);
return modelNode;
}
use of org.jboss.as.controller.SimpleAttributeDefinition in project wildfly by wildfly.
the class WSSubsystemWriter method writeContent.
@Override
public void writeContent(final XMLExtendedStreamWriter writer, final SubsystemMarshallingContext context) throws XMLStreamException {
// write ws subsystem start element
context.startSubsystemElement(Namespace.CURRENT.getUriString(), false);
ModelNode subsystem = context.getModelNode();
if (Attributes.STATISTICS_ENABLED.isMarshallable(subsystem)) {
Attributes.STATISTICS_ENABLED.marshallAsAttribute(subsystem, writer);
}
for (SimpleAttributeDefinition attr : Attributes.SUBSYSTEM_ATTRIBUTES) {
attr.marshallAsElement(subsystem, true, writer);
}
if (subsystem.hasDefined(ENDPOINT_CONFIG)) {
// write endpoint-config elements
final ModelNode endpointConfigs = subsystem.get(ENDPOINT_CONFIG);
writeConfigs(ENDPOINT_CONFIG, writer, endpointConfigs);
}
if (subsystem.hasDefined(CLIENT_CONFIG)) {
// write client-config elements
final ModelNode clientConfigs = subsystem.get(CLIENT_CONFIG);
writeConfigs(CLIENT_CONFIG, writer, clientConfigs);
}
// write ws subsystem end element
writer.writeEndElement();
}
Aggregations