Skip to content

Commit

Permalink
Rename 'connection' to connection factory in XML and model. Fix subsy…
Browse files Browse the repository at this point in the history
…stem ADD handler to call the right config setters
  • Loading branch information
Thomas Diesler authored and n1hility committed Dec 9, 2011
1 parent 6c19b19 commit a5e479a
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 46 deletions.
4 changes: 2 additions & 2 deletions build/src/main/resources/docs/schema/jboss-as-jaxr_1_0.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
</xs:documentation>
</xs:annotation>
<xs:all>
<xs:element name="datasource" type="connectionType" minOccurs="0" maxOccurs="1"/>
<xs:element name="connectionFactory" type="connectionFactoryType" minOccurs="0" maxOccurs="1"/>
<xs:element name="datasource" type="datasourceType" minOccurs="0" maxOccurs="1"/>
<xs:element name="flags" type="flagsType" minOccurs="0" maxOccurs="1"/>
</xs:all>
</xs:complexType>

<xs:complexType name="connectionType" mixed="false">
<xs:complexType name="connectionFactoryType" mixed="false">
<xs:attribute name="jndi-name" type="xs:token" use="required">
<xs:annotation>
<xs:documentation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
</subsystem>
<subsystem xmlns="urn:jboss:domain:jacorb:1.1"/>
<subsystem xmlns="urn:jboss:domain:jaxr:1.0">
<connection jndi-name="java:/jaxr/ConnectionFactory"/>
<connectionFactory jndi-name="java:/jaxr/ConnectionFactory"/>
<datasource jndi-name="java:jboss/datasources/ExampleDS"/>
<flags dropOnStart="true" createOnStart="true" dropOnStop="false"/>
</subsystem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,18 @@
*/
package org.jboss.as.jaxr.extension;

import org.jboss.as.controller.AbstractAddStepHandler;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.descriptions.DescriptionProvider;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.dmr.ModelNode;

import java.util.Locale;

import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD;

