tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r659292 - in /incubator/tuscany/java/sca/modules/databinding-jaxb-axiom/src/main: java/org/apache/tuscany/sca/databinding/jaxb/axiom/ java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/ resources/META-INF/services/
Date Thu, 22 May 2008 22:35:47 GMT
Author: rfeng
Date: Thu May 22 15:35:46 2008
New Revision: 659292

URL: http://svn.apache.org/viewvc?rev=659292&view=rev
Log:
Add OMElement2JAXB and refactor the SourceDataSource/XMLStringDataSource into ext package

Added:
    incubator/tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/OMElement2JAXB.java
  (with props)
    incubator/tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/SourceDataSource.java
      - copied, changed from r658953, incubator/tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/SourceDataSource.java
    incubator/tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/XMLStringDataSource.java
      - copied, changed from r658953, incubator/tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/XMLStringDataSource.java
Removed:
    incubator/tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/SourceDataSource.java
    incubator/tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/XMLStringDataSource.java
Modified:
    incubator/tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer

Added: incubator/tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/OMElement2JAXB.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/OMElement2JAXB.java?rev=659292&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/OMElement2JAXB.java
(added)
+++ incubator/tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/OMElement2JAXB.java
Thu May 22 15:35:46 2008
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.databinding.jaxb.axiom;
+
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.tuscany.sca.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.impl.BaseTransformer;
+import org.apache.tuscany.sca.databinding.jaxb.JAXBContextHelper;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class OMElement2JAXB extends BaseTransformer<OMElement, Object> implements PullTransformer<OMElement,
Object> {
+
+    @Override
+    public String getSourceDataBinding() {
+        return org.apache.axiom.om.OMElement.class.getName();
+    }
+
+    @SuppressWarnings("unchecked")
+    public Object transform(final OMElement source, final TransformationContext context)
throws TransformationException {
+        try {
+            return AccessController.doPrivileged(new PrivilegedExceptionAction<Object>()
{
+                public Object run() throws JAXBException, XMLStreamException {
+                    // Marshalling directly to the output stream is faster than marshalling
through the
+                    // XMLStreamWriter. 
+                    // Take advantage of this optimization if there is an output stream.
+                    JAXBContext jaxbContext = JAXBContextHelper.createJAXBContext(context,
true);
+                    Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
+                    XMLStreamReader reader = source.getXMLStreamReaderWithoutCaching();
+                    Object result =
+                        unmarshaller.unmarshal(reader, JAXBContextHelper.getJavaType(context.getTargetDataType()));
+                    reader.close();
+                    return JAXBContextHelper.createReturnValue(context.getTargetDataType(),
result);
+                }
+            });
+        } catch (PrivilegedActionException e) {
+            throw new TransformationException(e.getException());
+        }
+    }
+
+    @Override
+    public Class<OMElement> getSourceType() {
+        return OMElement.class;
+    }
+
+    @Override
+    public Class<Object> getTargetType() {
+        return Object.class;
+    }
+
+    @Override
+    public int getWeight() {
+        return 3000;
+    }
+}

Propchange: incubator/tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/OMElement2JAXB.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/OMElement2JAXB.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Copied: incubator/tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/SourceDataSource.java
(from r658953, incubator/tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/SourceDataSource.java)
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/SourceDataSource.java?p2=incubator/tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/SourceDataSource.java&p1=incubator/tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/SourceDataSource.java&r1=658953&r2=659292&rev=659292&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/SourceDataSource.java
(original)
+++ incubator/tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/SourceDataSource.java
Thu May 22 15:35:46 2008
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.apache.tuscany.sca.databinding.jaxb.axiom;
+package org.apache.tuscany.sca.databinding.jaxb.axiom.ext;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;

Copied: incubator/tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/XMLStringDataSource.java
(from r658953, incubator/tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/XMLStringDataSource.java)
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/XMLStringDataSource.java?p2=incubator/tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/XMLStringDataSource.java&p1=incubator/tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/XMLStringDataSource.java&r1=658953&r2=659292&rev=659292&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/XMLStringDataSource.java
(original)
+++ incubator/tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/XMLStringDataSource.java
Thu May 22 15:35:46 2008
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.apache.tuscany.sca.databinding.jaxb.axiom;
+package org.apache.tuscany.sca.databinding.jaxb.axiom.ext;
 
 import java.io.IOException;
 import java.io.StringReader;

Modified: incubator/tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer?rev=659292&r1=659291&r2=659292&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer
(original)
+++ incubator/tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer
Thu May 22 15:35:46 2008
@@ -18,4 +18,9 @@
 # Implementation classes for the transformers
 org.apache.tuscany.sca.databinding.jaxb.axiom.JAXB2OMElement;source=javax.xml.bind.JAXBElement,target=org.apache.axiom.om.OMElement,weight=3000
 org.apache.tuscany.sca.databinding.jaxb.axiom.JAXB2OMElement;source=java:simpleType,target=org.apache.axiom.om.OMElement,weight=3000
-org.apache.tuscany.sca.databinding.jaxb.axiom.JAXB2OMElement;source=java:complexType,target=org.apache.axiom.om.OMElement,weight=3000
\ No newline at end of file
+org.apache.tuscany.sca.databinding.jaxb.axiom.JAXB2OMElement;source=java:complexType,target=org.apache.axiom.om.OMElement,weight=3000
+
+org.apache.tuscany.sca.databinding.jaxb.axiom.OMElement2JAXB;source=org.apache.axiom.om.OMElement,target=javax.xml.bind.JAXBElement,weight=3000,public=false
+org.apache.tuscany.sca.databinding.jaxb.axiom.OMElement2JAXB;source=org.apache.axiom.om.OMElement,target=java:complexType,weight=90000,public=false
+org.apache.tuscany.sca.databinding.jaxb.axiom.OMElement2JAXB;source=org.apache.axiom.om.OMElement,target=java:simpleType,weight=90000,public=false
+



Mime
View raw message