use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.
the class MessagingSubsystem30TestCase method doTestRejectExpressions_2_0_0_or_2_1_0.
/**
* Tests rejection of expressions in either 2.0.0 or 2.1.0 model.
*/
private void doTestRejectExpressions_2_0_0_or_2_1_0(KernelServicesBuilder builder, ModelVersion version) throws Exception {
KernelServices mainServices = builder.build();
assertTrue(mainServices.isSuccessfulBoot());
KernelServices legacyServices = mainServices.getLegacyServices(version);
assertNotNull(legacyServices);
assertTrue(legacyServices.isSuccessfulBoot());
//Use the real xml with expressions for testing all the attributes
PathAddress subsystemAddress = PathAddress.pathAddress(pathElement(SUBSYSTEM, MessagingExtension.SUBSYSTEM_NAME));
List<ModelNode> modelNodes = builder.parseXmlResource("subsystem_3_0_expressions.xml");
modelNodes.remove(0);
checkFailedTransformedBootOperations(mainServices, version, modelNodes, new FailedOperationTransformationConfig().addFailedAttribute(subsystemAddress.append(HORNETQ_SERVER_PATH), createChainedConfig(new AttributeDefinition[] {}, new AttributeDefinition[] { OVERRIDE_IN_VM_SECURITY })).addFailedAttribute(subsystemAddress.append(HORNETQ_SERVER_PATH).append(AddressSettingDefinition.PATH), createChainedConfig(new AttributeDefinition[] {}, new AttributeDefinition[] { AddressSettingDefinition.MAX_REDELIVERY_DELAY, AddressSettingDefinition.REDELIVERY_MULTIPLIER, AddressSettingDefinition.SLOW_CONSUMER_CHECK_PERIOD, AddressSettingDefinition.SLOW_CONSUMER_POLICY, AddressSettingDefinition.SLOW_CONSUMER_THRESHOLD })));
}
use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.
the class PooledConnectionFactoryDefinition method define.
// the generation of the Pooled CF attributes is a bit ugly but it is with purpose:
// * factorize the attributes which are common between the regular CF and the pooled CF
// * keep in a single place the subtle differences (e.g. different default values for reconnect-attempts between
// the regular and pooled CF
// * define the attributes in the *same order than the XSD* to write them to the XML configuration by simply iterating over the array
private static ConnectionFactoryAttribute[] define(ConnectionFactoryAttribute[] specific, ConnectionFactoryAttribute... common) {
int size = common.length + specific.length;
ConnectionFactoryAttribute[] result = new ConnectionFactoryAttribute[size];
arraycopy(specific, 0, result, 0, specific.length);
for (int i = 0; i < common.length; i++) {
ConnectionFactoryAttribute attr = common[i];
AttributeDefinition definition = attr.getDefinition();
ConnectionFactoryAttribute newAttr;
// replace the reconnect-attempts attribute to use a different default value for pooled CF
if (definition == Common.RECONNECT_ATTEMPTS) {
AttributeDefinition copy = copy(Pooled.RECONNECT_ATTEMPTS, AttributeAccess.Flag.RESTART_ALL_SERVICES);
newAttr = ConnectionFactoryAttribute.create(copy, Pooled.RECONNECT_ATTEMPTS_PROP_NAME, true);
} else {
AttributeDefinition copy = copy(definition, AttributeAccess.Flag.RESTART_ALL_SERVICES);
newAttr = ConnectionFactoryAttribute.create(copy, attr.getPropertyName(), attr.isResourceAdapterProperty(), attr.isInboundConfig());
}
result[specific.length + i] = newAttr;
}
return result;
}
use of org.jboss.as.controller.AttributeDefinition 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.AttributeDefinition in project wildfly by wildfly.
the class MessagingXMLWriter method writeBridges.
private static void writeBridges(XMLExtendedStreamWriter writer, ModelNode node) throws XMLStreamException {
if (!node.isDefined()) {
return;
}
List<Property> properties = node.asPropertyList();
if (!properties.isEmpty()) {
writer.writeStartElement(Element.BRIDGES.getLocalName());
for (final Property property : node.asPropertyList()) {
writer.writeStartElement(Element.BRIDGE.getLocalName());
writer.writeAttribute(Attribute.NAME.getLocalName(), property.getName());
for (AttributeDefinition attribute : BridgeDefinition.ATTRIBUTES) {
if (CommonAttributes.FILTER == attribute) {
writeFilter(writer, property.getValue());
} else {
attribute.marshallAsElement(property.getValue(), writer);
}
}
writer.writeEndElement();
}
writer.writeEndElement();
writeNewLine(writer);
}
}
use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.
the class MessagingXMLWriter method writeDiscoveryGroups.
private static void writeDiscoveryGroups(final XMLExtendedStreamWriter writer, final ModelNode node) throws XMLStreamException {
if (!node.isDefined()) {
return;
}
List<Property> properties = node.asPropertyList();
if (!properties.isEmpty()) {
writer.writeStartElement(Element.DISCOVERY_GROUPS.getLocalName());
for (final Property property : properties) {
writer.writeStartElement(Element.DISCOVERY_GROUP.getLocalName());
writer.writeAttribute(Attribute.NAME.getLocalName(), property.getName());
for (AttributeDefinition attribute : DiscoveryGroupDefinition.ATTRIBUTES) {
attribute.marshallAsElement(property.getValue(), writer);
}
writer.writeEndElement();
}
writer.writeEndElement();
writeNewLine(writer);
}
}
Aggregations