diff options
9 files changed, 117 insertions, 8 deletions
diff --git a/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBinding.java b/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBinding.java index 7db508dbd2..6fdffaf4d4 100644 --- a/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBinding.java +++ b/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBinding.java @@ -102,6 +102,10 @@ public class JMSBinding implements Binding { private Map<String, Long> operationJMSTimeToLives = new HashMap<String, Long>(); private Map<String, Integer> operationJMSPriorities = new HashMap<String, Integer>(); private String jmsSelector; + private String requestConnectionName; + private String responseConnectionName; + private JMSBinding requestConnectionBinding; + private JMSBinding responseConnectionBinding; public JMSBinding() { super(); @@ -183,7 +187,11 @@ public class JMSBinding implements Binding { } public String getDestinationName() { - return destinationName; + if (requestConnectionBinding != null && requestConnectionBinding.getDestinationName() != null) { + return requestConnectionBinding.getDestinationName(); + } else { + return destinationName; + } } public void setDestinationName(String destinationName) { @@ -207,7 +215,11 @@ public class JMSBinding implements Binding { } public String getConnectionFactoryName() { - return connectionFactoryName; + if (requestConnectionBinding != null && requestConnectionBinding.getConnectionFactoryName() != null) { + return requestConnectionBinding.getConnectionFactoryName(); + } else { + return connectionFactoryName; + } } public void setConnectionFactoryName(String connectionFactoryName) { @@ -239,7 +251,11 @@ public class JMSBinding implements Binding { } public String getResponseDestinationName() { - return this.responseDestinationName; + if (requestConnectionBinding != null && requestConnectionBinding.getResponseDestinationName() != null) { + return requestConnectionBinding.getResponseDestinationName(); + } else { + return this.responseDestinationName; + } } public void setResponseDestinationName(String name) { @@ -263,7 +279,11 @@ public class JMSBinding implements Binding { } public String getResponseConnectionFactoryName() { - return responseConnectionFactoryName; + if (requestConnectionBinding != null && requestConnectionBinding.getResponseConnectionFactoryName() != null) { + return requestConnectionBinding.getResponseConnectionFactoryName(); + } else { + return responseConnectionFactoryName; + } } public void setResponseConnectionFactoryName(String connectionFactoryName) { @@ -483,4 +503,32 @@ public class JMSBinding implements Binding { this.jmsSelector = jmsSelector; } + public String getRequestConnectionName() { + return requestConnectionName; + } + + public void setRequestConnectionName(String requestConnectionName) { + this.requestConnectionName = requestConnectionName; + } + + public void setResponseConnectionName(String responseConnectionName) { + this.responseConnectionName = responseConnectionName; + } + public String getResponseConnectionName() { + return responseConnectionName; + } + + public void setRequestConnectionBinding(JMSBinding binding) { + this.requestConnectionBinding = binding; + } + public JMSBinding getRequestConnectionBinding() { + return requestConnectionBinding; + } + + public void setResponseConnectionBinding(JMSBinding binding) { + this.responseConnectionBinding = binding; + } + public JMSBinding getResponseConnectionBinding() { + return responseConnectionBinding; + } } diff --git a/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java b/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java index e3d46edc46..6913be730b 100644 --- a/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java +++ b/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java @@ -22,6 +22,7 @@ package org.apache.tuscany.sca.binding.jms.impl; import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; +import java.util.Map; import java.util.StringTokenizer; import javax.xml.namespace.QName; @@ -34,6 +35,8 @@ import org.apache.tuscany.sca.assembly.xml.Constants; import org.apache.tuscany.sca.assembly.xml.PolicyAttachPointProcessor; import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver; +import org.apache.tuscany.sca.contribution.resolver.ExtensibleModelResolver; import org.apache.tuscany.sca.contribution.resolver.ModelResolver; import org.apache.tuscany.sca.contribution.service.ContributionReadException; import org.apache.tuscany.sca.contribution.service.ContributionResolveException; @@ -215,10 +218,14 @@ public class JMSBindingProcessor implements StAXArtifactProcessor<JMSBinding> { } - // Read requestConnection - // TODO - // Read reponseConnection - // TODO + String requestConnectionName = reader.getAttributeValue(null, "requestConnection"); + if (requestConnectionName != null && requestConnectionName.length() > 0) { + jmsBinding.setRequestConnectionName(requestConnectionName); + } + String responseConnectionName = reader.getAttributeValue(null, "responseConnection"); + if (responseConnectionName != null && responseConnectionName.length() > 0) { + jmsBinding.setResponseConnectionName(responseConnectionName); + } // Read sub-elements of binding.jms boolean endFound = false; @@ -286,6 +293,28 @@ public class JMSBindingProcessor implements StAXArtifactProcessor<JMSBinding> { } public void resolve(JMSBinding model, ModelResolver resolver) throws ContributionResolveException { + if (model.getRequestConnectionName() != null) { + model.setRequestConnectionBinding(getConnectionBinding(model.getRequestConnectionName(), resolver)); + } + if (model.getResponseConnectionName() != null) { + model.setResponseConnectionBinding(getConnectionBinding(model.getResponseConnectionName(), resolver)); + } + } + + private JMSBinding getConnectionBinding(String bindingName, ModelResolver resolver) { + if (resolver instanceof ExtensibleModelResolver) { + DefaultModelResolver dr = (DefaultModelResolver)((ExtensibleModelResolver) resolver).getDefaultModelResolver(); + Map models = dr.getModels(); + for (Object o : models.keySet()) { + if (o instanceof JMSBinding) { + JMSBinding binding = (JMSBinding) o; + if (bindingName.equals(binding.getName())) { + return binding; + } + } + } + } + return null; } public void write(JMSBinding rmiBinding, XMLStreamWriter writer) throws ContributionWriteException, diff --git a/java/sca/modules/contribution-impl/src/main/java/org/apache/tuscany/sca/contribution/service/impl/ContributionServiceImpl.java b/java/sca/modules/contribution-impl/src/main/java/org/apache/tuscany/sca/contribution/service/impl/ContributionServiceImpl.java index 0e39174497..a91f620ad2 100644 --- a/java/sca/modules/contribution-impl/src/main/java/org/apache/tuscany/sca/contribution/service/impl/ContributionServiceImpl.java +++ b/java/sca/modules/contribution-impl/src/main/java/org/apache/tuscany/sca/contribution/service/impl/ContributionServiceImpl.java @@ -474,6 +474,9 @@ public class ContributionServiceImpl implements ContributionService { for (IntentAttachPointType attachPointType : definitions.getImplementationTypes() ) { policyDefinitionsResolver.addModel(attachPointType); } + for (Object binding : definitions.getBindings() ) { + policyDefinitionsResolver.addModel(binding); + } } } } diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolver.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolver.java index a001baa47f..bf175813f3 100644 --- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolver.java +++ b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolver.java @@ -57,4 +57,10 @@ public class DefaultModelResolver implements ModelResolver { return map.remove(resolved); } + // FIXME: TUSCANY-2499: temporarily give access to the models to get the jms binding + // use of definitions.xml working while the definitions.xml processing is being refactored + public Map getModels() { + return map; + } + } diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolver.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolver.java index 0cfba8e1ed..de54d54f94 100644 --- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolver.java +++ b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolver.java @@ -191,5 +191,11 @@ public class ExtensibleModelResolver implements ModelResolver { return unresolved; } + + // FIXME: TUSCANY-2499: temporarily give access to the defaultResolver to get the jms binding + // use of definitions.xml working while the definitions.xml processing is being refactored + public ModelResolver getDefaultModelResolver() { + return defaultResolver; + } } diff --git a/java/sca/modules/definitions-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/SCADefinitionsProcessor.java b/java/sca/modules/definitions-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/SCADefinitionsProcessor.java index be5ddea3ac..b87d890866 100644 --- a/java/sca/modules/definitions-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/SCADefinitionsProcessor.java +++ b/java/sca/modules/definitions-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/SCADefinitionsProcessor.java @@ -31,6 +31,7 @@ import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; import javax.xml.stream.XMLStreamWriter; +import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor; import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; import org.apache.tuscany.sca.contribution.resolver.ModelResolver; @@ -120,6 +121,9 @@ public class SCADefinitionsProcessor extends BaseStAXArtifactProcessor implement policySet.setName(new QName(targetNamespace, policySet.getName().getLocalPart())); definitions.getPolicySets().add(policySet); + } else if ( extension instanceof Binding ) { + Binding binding = (Binding)extension; + definitions.getBindings().add(binding); } else if ( extension instanceof IntentAttachPointType ) { IntentAttachPointType type = (IntentAttachPointType)extension; if ( type.getName().getLocalPart().startsWith(BINDING)) { diff --git a/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/SCADefinitions.java b/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/SCADefinitions.java index 018b65de98..2039b9ecc9 100644 --- a/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/SCADefinitions.java +++ b/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/SCADefinitions.java @@ -72,4 +72,11 @@ public interface SCADefinitions { * @return a list of domain wide Implementation Types
*/
List<IntentAttachPointType> getImplementationTypes();
+
+ /**
+ * Returns a list of domain wide binding definition objects
+ *
+ * @return a list of domain wide binding definition objects
+ */
+ List<Object> getBindings();
}
diff --git a/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/impl/SCADefinitionsImpl.java b/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/impl/SCADefinitionsImpl.java index baaf9d7a28..a5178497a0 100644 --- a/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/impl/SCADefinitionsImpl.java +++ b/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/impl/SCADefinitionsImpl.java @@ -38,6 +38,7 @@ public class SCADefinitionsImpl implements SCADefinitions { private List<PolicySet> policySets = new CopyOnWriteArrayList<PolicySet>();
private List<IntentAttachPointType> bindingTypes = new CopyOnWriteArrayList<IntentAttachPointType>();
private List<IntentAttachPointType> implementationTypes = new CopyOnWriteArrayList<IntentAttachPointType>();
+ private List<Object> bindings = new CopyOnWriteArrayList<Object>();
public List<IntentAttachPointType> getBindingTypes() {
@@ -63,4 +64,8 @@ public class SCADefinitionsImpl implements SCADefinitions { public void setTargetNamespace(String ns) {
this.targetNamespace = ns;
}
+
+ public List<Object> getBindings() {
+ return bindings;
+ }
}
diff --git a/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/util/SCADefinitionsUtil.java b/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/util/SCADefinitionsUtil.java index 3ba3255ee7..8de6f63c05 100644 --- a/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/util/SCADefinitionsUtil.java +++ b/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/util/SCADefinitionsUtil.java @@ -73,6 +73,7 @@ public class SCADefinitionsUtil { target.getPolicySets().addAll(source.getPolicySets());
target.getBindingTypes().addAll(source.getBindingTypes());
target.getImplementationTypes().addAll(source.getImplementationTypes());
+ target.getBindings().addAll(source.getBindings());
}
public static boolean isSCADefnsFile(URI uri) {
|