Skip to content

Commit

Permalink
[WFLY-6391] Move additions to the Datasources subsystem to version 5.
Browse files Browse the repository at this point in the history
  • Loading branch information
darranl committed Jan 22, 2017
1 parent 524bfc9 commit 664a2f0
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 99 deletions.
Expand Up @@ -307,7 +307,6 @@ static void registerTransformers300(ResourceTransformationDescriptionBuilder par
.end(); .end();
} }



static void registerTransformers400(ResourceTransformationDescriptionBuilder parentBuilder) { static void registerTransformers400(ResourceTransformationDescriptionBuilder parentBuilder) {
ResourceTransformationDescriptionBuilder builder = parentBuilder.addChildResource(PATH_DATASOURCE); ResourceTransformationDescriptionBuilder builder = parentBuilder.addChildResource(PATH_DATASOURCE);
builder.getAttributeBuilder() builder.getAttributeBuilder()
Expand Down
Expand Up @@ -223,7 +223,7 @@ private void parseDataSources(final XMLExtendedStreamReader reader, final List<M
case DATASOURCES_3_0: case DATASOURCES_3_0:
parseDataSource_3_0(reader, list, parentAddress); parseDataSource_3_0(reader, list, parentAddress);
break; break;
case DATASOURCES_4_0: default:
parseDataSource_4_0(reader, list, parentAddress); parseDataSource_4_0(reader, list, parentAddress);
break; break;
} }
Expand All @@ -241,7 +241,7 @@ private void parseDataSources(final XMLExtendedStreamReader reader, final List<M
case DATASOURCES_3_0: case DATASOURCES_3_0:
parseXADataSource_3_0(reader, list, parentAddress); parseXADataSource_3_0(reader, list, parentAddress);
break; break;
case DATASOURCES_4_0: default:
parseXADataSource_4_0(reader, list, parentAddress); parseXADataSource_4_0(reader, list, parentAddress);
break; break;
} }
Expand Down Expand Up @@ -1285,7 +1285,15 @@ private void parseXADataSource_4_0(XMLExtendedStreamReader reader, final List<Mo
break; break;
} }
case SECURITY: { case SECURITY: {
parseDsSecurity_4_0(reader, operation); switch (Namespace.forUri(reader.getNamespaceURI())) {
// This method is only called for version 4 and later.
case DATASOURCES_4_0:
parseDsSecurity(reader, operation);
break;
default:
parseDsSecurity_5_0(reader, operation);
break;
}
break; break;
} }
case STATEMENT: { case STATEMENT: {
Expand All @@ -1301,7 +1309,7 @@ private void parseXADataSource_4_0(XMLExtendedStreamReader reader, final List<Mo
break; break;
} }
case RECOVERY: { case RECOVERY: {
parseRecovery_4_0(reader, operation); parseRecovery(reader, operation);
break; break;
} }
default: default:
Expand Down Expand Up @@ -1368,7 +1376,7 @@ private void parseDsSecurity(XMLExtendedStreamReader reader, final ModelNode ope
throw new ParserException(bundle.unexpectedEndOfDocument()); throw new ParserException(bundle.unexpectedEndOfDocument());
} }


