tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ramku...@apache.org
Subject svn commit: r745778 - in /tuscany/branches/sca-java-1.x/modules/core-databinding: ./ src/main/java/org/apache/tuscany/sca/core/databinding/module/ src/main/java/org/apache/tuscany/sca/core/databinding/transformers/
Date Thu, 19 Feb 2009 08:34:11 GMT
Author: ramkumar
Date: Thu Feb 19 08:34:11 2009
New Revision: 745778

URL: http://svn.apache.org/viewvc?rev=745778&view=rev
Log:
Fixes for TUSCANY-2840-Part2

Added:
    tuscany/branches/sca-java-1.x/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/OMElementXMLAdapter.java
Modified:
    tuscany/branches/sca-java-1.x/modules/core-databinding/pom.xml
    tuscany/branches/sca-java-1.x/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/module/DataBindingModuleActivator.java

Modified: tuscany/branches/sca-java-1.x/modules/core-databinding/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/core-databinding/pom.xml?rev=745778&r1=745777&r2=745778&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/core-databinding/pom.xml (original)
+++ tuscany/branches/sca-java-1.x/modules/core-databinding/pom.xml Thu Feb 19 08:34:11 2009
@@ -85,6 +85,37 @@
                 </exclusion>
             </exclusions>
         </dependency>
+        
+        <dependency>
+            <groupId>org.apache.ws.commons.axiom</groupId>
+            <artifactId>axiom-api</artifactId>
+            <version>1.2.7</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>xerces</groupId>
+                    <artifactId>xercesImpl</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>javax.mail</groupId>
+                    <artifactId>mail</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>commons-logging</groupId>
+                    <artifactId>commons-logging</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>xml-apis</groupId>
+                    <artifactId>xml-apis</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.ws.commons.axiom</groupId>
+            <artifactId>axiom-impl</artifactId>
+            <version>1.2.7</version>
+            <scope>runtime</scope>
+        </dependency>
     </dependencies>
 
     <build>

Modified: tuscany/branches/sca-java-1.x/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/module/DataBindingModuleActivator.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/module/DataBindingModuleActivator.java?rev=745778&r1=745777&r2=745778&view=diff
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/module/DataBindingModuleActivator.java
(original)
+++ tuscany/branches/sca-java-1.x/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/module/DataBindingModuleActivator.java
Thu Feb 19 08:34:11 2009
@@ -31,6 +31,7 @@
 import org.apache.tuscany.sca.core.databinding.transformers.Input2InputTransformer;
 import org.apache.tuscany.sca.core.databinding.transformers.Output2OutputTransformer;
 import org.apache.tuscany.sca.core.databinding.transformers.XMLStreamReader2CallableReference;
+import org.apache.tuscany.sca.core.databinding.transformers.OMElementXMLAdapter;
 import org.apache.tuscany.sca.core.databinding.wire.DataBindingRuntimeWireProcessor;
 import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
 import org.apache.tuscany.sca.databinding.TransformerExtensionPoint;
@@ -43,6 +44,7 @@
 import org.apache.tuscany.sca.interfacedef.java.jaxws.JAXWSJavaInterfaceProcessor;
 import org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint;
 import org.osoa.sca.CallableReference;
+import org.apache.axiom.om.OMElement;
 
 /**
  * @version $Rev$ $Date$
@@ -55,6 +57,7 @@
 
         XMLAdapterExtensionPoint xmlAdapterExtensionPoint = registry.getExtensionPoint(XMLAdapterExtensionPoint.class);
         xmlAdapterExtensionPoint.addAdapter(CallableReference.class, CallableReferenceXMLAdapter.class);
+        xmlAdapterExtensionPoint.addAdapter(OMElement.class, OMElementXMLAdapter.class);
         FaultExceptionMapper faultExceptionMapper = new JAXWSFaultExceptionMapper(dataBindings,
xmlAdapterExtensionPoint);
         
         MediatorImpl mediator = new MediatorImpl(dataBindings, transformers);

Added: tuscany/branches/sca-java-1.x/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/OMElementXMLAdapter.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/OMElementXMLAdapter.java?rev=745778&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/OMElementXMLAdapter.java
(added)
+++ tuscany/branches/sca-java-1.x/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/OMElementXMLAdapter.java
Thu Feb 19 08:34:11 2009
@@ -0,0 +1,44 @@
+package org.apache.tuscany.sca.core.databinding.transformers;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+
+import javax.xml.transform.Source;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.tuscany.sca.databinding.xml.XMLStreamReader2String;
+
+/**
+ * This special XmlAdapter can be used by JAXB classes to convert from OMElement to Source
+ */
+public class OMElementXMLAdapter extends XmlAdapter<Source, OMElement> {
+	
+	private TransformerFactory transformerFactory = TransformerFactory.newInstance();
+    private XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+    
+    @Override
+    public Source marshal(OMElement v) throws Exception {
+    	XMLStreamReader reader = v.getXMLStreamReaderWithoutCaching();
+        XMLStreamReader2String t2 = new XMLStreamReader2String();
+        String xml = t2.transform(reader, null);
+        return new StreamSource(new StringReader(xml));    	
+    }
+
+    @Override
+    public OMElement unmarshal(Source v) throws Exception {        
+    	StringWriter sw = new StringWriter();
+        StreamResult result = new StreamResult(sw);
+        transformerFactory.newTransformer().transform(v, result);
+        XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(sw.toString()));

+        // Build OMElement from XMLStreamReader
+        StAXOMBuilder builder = new StAXOMBuilder(reader);
+        return builder.getDocumentElement();
+    }
+}



Mime
View raw message