tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r689448 - in /tuscany/java/sca/modules: binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/ contribution-impl/src/main/java/org/apache/tuscany/sca/contribution/service/impl/ contribution/src/main/java/org/apache/tuscany/sca/c...
Date Wed, 27 Aug 2008 11:09:52 GMT
Author: antelder
Date: Wed Aug 27 04:09:51 2008
New Revision: 689448

URL: http://svn.apache.org/viewvc?rev=689448&view=rev
Log:
Updates to get the JMS binding requestConnection and responseConnection attributes working
using bindings defined in the definitions.xml file. This is not the final code for this as
the definitions.xml processing is being refactored (by Simon Laws?) as part of TUSCANY-2499,
this shows the type of function that the JMS binding will need as part of that work. Two parts
that need work are that SCADefinitions.getBindings  currently returns a list of Objects not
Bindings as otherwise theres a cyclic dependency in the maven modules, and there needs to
be a way for bindings to get at the SCADefinitions which is currently being done by getting
at the contribution processing internals with ExtensibleModelResolver.getDefaultModelResolver
and DefaultModelResolver.getModels. 

Modified:
    tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBinding.java
    tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java
    tuscany/java/sca/modules/contribution-impl/src/main/java/org/apache/tuscany/sca/contribution/service/impl/ContributionServiceImpl.java
    tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolver.java
    tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolver.java
    tuscany/java/sca/modules/definitions-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/SCADefinitionsProcessor.java
    tuscany/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/SCADefinitions.java
    tuscany/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/impl/SCADefinitionsImpl.java
    tuscany/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/util/SCADefinitionsUtil.java

Modified: tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBinding.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBinding.java?rev=689448&r1=689447&r2=689448&view=diff
==============================================================================
--- tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBinding.java
(original)
+++ tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBinding.java
Wed Aug 27 04:09:51 2008
@@ -102,6 +102,10 @@
     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 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 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 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 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 @@
         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;
+    }
 }

Modified: tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java?rev=689448&r1=689447&r2=689448&view=diff
==============================================================================
--- tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java
(original)
+++ tuscany/java/sca/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java
Wed Aug 27 04:09:51 2008
@@ -22,6 +22,7 @@
 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.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 @@
 
         }
 
-        // 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 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,

Modified: tuscany/java/sca/modules/contribution-impl/src/main/java/org/apache/tuscany/sca/contribution/service/impl/ContributionServiceImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/contribution-impl/src/main/java/org/apache/tuscany/sca/contribution/service/impl/ContributionServiceImpl.java?rev=689448&r1=689447&r2=689448&view=diff
==============================================================================
--- tuscany/java/sca/modules/contribution-impl/src/main/java/org/apache/tuscany/sca/contribution/service/impl/ContributionServiceImpl.java
(original)
+++ tuscany/java/sca/modules/contribution-impl/src/main/java/org/apache/tuscany/sca/contribution/service/impl/ContributionServiceImpl.java
Wed Aug 27 04:09:51 2008
@@ -474,6 +474,9 @@
                         for (IntentAttachPointType attachPointType : definitions.getImplementationTypes()
) {
                             policyDefinitionsResolver.addModel(attachPointType);
                         }
+                        for (Object binding : definitions.getBindings() ) {
+                            policyDefinitionsResolver.addModel(binding);
+                        }
                     }
                 }
             }

Modified: tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolver.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolver.java?rev=689448&r1=689447&r2=689448&view=diff
==============================================================================
--- tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolver.java
(original)
+++ tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolver.java
Wed Aug 27 04:09:51 2008
@@ -57,4 +57,10 @@
         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;
+    }
+    
 }

Modified: tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolver.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolver.java?rev=689448&r1=689447&r2=689448&view=diff
==============================================================================
--- tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolver.java
(original)
+++ tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolver.java
Wed Aug 27 04:09:51 2008
@@ -191,5 +191,11 @@
 
         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;
+    }
 
 }

Modified: tuscany/java/sca/modules/definitions-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/SCADefinitionsProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/definitions-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/SCADefinitionsProcessor.java?rev=689448&r1=689447&r2=689448&view=diff
==============================================================================
--- tuscany/java/sca/modules/definitions-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/SCADefinitionsProcessor.java
(original)
+++ tuscany/java/sca/modules/definitions-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/SCADefinitionsProcessor.java
Wed Aug 27 04:09:51 2008
@@ -31,6 +31,7 @@
 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 @@
                                 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)) {

Modified: tuscany/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/SCADefinitions.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/SCADefinitions.java?rev=689448&r1=689447&r2=689448&view=diff
==============================================================================
--- tuscany/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/SCADefinitions.java
(original)
+++ tuscany/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/SCADefinitions.java
Wed Aug 27 04:09:51 2008
@@ -72,4 +72,11 @@
      * @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();
 }

Modified: tuscany/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/impl/SCADefinitionsImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/impl/SCADefinitionsImpl.java?rev=689448&r1=689447&r2=689448&view=diff
==============================================================================
--- tuscany/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/impl/SCADefinitionsImpl.java
(original)
+++ tuscany/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/impl/SCADefinitionsImpl.java
Wed Aug 27 04:09:51 2008
@@ -38,6 +38,7 @@
     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 void setTargetNamespace(String ns) {
        this.targetNamespace = ns;
     }
+
+    public List<Object> getBindings() {
+        return bindings;
+    }
 }

Modified: tuscany/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/util/SCADefinitionsUtil.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/util/SCADefinitionsUtil.java?rev=689448&r1=689447&r2=689448&view=diff
==============================================================================
--- tuscany/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/util/SCADefinitionsUtil.java
(original)
+++ tuscany/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/util/SCADefinitionsUtil.java
Wed Aug 27 04:09:51 2008
@@ -73,6 +73,7 @@
         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) {



Mime
View raw message