private void parseDsSecurity_4_0(XMLExtendedStreamReader reader, final ModelNode operation) throws XMLStreamException, ParserException, private void parseDsSecurity_5_0(XMLExtendedStreamReader reader, final ModelNode operation) throws XMLStreamException, ParserException,
ValidateException { ValidateException {


boolean securityDomainMatched = false; boolean securityDomainMatched = false;
Expand Down Expand Up @@ -1986,7 +1994,15 @@ private void parseDataSource_4_0(final XMLExtendedStreamReader reader, final Lis
break; break;
} }
case SECURITY: { case SECURITY: {
parseDsSecurity_4_0(reader, operation); switch (Namespace.forUri(reader.getNamespaceURI())) {
// This method is only called for version 4 and later.
case DATASOURCES_4_0:
parseDsSecurity(reader, operation);
break;
default:
parseDsSecurity_5_0(reader, operation);
break;
}
break; break;
} }
case STATEMENT: { case STATEMENT: {
Expand Down Expand Up @@ -2267,55 +2283,18 @@ private void parseRecovery(XMLExtendedStreamReader reader, final ModelNode opera
Recovery.Tag tag = Recovery.Tag.forName(reader.getLocalName()); Recovery.Tag tag = Recovery.Tag.forName(reader.getLocalName());
switch (tag) { switch (tag) {
case RECOVER_CREDENTIAL: { case RECOVER_CREDENTIAL: {
parseCredential(reader, operation); switch (Namespace.forUri(reader.getNamespaceURI())) {
break; case DATASOURCES_1_1:
} case DATASOURCES_1_2:
case RECOVER_PLUGIN: { case DATASOURCES_2_0:
parseExtension(reader, tag.getLocalName(), operation, RECOVER_PLUGIN_CLASSNAME, RECOVER_PLUGIN_PROPERTIES); case DATASOURCES_3_0:
break; case DATASOURCES_4_0:
} parseCredential(reader, operation);
default: break;
throw new ParserException(bundle.unexpectedElement(reader.getLocalName())); default:
} parseCredential_5_0(reader, operation);
break; break;
} }
}
}
throw new ParserException(bundle.unexpectedEndOfDocument());
}

private void parseRecovery_4_0(XMLExtendedStreamReader reader, final ModelNode operation) throws XMLStreamException, ParserException,
ValidateException {

for (Recovery.Attribute attribute : Recovery.Attribute.values()) {
switch (attribute) {
case NO_RECOVERY: {
String value = rawAttributeText(reader, NO_RECOVERY.getXmlName());
NO_RECOVERY.parseAndSetParameter(value, operation, reader);
break;
}
default:
break;
}
}

while (reader.hasNext()) {
switch (reader.nextTag()) {
case END_ELEMENT: {
if (XaDataSource.Tag.forName(reader.getLocalName()) == XaDataSource.Tag.RECOVERY) {
return;
} else {
if (Recovery.Tag.forName(reader.getLocalName()) == Recovery.Tag.UNKNOWN) {
throw new ParserException(bundle.unexpectedEndTag(reader.getLocalName()));
}
}
break;
}
case START_ELEMENT: {
Recovery.Tag tag = Recovery.Tag.forName(reader.getLocalName());
switch (tag) {
case RECOVER_CREDENTIAL: {
parseCredential_4_0(reader, operation);
break; break;
} }
case RECOVER_PLUGIN: { case RECOVER_PLUGIN: {
Expand Down Expand Up @@ -2376,7 +2355,7 @@ private void parseCredential(XMLExtendedStreamReader reader, final ModelNode ope
throw new ParserException(bundle.unexpectedEndOfDocument()); throw new ParserException(bundle.unexpectedEndOfDocument());
} }


private void parseCredential_4_0(XMLExtendedStreamReader reader, final ModelNode operation) throws XMLStreamException, ParserException, private void parseCredential_5_0(XMLExtendedStreamReader reader, final ModelNode operation) throws XMLStreamException, ParserException,
ValidateException { ValidateException {


while (reader.hasNext()) { while (reader.hasNext()) {
Expand Down
34 changes: 1 addition & 33 deletions connector/src/main/resources/schema/wildfly-datasources_4_0.xsd
Expand Up @@ -920,38 +920,6 @@
</xs:documentation> </xs:documentation>
</xs:annotation> </xs:annotation>
</xs:element> </xs:element>
<xs:sequence minOccurs="0">
<xs:element name="elytron-enabled" type="boolean-presenceType">
<xs:annotation>
<xs:documentation>
<![CDATA[[
Indicates that Elytron is responsible for authenticating connections. If authentication-context
is configured (via authentication-context), Elytron will use the specified context
for authenticating. Else, Elytron will use the current authentication context of the caller that
is retrieving the connection.
Ex:
<elytron-enabled/>
]]>
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="authentication-context" type="xs:token" minOccurs="0">
<xs:annotation>
<xs:documentation>
<![CDATA[[
Indicates the Elytron context that will be used for authenticating connections during
container-managed sign-on.
The resulting Subject will be used to distinguish connections in the pool.
The authentication-context name correlates to the authentication context defined in
the Elytron subsystem.
Ex:
<elytron-enabled/>
<authentication-context>HsqlDbContext</authentication-context>
]]>
</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:choice> </xs:choice>
<xs:element name="reauth-plugin" type="extensionType" minOccurs="0" maxOccurs="1"></xs:element> <xs:element name="reauth-plugin" type="extensionType" minOccurs="0" maxOccurs="1"></xs:element>
</xs:sequence> </xs:sequence>
Expand Down Expand Up @@ -1120,4 +1088,4 @@
</xs:element> </xs:element>
</xs:sequence> </xs:sequence>
</xs:complexType> </xs:complexType>
</xs:schema> </xs:schema>
36 changes: 34 additions & 2 deletions connector/src/main/resources/schema/wildfly-datasources_5_0.xsd
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
~ JBoss, Home of Professional Open Source. ~ JBoss, Home of Professional Open Source.
~ Copyright 2011, Red Hat, Inc., and individual contributors ~ Copyright 2017, Red Hat, Inc., and individual contributors
~ as indicated by the @author tags. See the copyright.txt file in the ~ as indicated by the @author tags. See the copyright.txt file in the
~ distribution for a full listing of individual contributors. ~ distribution for a full listing of individual contributors.
~ ~
Expand Down Expand Up @@ -920,6 +920,38 @@
</xs:documentation> </xs:documentation>
</xs:annotation> </xs:annotation>
</xs:element> </xs:element>
<xs:sequence minOccurs="0">
<xs:element name="elytron-enabled" type="boolean-presenceType">
<xs:annotation>
<xs:documentation>
<![CDATA[[
Indicates that Elytron is responsible for authenticating connections. If authentication-context
is configured (via authentication-context), Elytron will use the specified context
for authenticating. Else, Elytron will use the current authentication context of the caller that
is retrieving the connection.
Ex:
<elytron-enabled/>
]]>
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="authentication-context" type="xs:token" minOccurs="0">
<xs:annotation>
<xs:documentation>
<![CDATA[[
Indicates the Elytron context that will be used for authenticating connections during
container-managed sign-on.
The resulting Subject will be used to distinguish connections in the pool.
The authentication-context name correlates to the authentication context defined in
the Elytron subsystem.
Ex:
<elytron-enabled/>
<authentication-context>HsqlDbContext</authentication-context>
]]>
</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:choice> </xs:choice>
<xs:element name="reauth-plugin" type="extensionType" minOccurs="0" maxOccurs="1"></xs:element> <xs:element name="reauth-plugin" type="extensionType" minOccurs="0" maxOccurs="1"></xs:element>
</xs:sequence> </xs:sequence>
Expand Down Expand Up @@ -1088,4 +1120,4 @@
</xs:element> </xs:element>
</xs:sequence> </xs:sequence>
</xs:complexType> </xs:complexType>
</xs:schema> </xs:schema>
Expand Up @@ -2,7 +2,7 @@
<!-- See src/resources/configuration/ReadMe.txt for how the configuration assembly works --> <!-- See src/resources/configuration/ReadMe.txt for how the configuration assembly works -->
<config> <config>
<extension-module>org.jboss.as.connector</extension-module> <extension-module>org.jboss.as.connector</extension-module>
<subsystem xmlns="urn:jboss:domain:datasources:4.0"> <subsystem xmlns="urn:jboss:domain:datasources:5.0">
<datasources> <datasources>
<datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true"> <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">
<connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url> <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
Expand Down
Expand Up @@ -60,7 +60,7 @@ protected String getSubsystemXml() throws IOException {


@Override @Override
protected String getSubsystemXsdPath() throws Exception { protected String getSubsystemXsdPath() throws Exception {
return "schema/wildfly-datasources_4_0.xsd"; return "schema/wildfly-datasources_5_0.xsd";
} }


@Override @Override
Expand Down Expand Up @@ -122,7 +122,7 @@ public void testTransformerExpressionEAP64() throws Exception {


@Test @Test
public void testTransformerElytronEnabledEAP64() throws Exception { public void testTransformerElytronEnabledEAP64() throws Exception {
testTransformerElytronEnabled("datasources-elytron-enabled_4_0.xml", ModelTestControllerVersion.EAP_6_4_0, ModelVersion.create(1, 3, 0)); testTransformerElytronEnabled("datasources-elytron-enabled_5_0.xml", ModelTestControllerVersion.EAP_6_4_0, ModelVersion.create(1, 3, 0));
} }
@Test @Test
public void testTransformerEAP7() throws Exception { public void testTransformerEAP7() throws Exception {
Expand Down
@@ -1,4 +1,4 @@
<urn:subsystem xmlns:urn="urn:jboss:domain:datasources:4.0"> <urn:subsystem xmlns:urn="urn:jboss:domain:datasources:5.0">
<urn:datasources> <urn:datasources>
<!--You have a CHOICE of the next 2 items at this level--> <!--You have a CHOICE of the next 2 items at this level-->
<urn:datasource jta="true" jndi-name="java:/token" pool-name="token" enabled="true" use-java-context="true" spy="false" use-ccm="true" connectable="${test.expr:true}" statistics-enabled="true" tracking="true"> <urn:datasource jta="true" jndi-name="java:/token" pool-name="token" enabled="true" use-java-context="true" spy="false" use-ccm="true" connectable="${test.expr:true}" statistics-enabled="true" tracking="true">
Expand Down
@@ -1,4 +1,4 @@
<subsystem xmlns="urn:jboss:domain:datasources:4.0"> <subsystem xmlns="urn:jboss:domain:datasources:5.0">
<datasources> <datasources>
<datasource jndi-name="java:jboss/datasources/complexDs" pool-name="complexDs_Pool" <datasource jndi-name="java:jboss/datasources/complexDs" pool-name="complexDs_Pool"
use-java-context="${test.expr:true}" spy="${test.expr:false}" use-ccm="${test.expr:true}" jta="${test.expr:false}" use-java-context="${test.expr:true}" spy="${test.expr:false}" use-ccm="${test.expr:true}" jta="${test.expr:false}"
Expand Down
@@ -1,4 +1,4 @@
<subsystem xmlns="urn:jboss:domain:datasources:4.0"> <subsystem xmlns="urn:jboss:domain:datasources:5.0">
<datasources> <datasources>
<datasource jndi-name="java:jboss/datasources/complexDs" pool-name="complexDs_Pool" jta="false" <datasource jndi-name="java:jboss/datasources/complexDs" pool-name="complexDs_Pool" jta="false"
use-java-context="true" spy="false" use-ccm="true" connectable="false" statistics-enabled="true" tracking="true"> use-java-context="true" spy="false" use-ccm="true" connectable="false" statistics-enabled="true" tracking="true">
Expand Down
@@ -1,4 +1,4 @@
<subsystem xmlns="urn:jboss:domain:datasources:4.0"> <subsystem xmlns="urn:jboss:domain:datasources:5.0">
<datasources> <datasources>
<datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS"
use-java-context="true"> use-java-context="true">
Expand Down

0 comments on commit 664a2f0

Please sign in to comment.