diff options
Diffstat (limited to 'sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src')
14 files changed, 890 insertions, 0 deletions
diff --git a/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/main/java/org/apache/tuscany/sca/databinding/xstream/MetaObject.java b/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/main/java/org/apache/tuscany/sca/databinding/xstream/MetaObject.java new file mode 100644 index 0000000000..4c57cfe06b --- /dev/null +++ b/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/main/java/org/apache/tuscany/sca/databinding/xstream/MetaObject.java @@ -0,0 +1,37 @@ +/* + * 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.xstream; + +/** + * Wrapper for XObject + * @version $Rev$ $Date$ + */ +public interface MetaObject { + void setName(String name); + + String getName(); + + Class<?> getType(); + + String getID(); + + XObject getInstance(); + //byte[] getByteCode(); +} diff --git a/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/main/java/org/apache/tuscany/sca/databinding/xstream/MetaObjectImpl.java b/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/main/java/org/apache/tuscany/sca/databinding/xstream/MetaObjectImpl.java new file mode 100644 index 0000000000..d223a4db23 --- /dev/null +++ b/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/main/java/org/apache/tuscany/sca/databinding/xstream/MetaObjectImpl.java @@ -0,0 +1,95 @@ +/* + * 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.xstream; + +import java.io.FileNotFoundException; +import java.io.IOException; + +/** + * Implementation of a wrapper for XObject. + * + * @version $Rev$ $Date$ + */ +public class MetaObjectImpl implements MetaObject { + private String obID; + private String name; + private XObject obInstance; + + //private byte[] bytecode = null; + + public MetaObjectImpl() { + this.obID = Utils.uniqueID(); + } + + public MetaObjectImpl(XObject x) { + //this.name = path; + this.obID = Utils.uniqueID(); + this.obInstance = x; + + try { + initMetaOb(this.obInstance.getClass()); + + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + private void initMetaOb(Class<?> class1) throws FileNotFoundException, IOException { + /* + File file = new File(cname); + DataInputStream cstream = new DataInputStream(new FileInputStream(file)); + bytecode = new byte[(int)file.length()]; + cstream.readFully(bytecode); + */ + name = class1.getName(); + + } + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + public String getID() { + return obID; + } + + public Class<?> getType() { + + return this.obInstance.getClass(); + } + + public XObject getInstance() { + return this.obInstance; + } + /* + * TODO Add bytecode with Serialization + public byte[] getByteCode() { + return bytecode; + } + */ + +} diff --git a/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/main/java/org/apache/tuscany/sca/databinding/xstream/Node2XObject.java b/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/main/java/org/apache/tuscany/sca/databinding/xstream/Node2XObject.java new file mode 100644 index 0000000000..2b7fa9d506 --- /dev/null +++ b/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/main/java/org/apache/tuscany/sca/databinding/xstream/Node2XObject.java @@ -0,0 +1,69 @@ +/* + * 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.xstream; + +import org.apache.tuscany.sca.databinding.PullTransformer; +import org.apache.tuscany.sca.databinding.TransformationContext; +import org.apache.tuscany.sca.databinding.TransformationException; +import org.apache.tuscany.sca.databinding.impl.BaseTransformer; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.io.xml.DomReader; + +/** + * DOM Node --> XStream transformer + * + * @version $Rev$ $Date$ + */ +public class Node2XObject extends BaseTransformer<Node, XObject> implements PullTransformer<Node, XObject> { + + public XObject transform(Node source, TransformationContext context) { + try { + DomReader in = null; + if (source instanceof Document) { + in = new DomReader((Document)source); + } else if (source instanceof Element) { + in = new DomReader((Element)source); + } + XStream xs = new XStream(); + return (XObject)xs.unmarshal(in); + } catch (Exception e) { + throw new TransformationException(e); + } + } + + @Override + public Class<Node> getSourceType() { + return Node.class; + } + + @Override + public Class<XObject> getTargetType() { + return XObject.class; + } + + @Override + public int getWeight() { + return 10; + } + +} diff --git a/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/main/java/org/apache/tuscany/sca/databinding/xstream/OMElement2XObject.java b/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/main/java/org/apache/tuscany/sca/databinding/xstream/OMElement2XObject.java new file mode 100644 index 0000000000..a465e92e65 --- /dev/null +++ b/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/main/java/org/apache/tuscany/sca/databinding/xstream/OMElement2XObject.java @@ -0,0 +1,76 @@ +/* + * 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.xstream; + +import java.io.StringWriter; + +import javax.xml.stream.XMLStreamException; + +import org.apache.axiom.om.OMElement; +import org.apache.tuscany.sca.databinding.PullTransformer; +import org.apache.tuscany.sca.databinding.TransformationContext; +import org.apache.tuscany.sca.databinding.impl.BaseTransformer; + +import com.thoughtworks.xstream.XStream; + +/** + * Job DataObject --> AXIOM OMElement transformer + * + * @version $Rev$ $Date$ + */ +public class OMElement2XObject extends BaseTransformer<OMElement, XObject> implements + PullTransformer<OMElement, XObject> { + + public XObject transform(OMElement source, TransformationContext context) { + + XStream xs = new XStream(); + xs.alias("xobject", MetaObjectImpl.class); + MetaObjectImpl mo; + try { + java.io.StringWriter writer = new StringWriter(); + source.serialize(writer); + String w = writer.toString(); + // FIXME: a better way to get eliminate param0 + w = w.replaceAll("param0", "xobject"); + w = w.replaceAll("xmlns=\"\"", ""); + mo = (MetaObjectImpl)xs.fromXML(w.trim()); + return mo.getInstance(); + } catch (XMLStreamException e) { + + e.printStackTrace(); + } + return null; + } + + @Override + public Class<OMElement> getSourceType() { + return OMElement.class; + } + + @Override + public Class<XObject> getTargetType() { + return XObject.class; + } + + @Override + public int getWeight() { + return 10; + } + +} diff --git a/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/main/java/org/apache/tuscany/sca/databinding/xstream/Utils.java b/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/main/java/org/apache/tuscany/sca/databinding/xstream/Utils.java new file mode 100644 index 0000000000..d819975910 --- /dev/null +++ b/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/main/java/org/apache/tuscany/sca/databinding/xstream/Utils.java @@ -0,0 +1,79 @@ +/* + * 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.xstream; + +import java.io.IOException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; + +/** + * Utility methods. + * + * @version $Rev$ $Date$ + */ +public class Utils { + public static String toBase64(byte[] array) { + String code = null; + code = new sun.misc.BASE64Encoder().encode(array); + return code; + } + + public static byte[] fromBase64(String bytecode) { + byte[] dec = null; + try { + dec = new sun.misc.BASE64Decoder().decodeBuffer(bytecode); + } catch (IOException e) { + e.printStackTrace(); + } + return dec; + } + + public static String uniqueID() { + try { + //Initialize SecureRandom + //This is a lengthy operation, to be done only upon + //initialization of the application + SecureRandom prng = SecureRandom.getInstance("SHA1PRNG"); + + //generate a random number + String randomNum = Integer.toString(prng.nextInt()); + + //get its digest + MessageDigest sha = MessageDigest.getInstance("SHA-1"); + byte[] result = sha.digest(randomNum.getBytes()); + return hexEncode(result); + } catch (NoSuchAlgorithmException ex) { + ex.printStackTrace(); + } + return null; + } + + private static String hexEncode(byte[] aInput) { + StringBuffer result = new StringBuffer(); + char[] digits = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; + for (int idx = 0; idx < aInput.length; ++idx) { + byte b = aInput[idx]; + result.append(digits[(b & 0xf0) >> 4]); + result.append(digits[b & 0x0f]); + } + return result.toString(); + } + +} diff --git a/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/main/java/org/apache/tuscany/sca/databinding/xstream/XObject.java b/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/main/java/org/apache/tuscany/sca/databinding/xstream/XObject.java new file mode 100644 index 0000000000..21112efcf5 --- /dev/null +++ b/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/main/java/org/apache/tuscany/sca/databinding/xstream/XObject.java @@ -0,0 +1,28 @@ +/* + * 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.xstream; + +/** + * Marker interface for XStream Serializable objects + * + * @version $Rev$ $Date$ + */ +// FIXME: Why do we require a marker interface? +public interface XObject { +} diff --git a/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/main/java/org/apache/tuscany/sca/databinding/xstream/XObject2Node.java b/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/main/java/org/apache/tuscany/sca/databinding/xstream/XObject2Node.java new file mode 100644 index 0000000000..98e0e69f9b --- /dev/null +++ b/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/main/java/org/apache/tuscany/sca/databinding/xstream/XObject2Node.java @@ -0,0 +1,69 @@ +/* + * 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.xstream; + +import org.apache.tuscany.sca.databinding.PullTransformer; +import org.apache.tuscany.sca.databinding.TransformationContext; +import org.apache.tuscany.sca.databinding.TransformationException; +import org.apache.tuscany.sca.databinding.impl.BaseTransformer; +import org.apache.tuscany.sca.databinding.impl.DOMHelper; +import org.w3c.dom.Document; +import org.w3c.dom.Node; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.io.xml.DomWriter; + +/** + * XObject --> DOM Node transformer + * + * @version $Rev$ $Date$ + */ +public class XObject2Node extends BaseTransformer<XObject, Node> implements PullTransformer<XObject, Node> { + + public Node transform(XObject source, TransformationContext context) { + try { + MetaObject mj = new MetaObjectImpl(source); + Document root = DOMHelper.newDocument(); + DomWriter out = new DomWriter(DOMHelper.newDocument()); + XStream xs = new XStream(); + xs.alias("xobject", mj.getClass()); + xs.marshal(source, out); + DOMHelper.adjustElementName(context, root.getDocumentElement()); + return root; + } catch (Exception e) { + throw new TransformationException(e); + } + } + + @Override + public Class<XObject> getSourceType() { + return XObject.class; + } + + @Override + public Class<Node> getTargetType() { + return Node.class; + } + + @Override + public int getWeight() { + return 10; + } + +} diff --git a/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/main/java/org/apache/tuscany/sca/databinding/xstream/XObject2OMElement.java b/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/main/java/org/apache/tuscany/sca/databinding/xstream/XObject2OMElement.java new file mode 100644 index 0000000000..ff4305491a --- /dev/null +++ b/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/main/java/org/apache/tuscany/sca/databinding/xstream/XObject2OMElement.java @@ -0,0 +1,106 @@ +/* + * 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.xstream; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; + +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.sca.databinding.PullTransformer; +import org.apache.tuscany.sca.databinding.TransformationContext; +import org.apache.tuscany.sca.databinding.TransformationException; +import org.apache.tuscany.sca.databinding.impl.BaseTransformer; +import org.apache.tuscany.sca.interfacedef.DataType; +import org.apache.tuscany.sca.interfacedef.util.XMLType; + +import com.thoughtworks.xstream.XStream; + +/** + * XObject --> AXIOM OMElement transformer + * + * @version $Rev$ $Date$ + */ +public class XObject2OMElement extends BaseTransformer<XObject, OMElement> implements + PullTransformer<XObject, OMElement> { + + public OMElement transform(XObject source, TransformationContext context) { + MetaObject mj = new MetaObjectImpl(source); + OMElement element = null; + ByteArrayOutputStream out = new ByteArrayOutputStream(); + XStream xs = new XStream(); + xs.alias("xobject", mj.getClass()); + xs.toXML(mj, out); + /* TODO: Maybe a base64 conversion...? or not? + * ie. new ByteArrayInputStream(Utils.toBase64(out.toByteArray()).getBytes()) + */ + try { + // what's better this one: + StAXOMBuilder builder = new StAXOMBuilder(new ByteArrayInputStream(out.toByteArray())); + // or this one: + // StaAXOMBuilder builder = new StAXOMBuilder(new ByteArrayInputStream(Utils.toBase64(out.toByteArray()).getBytes())) + element = builder.getDocumentElement(); + adjustElementName(context, element); + } catch (Exception e) { + throw new TransformationException(e); + } + return element; + + } + + private static void adjustElementName(TransformationContext context, OMElement element) { + if (context != null) { + DataType dataType = context.getTargetDataType(); + Object logical = dataType == null ? null : dataType.getLogical(); + if (!(logical instanceof XMLType)) { + return; + } + XMLType xmlType = (XMLType)logical; + if (xmlType.isElement() && !xmlType.getElementName().equals(element.getQName())) { + // FIXME:: Throw exception or switch to the new Element? + OMFactory factory = OMAbstractFactory.getOMFactory(); + QName name = xmlType.getElementName(); + OMNamespace namespace = factory.createOMNamespace(name.getNamespaceURI(), name.getPrefix()); + element.setNamespace(namespace); + element.setLocalName(name.getLocalPart()); + } + } + } + + @Override + public Class<XObject> getSourceType() { + return XObject.class; + } + + @Override + public Class<OMElement> getTargetType() { + return OMElement.class; + } + + @Override + public int getWeight() { + return 10; + } + +} diff --git a/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/main/java/org/apache/tuscany/sca/databinding/xstream/XObjectDataBinding.java b/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/main/java/org/apache/tuscany/sca/databinding/xstream/XObjectDataBinding.java new file mode 100644 index 0000000000..b319c7d557 --- /dev/null +++ b/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/main/java/org/apache/tuscany/sca/databinding/xstream/XObjectDataBinding.java @@ -0,0 +1,37 @@ +/* + * 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.xstream; + +import org.apache.tuscany.sca.databinding.impl.BaseDataBinding; + +/** + * DataBinding for Jobs + * + * @version $Rev$ $Date$ + */ +public class XObjectDataBinding extends BaseDataBinding { + + public static final String NAME = XObject.class.getName(); + + public XObjectDataBinding() { + super(NAME, XObject.class); + } + +} diff --git a/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding b/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding new file mode 100644 index 0000000000..e2f467b8dd --- /dev/null +++ b/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding @@ -0,0 +1,20 @@ +# 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.
+
+# implementation classes for the databindings
+org.apache.tuscany.sca.databinding.xstream.XObjectDataBinding;name=org.apache.tuscany.sca.databinding.xstream.XObject
+
diff --git a/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer b/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer new file mode 100644 index 0000000000..a733ad7b7d --- /dev/null +++ b/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer @@ -0,0 +1,18 @@ +# 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.
+org.apache.tuscany.sca.databinding.xstream.XObject2OMElement;source=org.apache.tuscany.sca.databinding.xstream.XObject,target=org.apache.axiom.om.OMElement,weight=10
+org.apache.tuscany.sca.databinding.xstream.OMElement2XObject;source=org.apache.axiom.om.OMElement,target=org.apache.tuscany.sca.databinding.xstream.XObject,weight=10
diff --git a/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/test/resources/ipo.xml b/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/test/resources/ipo.xml new file mode 100644 index 0000000000..1699538d62 --- /dev/null +++ b/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/test/resources/ipo.xml @@ -0,0 +1,48 @@ +<?xml version="1.0"?> +<!-- + * 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. +--> +<ipo:purchaseOrder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ipo="http://www.example.com/IPO" + xsi:schemaLocation="http://www.example.com/IPO ipo.xsd" orderDate="1999-12-01"> + + <shipTo exportCode="1" xsi:type="ipo:UKAddress"> + <name>Helen Zoe</name> + <street>47 Eden Street</street> + <city>Cambridge</city> + <postcode>CB1 1JR</postcode> + </shipTo> + + <billTo xsi:type="ipo:USAddress"> + <name>Robert Smith</name> + <street>8 Oak Avenue</street> + <city>Old Town</city> + <state>PA</state> + <zip>95819</zip> + </billTo> + + <items> + <item partNum="833-AA"> + <productName>Lapis necklace</productName> + <quantity>1</quantity> + <USPrice>99.95</USPrice> + <ipo:comment>Want this for the holidays</ipo:comment> + <shipDate>1999-12-05</shipDate> + </item> + </items> +</ipo:purchaseOrder> + diff --git a/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/test/resources/ipo.xsd b/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/test/resources/ipo.xsd new file mode 100644 index 0000000000..aac7ded180 --- /dev/null +++ b/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/test/resources/ipo.xsd @@ -0,0 +1,132 @@ +<!-- + * 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. +--> + +<schema targetNamespace="http://www.example.com/IPO" xmlns="http://www.w3.org/2001/XMLSchema" + xmlns:ipo="http://www.example.com/IPO"> + + <annotation> + <documentation xml:lang="en"> + International Purchase order schema for Example.com Copyright 2000 Example.com. All rights reserved. + </documentation> + </annotation> + + + <element name="purchaseOrder" type="ipo:PurchaseOrderType" /> + + <element name="comment" type="string" /> + + <complexType name="PurchaseOrderType"> + <sequence> + <element name="shipTo" type="ipo:Address" /> + <element name="billTo" type="ipo:Address" /> + <element ref="ipo:comment" minOccurs="0" /> + <element name="items" type="ipo:Items" /> + </sequence> + <attribute name="orderDate" type="date" /> + </complexType> + + <complexType name="Items"> + <sequence> + <element name="item" minOccurs="0" maxOccurs="unbounded"> + <complexType> + <sequence> + <element name="productName" type="string" /> + <element name="quantity"> + <simpleType> + <restriction base="positiveInteger"> + <maxExclusive value="100" /> + </restriction> + </simpleType> + </element> + <element name="USPrice" type="decimal" /> + <element ref="ipo:comment" minOccurs="0" /> + <element name="shipDate" type="date" minOccurs="0" /> + </sequence> + <attribute name="partNum" type="ipo:SKU" use="required" /> + </complexType> + </element> + </sequence> + </complexType> + + <simpleType name="SKU"> + <restriction base="string"> + <pattern value="\d{3}-[A-Z]{2}" /> + </restriction> + </simpleType> + + <complexType name="Address"> + <sequence> + <element name="name" type="string" /> + <element name="street" type="string" /> + <element name="city" type="string" /> + </sequence> + </complexType> + + <complexType name="USAddress"> + <complexContent> + <extension base="ipo:Address"> + <sequence> + <element name="state" type="ipo:USState" /> + <element name="zip" type="positiveInteger" /> + </sequence> + </extension> + </complexContent> + </complexType> + + <complexType name="UKAddress"> + <complexContent> + <extension base="ipo:Address"> + <sequence> + <element name="postcode" type="ipo:UKPostcode" /> + </sequence> + <attribute name="exportCode" type="positiveInteger" fixed="1" /> + </extension> + </complexContent> + </complexType> + + <!-- other Address derivations for more countries --> + + <simpleType name="USState"> + <restriction base="string"> + <enumeration value="AK" /> + <enumeration value="AL" /> + <enumeration value="AR" /> + <enumeration value="CA" /> + <enumeration value="PA" /> + <!-- and so on ... --> + </restriction> + </simpleType> + + <simpleType name="Postcode"> + <restriction base="string"> + <length value="7" fixed="true" /> + </restriction> + </simpleType> + + + <simpleType name="UKPostcode"> + <restriction base="ipo:Postcode"> + <pattern value="[A-Z]{2}\d\s\d[A-Z]{2}" /> + </restriction> + </simpleType> + + + +</schema> + diff --git a/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/test/resources/order.wsdl b/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/test/resources/order.wsdl new file mode 100644 index 0000000000..65da5b602a --- /dev/null +++ b/sca-java-1.x/tags/1.5-RC0/modules/databinding-xstream/src/test/resources/order.wsdl @@ -0,0 +1,76 @@ +<?xml version="1.0"?>
+<!--
+ * 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.
+-->
+<definitions name="StockQuote" targetNamespace="http://example.com/order.wsdl" xmlns:tns="http://example.com/order.wsdl"
+ xmlns:xsd1="http://example.com/order.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns="http://schemas.xmlsoap.org/wsdl/">
+
+ <types>
+ <schema targetNamespace="http://example.com/order.xsd" xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:ipo="http://www.example.com/IPO">
+ <import namespace="http://www.example.com/IPO" schemaLocation="ipo.xsd" />
+ <element name="checkOrderStatus">
+ <complexType>
+ <sequence>
+ <element name="customerId" type="string" />
+ <element name="order" type="ipo:PurchaseOrderType" />
+ <element name="flag" type="int" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="checkOrderStatusResponse">
+ <complexType>
+ <sequence>
+ <element name="status" type="string" />
+ </sequence>
+ </complexType>
+ </element>
+ <element name="note" type="string" />
+ </schema>
+ </types>
+
+ <message name="CheckOrderStatusInput1">
+ <part name="body" element="xsd1:checkOrderStatus" />
+ </message>
+
+ <message name="CheckOrderStatusOutput1">
+ <part name="body" element="xsd1:checkOrderStatusResponse" />
+ </message>
+
+ <message name="CheckOrderStatusInput2">
+ <part name="p1" element="xsd1:checkOrderStatus" />
+ <part name="p2" element="xsd1:note" />
+ </message>
+
+ <message name="CheckOrderStatusOutput2">
+ <part name="p1" element="xsd1:checkOrderStatusResponse" />
+ </message>
+
+ <portType name="OrderPortType">
+ <operation name="checkOrderStatus">
+ <input message="tns:CheckOrderStatusInput1" />
+ <output message="tns:CheckOrderStatusOutput1" />
+ </operation>
+ <operation name="checkOrderStatus2">
+ <input message="tns:CheckOrderStatusInput2" />
+ <output message="tns:CheckOrderStatusOutput2" />
+ </operation>
+ </portType>
+
+</definitions>
\ No newline at end of file |