summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/databinding-jaxb/src/main
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2008-11-19 05:27:58 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2008-11-19 05:27:58 +0000
commit5f3869c451e46aadc943d00087d6847877dd1c50 (patch)
treee22baaff1fb9ea42606b7d04af52e032e3bc03bc /java/sca/modules/databinding-jaxb/src/main
parent60744a36aae604ac3c4499ed54f1082ab8f5947d (diff)
Merging the 1.x delta on top of the equinox based modules
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@718858 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/databinding-jaxb/src/main')
-rw-r--r--java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/AnyTypeXmlAdapter.java39
-rw-r--r--java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/DOMElementXmlAdapter.java57
-rw-r--r--java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java26
-rw-r--r--java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBinding.java3
-rw-r--r--java/sca/modules/databinding-jaxb/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding2
5 files changed, 98 insertions, 29 deletions
diff --git a/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/AnyTypeXmlAdapter.java b/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/AnyTypeXmlAdapter.java
new file mode 100644
index 0000000000..57922e1c89
--- /dev/null
+++ b/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/AnyTypeXmlAdapter.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.databinding.jaxb;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
+/**
+ * This special XmlAdapter can be used by JAXB classes to annotate the references to java interfaces
+ */
+public class AnyTypeXmlAdapter extends XmlAdapter<Object, Object> {
+
+ @Override
+ public Object marshal(Object v) throws Exception {
+ return v;
+ }
+
+ @Override
+ public Object unmarshal(Object v) throws Exception {
+ return v;
+ }
+
+}
diff --git a/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/DOMElementXmlAdapter.java b/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/DOMElementXmlAdapter.java
new file mode 100644
index 0000000000..91cb39b0f2
--- /dev/null
+++ b/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/DOMElementXmlAdapter.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.databinding.jaxb;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.databinding.xml.DOMDataBinding;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.w3c.dom.Element;
+
+/**
+ * A generic XmlAdapter for JAXB to marshal/unmarshal between the java objects and DOM elements
+ */
+public class DOMElementXmlAdapter extends XmlAdapter<Element, Object> {
+ private Mediator mediator;
+ private DataType dataType;
+ private DataType domType;
+
+ public DOMElementXmlAdapter(Mediator mediator, DataType dataType) {
+ this.mediator = mediator;
+ this.dataType = dataType;
+ this.domType = new DataTypeImpl(DOMDataBinding.NAME, Element.class, dataType.getLogical());
+ }
+
+ @Override
+ public Element marshal(Object value) throws Exception {
+ return (Element) mediator.mediate(value, dataType, domType, null);
+ }
+
+ @Override
+ public Object unmarshal(Element element) throws Exception {
+ return mediator.mediate(element, domType, dataType, null);
+ }
+
+ public void setMediator(Mediator mediator) {
+ this.mediator = mediator;
+ }
+}
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 7297399f5e..5265184ba6 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
@@ -18,7 +18,6 @@
*/
package org.apache.tuscany.sca.databinding.jaxb;
-import java.io.IOException;
import java.lang.reflect.GenericArrayType;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
@@ -34,15 +33,12 @@ import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.JAXBIntrospector;
import javax.xml.bind.Marshaller;
-import javax.xml.bind.SchemaOutputResolver;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSchema;
import javax.xml.bind.annotation.XmlType;
import javax.xml.namespace.QName;
-import javax.xml.transform.Result;
-import javax.xml.transform.dom.DOMResult;
import org.apache.tuscany.sca.databinding.TransformationContext;
import org.apache.tuscany.sca.databinding.TransformationException;
@@ -53,7 +49,6 @@ import org.apache.tuscany.sca.interfacedef.Interface;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.interfacedef.util.WrapperInfo;
import org.apache.tuscany.sca.interfacedef.util.XMLType;
-import org.w3c.dom.Node;
/**
*
@@ -444,25 +439,4 @@ public class JAXBContextHelper {
return name.substring(0, decap).toLowerCase() + name.substring(decap);
}
- public static Node generateSchema(JAXBContext context) throws Exception {
- SchemaOutputResolverImpl resolver = new SchemaOutputResolverImpl();
- context.generateSchema(resolver);
- return resolver.getSchema();
- }
-
- public static class SchemaOutputResolverImpl extends SchemaOutputResolver {
- private DOMResult result = new DOMResult();
-
- @Override
- public Result createOutput(String ns, String file) throws IOException {
- result.setSystemId("sca:dom");
- return result;
- }
-
- public Node getSchema() {
- return result != null ? result.getNode() : null;
- }
-
- }
-
}
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 eebb4b2e37..38efd288cb 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
@@ -43,7 +43,6 @@ import org.w3c.dom.Document;
*/
public class JAXBDataBinding extends BaseDataBinding {
public static final String NAME = JAXBElement.class.getName();
- public static final String[] ALIASES = new String[] {"jaxb"};
public static final String ROOT_NAMESPACE = "http://tuscany.apache.org/xmlns/sca/databinding/jaxb/1.0";
public static final QName ROOT_ELEMENT = new QName(ROOT_NAMESPACE, "root");
@@ -52,7 +51,7 @@ public class JAXBDataBinding extends BaseDataBinding {
private JAXBTypeHelper xmlTypeHelper;
public JAXBDataBinding() {
- super(NAME, ALIASES, JAXBElement.class);
+ super(NAME, JAXBElement.class);
this.wrapperHandler = new JAXBWrapperHandler();
this.xmlTypeHelper = new JAXBTypeHelper();
}
diff --git a/java/sca/modules/databinding-jaxb/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding b/java/sca/modules/databinding-jaxb/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding
index 58d6123373..3f2978ad25 100644
--- a/java/sca/modules/databinding-jaxb/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding
+++ b/java/sca/modules/databinding-jaxb/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding
@@ -16,4 +16,4 @@
# under the License.
# implementation classes for the databindings
-org.apache.tuscany.sca.databinding.jaxb.JAXBDataBinding;type=javax.xml.bind.JAXBElement,name=jaxb
+org.apache.tuscany.sca.databinding.jaxb.JAXBDataBinding;name=javax.xml.bind.JAXBElement