tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r831163 - in /tuscany/java/sca/modules: databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/ databinding-jaxb-axiom/src/t...
Date Fri, 30 Oct 2009 00:04:49 GMT
Author: rfeng
Date: Fri Oct 30 00:04:47 2009
New Revision: 831163

URL: http://svn.apache.org/viewvc?rev=831163&view=rev
Log:
Refactor JAXBContextCache/JAXBContextHelper to be a utility bound to the extension point registry

Modified:
    tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/JAXB2OMElement.java
    tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/JAXBDataSource.java
    tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/OMElement2JAXB.java
    tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/JAXBDSContext.java
    tuscany/java/sca/modules/databinding-jaxb-axiom/src/test/java/org/apache/tuscany/databinding/jaxb/axiom/JAXB2OMTestCase.java
    tuscany/java/sca/modules/databinding-jaxb-axiom/src/test/java/org/apache/tuscany/databinding/jaxb/axiom/OMElement2JAXBTestCase.java
    tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2Node.java
    tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2SAX.java
    tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2String.java
    tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCache.java
    tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java
    tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBinding.java
    tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTypeHelper.java
    tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Node2JAXB.java
    tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Reader2JAXB.java
    tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/String2JAXB.java
    tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/XMLStreamReader2JAXB.java
    tuscany/java/sca/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCacheTestCase.java
    tuscany/java/sca/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTestCase.java
    tuscany/java/sca/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/FaultBeanGeneratorTestCase.java
    tuscany/java/sca/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGeneratorTestCase.java

Modified: tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/JAXB2OMElement.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/JAXB2OMElement.java?rev=831163&r1=831162&r2=831163&view=diff
==============================================================================
--- tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/JAXB2OMElement.java (original)
+++ tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/JAXB2OMElement.java Fri Oct 30 00:04:47 2009
@@ -25,6 +25,7 @@
 import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
 import org.apache.tuscany.sca.databinding.PullTransformer;
 import org.apache.tuscany.sca.databinding.TransformationContext;
 import org.apache.tuscany.sca.databinding.TransformationException;
