tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From becke...@apache.org
Subject svn commit: r745909 - in /tuscany/branches/sca-java-1.x/modules/binding-jms/src: main/java/org/apache/tuscany/sca/binding/jms/impl/ test/java/org/apache/tuscany/sca/binding/jms/impl/
Date Thu, 19 Feb 2009 16:02:04 GMT
Author: beckerdo
Date: Thu Feb 19 16:02:03 2009
New Revision: 745909

URL: http://svn.apache.org/viewvc?rev=745909&view=rev
Log:
TUSCANY-2849 Unable to define operation-level intents on binding.jms

Modified:
    tuscany/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBinding.java
    tuscany/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java
    tuscany/branches/sca-java-1.x/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessorTestCase.java
    tuscany/branches/sca-java-1.x/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessorWriteTestCase.java

Modified: tuscany/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBinding.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBinding.java?rev=745909&r1=745908&r2=745909&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBinding.java
(original)
+++ tuscany/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBinding.java
Thu Feb 19 16:02:03 2009
@@ -27,7 +27,9 @@
 import java.util.TreeSet;
 
 import org.apache.tuscany.sca.assembly.BindingRRB;
+import org.apache.tuscany.sca.assembly.ConfiguredOperation;
 import org.apache.tuscany.sca.assembly.OperationSelector;
+import org.apache.tuscany.sca.assembly.OperationsConfigurator;
 import org.apache.tuscany.sca.assembly.WireFormat;
 import org.apache.tuscany.sca.policy.Intent;
 import org.apache.tuscany.sca.policy.IntentAttachPointType;
@@ -40,7 +42,7 @@
  * @version $Rev$ $Date$
  */
 
