summaryrefslogtreecommitdiffstats
path: root/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main
diff options
context:
space:
mode:
authordims <dims@13f79535-47bb-0310-9956-ffa450edef68>2008-06-17 00:23:01 +0000
committerdims <dims@13f79535-47bb-0310-9956-ffa450edef68>2008-06-17 00:23:01 +0000
commitbdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a (patch)
tree38a92061c0793434c4be189f1d70c3458b6bc41d /branches/pre-spec-changes/services/databinding/databinding-axiom/src/main
Move Tuscany from Incubator to top level.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/pre-spec-changes/services/databinding/databinding-axiom/src/main')
-rw-r--r--branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/AxiomDataBinding.java72
-rw-r--r--branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElement2Object.java40
-rwxr-xr-xbranches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElement2String.java62
-rwxr-xr-xbranches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElement2XMLStreamReader.java50
-rw-r--r--branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElementWrapperHandler.java67
-rw-r--r--branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/Object2OMElement.java54
-rwxr-xr-xbranches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/String2OMElement.java88
-rwxr-xr-xbranches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/XMLStreamReader2OMElement.java90
-rw-r--r--branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/resources/META-INF/sca/databinding.axiom.scdl57
-rw-r--r--branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/resources/META-INF/sca/default.scdl56
10 files changed, 636 insertions, 0 deletions
diff --git a/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/AxiomDataBinding.java b/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/AxiomDataBinding.java
new file mode 100644
index 0000000000..771e7221ef
--- /dev/null
+++ b/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/AxiomDataBinding.java
@@ -0,0 +1,72 @@
+/*
+ * 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.databinding.axiom;
+
+import java.io.ByteArrayInputStream;
+import java.io.StringWriter;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.tuscany.api.TuscanyRuntimeException;
+import org.apache.tuscany.spi.databinding.DataBinding;
+import org.apache.tuscany.spi.databinding.WrapperHandler;
+import org.apache.tuscany.spi.databinding.extension.DataBindingExtension;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * DataBinding for AXIOM
+ */
+@Service(DataBinding.class)
+public class AxiomDataBinding extends DataBindingExtension {
+
+ public static final String NAME = OMElement.class.getName();
+
+ public AxiomDataBinding() {
+ super(OMElement.class);
+ }
+
+ /**
+ * @see org.apache.tuscany.spi.databinding.extension.DataBindingExtension#getWrapperHandler()
+ */
+ @Override
+ public WrapperHandler getWrapperHandler() {
+ return new OMElementWrapperHandler();
+ }
+
+ public Object copy(Object source) {
+ if ( OMElement.class.isAssignableFrom(source.getClass()) ) {
+ try {
+ OMElement sourceElement = (OMElement)source;
+ StringWriter writer = new StringWriter();
+ sourceElement.serialize(writer);
+
+ StAXOMBuilder builder = new StAXOMBuilder(new ByteArrayInputStream(writer.toString().getBytes()));
+ OMElement copyElement = builder.getDocumentElement();
+ return copyElement;
+ } catch ( XMLStreamException e ) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+ return super.copy(source);
+ }
+
+}
diff --git a/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElement2Object.java b/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElement2Object.java
new file mode 100644
index 0000000000..91b1f4da90
--- /dev/null
+++ b/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElement2Object.java
@@ -0,0 +1,40 @@
+/*
+ * 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.databinding.axiom;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.SimpleType2JavaTransformer;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * Transformer to convert data from a simple java bject to OMElement
+ */
+@Service(Transformer.class)
+public class OMElement2Object extends SimpleType2JavaTransformer<OMElement> {
+
+ @Override
+ protected String getText(OMElement source) {
+ return source.getText();
+ }
+
+ public Class getSourceType() {
+ return OMElement.class;
+ }
+}
diff --git a/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElement2String.java b/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElement2String.java
new file mode 100755
index 0000000000..52be08537d
--- /dev/null
+++ b/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElement2String.java
@@ -0,0 +1,62 @@
+/*
+ * 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.databinding.axiom;
+
+import java.io.StringWriter;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * Transformer to convert data from an OMElement to XML String
+ */
+@Service(Transformer.class)
+public class OMElement2String extends TransformerExtension<OMElement, String> implements PullTransformer<OMElement, String> {
+ // private XmlOptions options;
+
+ public String transform(OMElement source, TransformationContext context) {
+ try {
+ StringWriter writer = new StringWriter();
+ source.serialize(writer);
+ return writer.toString();
+ } catch (XMLStreamException e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ public Class getSourceType() {
+ return OMElement.class;
+ }
+
+ public Class getTargetType() {
+ return String.class;
+ }
+
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElement2XMLStreamReader.java b/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElement2XMLStreamReader.java
new file mode 100755
index 0000000000..343408a027
--- /dev/null
+++ b/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElement2XMLStreamReader.java
@@ -0,0 +1,50 @@
+/*
+ * 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.databinding.axiom;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.osoa.sca.annotations.Service;
+
+@Service(Transformer.class)
+public class OMElement2XMLStreamReader extends TransformerExtension<OMElement, XMLStreamReader> implements PullTransformer<OMElement, XMLStreamReader> {
+ // private XmlOptions options;
+
+ public XMLStreamReader transform(OMElement source, TransformationContext context) {
+ return source.getXMLStreamReader();
+ }
+
+ public Class getSourceType() {
+ return OMElement.class;
+ }
+
+ public Class getTargetType() {
+ return XMLStreamReader.class;
+ }
+
+ public int getWeight() {
+ return 10;
+ }
+
+}
diff --git a/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElementWrapperHandler.java b/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElementWrapperHandler.java
new file mode 100644
index 0000000000..0ba2863735
--- /dev/null
+++ b/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/OMElementWrapperHandler.java
@@ -0,0 +1,67 @@
+/*
+ * 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.databinding.axiom;
+
+import java.util.Iterator;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.WrapperHandler;
+import org.apache.tuscany.spi.idl.ElementInfo;
+
+/**
+ * OMElement wrapper handler implementation
+ */
+public class OMElementWrapperHandler implements WrapperHandler<OMElement> {
+
+ private OMFactory factory;
+
+ public OMElementWrapperHandler() {
+ super();
+ this.factory = OMAbstractFactory.getOMFactory();
+ }
+
+ public OMElement create(ElementInfo element, TransformationContext context) {
+ OMElement wrapper = factory.createOMElement(element.getQName(), null);
+ return wrapper;
+ }
+
+ public Object getChild(OMElement wrapper, int i, ElementInfo element) {
+ int index = 0;
+ for (Iterator e = wrapper.getChildElements(); e.hasNext();) {
+ OMElement child = (OMElement) e.next();
+ if (index != i) {
+ index++;
+ continue;
+ }
+ if (child.getQName().equals(element.getQName())) {
+ return child;
+ }
+ }
+ return null;
+ }
+
+ public void setChild(OMElement wrapper, int i, ElementInfo childElement, Object value) {
+ wrapper.addChild((OMElement) value);
+ }
+
+}
diff --git a/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/Object2OMElement.java b/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/Object2OMElement.java
new file mode 100644
index 0000000000..5416b5239e
--- /dev/null
+++ b/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/Object2OMElement.java
@@ -0,0 +1,54 @@
+/*
+ * 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.databinding.axiom;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.Java2SimpleTypeTransformer;
+import org.apache.tuscany.spi.idl.ElementInfo;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * Transformer to convert data from an simple OMElement to Java Object
+ */
+@Service(Transformer.class)
+public class Object2OMElement extends Java2SimpleTypeTransformer<OMElement> {
+
+ private OMFactory factory;
+
+ public Object2OMElement() {
+ super();
+ factory = OMAbstractFactory.getOMFactory();
+ }
+
+ protected OMElement createElement(ElementInfo element, String text, TransformationContext context) {
+ OMElement omElement = factory.createOMElement(element.getQName(), null);
+ factory.createOMText(omElement, text);
+ return omElement;
+ }
+
+ @Override
+ public Class getTargetType() {
+ return OMElement.class;
+ }
+
+}
diff --git a/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/String2OMElement.java b/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/String2OMElement.java
new file mode 100755
index 0000000000..59ac5423d7
--- /dev/null
+++ b/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/String2OMElement.java
@@ -0,0 +1,88 @@
+/*
+ * 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.databinding.axiom;
+
+import java.io.ByteArrayInputStream;
+
+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.axiom.om.OMNamespace;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.apache.tuscany.spi.model.DataType;
+import org.osoa.sca.annotations.Service;
+
+@Service(Transformer.class)
+public class String2OMElement extends TransformerExtension<String, OMElement> implements
+ PullTransformer<String, OMElement> {
+
+ @SuppressWarnings("unchecked")
+ public OMElement transform(String source, TransformationContext context) {
+ try {
+ StAXOMBuilder builder = new StAXOMBuilder(new ByteArrayInputStream(source.getBytes()));
+ OMElement element = builder.getDocumentElement();
+ adjustElementName(context, element);
+ return element;
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ /**
+ * @param context
+ * @param element
+ */
+ private void adjustElementName(TransformationContext context, OMElement element) {
+ if (context != null) {
+ DataType dataType = context.getTargetDataType();
+ Object targetQName = dataType == null ? null : dataType.getLogical();
+ if (!(targetQName instanceof QName)) {
+ return;
+ }
+ if (!element.getQName().equals(targetQName)) {
+ // TODO: Throw expection or switch to the new Element
+ OMFactory factory = OMAbstractFactory.getOMFactory();
+ QName name = (QName)targetQName;
+ OMNamespace namespace = factory.createOMNamespace(name.getNamespaceURI(), name.getPrefix());
+ element.setNamespace(namespace);
+ element.setLocalName(name.getLocalPart());
+ }
+ }
+ }
+
+ public Class getTargetType() {
+ return OMElement.class;
+ }
+
+ public Class getSourceType() {
+ return String.class;
+ }
+
+ public int getWeight() {
+ return 40;
+ }
+
+}
diff --git a/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/XMLStreamReader2OMElement.java b/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/XMLStreamReader2OMElement.java
new file mode 100755
index 0000000000..5b2c89b443
--- /dev/null
+++ b/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/java/org/apache/tuscany/databinding/axiom/XMLStreamReader2OMElement.java
@@ -0,0 +1,90 @@
+/*
+ * 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.databinding.axiom;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.apache.tuscany.spi.model.DataType;
+import org.osoa.sca.annotations.Service;
+
+@Service(Transformer.class)
+public class XMLStreamReader2OMElement extends TransformerExtension<XMLStreamReader, OMElement> implements
+ PullTransformer<XMLStreamReader, OMElement> {
+
+ public XMLStreamReader2OMElement() {
+ super();
+ }
+
+ public OMElement transform(XMLStreamReader source, TransformationContext context) {
+ try {
+ StAXOMBuilder builder = new StAXOMBuilder(source);
+ OMElement element = builder.getDocumentElement();
+ adjustElementName(context, element);
+ return element;
+ } catch (Exception e) {
+ throw new TransformationException(e);
+ }
+ }
+
+ /**
+ * @param context
+ * @param element
+ */
+ private void adjustElementName(TransformationContext context, OMElement element) {
+ if (context != null) {
+ DataType dataType = context.getTargetDataType();
+ Object targetQName = dataType == null ? null : dataType.getLogical();
+ if (!(targetQName instanceof QName)) {
+ return;
+ }
+ if (!element.getQName().equals(targetQName)) {
+ // TODO: Throw expection or switch to the new Element
+ OMFactory factory = OMAbstractFactory.getOMFactory();
+ QName name = (QName)targetQName;
+ OMNamespace namespace = factory.createOMNamespace(name.getNamespaceURI(), name.getPrefix());
+ element.setNamespace(namespace);
+ element.setLocalName(name.getLocalPart());
+ }
+ }
+ }
+
+ public Class getTargetType() {
+ return OMElement.class;
+ }
+
+ public Class getSourceType() {
+ return XMLStreamReader.class;
+ }
+
+ public int getWeight() {
+ return 10;
+ }
+
+}
diff --git a/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/resources/META-INF/sca/databinding.axiom.scdl b/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/resources/META-INF/sca/databinding.axiom.scdl
new file mode 100644
index 0000000000..ecdaab994e
--- /dev/null
+++ b/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/resources/META-INF/sca/databinding.axiom.scdl
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<!-- This is the copy ot be included by other extensions -->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:system="http://tuscany.apache.org/xmlns/system/1.0-SNAPSHOT"
+ name="org.apache.tuscany.databinding.axiom.include">
+
+ <dependency xmlns="http://tuscany.apache.org/xmlns/1.0-SNAPSHOT">
+ <group>org.apache.tuscany.sca.services.databinding</group>
+ <name>databinding-axiom</name>
+ <version>1.0-incubator-SNAPSHOT</version>
+ </dependency>
+
+ <component name="databinding.axiom">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.AxiomDataBinding" />
+ </component>
+
+ <component name="transformer.XMLStreamReader2OMElement">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.XMLStreamReader2OMElement" />
+ </component>
+
+ <component name="transformer.OMElement2XMLStreamReader">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.OMElement2XMLStreamReader" />
+ </component>
+
+ <component name="transformer.String2OMElement">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.String2OMElement" />
+ </component>
+
+ <component name="transformer.OMElement2String">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.OMElement2String" />
+ </component>
+
+ <component name="transformer.Object2OMElement">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.Object2OMElement" />
+ </component>
+
+ <component name="transformer.OMElement2Object">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.OMElement2Object" />
+ </component>
+</composite> \ No newline at end of file
diff --git a/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/resources/META-INF/sca/default.scdl b/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/resources/META-INF/sca/default.scdl
new file mode 100644
index 0000000000..2350c77b17
--- /dev/null
+++ b/branches/pre-spec-changes/services/databinding/databinding-axiom/src/main/resources/META-INF/sca/default.scdl
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:system="http://tuscany.apache.org/xmlns/system/1.0-SNAPSHOT"
+ name="org.apache.tuscany.databinding.axiom">
+
+ <dependency xmlns="http://tuscany.apache.org/xmlns/1.0-SNAPSHOT">
+ <group>org.apache.tuscany.sca.services.databinding</group>
+ <name>databinding-axiom</name>
+ <version>1.0-incubator-SNAPSHOT</version>
+ </dependency>
+
+ <component name="databinding.axiom">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.AxiomDataBinding" />
+ </component>
+
+ <component name="transformer.XMLStreamReader2OMElement">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.XMLStreamReader2OMElement" />
+ </component>
+
+ <component name="transformer.OMElement2XMLStreamReader">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.OMElement2XMLStreamReader" />
+ </component>
+
+ <component name="transformer.String2OMElement">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.String2OMElement" />
+ </component>
+
+ <component name="transformer.OMElement2String">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.OMElement2String" />
+ </component>
+
+ <component name="transformer.Object2OMElement">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.Object2OMElement" />
+ </component>
+
+ <component name="transformer.OMElement2Object">
+ <system:implementation.system class="org.apache.tuscany.databinding.axiom.OMElement2Object" />
+ </component>
+</composite> \ No newline at end of file