@@ -38,12 +39,14 @@
  * @version $Rev$ $Date$
  */
 public class JAXB2OMElement extends BaseTransformer<Object, OMElement> implements PullTransformer<Object, OMElement> {
-    public JAXB2OMElement() {
+    private OMFactory factory = OMAbstractFactory.getOMFactory();
+    private JAXBContextHelper contextHelper;
+    
+    public JAXB2OMElement(ExtensionPointRegistry registry) {
         super();
+        contextHelper = JAXBContextHelper.getInstance(registry);
     }
 
-    private OMFactory factory = OMAbstractFactory.getOMFactory();
-
     @Override
     public String getSourceDataBinding() {
         return JAXBDataBinding.NAME;
@@ -52,13 +55,13 @@
     public OMElement transform(Object source, TransformationContext context) throws TransformationException {
         JAXBContext jaxbContext;
         try {
-            jaxbContext = JAXBContextHelper.createJAXBContext(context, true);
+            jaxbContext = contextHelper.createJAXBContext(context, true);
         } catch (JAXBException e) {
             throw new TransformationException(e);
         }
         Object element = JAXBContextHelper.createJAXBElement(jaxbContext, context.getTargetDataType(), source);
         QName name = jaxbContext.createJAXBIntrospector().getElementName(element);
-        JAXBDataSource dataSource = new JAXBDataSource(element, jaxbContext);
+        JAXBDataSource dataSource = new JAXBDataSource(element, jaxbContext, contextHelper);
         OMElement omElement = AxiomHelper.createOMElement(factory, name, dataSource);
         return omElement;
     }

Modified: tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/JAXBDataSource.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/JAXBDataSource.java?rev=831163&r1=831162&r2=831163&view=diff
==============================================================================
--- tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/JAXBDataSource.java (original)
+++ tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/JAXBDataSource.java Fri Oct 30 00:04:47 2009
@@ -18,9 +18,6 @@
  */
 package org.apache.tuscany.sca.databinding.jaxb.axiom;
 
-import static org.apache.tuscany.sca.databinding.jaxb.JAXBContextHelper.getMarshaller;
-import static org.apache.tuscany.sca.databinding.jaxb.JAXBContextHelper.releaseJAXBMarshaller;
-
 import java.io.OutputStream;
 import java.io.StringReader;
 import java.io.StringWriter;
@@ -38,6 +35,7 @@
 import org.apache.axiom.om.OMDataSource;
 import org.apache.axiom.om.OMOutputFormat;
 import org.apache.axiom.om.util.StAXUtils;
+import org.apache.tuscany.sca.databinding.jaxb.JAXBContextHelper;
 
 /**
  *
@@ -46,11 +44,12 @@
 public class JAXBDataSource implements OMDataSource {
     private JAXBContext context;
     private Object element;
-    // private Marshaller marshaller;
+    private JAXBContextHelper contextHelper; 
 
-    public JAXBDataSource(Object element, JAXBContext context) {
+    public JAXBDataSource(Object element, JAXBContext context, JAXBContextHelper contextHelper) {
         this.element = element;
         this.context = context;
+        this.contextHelper = contextHelper;
     }
 
     public XMLStreamReader getReader() throws XMLStreamException {
@@ -70,10 +69,10 @@
                 public Object run() throws Exception {
                     Marshaller marshaller = null;
                     try {
-                        marshaller = getMarshaller(context);
+                        marshaller = contextHelper.getMarshaller(context);
                         marshaller.marshal(element, xmlWriter);
                     } finally {
-                        releaseJAXBMarshaller(context, marshaller);
+                        contextHelper.releaseJAXBMarshaller(context, marshaller);
                     }
                     return null;
                 }
@@ -90,10 +89,10 @@
                 public Object run() throws Exception {
                     Marshaller marshaller = null;
                     try {
-                        marshaller = getMarshaller(context);
+                        marshaller = contextHelper.getMarshaller(context);
                         marshaller.marshal(element, output);
                     } finally {
-                        releaseJAXBMarshaller(context, marshaller);
+                        contextHelper.releaseJAXBMarshaller(context, marshaller);
                     }
                     return null;
                 }
@@ -109,10 +108,10 @@
                 public Object run() throws Exception {
                     Marshaller marshaller = null;
                     try {
-                        marshaller = getMarshaller(context);
+                        marshaller = contextHelper.getMarshaller(context);
                         marshaller.marshal(element, writer);
                     } finally {
-                        releaseJAXBMarshaller(context, marshaller);
+                        contextHelper.releaseJAXBMarshaller(context, marshaller);
                     }
                     return null;
                 }

Modified: 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/tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/OMElement2JAXB.java?rev=831163&r1=831162&r2=831163&view=diff
==============================================================================
--- tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/OMElement2JAXB.java (original)
+++ tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/OMElement2JAXB.java Fri Oct 30 00:04:47 2009
@@ -30,6 +30,7 @@
 import javax.xml.stream.util.StreamReaderDelegate;
 
 import org.apache.axiom.om.OMElement;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
 import org.apache.tuscany.sca.databinding.PullTransformer;
 import org.apache.tuscany.sca.databinding.TransformationContext;
 import org.apache.tuscany.sca.databinding.TransformationException;
@@ -40,7 +41,12 @@
  * @version $Rev$ $Date$
  */
 public class OMElement2JAXB extends BaseTransformer<OMElement, Object> implements PullTransformer<OMElement, Object> {
-
+    private JAXBContextHelper contextHelper;
+    
+    public OMElement2JAXB(ExtensionPointRegistry registry) {
+        super();
+        contextHelper = JAXBContextHelper.getInstance(registry);
+    }
     @Override
     public String getSourceDataBinding() {
         return org.apache.axiom.om.OMElement.class.getName();
@@ -56,9 +62,9 @@
                     // 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, false);
+                    JAXBContext jaxbContext = contextHelper.createJAXBContext(context, false);
                     try {
-                        unmarshaller = JAXBContextHelper.getUnmarshaller(jaxbContext);
+                        unmarshaller = contextHelper.getUnmarshaller(jaxbContext);
                         reader = source.getXMLStreamReaderWithoutCaching();
                         // https://issues.apache.org/jira/browse/WSCOMMONS-395
                         reader = new StreamReaderDelegate(reader) {
@@ -73,7 +79,7 @@
                         if (reader != null) {
                             reader.close();
                         }
-                        JAXBContextHelper.releaseJAXBUnmarshaller(jaxbContext, unmarshaller);
+                        contextHelper.releaseJAXBUnmarshaller(jaxbContext, unmarshaller);
                     }
                     return JAXBContextHelper.createReturnValue(jaxbContext, context.getTargetDataType(), result);
                 }

Modified: tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/JAXBDSContext.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/JAXBDSContext.java?rev=831163&r1=831162&r2=831163&view=diff
==============================================================================
--- tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/JAXBDSContext.java (original)
+++ tuscany/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/JAXBDSContext.java Fri Oct 30 00:04:47 2009
@@ -51,6 +51,7 @@
     private static final boolean DEBUG_ENABLED = log.isLoggable(Level.FINER);
 
     private JAXBContext jaxbContext = null; // JAXBContext
+    private JAXBContextHelper contextHelper;
 
     /**
      * "Dispatch" Constructor Use this full constructor when the JAXBContent is provided by the
@@ -58,8 +59,9 @@
      *
      * @param jaxbContext
      */
-    public JAXBDSContext(JAXBContext jaxbContext) {
+    public JAXBDSContext(JAXBContext jaxbContext, JAXBContextHelper contextHelper) {
         this.jaxbContext = jaxbContext;
+        this.contextHelper = contextHelper;
     }
 
     public JAXBContext getJAXBContext() {
@@ -74,7 +76,7 @@
      */
     public Object unmarshal(XMLStreamReader reader) throws JAXBException {
 
-        Unmarshaller u = JAXBContextHelper.getUnmarshaller(getJAXBContext());
+        Unmarshaller u = contextHelper.getUnmarshaller(getJAXBContext());
 
         Object jaxb = null;
 
@@ -101,7 +103,7 @@
 
         // Very easy, use the Context to get the Marshaller.
         // Use the marshaller to write the object.
-        Marshaller m = JAXBContextHelper.getMarshaller(getJAXBContext());
+        Marshaller m = contextHelper.getMarshaller(getJAXBContext());
         AttachmentMarshaller am = m.getAttachmentMarshaller();
         boolean xop = am != null ? am.isXOPPackage() : false;
         // Marshal the object

Modified: tuscany/java/sca/modules/databinding-jaxb-axiom/src/test/java/org/apache/tuscany/databinding/jaxb/axiom/JAXB2OMTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/databinding-jaxb-axiom/src/test/java/org/apache/tuscany/databinding/jaxb/axiom/JAXB2OMTestCase.java?rev=831163&r1=831162&r2=831163&view=diff
==============================================================================
--- tuscany/java/sca/modules/databinding-jaxb-axiom/src/test/java/org/apache/tuscany/databinding/jaxb/axiom/JAXB2OMTestCase.java (original)
+++ tuscany/java/sca/modules/databinding-jaxb-axiom/src/test/java/org/apache/tuscany/databinding/jaxb/axiom/JAXB2OMTestCase.java Fri Oct 30 00:04:47 2009
@@ -27,6 +27,7 @@
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
 import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
 import org.apache.tuscany.sca.databinding.TransformationContext;
 import org.apache.tuscany.sca.databinding.impl.TransformationContextImpl;
 import org.apache.tuscany.sca.databinding.jaxb.JAXB2Node;
@@ -57,11 +58,13 @@
         tContext.setSourceDataType(sourceDataType);
         tContext.setTargetDataType(targetDataType);
 
+        ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+        JAXBContextHelper contextHelper = JAXBContextHelper.getInstance(registry);
         // Force the JAXBContext to be cached
-        JAXBContextHelper.createJAXBContext(tContext, true);
+        contextHelper.createJAXBContext(tContext, true);
 
         long start = System.currentTimeMillis();
-        JAXB2OMElement t1 = new JAXB2OMElement();
+        JAXB2OMElement t1 = new JAXB2OMElement(registry);
         OMElement om = t1.transform(po, tContext);
         long duration1 = System.currentTimeMillis() - start;
         StringWriter sw = new StringWriter();
@@ -88,7 +91,7 @@
         TransformationContext tContext = new TransformationContextImpl();
         tContext.setSourceDataType(sourceDataType);
         tContext.setTargetDataType(targetDataType);
-        OMElement om = new JAXB2OMElement().transform(po.getValue(), tContext);
+        OMElement om = new JAXB2OMElement(new DefaultExtensionPointRegistry()).transform(po.getValue(), tContext);
         StringWriter sw = new StringWriter();
         om.serializeAndConsume(sw);
         System.out.println(sw.toString());

Modified: tuscany/java/sca/modules/databinding-jaxb-axiom/src/test/java/org/apache/tuscany/databinding/jaxb/axiom/OMElement2JAXBTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/databinding-jaxb-axiom/src/test/java/org/apache/tuscany/databinding/jaxb/axiom/OMElement2JAXBTestCase.java?rev=831163&r1=831162&r2=831163&view=diff
==============================================================================
--- tuscany/java/sca/modules/databinding-jaxb-axiom/src/test/java/org/apache/tuscany/databinding/jaxb/axiom/OMElement2JAXBTestCase.java (original)
+++ tuscany/java/sca/modules/databinding-jaxb-axiom/src/test/java/org/apache/tuscany/databinding/jaxb/axiom/OMElement2JAXBTestCase.java Fri Oct 30 00:04:47 2009
@@ -27,6 +27,7 @@
 
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
 import org.apache.tuscany.sca.databinding.TransformationContext;
 import org.apache.tuscany.sca.databinding.impl.TransformationContextImpl;
 import org.apache.tuscany.sca.databinding.jaxb.axiom.OMElement2JAXB;
@@ -65,7 +66,7 @@
         OMElement root = builder.getDocumentElement();
         OMElement next = (OMElement)root.getChildElements().next();
         OMElement po = (OMElement)next.getChildElements().next();
-        Object jaxb = new OMElement2JAXB().transform(po, tContext);
+        Object jaxb = new OMElement2JAXB(new DefaultExtensionPointRegistry()).transform(po, tContext);
         Assert.assertTrue(jaxb instanceof PurchaseOrderType);
     }
 }

Modified: tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2Node.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2Node.java?rev=831163&r1=831162&r2=831163&view=diff
==============================================================================
--- tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2Node.java (original)
+++ tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2Node.java Fri Oct 30 00:04:47 2009
@@ -37,10 +37,12 @@
  */
 public class JAXB2Node extends BaseTransformer<Object, Node> implements PullTransformer<Object, Node> {
     private DOMHelper helper;
+    private JAXBContextHelper contextHelper;
     
     public JAXB2Node(ExtensionPointRegistry registry) {
         super();
         helper = DOMHelper.getInstance(registry);
+        contextHelper = JAXBContextHelper.getInstance(registry);
     }
     
     public Node transform(Object source, TransformationContext tContext) {
@@ -48,7 +50,7 @@
 //            return null;
 //        }
         try {
-            JAXBContext context = JAXBContextHelper.createJAXBContext(tContext, true);
+            JAXBContext context = contextHelper.createJAXBContext(tContext, true);
             Marshaller marshaller = context.createMarshaller();
             // FIXME: The default Marshaller doesn't support
             // marshaller.getNode()

Modified: tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2SAX.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2SAX.java?rev=831163&r1=831162&r2=831163&view=diff
==============================================================================
--- tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2SAX.java (original)
+++ tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2SAX.java Fri Oct 30 00:04:47 2009
@@ -22,6 +22,7 @@
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.Marshaller;
 
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
 import org.apache.tuscany.sca.databinding.PushTransformer;
 import org.apache.tuscany.sca.databinding.TransformationContext;
 import org.apache.tuscany.sca.databinding.TransformationException;
@@ -34,6 +35,12 @@
 public class JAXB2SAX extends BaseTransformer<Object, ContentHandler> implements
     PushTransformer<Object, ContentHandler> {
 
+    private JAXBContextHelper contextHelper;
+    
+    public JAXB2SAX(ExtensionPointRegistry registry) {
+        contextHelper = JAXBContextHelper.getInstance(registry);
+    }
+    
     @Override
     protected Class<Object> getSourceType() {
         return Object.class;
@@ -49,7 +56,7 @@
      */
     public void transform(Object source, ContentHandler target, TransformationContext tContext) {
         try {
-            JAXBContext context = JAXBContextHelper.createJAXBContext(tContext, true);
+            JAXBContext context = contextHelper.createJAXBContext(tContext, true);
             Marshaller marshaller = context.createMarshaller();
             Object jaxbElement = JAXBContextHelper.createJAXBElement(context, tContext.getSourceDataType(), source);
             marshaller.marshal(jaxbElement, target);

Modified: tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2String.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2String.java?rev=831163&r1=831162&r2=831163&view=diff
==============================================================================
--- tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2String.java (original)
+++ tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2String.java Fri Oct 30 00:04:47 2009
@@ -24,6 +24,7 @@
 import javax.xml.bind.Marshaller;
 import javax.xml.transform.stream.StreamResult;
 
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
 import org.apache.tuscany.sca.databinding.PullTransformer;
 import org.apache.tuscany.sca.databinding.TransformationContext;
 import org.apache.tuscany.sca.databinding.TransformationException;
@@ -35,10 +36,14 @@
  * @version $Rev$ $Date$
  */
 public class JAXB2String extends BaseTransformer<Object, String> implements PullTransformer<Object, String> {
-
+    private JAXBContextHelper contextHelper;
+    
+    public JAXB2String(ExtensionPointRegistry registry) {
+        contextHelper = JAXBContextHelper.getInstance(registry);
+    }
     public String transform(Object source, TransformationContext tContext) {
         try {
-            JAXBContext context = JAXBContextHelper.createJAXBContext(tContext, true);
+            JAXBContext context = contextHelper.createJAXBContext(tContext, true);
             Marshaller marshaller = context.createMarshaller();
             StringWriter writer = new StringWriter();
             StreamResult result = new StreamResult(writer);

Modified: tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCache.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCache.java?rev=831163&r1=831162&r2=831163&view=diff
==============================================================================
--- tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCache.java (original)
+++ tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCache.java Fri Oct 30 00:04:47 2009
@@ -55,9 +55,9 @@
 import javax.xml.datatype.DatatypeFactory;
 import javax.xml.transform.Source;
 
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
 import org.apache.tuscany.sca.databinding.util.LRUCache;
 import org.apache.tuscany.sca.extensibility.ClassLoaderContext;
-import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
 
 /**
  * @version $Rev$ $Date$
@@ -108,28 +108,32 @@
 
     // protected JAXBContext commonContext;
     protected JAXBContext defaultContext;
-
-    public JAXBContextCache() {
-        this(CACHE_SIZE, CACHE_SIZE, CACHE_SIZE);
+    private ExtensionPointRegistry registry;
+    
+    public JAXBContextCache(ExtensionPointRegistry registry) {
+        this(CACHE_SIZE, CACHE_SIZE, CACHE_SIZE, registry);
     }
 
-    public JAXBContextCache(int contextSize, int marshallerSize, int unmarshallerSize) {
+    public JAXBContextCache(int contextSize, int marshallerSize, int unmarshallerSize, ExtensionPointRegistry registry) {
+        this.registry = registry;
         cache = new LRUCache<Object, JAXBContext>(contextSize);
         mpool = new Pool<JAXBContext, Marshaller>();
         upool = new Pool<JAXBContext, Unmarshaller>();
         defaultContext = getDefaultJAXBContext();
     }
     
-    private static JAXBContext newJAXBContext(final Class<?>... classesToBeBound) throws JAXBException {
+    private JAXBContext newJAXBContext(final Class<?>... classesToBeBound) throws JAXBException {
         try {
             return AccessController.doPrivileged(new PrivilegedExceptionAction<JAXBContext>() {
                 public JAXBContext run() throws JAXBException {
                     // Try to set up TCCL so that JAXBContext service discovery works in OSGi
                     ClassLoader tccl =
                         ClassLoaderContext.setContextClassLoader(JAXBContextCache.class.getClassLoader(),
-                                                                 ServiceDiscovery.getInstance(),
-                                                                 JAXBContext.class,
-                                                                 DatatypeFactory.class);
+                                                                 registry.getServiceDiscovery(),
+                                                                 // The service provider of JAXBContext doesn't extend JAXBContext
+                                                                 // We should use the service name instead of the class
+                                                                 JAXBContext.class.getName(), 
+                                                                 DatatypeFactory.class.getName());
                     try {
                         JAXBContext context = JAXBContext.newInstance(classesToBeBound);
                         return context;
@@ -146,7 +150,7 @@
     }
 
 
-    public static JAXBContext getDefaultJAXBContext() {
+    public JAXBContext getDefaultJAXBContext() {
         try {
             return newJAXBContext();
         } catch (JAXBException e) {

Modified: tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java?rev=831163&r1=831162&r2=831163&view=diff
==============================================================================
--- tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java (original)
+++ tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java Fri Oct 30 00:04:47 2009
@@ -41,6 +41,8 @@
 import javax.xml.bind.annotation.XmlType;
 import javax.xml.namespace.QName;
 
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
 import org.apache.tuscany.sca.databinding.SimpleTypeMapper;
 import org.apache.tuscany.sca.databinding.TransformationContext;
 import org.apache.tuscany.sca.databinding.TransformationException;
@@ -60,14 +62,16 @@
  */
 // FIXME: [rfeng] We probably should turn this into a pluggable system service
 public final class JAXBContextHelper {
-    // public static final String JAXB_CLASSES = "jaxb.classes";
+    private final JAXBContextCache cache;
+    private final static SimpleTypeMapper SIMPLE_TYPE_MAPPER = new SimpleTypeMapperImpl();
 
-    // public static final String JAXB_CONTEXT_PATH = "jaxb.contextPath";
-
-    private static final JAXBContextCache cache = new JAXBContextCache();
-    private static final SimpleTypeMapper SIMPLE_TYPE_MAPPER = new SimpleTypeMapperImpl();
-
-    private JAXBContextHelper() {
+    public JAXBContextHelper(ExtensionPointRegistry registry) {
+        cache = new JAXBContextCache(registry);
+    }
+    
+    public static JAXBContextHelper getInstance(ExtensionPointRegistry registry) {
+        UtilityExtensionPoint utilityExtensionPoint = registry.getExtensionPoint(UtilityExtensionPoint.class);
+        return utilityExtensionPoint.getUtility(JAXBContextHelper.class);
     }
 
     /**
@@ -76,11 +80,11 @@
      * @return
      * @throws JAXBException
      */
-    public static JAXBContext createJAXBContext(Class<?> cls) throws JAXBException {
+    public JAXBContext createJAXBContext(Class<?> cls) throws JAXBException {
         return cache.getJAXBContext(cls);
     }
 
-    public static JAXBContext createJAXBContext(TransformationContext tContext, boolean source) throws JAXBException {
+    public JAXBContext createJAXBContext(TransformationContext tContext, boolean source) throws JAXBException {
         if (tContext == null)
             throw new TransformationException("JAXB context is not set for the transformation.");
 
@@ -116,23 +120,23 @@
         }
     }
 
-    public static JAXBContext createJAXBContext(DataType dataType) throws JAXBException {
+    public JAXBContext createJAXBContext(DataType dataType) throws JAXBException {
         return createJAXBContext(findClasses(dataType));
     }
 
-    public static Unmarshaller getUnmarshaller(JAXBContext context) throws JAXBException {
+    public Unmarshaller getUnmarshaller(JAXBContext context) throws JAXBException {
         return cache.getUnmarshaller(context);
     }
 
-    public static void releaseJAXBUnmarshaller(JAXBContext context, Unmarshaller unmarshaller) {
+    public void releaseJAXBUnmarshaller(JAXBContext context, Unmarshaller unmarshaller) {
         cache.releaseJAXBUnmarshaller(context, unmarshaller);
     }
     
-    public static Marshaller getMarshaller(JAXBContext context) throws JAXBException {
+    public Marshaller getMarshaller(JAXBContext context) throws JAXBException {
         return cache.getMarshaller(context);
     }
 
-    public static void releaseJAXBMarshaller(JAXBContext context, Marshaller marshaller) {
+    public void releaseJAXBMarshaller(JAXBContext context, Marshaller marshaller) {
         cache.releaseJAXBMarshaller(context, marshaller);
     }
     
@@ -191,11 +195,11 @@
      * @return
      * @throws JAXBException
      */
-    public static JAXBContext createJAXBContext(Class<?>[] classes) throws JAXBException {
+    public JAXBContext createJAXBContext(Class<?>[] classes) throws JAXBException {
         return cache.getJAXBContext(classes);
     }
 
-    public static JAXBContext createJAXBContext(Set<Class<?>> classes) throws JAXBException {
+    public JAXBContext createJAXBContext(Set<Class<?>> classes) throws JAXBException {
         return cache.getJAXBContext(classes);
     }
 
@@ -205,7 +209,7 @@
      * @return
      * @throws JAXBException
      */
-    public static JAXBContext createJAXBContext(Interface intf, boolean useWrapper) throws JAXBException {
+    public JAXBContext createJAXBContext(Interface intf, boolean useWrapper) throws JAXBException {
         synchronized (cache) {
             LRUCache<Object, JAXBContext> map = cache.getCache();
             Integer key = new Integer(System.identityHashCode(intf));
@@ -220,7 +224,7 @@
         }
     }
 
-    public static JAXBContext createJAXBContext(List<DataType> dataTypes) throws JAXBException {
+    public JAXBContext createJAXBContext(List<DataType> dataTypes) throws JAXBException {
         JAXBContext context;
         Set<Class<?>> classes = new HashSet<Class<?>>();
         Set<Type> visited = new HashSet<Type>();
@@ -296,7 +300,7 @@
         }
     }
 
-    public static JAXBContext createJAXBContext(Interface intf) throws JAXBException {
+    public JAXBContext createJAXBContext(Interface intf) throws JAXBException {
         return createJAXBContext(intf, true);
     }
 

Modified: tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBinding.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBinding.java?rev=831163&r1=831162&r2=831163&view=diff
==============================================================================
--- tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBinding.java (original)
+++ tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBinding.java Fri Oct 30 00:04:47 2009
@@ -51,12 +51,14 @@
     private JAXBWrapperHandler wrapperHandler;
     private JAXBTypeHelper xmlTypeHelper;
     private DOMHelper domHelper;
+    private JAXBContextHelper contextHelper;
     
     public JAXBDataBinding(ExtensionPointRegistry registry) {
         super(NAME, JAXBElement.class);
         this.wrapperHandler = new JAXBWrapperHandler();
-        this.xmlTypeHelper = new JAXBTypeHelper();
+        this.xmlTypeHelper = new JAXBTypeHelper(registry);
         this.domHelper = DOMHelper.getInstance(registry);
+        contextHelper = JAXBContextHelper.getInstance(registry);
     }
 
     @Override
@@ -106,7 +108,7 @@
                 }
                 dataType = new DataTypeImpl<XMLType>(NAME, cls, XMLType.UNKNOWN);
             }
-            JAXBContext context = JAXBContextHelper.createJAXBContext(dataType);
+            JAXBContext context = contextHelper.createJAXBContext(dataType);
             arg = JAXBContextHelper.createJAXBElement(context, dataType, arg);
             Document doc = domHelper.newDocument();
             context.createMarshaller().marshal(arg, doc);

Modified: tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTypeHelper.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTypeHelper.java?rev=831163&r1=831162&r2=831163&view=diff
==============================================================================
--- tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTypeHelper.java (original)
+++ tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTypeHelper.java Fri Oct 30 00:04:47 2009
@@ -36,6 +36,7 @@
 import javax.xml.transform.stream.StreamResult;
 
 import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
 import org.apache.tuscany.sca.databinding.XMLTypeHelper;
 import org.apache.tuscany.sca.interfacedef.DataType;
 import org.apache.tuscany.sca.interfacedef.Interface;
@@ -52,10 +53,11 @@
     private static final String ANYTYPE_NAME = "anyType";
     private static final QName ANYTYPE_QNAME = new QName(SCHEMA_NS, ANYTYPE_NAME);
 
-    // private List<Class<?>> types = new ArrayList<Class<?>>();
-
-    public JAXBTypeHelper() {
+    private JAXBContextHelper contextHelper;
+    
+    public JAXBTypeHelper(ExtensionPointRegistry registry) {
         super();
+        contextHelper = JAXBContextHelper.getInstance(registry);
     }
 
     public TypeInfo getTypeInfo(Class javaType, Object logical) {
@@ -218,7 +220,7 @@
 
     public List<XSDefinition> getSchemaDefinitions(XSDFactory factory, ModelResolver resolver, Interface intf) {
         try {
-            JAXBContext context = JAXBContextHelper.createJAXBContext(intf, false);
+            JAXBContext context = contextHelper.createJAXBContext(intf, false);
             List<XSDefinition> definitions = new ArrayList<XSDefinition>();
             generateSchemas(definitions, factory, context);
             return definitions;
@@ -230,7 +232,7 @@
     public List<XSDefinition> getSchemaDefinitions(XSDFactory factory, ModelResolver resolver, List<DataType> dataTypes) {
         try {
 
-            JAXBContext context = JAXBContextHelper.createJAXBContext(dataTypes);
+            JAXBContext context = contextHelper.createJAXBContext(dataTypes);
             List<XSDefinition> definitions = new ArrayList<XSDefinition>();
             generateSchemas(definitions, factory, context);
             return definitions;

Modified: tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Node2JAXB.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Node2JAXB.java?rev=831163&r1=831162&r2=831163&view=diff
==============================================================================
--- tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Node2JAXB.java (original)
+++ tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Node2JAXB.java Fri Oct 30 00:04:47 2009
@@ -21,6 +21,7 @@
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.Unmarshaller;
 
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
 import org.apache.tuscany.sca.databinding.PullTransformer;
 import org.apache.tuscany.sca.databinding.TransformationContext;
 import org.apache.tuscany.sca.databinding.TransformationException;
@@ -32,16 +33,17 @@
  * @version $Rev$ $Date$
  */
 public class Node2JAXB extends BaseTransformer<Node, Object> implements PullTransformer<Node, Object> {
-
-    public Node2JAXB() {
-        super();
+    private JAXBContextHelper contextHelper;
+    
+    public Node2JAXB(ExtensionPointRegistry registry) {
+        contextHelper = JAXBContextHelper.getInstance(registry);
     }
 
     public Object transform(Node source, TransformationContext context) {
         if (source == null)
             return null;
         try {
-            JAXBContext jaxbContext = JAXBContextHelper.createJAXBContext(context, false);
+            JAXBContext jaxbContext = contextHelper.createJAXBContext(context, false);
             Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
             Object result = unmarshaller.unmarshal(source, JAXBContextHelper.getJavaType(context.getTargetDataType()));
             return JAXBContextHelper.createReturnValue(jaxbContext, context.getTargetDataType(), result);

Modified: tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Reader2JAXB.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Reader2JAXB.java?rev=831163&r1=831162&r2=831163&view=diff
==============================================================================
--- tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Reader2JAXB.java (original)
+++ tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Reader2JAXB.java Fri Oct 30 00:04:47 2009
@@ -24,6 +24,7 @@
 import javax.xml.bind.Unmarshaller;
 import javax.xml.transform.stream.StreamSource;
 
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
 import org.apache.tuscany.sca.databinding.PullTransformer;
 import org.apache.tuscany.sca.databinding.TransformationContext;
 import org.apache.tuscany.sca.databinding.TransformationException;
@@ -35,13 +36,17 @@
  */
 public class Reader2JAXB extends BaseTransformer<Reader, Object> implements
     PullTransformer<Reader, Object> {
-
+    private JAXBContextHelper contextHelper;
+    
+    public Reader2JAXB(ExtensionPointRegistry registry) {
+        contextHelper = JAXBContextHelper.getInstance(registry);
+    }
     public Object transform(final Reader source, final TransformationContext context) {
         if (source == null) {
             return null;
         }
         try {
-            JAXBContext jaxbContext = JAXBContextHelper.createJAXBContext(context, false);
+            JAXBContext jaxbContext = contextHelper.createJAXBContext(context, false);
             Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
             StreamSource streamSource = new StreamSource(source);
             Object result = unmarshaller.unmarshal(streamSource, JAXBContextHelper.getJavaType(context.getTargetDataType()));

Modified: tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/String2JAXB.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/String2JAXB.java?rev=831163&r1=831162&r2=831163&view=diff
==============================================================================
--- tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/String2JAXB.java (original)
+++ tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/String2JAXB.java Fri Oct 30 00:04:47 2009
@@ -24,6 +24,7 @@
 import javax.xml.bind.Unmarshaller;
 import javax.xml.transform.stream.StreamSource;
 
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
 import org.apache.tuscany.sca.databinding.PullTransformer;
 import org.apache.tuscany.sca.databinding.TransformationContext;
 import org.apache.tuscany.sca.databinding.TransformationException;
@@ -36,13 +37,18 @@
  */
 public class String2JAXB extends BaseTransformer<String, Object> implements
     PullTransformer<String, Object> {
-
+    private JAXBContextHelper contextHelper;
+    
+    public String2JAXB(ExtensionPointRegistry registry) {
+        contextHelper = JAXBContextHelper.getInstance(registry);
+    }
+    
     public Object transform(final String source, final TransformationContext context) {
         if (source == null) {
             return null;
         }
         try {
-            JAXBContext jaxbContext = JAXBContextHelper.createJAXBContext(context, false);
+            JAXBContext jaxbContext = contextHelper.createJAXBContext(context, false);
             Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
             StreamSource streamSource = new StreamSource(new StringReader(source));
             Object result = unmarshaller.unmarshal(streamSource, JAXBContextHelper.getJavaType(context.getTargetDataType()));

Modified: tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/XMLStreamReader2JAXB.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/XMLStreamReader2JAXB.java?rev=831163&r1=831162&r2=831163&view=diff
==============================================================================
--- tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/XMLStreamReader2JAXB.java (original)
+++ tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/XMLStreamReader2JAXB.java Fri Oct 30 00:04:47 2009
@@ -22,6 +22,7 @@
 import javax.xml.bind.Unmarshaller;
 import javax.xml.stream.XMLStreamReader;
 
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
 import org.apache.tuscany.sca.databinding.PullTransformer;
 import org.apache.tuscany.sca.databinding.TransformationContext;
 import org.apache.tuscany.sca.databinding.TransformationException;
@@ -34,16 +35,18 @@
 public class XMLStreamReader2JAXB extends BaseTransformer<XMLStreamReader, Object> implements
     PullTransformer<XMLStreamReader, Object> {
 
-    public XMLStreamReader2JAXB() {
-        super();
+    private JAXBContextHelper contextHelper;
+    
+    public XMLStreamReader2JAXB(ExtensionPointRegistry registry) {
+        contextHelper = JAXBContextHelper.getInstance(registry);
     }
-
+    
     public Object transform(XMLStreamReader source, TransformationContext context) {
         if (source == null) {
             return null;
         }
         try {
-            JAXBContext jaxbContext = JAXBContextHelper.createJAXBContext(context, false);
+            JAXBContext jaxbContext = contextHelper.createJAXBContext(context, false);
             Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
             // FIXME: [rfeng] If the java type is Object.class, the unmarshalled result will be
             // a DOM Node

Modified: tuscany/java/sca/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCacheTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCacheTestCase.java?rev=831163&r1=831162&r2=831163&view=diff
==============================================================================
--- tuscany/java/sca/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCacheTestCase.java (original)
+++ tuscany/java/sca/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCacheTestCase.java Fri Oct 30 00:04:47 2009
@@ -29,6 +29,7 @@
 import javax.xml.transform.Source;
 import javax.xml.transform.stream.StreamSource;
 
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
 import org.apache.tuscany.sca.databinding.util.LRUCache;
 import org.junit.Assert;
 import org.junit.Test;
@@ -42,7 +43,7 @@
 public class JAXBContextCacheTestCase {
     @Test
     public void testCache() throws JAXBException {
-        JAXBContextCache cache = new JAXBContextCache();
+        JAXBContextCache cache = new JAXBContextCache(new DefaultExtensionPointRegistry());
         JAXBContext context1 = cache.getJAXBContext(String.class);
         JAXBContext context2 = cache.getJAXBContext(int.class);
         JAXBContext context3 = cache.getJAXBContext(String[].class);
@@ -85,7 +86,7 @@
 
     @Test
     public void testPerf() throws JAXBException {
-        JAXBContextCache cache = new JAXBContextCache();
+        JAXBContextCache cache = new JAXBContextCache(new DefaultExtensionPointRegistry());
         
         // Test JAXBContext for simple java classes
         long start = System.currentTimeMillis();

Modified: tuscany/java/sca/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTestCase.java?rev=831163&r1=831162&r2=831163&view=diff
==============================================================================
--- tuscany/java/sca/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTestCase.java (original)
+++ tuscany/java/sca/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTestCase.java Fri Oct 30 00:04:47 2009
@@ -75,7 +75,7 @@
 
     @Test
     public void testTransform() throws Exception {
-        Reader2JAXB t0 = new Reader2JAXB();
+        Reader2JAXB t0 = new Reader2JAXB(registry);
 
         DataType targetDataType = new DataTypeImpl<Class>(PurchaseOrderType.class, null);
 
@@ -94,7 +94,7 @@
 
         Assert.assertNotNull(node);
 
-        Node2JAXB t2 = new Node2JAXB();
+        Node2JAXB t2 = new Node2JAXB(registry);
         Object object2 = t2.transform(node, tContext);
         Assert.assertNotNull(object2);
 
@@ -102,7 +102,7 @@
 
     @Test
     public void testTransform2() throws Exception {
-        Reader2JAXB t0 = new Reader2JAXB();
+        Reader2JAXB t0 = new Reader2JAXB(registry);
 
         QName root = new QName("http://www.example.com/IPO", "purchaseOrder");
         DataType targetDataType = new DataTypeImpl<XMLType>(PurchaseOrderType.class, new XMLType(root, null));
@@ -123,7 +123,7 @@
 
         Assert.assertNotNull(node);
 
-        Node2JAXB t2 = new Node2JAXB();
+        Node2JAXB t2 = new Node2JAXB(registry);
         Object object2 = t2.transform(node, tContext);
         Assert.assertNotNull(object2);
 

Modified: tuscany/java/sca/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/FaultBeanGeneratorTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/FaultBeanGeneratorTestCase.java?rev=831163&r1=831162&r2=831163&view=diff
==============================================================================
--- tuscany/java/sca/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/FaultBeanGeneratorTestCase.java (original)
+++ tuscany/java/sca/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/FaultBeanGeneratorTestCase.java Fri Oct 30 00:04:47 2009
@@ -26,6 +26,7 @@
 
 import javax.xml.bind.JAXBContext;
 
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
 import org.apache.tuscany.sca.databinding.jaxb.JAXBContextHelper;
 import org.junit.Assert;
 import org.junit.Test;
@@ -55,7 +56,7 @@
         //        XmlType xmlType = cls.getAnnotation(XmlType.class);
         //        System.out.println(xmlType);
         Object bean = cls.newInstance();
-        JAXBContext context = JAXBContextHelper.createJAXBContext(cls);
+        JAXBContext context = new JAXBContextHelper(new DefaultExtensionPointRegistry()).createJAXBContext(cls);
         StringWriter sw = new StringWriter();
         context.createMarshaller().marshal(bean, sw);
         System.out.println(sw.toString());

Modified: tuscany/java/sca/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGeneratorTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGeneratorTestCase.java?rev=831163&r1=831162&r2=831163&view=diff
==============================================================================
--- tuscany/java/sca/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGeneratorTestCase.java (original)
+++ tuscany/java/sca/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGeneratorTestCase.java Fri Oct 30 00:04:47 2009
@@ -30,6 +30,7 @@
 import javax.xml.bind.JAXBContext;
 import javax.xml.transform.stream.StreamSource;
 
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
 import org.apache.tuscany.sca.databinding.jaxb.JAXBContextHelper;
 import org.apache.tuscany.sca.databinding.jaxb.JAXBTypeHelper;
 import org.junit.Test;
@@ -56,7 +57,7 @@
                 }
             }
         }
-        JAXBContext context = JAXBContextHelper.createJAXBContext(classes.toArray(new Class<?>[classes.size()]));
+        JAXBContext context = new JAXBContextHelper(new DefaultExtensionPointRegistry()).createJAXBContext(classes.toArray(new Class<?>[classes.size()]));
         for (Class<?> cls : classes) {
             Object obj = cls.newInstance();
             StringWriter sw = new StringWriter();
@@ -70,7 +71,7 @@
     @Test
     public void testGenerateSchema() throws Exception {
         List<Class<?>> classes = new WrapperBeanGenerator().generateWrapperBeans(TestInterface.class);
-        JAXBContext context = JAXBContextHelper.createJAXBContext(classes.toArray(new Class<?>[classes.size()]));
+        JAXBContext context = new JAXBContextHelper(new DefaultExtensionPointRegistry()).createJAXBContext(classes.toArray(new Class<?>[classes.size()]));
         Map<String, String> results = JAXBTypeHelper.generateSchema(context);
         for (String xsd : results.values()) {
             System.out.println(xsd);



Mime
View raw message