summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-10-30 00:04:47 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-10-30 00:04:47 +0000
commit8a515e9f25fc7fefa03860d1f14e4bcf47bdeb63 (patch)
treeb58a349a83afd25a8a677e7c3b1058e3996b2bcd
parent4fa2f6af33e964521800a3ad2919c2e14c6c956f (diff)
Refactor JAXBContextCache/JAXBContextHelper to be a utility bound to the extension point registry
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@831163 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/JAXB2OMElement.java13
-rw-r--r--java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/JAXBDataSource.java21
-rw-r--r--java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/OMElement2JAXB.java14
-rw-r--r--java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/JAXBDSContext.java8
-rw-r--r--java/sca/modules/databinding-jaxb-axiom/src/test/java/org/apache/tuscany/databinding/jaxb/axiom/JAXB2OMTestCase.java9
-rw-r--r--java/sca/modules/databinding-jaxb-axiom/src/test/java/org/apache/tuscany/databinding/jaxb/axiom/OMElement2JAXBTestCase.java3
-rw-r--r--java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2Node.java4
-rw-r--r--java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2SAX.java9
-rw-r--r--java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2String.java9
-rw-r--r--java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCache.java24
-rw-r--r--java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java42
-rw-r--r--java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBinding.java6
-rw-r--r--java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTypeHelper.java12
-rw-r--r--java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Node2JAXB.java10
-rw-r--r--java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Reader2JAXB.java9
-rw-r--r--java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/String2JAXB.java10
-rw-r--r--java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/XMLStreamReader2JAXB.java11
-rw-r--r--java/sca/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCacheTestCase.java5
-rw-r--r--java/sca/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTestCase.java8
-rw-r--r--java/sca/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/FaultBeanGeneratorTestCase.java3
-rw-r--r--java/sca/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGeneratorTestCase.java5
21 files changed, 147 insertions, 88 deletions
diff --git a/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/JAXB2OMElement.java b/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/JAXB2OMElement.java
index e0e0c08f6c..862894be09 100644
--- a/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/JAXB2OMElement.java
+++ b/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/JAXB2OMElement.java
@@ -25,6 +25,7 @@ import javax.xml.namespace.QName;
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 @@ import org.apache.tuscany.sca.databinding.jaxb.JAXBDataBinding;
* @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 class JAXB2OMElement extends BaseTransformer<Object, OMElement> implement
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;
}
diff --git a/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/JAXBDataSource.java b/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/JAXBDataSource.java
index cc28d5e710..0dacce996f 100644
--- a/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/JAXBDataSource.java
+++ b/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/JAXBDataSource.java
@@ -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 javax.xml.stream.XMLStreamWriter;
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 @@ import org.apache.axiom.om.util.StAXUtils;
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 class JAXBDataSource implements OMDataSource {
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 class JAXBDataSource implements OMDataSource {
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 class JAXBDataSource implements OMDataSource {
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;
}
diff --git a/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/OMElement2JAXB.java b/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/OMElement2JAXB.java
index 8e9b32cfc0..aa5fc5b789 100644
--- a/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/OMElement2JAXB.java
+++ b/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/OMElement2JAXB.java
@@ -30,6 +30,7 @@ import javax.xml.stream.XMLStreamReader;
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 @@ import org.apache.tuscany.sca.databinding.jaxb.JAXBContextHelper;
* @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 @@ public class OMElement2JAXB extends BaseTransformer<OMElement, Object> implement
// 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 @@ public class OMElement2JAXB extends BaseTransformer<OMElement, Object> implement
if (reader != null) {
reader.close();
}
- JAXBContextHelper.releaseJAXBUnmarshaller(jaxbContext, unmarshaller);
+ contextHelper.releaseJAXBUnmarshaller(jaxbContext, unmarshaller);
}
return JAXBContextHelper.createReturnValue(jaxbContext, context.getTargetDataType(), result);
}
diff --git a/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/JAXBDSContext.java b/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/JAXBDSContext.java
index 28997cd244..f6bd33864f 100644
--- a/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/JAXBDSContext.java
+++ b/java/sca/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/JAXBDSContext.java
@@ -51,6 +51,7 @@ public class JAXBDSContext {
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 @@ public class JAXBDSContext {
*
* @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 class JAXBDSContext {
*/
public Object unmarshal(XMLStreamReader reader) throws JAXBException {
- Unmarshaller u = JAXBContextHelper.getUnmarshaller(getJAXBContext());
+ Unmarshaller u = contextHelper.getUnmarshaller(getJAXBContext());
Object jaxb = null;
@@ -101,7 +103,7 @@ public class JAXBDSContext {
// 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
diff --git a/java/sca/modules/databinding-jaxb-axiom/src/test/java/org/apache/tuscany/databinding/jaxb/axiom/JAXB2OMTestCase.java b/java/sca/modules/databinding-jaxb-axiom/src/test/java/org/apache/tuscany/databinding/jaxb/axiom/JAXB2OMTestCase.java
index 9f79eeed04..df2b6dc4e3 100644
--- a/java/sca/modules/databinding-jaxb-axiom/src/test/java/org/apache/tuscany/databinding/jaxb/axiom/JAXB2OMTestCase.java
+++ b/java/sca/modules/databinding-jaxb-axiom/src/test/java/org/apache/tuscany/databinding/jaxb/axiom/JAXB2OMTestCase.java
@@ -27,6 +27,7 @@ import javax.xml.stream.XMLStreamReader;
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 @@ public class JAXB2OMTestCase {
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 @@ public class JAXB2OMTestCase {
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());
diff --git a/java/sca/modules/databinding-jaxb-axiom/src/test/java/org/apache/tuscany/databinding/jaxb/axiom/OMElement2JAXBTestCase.java b/java/sca/modules/databinding-jaxb-axiom/src/test/java/org/apache/tuscany/databinding/jaxb/axiom/OMElement2JAXBTestCase.java
index 3c00307941..abfcf358d2 100644
--- a/java/sca/modules/databinding-jaxb-axiom/src/test/java/org/apache/tuscany/databinding/jaxb/axiom/OMElement2JAXBTestCase.java
+++ b/java/sca/modules/databinding-jaxb-axiom/src/test/java/org/apache/tuscany/databinding/jaxb/axiom/OMElement2JAXBTestCase.java
@@ -27,6 +27,7 @@ import junit.framework.Assert;
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 @@ public class OMElement2JAXBTestCase {
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);
}
}
diff --git a/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2Node.java b/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2Node.java
index 1ff8f79059..08ea27725d 100644
--- a/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2Node.java
+++ b/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2Node.java
@@ -37,10 +37,12 @@ import org.w3c.dom.Node;
*/
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 @@ public class JAXB2Node extends BaseTransformer<Object, Node> implements PullTran
// 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()
diff --git a/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2SAX.java b/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2SAX.java
index eee5c77285..ba156ba548 100644
--- a/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2SAX.java
+++ b/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2SAX.java
@@ -22,6 +22,7 @@ package org.apache.tuscany.sca.databinding.jaxb;
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 @@ import org.xml.sax.ContentHandler;
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 class JAXB2SAX extends BaseTransformer<Object, ContentHandler> implements
*/
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);
diff --git a/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2String.java b/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2String.java
index 29951a5e16..a611219f21 100644
--- a/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2String.java
+++ b/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2String.java
@@ -24,6 +24,7 @@ import javax.xml.bind.JAXBContext;
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 @@ import org.apache.tuscany.sca.databinding.xml.XMLStringDataBinding;
* @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);
diff --git a/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCache.java b/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCache.java
index 9e08bbbbec..61e4066ee8 100644
--- a/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCache.java
+++ b/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCache.java
@@ -55,9 +55,9 @@ import javax.xml.bind.annotation.XmlType;
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 @@ public class JAXBContextCache {
// 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 class JAXBContextCache {
}
- public static JAXBContext getDefaultJAXBContext() {
+ public JAXBContext getDefaultJAXBContext() {
try {
return newJAXBContext();
} catch (JAXBException e) {
diff --git a/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java b/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java
index afa80d748a..c68456e733 100644
--- a/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java
+++ b/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java
@@ -41,6 +41,8 @@ import javax.xml.bind.annotation.XmlSeeAlso;
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 @@ import org.apache.tuscany.sca.interfacedef.util.XMLType;
*/
// 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 @@ public final class JAXBContextHelper {
* @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 final class JAXBContextHelper {
}
}
- 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 @@ public final class JAXBContextHelper {
* @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 @@ public final class JAXBContextHelper {
* @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 final class JAXBContextHelper {
}
}
- 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 final class JAXBContextHelper {
}
}
- public static JAXBContext createJAXBContext(Interface intf) throws JAXBException {
+ public JAXBContext createJAXBContext(Interface intf) throws JAXBException {
return createJAXBContext(intf, true);
}
diff --git a/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBinding.java b/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBinding.java
index 14e5148050..bd214cb02c 100644
--- a/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBinding.java
+++ b/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBinding.java
@@ -51,12 +51,14 @@ public class JAXBDataBinding extends BaseDataBinding {
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 @@ public class JAXBDataBinding extends BaseDataBinding {
}
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);
diff --git a/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTypeHelper.java b/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTypeHelper.java
index e29b634857..84529752de 100644
--- a/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTypeHelper.java
+++ b/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTypeHelper.java
@@ -36,6 +36,7 @@ import javax.xml.transform.dom.DOMResult;
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 @@ public class JAXBTypeHelper implements XMLTypeHelper {
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 class JAXBTypeHelper implements XMLTypeHelper {
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 class JAXBTypeHelper implements XMLTypeHelper {
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;
diff --git a/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Node2JAXB.java b/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Node2JAXB.java
index e375a9b85e..6236a336a3 100644
--- a/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Node2JAXB.java
+++ b/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Node2JAXB.java
@@ -21,6 +21,7 @@ package org.apache.tuscany.sca.databinding.jaxb;
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 @@ import org.w3c.dom.Node;
* @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);
diff --git a/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Reader2JAXB.java b/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Reader2JAXB.java
index 840edfd234..2ffb565745 100644
--- a/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Reader2JAXB.java
+++ b/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Reader2JAXB.java
@@ -24,6 +24,7 @@ import javax.xml.bind.JAXBContext;
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 @@ import org.apache.tuscany.sca.databinding.impl.BaseTransformer;
*/
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()));
diff --git a/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/String2JAXB.java b/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/String2JAXB.java
index 5559690de8..898e5b07bc 100644
--- a/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/String2JAXB.java
+++ b/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/String2JAXB.java
@@ -24,6 +24,7 @@ import javax.xml.bind.JAXBContext;
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 @@ import org.apache.tuscany.sca.databinding.xml.XMLStringDataBinding;
*/
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()));
diff --git a/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/XMLStreamReader2JAXB.java b/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/XMLStreamReader2JAXB.java
index af3fa3fb66..8af51f6f5c 100644
--- a/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/XMLStreamReader2JAXB.java
+++ b/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/XMLStreamReader2JAXB.java
@@ -22,6 +22,7 @@ import javax.xml.bind.JAXBContext;
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 @@ import org.apache.tuscany.sca.databinding.impl.BaseTransformer;
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
diff --git a/java/sca/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCacheTestCase.java b/java/sca/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCacheTestCase.java
index 1c46765d9f..7f616ac5e9 100644
--- a/java/sca/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCacheTestCase.java
+++ b/java/sca/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCacheTestCase.java
@@ -29,6 +29,7 @@ import javax.xml.namespace.QName;
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 @@ import com.example.ipo.jaxb.PurchaseOrderType;
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 @@ public class JAXBContextCacheTestCase {
@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();
diff --git a/java/sca/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTestCase.java b/java/sca/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTestCase.java
index f1329ab571..6e2a540ada 100644
--- a/java/sca/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTestCase.java
+++ b/java/sca/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTestCase.java
@@ -75,7 +75,7 @@ public class JAXBTestCase {
@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 @@ public class JAXBTestCase {
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 @@ public class JAXBTestCase {
@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 @@ public class JAXBTestCase {
Assert.assertNotNull(node);
- Node2JAXB t2 = new Node2JAXB();
+ Node2JAXB t2 = new Node2JAXB(registry);
Object object2 = t2.transform(node, tContext);
Assert.assertNotNull(object2);
diff --git a/java/sca/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/FaultBeanGeneratorTestCase.java b/java/sca/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/FaultBeanGeneratorTestCase.java
index 4caeb79fca..3ea1427494 100644
--- a/java/sca/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/FaultBeanGeneratorTestCase.java
+++ b/java/sca/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/FaultBeanGeneratorTestCase.java
@@ -26,6 +26,7 @@ import java.lang.annotation.Annotation;
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 @@ public class FaultBeanGeneratorTestCase {
// 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());
diff --git a/java/sca/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGeneratorTestCase.java b/java/sca/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGeneratorTestCase.java
index b14ef19939..f83c27e10a 100644
--- a/java/sca/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGeneratorTestCase.java
+++ b/java/sca/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGeneratorTestCase.java
@@ -30,6 +30,7 @@ import java.util.Map;
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 @@ public class WrapperBeanGeneratorTestCase {
}
}
}
- 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 @@ public class WrapperBeanGeneratorTestCase {
@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);