-public class JMSBinding implements BindingRRB, PolicySetAttachPoint {
+public class JMSBinding implements BindingRRB, PolicySetAttachPoint, OperationsConfigurator
{
 
     @Override
     public Object clone() throws CloneNotSupportedException {
@@ -60,6 +62,9 @@
     // properties required by IntentAttachPoint 
     private List<Intent> requiredIntents = new ArrayList<Intent>();
     private IntentAttachPointType intentAttachPointType;
+
+    // properties required to describe configured operations
+    private List<ConfiguredOperation>  configuredOperations = new ArrayList<ConfiguredOperation>();
     
     // Properties required to describe the JMS binding model
 
@@ -727,6 +732,14 @@
         return operationPropertiesProperties.get(opName);
     }
 
+    public List<ConfiguredOperation> getConfiguredOperations() {
+        return configuredOperations;
+    }
+
+    public void setConfiguredOperations(List<ConfiguredOperation> configuredOperations)
{
+        this.configuredOperations = configuredOperations;
+    }    
+    
     @Override
     public boolean equals( Object object ) {
         return ( object instanceof JMSBinding ) && equals( (JMSBinding) object );
@@ -786,6 +799,9 @@
         // Resource adapter
         if ( !optStringEquals( this.getResourceAdapterName(), binding.getResourceAdapterName()
)) return false;
 
+        // Configured operations
+        if ( this.configuredOperations.size() != binding.getConfiguredOperations().size()
) return false;
+        
         // Other fields could also be checked for equality. See class fields for details.
         return true;
     }

Modified: tuscany/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java?rev=745909&r1=745908&r2=745909&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java
(original)
+++ tuscany/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java
Thu Feb 19 16:02:03 2009
@@ -24,6 +24,7 @@
 
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.StringTokenizer;
@@ -33,10 +34,13 @@
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
 
+import org.apache.tuscany.sca.assembly.ConfiguredOperation;
 import org.apache.tuscany.sca.assembly.Extension;
 import org.apache.tuscany.sca.assembly.OperationSelector;
+import org.apache.tuscany.sca.assembly.OperationsConfigurator;
 import org.apache.tuscany.sca.assembly.WireFormat;
 import org.apache.tuscany.sca.assembly.builder.impl.ProblemImpl;
+import org.apache.tuscany.sca.assembly.xml.ConfiguredOperationProcessor;
 import org.apache.tuscany.sca.assembly.xml.Constants;
 import org.apache.tuscany.sca.assembly.xml.PolicyAttachPointProcessor;
 import org.apache.tuscany.sca.binding.jms.operationselector.jmsdefault.OperationSelectorJMSDefault;
@@ -130,16 +134,21 @@
 public class JMSBindingProcessor implements StAXArtifactProcessor<JMSBinding> {
     private PolicyFactory policyFactory;
     private PolicyAttachPointProcessor policyProcessor;
+    private ConfiguredOperationProcessor configuredOperationProcessor;
     protected StAXArtifactProcessor<Object> extensionProcessor;
     private Monitor monitor;
     protected String validationMessage;
 
+    private ModelFactoryExtensionPoint modelFactories; // DOB
     public JMSBindingProcessor(ModelFactoryExtensionPoint modelFactories, StAXArtifactProcessor<Object>
extensionProcessor, Monitor monitor) {
         this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
         this.policyProcessor = new PolicyAttachPointProcessor(policyFactory);
+        this.configuredOperationProcessor = 
+            new ConfiguredOperationProcessor(modelFactories, this.monitor);
         this.extensionProcessor = extensionProcessor;
         this.monitor = monitor;
         this.validationMessage = null;
+        this.modelFactories = modelFactories;
     }
     
     /**
@@ -277,6 +286,11 @@
                         parseOperationProperties(reader, jmsBinding);
                     } else if ("SubscriptionHeaders".equals(elementName)) {
                         parseSubscriptionHeaders(reader, jmsBinding);
+                    } else if (Constants.OPERATION_QNAME.equals(reader.getName())) {
+                        ConfiguredOperation confOp = configuredOperationProcessor.read(reader);
+                        if (confOp != null) {
+                            ((OperationsConfigurator)jmsBinding).getConfiguredOperations().add(confOp);
+                        }
                     } else {
                         Object extension = extensionProcessor.read(reader);
                         if (extension != null) {
@@ -929,6 +943,8 @@
         
         writeResourceAdapterProperties( jmsBinding, writer );
         
+        writeConfiguredOperations( jmsBinding, writer );
+        
         writer.writeEndElement();
     }
 
@@ -1428,4 +1444,26 @@
         writer.writeCharacters(" ");
     }
     
+    /**
+     * Writes configured operations if there are any.
+     *  <binding.jms uri=\"jms:testQueue\" >"
+     *      <operationProperties name=\"op1\">"
+     *      </operationProperties >" 
+     *       <operation name=\"op1\" requires=\"IntentOne IntentTwo\"/>"
+     *   </binding.jms>"
+     */
+    private void writeConfiguredOperations( JMSBinding jmsBinding, XMLStreamWriter writer)
throws XMLStreamException, ContributionWriteException {       
+        List<ConfiguredOperation> configOps = jmsBinding.getConfiguredOperations();
+        if (configOps == null || (configOps.size() < 1)) {
+            return;
+        }
+
+        for( Iterator<ConfiguredOperation> it = configOps.iterator(); it.hasNext();)
{
+           configuredOperationProcessor.write(it.next(), writer);
+        }
+
+        // Strange bug. Without white space, headers end tag improperly read.
+        writer.writeCharacters(" ");
+    }
+    
 }

Modified: tuscany/branches/sca-java-1.x/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessorTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessorTestCase.java?rev=745909&r1=745908&r2=745909&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessorTestCase.java
(original)
+++ tuscany/branches/sca-java-1.x/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessorTestCase.java
Thu Feb 19 16:02:03 2009
@@ -19,8 +19,10 @@
 
 package org.apache.tuscany.sca.binding.jms.impl;
 
+import java.io.InputStream;
 import java.io.StringReader;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -30,6 +32,8 @@
 import junit.framework.TestCase;
 
 import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.ConfiguredOperation;
+import org.apache.tuscany.sca.assembly.OperationsConfigurator;
 import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint;
 import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
 import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
@@ -333,6 +337,21 @@
             + " </component>"
             + "</composite>";
 
+    public static final String CONFIGURED_OPERATIONS =
+        "<?xml version=\"1.0\" encoding=\"ASCII\"?>" 
+        + "<composite xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" targetNamespace=\"http://binding-jms\"
name=\"binding-jms\">"
+            + " <component name=\"HelloWorldComponent\">"
+            + "   <implementation.java class=\"services.HelloWorld\"/>"
+            + "      <service name=\"HelloWorldService\">"
+            + "          <binding.jms uri=\"jms:testQueue\" >"
+            + "             <operationProperties name=\"op1\">"
+            + "             </operationProperties >" 
+            + "             <operation name=\"op1\" requires=\"IntentOne IntentTwo\"/>"
+            + "          </binding.jms>"
+            + "      </service>"
+            + " </component>"
+            + "</composite>";
+
     private XMLInputFactory inputFactory;
     private StAXArtifactProcessor<Object> staxProcessor;
     private Monitor monitor;
@@ -350,6 +369,7 @@
         }
         StAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(extensionPoints);
         staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory,
null, monitor);
+
     }
 
     /**
@@ -655,4 +675,21 @@
         }
     }
 
+    /**
+     * Tests the APIs:
+     *     public Set<String> getOperationNames();
+     * Provides no optional properties or sub elements
+     * @throws Exception
+     */
+    public void testConfiguredOperations1() throws Exception {
+        XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(CONFIGURED_OPERATIONS));
+        
+        Composite composite = (Composite)staxProcessor.read(reader);
+        JMSBinding binding = (JMSBinding)   composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
       