/**
* Handler responsible for adding the ConnectionFactory JNDI name to the model
*
* @author Thomas.Diesler@jboss.com
* @since 07-Nov-2011
*/
class JAXRConnectionAttributeHandler extends AbstractAttributeHandler {
class JAXRConnectionFactoryAttributeHandler extends AbstractAttributeHandler {

static final JAXRConnectionAttributeHandler INSTANCE = new JAXRConnectionAttributeHandler();
static final JAXRConnectionFactoryAttributeHandler INSTANCE = new JAXRConnectionFactoryAttributeHandler();

// Hide ctor
private JAXRConnectionAttributeHandler() {
super(ModelConstants.CONNECTION);
private JAXRConnectionFactoryAttributeHandler() {
super(ModelConstants.CONNECTIONFACTORY);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public String toString() {
enum Element {
// must be first
UNKNOWN(null),
CONNECTION("connection"),
CONNECTIONFACTORY("connectionFactory"),
DATASOURCE("datasource"),
FLAGS("flags"),
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ static ModelNode createAddSubsystemOperation() {
@Override
protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException {
JAXRConfiguration config = JAXRConfiguration.INSTANCE;
if (operation.has(ModelConstants.CONNECTION)) {
ModelNode node = operation.get(ModelConstants.CONNECTION);
model.get(ModelConstants.CONNECTION).set(node);
if (operation.has(ModelConstants.CONNECTIONFACTORY)) {
ModelNode node = operation.get(ModelConstants.CONNECTIONFACTORY);
model.get(ModelConstants.CONNECTIONFACTORY).set(node);
config.setConnectionFactoryBinding(node.asString());
}
if (operation.has(ModelConstants.DATASOURCE)) {
Expand All @@ -86,12 +86,12 @@ protected void populateModel(ModelNode operation, ModelNode model) throws Operat
if (operation.has(ModelConstants.CREATEONSTART)) {
ModelNode node = operation.get(ModelConstants.CREATEONSTART);
model.get(ModelConstants.CREATEONSTART).set(node);
config.setDropOnStart(node.asBoolean());
config.setCreateOnStart(node.asBoolean());
}
if (operation.has(ModelConstants.DROPONSTOP)) {
ModelNode node = operation.get(ModelConstants.DROPONSTOP);
model.get(ModelConstants.DROPONSTOP).set(node);
config.setDropOnStart(node.asBoolean());
config.setDropOnStop(node.asBoolean());
}
}

Expand All @@ -117,9 +117,9 @@ public ModelNode getModelDescription(Locale locale) {
final ModelNode node = new ModelNode();
node.get(ModelDescriptionConstants.OPERATION_NAME).set(ModelDescriptionConstants.ADD);
node.get(ModelDescriptionConstants.DESCRIPTION).set("Adds the JAXR subsystem");
node.get(ModelDescriptionConstants.REQUEST_PROPERTIES, ModelConstants.CONNECTION, ModelDescriptionConstants.DESCRIPTION).set("The JNDI name for the ConnectionFactory");
node.get(ModelDescriptionConstants.REQUEST_PROPERTIES, ModelConstants.CONNECTION, ModelDescriptionConstants.TYPE).set(ModelType.STRING);
node.get(ModelDescriptionConstants.REQUEST_PROPERTIES, ModelConstants.CONNECTION, ModelDescriptionConstants.REQUIRED).set(false);
node.get(ModelDescriptionConstants.REQUEST_PROPERTIES, ModelConstants.CONNECTIONFACTORY, ModelDescriptionConstants.DESCRIPTION).set("The JNDI name for the ConnectionFactory");
node.get(ModelDescriptionConstants.REQUEST_PROPERTIES, ModelConstants.CONNECTIONFACTORY, ModelDescriptionConstants.TYPE).set(ModelType.STRING);
node.get(ModelDescriptionConstants.REQUEST_PROPERTIES, ModelConstants.CONNECTIONFACTORY, ModelDescriptionConstants.REQUIRED).set(false);
node.get(ModelDescriptionConstants.REQUEST_PROPERTIES, ModelConstants.DATASOURCE, ModelDescriptionConstants.DESCRIPTION).set("The JNDI name for the DataSource");
node.get(ModelDescriptionConstants.REQUEST_PROPERTIES, ModelConstants.DATASOURCE, ModelDescriptionConstants.TYPE).set(ModelType.STRING);
node.get(ModelDescriptionConstants.REQUEST_PROPERTIES, ModelConstants.DATASOURCE, ModelDescriptionConstants.REQUIRED).set(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@

import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.DESCRIBE;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.WRITE_ATTRIBUTE_OPERATION;


/**
Expand All @@ -63,7 +62,7 @@ public void initialize(ExtensionContext context) {
SubsystemRegistration subsystem = context.registerSubsystem(JAXRConstants.SUBSYSTEM_NAME);
ManagementResourceRegistration registration = subsystem.registerSubsystemModel(JAXRSubsystemProviders.SUBSYSTEM);
registration.registerOperationHandler(ADD, JAXRSubsystemAdd.INSTANCE, JAXRSubsystemAdd.DESCRIPTION, false);
registration.registerReadWriteAttribute(ModelConstants.CONNECTION, null, JAXRConnectionAttributeHandler.INSTANCE, EnumSet.of(AttributeAccess.Flag.STORAGE_CONFIGURATION, AttributeAccess.Flag.RESTART_ALL_SERVICES));
registration.registerReadWriteAttribute(ModelConstants.CONNECTIONFACTORY, null, JAXRConnectionFactoryAttributeHandler.INSTANCE, EnumSet.of(AttributeAccess.Flag.STORAGE_CONFIGURATION, AttributeAccess.Flag.RESTART_ALL_SERVICES));
registration.registerReadWriteAttribute(ModelConstants.DATASOURCE, null, JAXRDatasourceAttributeHandler.INSTANCE, EnumSet.of(AttributeAccess.Flag.STORAGE_CONFIGURATION, AttributeAccess.Flag.RESTART_ALL_SERVICES));
registration.registerReadWriteAttribute(ModelConstants.DROPONSTART, null, JAXRDropOnStartAttributeHandler.INSTANCE, EnumSet.of(AttributeAccess.Flag.STORAGE_CONFIGURATION, AttributeAccess.Flag.RESTART_ALL_SERVICES));
registration.registerReadWriteAttribute(ModelConstants.CREATEONSTART, null, JAXRCreateOnStartAttributeHandler.INSTANCE, EnumSet.of(AttributeAccess.Flag.STORAGE_CONFIGURATION, AttributeAccess.Flag.RESTART_ALL_SERVICES));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ public void readElement(XMLExtendedStreamReader reader, List<ModelNode> operatio
case JAXR_1_0: {
final Element element = Element.forName(reader.getLocalName());
switch (element) {
case CONNECTION: {
parseBinding(reader, result, ModelConstants.CONNECTION);
case CONNECTIONFACTORY: {
parseBinding(reader, result, ModelConstants.CONNECTIONFACTORY);
break;
}
case DATASOURCE: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,13 @@
package org.jboss.as.jaxr.extension;

import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ATTRIBUTES;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.CHILDREN;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.DESCRIPTION;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OPERATION_NAME;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.HEAD_COMMENT_ALLOWED;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.NAMESPACE;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.TAIL_COMMENT_ALLOWED;
import static org.jboss.as.jaxr.extension.JAXRConstants.Namespace;

import java.util.Locale;
import java.util.ResourceBundle;

import org.jboss.as.controller.descriptions.DescriptionProvider;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
Expand All @@ -56,11 +53,11 @@ public ModelNode getModelDescription(Locale locale) {
subsystem.get(TAIL_COMMENT_ALLOWED).set(true);
subsystem.get(NAMESPACE).set(Namespace.CURRENT.getUriString());

subsystem.get(ATTRIBUTES, ModelConstants.CONNECTION, ModelDescriptionConstants.DESCRIPTION).set("The JNDI name for the ConnectionFactory");
subsystem.get(ATTRIBUTES, ModelConstants.CONNECTION, ModelDescriptionConstants.REQUIRED).set(false);
subsystem.get(ATTRIBUTES, ModelConstants.CONNECTION, ModelDescriptionConstants.TYPE).set(ModelType.STRING);
subsystem.get(ATTRIBUTES, ModelConstants.CONNECTION, ModelDescriptionConstants.ACCESS_TYPE).set(AttributeAccess.AccessType.READ_WRITE.toString());
subsystem.get(ATTRIBUTES, ModelConstants.CONNECTION, ModelDescriptionConstants.RESTART_REQUIRED).set(AttributeAccess.Flag.RESTART_ALL_SERVICES.toString());
subsystem.get(ATTRIBUTES, ModelConstants.CONNECTIONFACTORY, ModelDescriptionConstants.DESCRIPTION).set("The JNDI name for the ConnectionFactory");
subsystem.get(ATTRIBUTES, ModelConstants.CONNECTIONFACTORY, ModelDescriptionConstants.REQUIRED).set(false);
subsystem.get(ATTRIBUTES, ModelConstants.CONNECTIONFACTORY, ModelDescriptionConstants.TYPE).set(ModelType.STRING);
subsystem.get(ATTRIBUTES, ModelConstants.CONNECTIONFACTORY, ModelDescriptionConstants.ACCESS_TYPE).set(AttributeAccess.AccessType.READ_WRITE.toString());
subsystem.get(ATTRIBUTES, ModelConstants.CONNECTIONFACTORY, ModelDescriptionConstants.RESTART_REQUIRED).set(AttributeAccess.Flag.RESTART_ALL_SERVICES.toString());

subsystem.get(ATTRIBUTES, ModelConstants.DATASOURCE, ModelDescriptionConstants.DESCRIPTION).set("The JNDI name for the DataSource");
subsystem.get(ATTRIBUTES, ModelConstants.DATASOURCE, ModelDescriptionConstants.REQUIRED).set(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ private JAXRSubsystemWriter() {
public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context) throws XMLStreamException {
context.startSubsystemElement(Namespace.CURRENT.getUriString(), false);
ModelNode node = context.getModelNode();
if (has(node, ModelConstants.CONNECTION)) {
writer.writeStartElement(Element.CONNECTION.getLocalName());
writeAttribute(writer, Attribute.JNDI_NAME, node.get(ModelConstants.CONNECTION));
if (has(node, ModelConstants.CONNECTIONFACTORY)) {
writer.writeStartElement(Element.CONNECTIONFACTORY.getLocalName());
writeAttribute(writer, Attribute.JNDI_NAME, node.get(ModelConstants.CONNECTIONFACTORY));
writer.writeEndElement();
}
if (has(node, ModelConstants.DATASOURCE)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
*/
public interface ModelConstants {

String CONNECTION = "connection";
String CONNECTIONFACTORY = "connection-factory";
String DATASOURCE = "datasource";
String DROPONSTART = "dropOnStart";
String CREATEONSTART = "createOnStart";
String DROPONSTOP = "dropOnStop";
String DROPONSTART = "drop-on-start";
String CREATEONSTART = "create-on-start";
String DROPONSTOP = "drop-on-stop";

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class JAXRSubsystemParsingTestCase extends AbstractSubsystemTest {

public static final String SUBSYSTEM_XML =
"<subsystem xmlns='" + Namespace.CURRENT.getUriString() + "'>" +
"<connection jndi-name='java:ConnectionFactory'/>" +
"<connectionFactory jndi-name='java:ConnectionFactory'/>" +
"<datasource jndi-name='java:DataSource'/>" +
"<flags dropOnStart='true' createOnStart='true' dropOnStop='true'/>" +
"</subsystem>";
Expand Down

0 comments on commit a5e479a

Please sign in to comment.