diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2010-08-25 17:04:13 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2010-08-25 17:04:13 +0000 |
commit | 20d0bd15a54135efd9b7cfca5afbe3b8e05e112a (patch) | |
tree | 7509528f45f6df0702ebfbfb8aac83b39ee81492 /sca-java-2.x/trunk/modules/binding-jms/src | |
parent | 53b9703d74bd3f7a87d4083e37615ee74ef34014 (diff) |
Updates for create attribute validation
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@989225 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-jms/src')
3 files changed, 98 insertions, 18 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBinding.java b/sca-java-2.x/trunk/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBinding.java index 39ffbfb854..977ef17d52 100644 --- a/sca-java-2.x/trunk/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBinding.java +++ b/sca-java-2.x/trunk/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBinding.java @@ -88,14 +88,14 @@ public class JMSBinding implements Binding, PolicySubject, OperationsConfigurato private Map<String, BindingProperty> connectionFactoryProperties = new HashMap<String, BindingProperty>(); private String activationSpecName = null; - private String activationSpecCreate = null; + private String activationSpecCreate = JMSBindingConstants.CREATE_IF_NOT_EXIST; private Map<String, BindingProperty> activationSpecProperties = new HashMap<String, BindingProperty>(); private String resourceAdapterName;; private Map<String, BindingProperty> resourceAdapterProperties = new HashMap<String, BindingProperty>(); private String responseActivationSpecName = null; - private String responseActivationSpecCreate = null; + private String responseActivationSpecCreate = JMSBindingConstants.CREATE_IF_NOT_EXIST; private Map<String, BindingProperty> responseActivationSpecProperties = new HashMap<String, BindingProperty>(); private String responseDestinationName = null; diff --git a/sca-java-2.x/trunk/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessor.java b/sca-java-2.x/trunk/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessor.java index f4f1e5a2e3..b58a23c5ca 100644 --- a/sca-java-2.x/trunk/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessor.java +++ b/sca-java-2.x/trunk/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessor.java @@ -448,7 +448,12 @@ public class JMSBindingProcessor extends BaseStAXArtifactProcessor implements St if (jmsBinding.getDestinationCreate().equals(JMSBindingConstants.CREATE_IF_NOT_EXIST)) { if (name == null || name.length() < 1) { - error(monitor, "MissingNameForCreate", reader); + error(monitor, "MissingNameForCREATE_IF_NOT_EXIST", reader); + } + } + if (jmsBinding.getDestinationCreate().equals(JMSBindingConstants.CREATE_NEVER)) { + if (name == null || name.length() < 1) { + error(monitor, "MissingNameForCREATE_NEVER", reader); } } } @@ -460,6 +465,23 @@ public class JMSBindingProcessor extends BaseStAXArtifactProcessor implements St } else { error(monitor, "MissingConnectionFactoryName", reader); } + + String create = reader.getAttributeValue(null, "create"); + if (create != null && create.length() > 0) { + validateCreate(create, reader, monitor); + jmsBinding.setConnectionFactoryCreate(create); + } + if (jmsBinding.getConnectionFactoryCreate().equals(JMSBindingConstants.CREATE_IF_NOT_EXIST)) { + if (name == null || name.length() < 1) { + error(monitor, "MissingNameForCREATE_IF_NOT_EXIST", reader); + } + } + if (jmsBinding.getConnectionFactoryCreate().equals(JMSBindingConstants.CREATE_NEVER)) { + if (name == null || name.length() < 1) { + error(monitor, "MissingNameForCREATE_NEVER", reader); + } + } + jmsBinding.getConnectionFactoryProperties().putAll(parseBindingProperties(reader, monitor)); } @@ -470,6 +492,23 @@ public class JMSBindingProcessor extends BaseStAXArtifactProcessor implements St } else { error(monitor, "MissingActivationSpecName", reader); } + + String create = reader.getAttributeValue(null, "create"); + if (create != null && create.length() > 0) { + validateCreate(create, reader, monitor); + jmsBinding.setActivationSpecCreate(create); + } + if (jmsBinding.getActivationSpecCreate().equals(JMSBindingConstants.CREATE_IF_NOT_EXIST)) { + if (name == null || name.length() < 1) { + error(monitor, "MissingNameForCREATE_IF_NOT_EXIST", reader); + } + } + if (jmsBinding.getActivationSpecCreate().equals(JMSBindingConstants.CREATE_NEVER)) { + if (name == null || name.length() < 1) { + error(monitor, "MissingNameForCREATE_NEVER", reader); + } + } + jmsBinding.getActivationSpecProperties().putAll(parseBindingProperties(reader, monitor)); } @@ -496,23 +535,20 @@ public class JMSBindingProcessor extends BaseStAXArtifactProcessor implements St validateCreate(create, reader, monitor); jmsBinding.setResponseDestinationCreate(create); } + if (jmsBinding.getResponseDestinationCreate().equals(JMSBindingConstants.CREATE_IF_NOT_EXIST)) { + if (name == null || name.length() < 1) { + error(monitor, "MissingNameForCREATE_IF_NOT_EXIST", reader); + } + } + if (jmsBinding.getResponseDestinationCreate().equals(JMSBindingConstants.CREATE_NEVER)) { + if (name == null || name.length() < 1) { + error(monitor, "MissingNameForCREATE_NEVER", reader); + } + } jmsBinding.getResponseDestinationProperties().putAll(parseBindingProperties(reader, monitor)); } - private void validateCreate(String create, XMLStreamReader reader, Monitor monitor) { - if (JMSBindingConstants.CREATE_ALWAYS.equals(create)) { - return; - } - if (JMSBindingConstants.CREATE_NEVER.equals(create)) { - return; - } - if (JMSBindingConstants.CREATE_IF_NOT_EXIST.equals(create)) { - return; - } - error(monitor, "InvalidCreate", reader, create); - } - private void parseResponseConnectionFactory(XMLStreamReader reader, JMSBinding jmsBinding, Monitor monitor) throws XMLStreamException { String name = getURIString(reader, "jndiName"); if (name != null && name.length() > 0) { @@ -520,6 +556,21 @@ public class JMSBindingProcessor extends BaseStAXArtifactProcessor implements St } else { warning(monitor, "MissingResponseConnectionFactory", reader); } + String create = reader.getAttributeValue(null, "create"); + if (create != null && create.length() > 0) { + validateCreate(create, reader, monitor); + jmsBinding.setResponseConnectionFactoryCreate(create); + } + if (jmsBinding.getResponseConnectionFactoryCreate().equals(JMSBindingConstants.CREATE_IF_NOT_EXIST)) { + if (name == null || name.length() < 1) { + error(monitor, "MissingNameForCREATE_IF_NOT_EXIST", reader); + } + } + if (jmsBinding.getResponseConnectionFactoryCreate().equals(JMSBindingConstants.CREATE_NEVER)) { + if (name == null || name.length() < 1) { + error(monitor, "MissingNameForCREATE_NEVER", reader); + } + } jmsBinding.getResponseConnectionFactoryProperties().putAll(parseBindingProperties(reader, monitor)); } @@ -530,9 +581,37 @@ public class JMSBindingProcessor extends BaseStAXArtifactProcessor implements St } else { warning(monitor, "MissingResponseActivationSpec", reader); } + String create = reader.getAttributeValue(null, "create"); + if (create != null && create.length() > 0) { + validateCreate(create, reader, monitor); + jmsBinding.setResponseActivationSpecCreate(create); + } + if (jmsBinding.getResponseActivationSpecCreate().equals(JMSBindingConstants.CREATE_IF_NOT_EXIST)) { + if (name == null || name.length() < 1) { + error(monitor, "MissingNameForCREATE_IF_NOT_EXIST", reader); + } + } + if (jmsBinding.getResponseActivationSpecCreate().equals(JMSBindingConstants.CREATE_NEVER)) { + if (name == null || name.length() < 1) { + error(monitor, "MissingNameForCREATE_NEVER", reader); + } + } jmsBinding.getResponseActivationSpecProperties().putAll(parseBindingProperties(reader, monitor)); } + private void validateCreate(String create, XMLStreamReader reader, Monitor monitor) { + if (JMSBindingConstants.CREATE_ALWAYS.equals(create)) { + return; + } + if (JMSBindingConstants.CREATE_NEVER.equals(create)) { + return; + } + if (JMSBindingConstants.CREATE_IF_NOT_EXIST.equals(create)) { + return; + } + error(monitor, "InvalidCreate", reader, create); + } + private void parseResponse(XMLStreamReader reader, JMSBinding jmsBinding, ProcessorContext context) throws ContributionReadException, XMLStreamException { // Read sub-elements of response Monitor monitor = context.getMonitor(); diff --git a/sca-java-2.x/trunk/modules/binding-jms/src/main/resources/binding-jms-validation-messages.properties b/sca-java-2.x/trunk/modules/binding-jms/src/main/resources/binding-jms-validation-messages.properties index acc7024a9c..147290b862 100644 --- a/sca-java-2.x/trunk/modules/binding-jms/src/main/resources/binding-jms-validation-messages.properties +++ b/sca-java-2.x/trunk/modules/binding-jms/src/main/resources/binding-jms-validation-messages.properties @@ -52,5 +52,6 @@ DuplicateOperationProperties = Must not use both operationProperties attribute a WireFormatAlreadyDefined = The request wireformat has already been defined. Only one request wire format can be specified. OpSelectorAlreadyDefined = More than one operation selector has been specified. Only one operation selector can be specified. ResponseWireformatAlreadyDefined = The response wireformat has already been defined. Only one response wire format can be specified. -MissingNameForCreate = Must specify jndiName attribute when create mode is "ifNotExist" -InvalidCreate = Attribute create {0} invalid, must be 'always', 'never', or 'ifNotExist'
\ No newline at end of file +MissingNameForCREATE_NEVER = Must specify jndiName attribute when create mode is "never" +MissingNameForCREATE_IF_NOT_EXIST = Must specify jndiName attribute when create mode is "ifNotExist" +InvalidCreate = Attribute create {0} invalid, must be 'always', 'never', or 'ifNotExist' |