+        assertNotNull(binding);
+        
+        OperationsConfigurator opConfig = ((OperationsConfigurator)binding);
+        assertEquals(opConfig.getConfiguredOperations().get(0).getRequiredIntents().size(),
2);
+    }
+
 }

Modified: tuscany/branches/sca-java-1.x/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessorWriteTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessorWriteTestCase.java?rev=745909&r1=745908&r2=745909&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessorWriteTestCase.java
(original)
+++ tuscany/branches/sca-java-1.x/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessorWriteTestCase.java
Thu Feb 19 16:02:03 2009
@@ -54,24 +54,6 @@
  */
 public class JMSBindingProcessorWriteTestCase extends TestCase {
     
-//    public static final String COMPOSITE =
-//    public static final String HEADERS1 =
-//    public static final String PROPERTIES1 =
-//    public static final String OP_PROPERTIES1 =
-//    public static final String OP_NAMES_NO_PROPERTIES1 =
-//    public static final String SELECTOR =
-//    public static final String COMPOSITE_INVALID_URI =
-//    // Invalid: contains both a response attribute and a response element.
-//    public static final String COMPOSITE_INVALID_RESPONSE_ATTR_ELEMENT =
-//    public static final String DEST_PROPS =
-//    public static final String CF_PROPS =
-//    public static final String AS_PROPS =
-//    public static final String RESP_DEST_PROPS =
-//    public static final String RESP_CF_PROPS =
-//    public static final String RESP_AS_PROPS =
-//    public static final String OP_PROPS_PROPS =
-//    public static final String RES_ADPT_PROPS =
-
     private XMLInputFactory inputFactory;
     private XMLOutputFactory outputFactory;
     private StAXArtifactProcessor<Object> staxProcessor;
@@ -358,4 +340,25 @@
         // Compare initial binding to written binding.
         assertEquals(binding, binding2);
     }
+
+    public void testConfiguredOperations() throws Exception {
+        XMLStreamReader reader =
+            inputFactory.createXMLStreamReader(new StringReader(JMSBindingProcessorTestCase.CONFIGURED_OPERATIONS));
+        Composite composite = (Composite)staxProcessor.read(reader);
+        JMSBinding binding = (JMSBinding)composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+        assertNotNull(binding);
+
+        // Write out JMSBinding model to stream.
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos));
+
+        // Read written JMSBinding to a different JMSBinding model.
+        XMLStreamReader reader2 = inputFactory.createXMLStreamReader(new StringReader(bos.toString()));
+        Composite composite2 = (Composite)staxProcessor.read(reader2);
+        JMSBinding binding2 = (JMSBinding)composite2.getComponents().get(0).getServices().get(0).getBindings().get(0);
+        assertNotNull(binding2);
+
+        // Compare initial binding to written binding.
+        assertEquals(binding, binding2);
+    }
 }



Mime
View raw message