cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r796024 - in /cxf/trunk/rt/databinding/sdo: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/cxf/ src/main/java/org/apache/cxf/sdo/ src/main/java/org/apache/cxf/sdo/tools/ src/main/resou...
Date Mon, 20 Jul 2009 21:28:05 GMT
Author: dkulp
Date: Mon Jul 20 21:28:04 2009
New Revision: 796024

URL: http://svn.apache.org/viewvc?rev=796024&view=rev
Log:
Add start of SDO databinding

Added:
    cxf/trunk/rt/databinding/sdo/
    cxf/trunk/rt/databinding/sdo/pom.xml   (with props)
    cxf/trunk/rt/databinding/sdo/src/
    cxf/trunk/rt/databinding/sdo/src/main/
    cxf/trunk/rt/databinding/sdo/src/main/java/
    cxf/trunk/rt/databinding/sdo/src/main/java/org/
    cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/
    cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/
    cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/
    cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/DataReaderImpl.java   (with props)
    cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/DataWriterImpl.java   (with props)
    cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/NodeDataWriterImpl.java   (with props)
    cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/SDOClassCollector.java   (with props)
    cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/SDODataBinding.java   (with props)
    cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/tools/
    cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/tools/SDODatabinding.java   (with props)
    cxf/trunk/rt/databinding/sdo/src/main/resources/
    cxf/trunk/rt/databinding/sdo/src/main/resources/META-INF/
    cxf/trunk/rt/databinding/sdo/src/main/resources/META-INF/tools-plugin.xml   (with props)
    cxf/trunk/rt/databinding/sdo/src/test/
    cxf/trunk/rt/databinding/sdo/src/test/java/
    cxf/trunk/rt/databinding/sdo/src/test/java/org/
    cxf/trunk/rt/databinding/sdo/src/test/java/org/apache/
    cxf/trunk/rt/databinding/sdo/src/test/java/org/apache/cxf/
    cxf/trunk/rt/databinding/sdo/src/test/java/org/apache/cxf/sdo/
    cxf/trunk/rt/databinding/sdo/src/test/java/org/apache/cxf/sdo/AbstractSDOTest.java   (with props)
    cxf/trunk/rt/databinding/sdo/src/test/java/org/apache/cxf/sdo/HelloWorldStaticTest.java   (with props)
    cxf/trunk/rt/databinding/sdo/src/test/java/org/apache/cxf/sdo/bean11.xml   (with props)
    cxf/trunk/rt/databinding/sdo/src/test/resources/
    cxf/trunk/rt/databinding/sdo/src/test/resources/wsdl_sdo/
    cxf/trunk/rt/databinding/sdo/src/test/resources/wsdl_sdo/HelloService.wsdl   (with props)

Added: cxf/trunk/rt/databinding/sdo/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/sdo/pom.xml?rev=796024&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/sdo/pom.xml (added)
+++ cxf/trunk/rt/databinding/sdo/pom.xml Mon Jul 20 21:28:04 2009
@@ -0,0 +1,141 @@
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>cxf-rt-databinding-sdo</artifactId>
+    <packaging>jar</packaging>
+    <name>Apache CXF Runtime SDO DataBinding</name>
+    <url>http://cxf.apache.org</url>
+
+    <parent>
+        <groupId>org.apache.cxf</groupId>
+        <artifactId>cxf-parent</artifactId>
+        <version>2.3.0-SNAPSHOT</version>
+        <relativePath>../../../parent/pom.xml</relativePath>
+    </parent>
+
+
+    <dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.easymock</groupId>
+            <artifactId>easymockclassextension</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-core</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-tools-common</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        
+
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-tools-wsdlto-core</artifactId>
+            <version>${project.version}</version>
+            <scope>provided</scope>
+        </dependency>
+
+
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-testutils</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sdo</groupId>
+            <artifactId>tuscany-sdo-impl</artifactId>
+            <version>1.1.1</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tuscany.sdo</groupId>
+            <artifactId>tuscany-sdo-tools</artifactId>
+            <version>1.1.1</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-tools-wsdlto-frontend-jaxws</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-stax-api_1.0_spec</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${stax.impl.groupId}</groupId>
+            <artifactId>${stax.impl.artifactId}</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-transports-local</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-transports-http</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-transports-http-jetty</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-frontend-jaxws</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-testsupport</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+    </dependencies>
+
+</project>

Propchange: cxf/trunk/rt/databinding/sdo/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/databinding/sdo/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/trunk/rt/databinding/sdo/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/DataReaderImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/DataReaderImpl.java?rev=796024&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/DataReaderImpl.java (added)
+++ cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/DataReaderImpl.java Mon Jul 20 21:28:04 2009
@@ -0,0 +1,82 @@
+/**
+ * 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.cxf.sdo;
+
+import java.util.Collection;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.validation.Schema;
+
+
+import org.apache.cxf.databinding.DataReader;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.Attachment;
+import org.apache.cxf.service.model.MessagePartInfo;
+
+import commonj.sdo.helper.HelperContext;
+
+public class DataReaderImpl implements DataReader<XMLStreamReader> {
+    HelperContext context;
+    Object xmlStreamHelper;
+    
+    public DataReaderImpl(HelperContext context) {
+        this.context = context;
+        try {
+            xmlStreamHelper = context.getClass().getMethod("getXMLStreamHelper", 
+                                                           new Class[0]).invoke(context);
+        } catch (Throwable t) {
+            xmlStreamHelper = null;
+        }
+    }
+
+    public Object read(XMLStreamReader input) {
+        return read(null, input);
+    }
+
+    public Object read(MessagePartInfo part, XMLStreamReader reader) {
+        if (xmlStreamHelper != null) {
+            try {
+                Object o = xmlStreamHelper.getClass().getMethod("loadObject", 
+                                                     new Class[] {XMLStreamReader.class})
+                                                         .invoke(xmlStreamHelper, reader);
+                
+                return o;
+            } catch (Exception e) {
+                new Fault(e);
+            }
+        }
+        return null;
+    }
+
+    public Object read(QName name, XMLStreamReader input, Class type) {        
+        return null;
+    }
+
+    
+    public void setAttachments(Collection<Attachment> attachments) {
+    }
+
+    public void setProperty(String prop, Object value) {
+    }
+
+    public void setSchema(Schema s) {
+    }
+}

Propchange: cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/DataReaderImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/DataReaderImpl.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/DataReaderImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/DataWriterImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/DataWriterImpl.java?rev=796024&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/DataWriterImpl.java (added)
+++ cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/DataWriterImpl.java Mon Jul 20 21:28:04 2009
@@ -0,0 +1,75 @@
+/**
+ * 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.cxf.sdo;
+
+import java.util.Collection;
+
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.validation.Schema;
+
+
+import org.apache.cxf.databinding.DataWriter;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.Attachment;
+import org.apache.cxf.service.model.MessagePartInfo;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.HelperContext;
+
+public class DataWriterImpl implements DataWriter<XMLStreamWriter> {
+    HelperContext context;
+    Object xmlStreamHelper;
+    
+    public DataWriterImpl(HelperContext context) {
+        this.context = context;
+        try {
+            xmlStreamHelper = context.getClass().getMethod("getXMLStreamHelper", 
+                                                           new Class[0]).invoke(context);
+        } catch (Throwable t) {
+            xmlStreamHelper = null;
+        }
+    }
+    
+    public void write(Object obj, XMLStreamWriter output) {
+        write(obj, null, output);
+    }
+    
+    public void write(Object obj, MessagePartInfo part, XMLStreamWriter output) {
+        try {
+            xmlStreamHelper.getClass().getMethod("saveObject", 
+                                                        new Class[] {DataObject.class,
+                                                                     XMLStreamWriter.class})
+                                                            .invoke(xmlStreamHelper, obj, output);
+        } catch (Exception ex) {
+            throw new Fault(ex);
+        }
+
+    }
+
+
+    public void setAttachments(Collection<Attachment> attachments) {
+    }
+
+    public void setProperty(String key, Object value) {
+    }
+
+    public void setSchema(Schema schema) {
+    }
+}

Propchange: cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/DataWriterImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/DataWriterImpl.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/DataWriterImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/NodeDataWriterImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/NodeDataWriterImpl.java?rev=796024&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/NodeDataWriterImpl.java (added)
+++ cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/NodeDataWriterImpl.java Mon Jul 20 21:28:04 2009
@@ -0,0 +1,64 @@
+/**
+ * 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.cxf.sdo;
+
+
+import java.util.Collection;
+import javax.xml.validation.Schema;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+
+import org.apache.cxf.databinding.DataWriter;
+import org.apache.cxf.message.Attachment;
+import org.apache.cxf.service.model.MessagePartInfo;
+import org.apache.cxf.staxutils.W3CDOMStreamWriter;
+
+import commonj.sdo.helper.HelperContext;
+
+public class NodeDataWriterImpl implements DataWriter<Node> {
+    DataWriterImpl writer;
+    
+    public NodeDataWriterImpl(HelperContext ctx) {
+        writer = new DataWriterImpl(ctx);
+    }
+    
+    public void write(Object obj, Node output) {
+        write(obj, null, output);
+    }
+    
+    public void write(Object obj, MessagePartInfo part, Node output) {
+        W3CDOMStreamWriter domWriter = new W3CDOMStreamWriter((Element)output);
+        writer.write(obj, part, domWriter);
+    }
+
+    public void setAttachments(Collection<Attachment> attachments) {
+        writer.setAttachments(attachments);
+    }
+
+    public void setProperty(String key, Object value) {
+        writer.setProperty(key, value);
+    }
+
+    public void setSchema(Schema s) {
+        writer.setSchema(s);
+    }
+}

Propchange: cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/NodeDataWriterImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/NodeDataWriterImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/SDOClassCollector.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/SDOClassCollector.java?rev=796024&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/SDOClassCollector.java (added)
+++ cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/SDOClassCollector.java Mon Jul 20 21:28:04 2009
@@ -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.cxf.sdo;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.cxf.service.ServiceModelVisitor;
+import org.apache.cxf.service.model.MessagePartInfo;
+import org.apache.cxf.service.model.ServiceInfo;
+
+/**
+ * 
+ */
+class SDOClassCollector extends ServiceModelVisitor { 
+    Set<Class<?>> classes = new HashSet<Class<?>>();
+    
+    public SDOClassCollector(ServiceInfo serviceInfo) {
+        super(serviceInfo);
+    }
+    
+    public Set<Class<?>> getClasses() {
+        return classes;
+    }
+    
+    @Override
+    public void begin(MessagePartInfo part) {
+        Class<?> cls = part.getTypeClass();
+        if (cls != null) {
+            classes.add(cls);
+        }
+    }
+}

Propchange: cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/SDOClassCollector.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/SDOClassCollector.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/SDODataBinding.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/SDODataBinding.java?rev=796024&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/SDODataBinding.java (added)
+++ cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/SDODataBinding.java Mon Jul 20 21:28:04 2009
@@ -0,0 +1,205 @@
+/**
+ * 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.cxf.sdo;
+
+import java.io.InputStream;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.w3c.dom.Node;
+
+import org.apache.cxf.databinding.AbstractDataBinding;
+import org.apache.cxf.databinding.DataReader;
+import org.apache.cxf.databinding.DataWriter;
+import org.apache.cxf.databinding.WrapperCapableDatabinding;
+import org.apache.cxf.databinding.WrapperHelper;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.resource.ExtendedURIResolver;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.tuscany.sdo.api.SDOUtil;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Type;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.impl.HelperProvider;
+
+
+/**
+ * 
+ */
+public class SDODataBinding extends AbstractDataBinding 
+    implements WrapperCapableDatabinding { 
+
+    private final class SDOWrapperHelper implements WrapperHelper {
+        private final List<String> partNames;
+        private Method fact;
+        private Object factory;
+
+        private SDOWrapperHelper(List<String> partNames, Class<?> wrapperType) {
+            this.partNames = partNames;
+            try {
+                String s = wrapperType.getPackage().getName() + ".SdoFactory";
+                Class<?> cls = Class.forName(s, false, wrapperType.getClassLoader());
+                for (Method m : cls.getMethods()) {
+                    if (m.getReturnType() == wrapperType) {
+                        fact = m;
+                        break;
+                    }
+                }
+                factory = cls.getField("INSTANCE").get(null);
+            } catch (Exception ex) {
+                ex.printStackTrace();
+            }
+        }
+
+        public Object createWrapperObject(List<?> lst) throws Fault {
+            DataObject o;
+            try {
+                o = (DataObject)fact.invoke(factory);
+            } catch (Exception e) {
+                throw new Fault(e); 
+            }
+            for (int x = 0; x < lst.size(); x++) {
+                o.set(partNames.get(x), lst.get(x));
+            }
+            return o;
+        }
+
+        public String getSignature() {
+            return "" + System.identityHashCode(this);
+        }
+
+        public List<Object> getWrapperParts(Object o) throws Fault {
+            List<Object> lst = new ArrayList<Object>();
+            DataObject obj = (DataObject)o;
+            for (String s : partNames) {
+                lst.add(obj.get(s));
+            }
+            return lst;
+        }
+    }
+
+
+
+    private static final Class<?> SUPPORTED_READER_FORMATS[] = new Class<?>[] {XMLStreamReader.class};
+    private static final Class<?> SUPPORTED_WRITER_FORMATS[]
+        = new Class<?>[] {XMLStreamWriter.class, Node.class};
+    HelperProvider provider;
+    HelperContext context;
+    
+    public void initialize(Service service) {
+        context = SDOUtil.createHelperContext();
+        
+        Set<String> pkgs = new HashSet<String>();
+        for (ServiceInfo serviceInfo : service.getServiceInfos()) {
+            SDOClassCollector cc = new SDOClassCollector(serviceInfo);
+            cc.walk();
+            
+            for (Class<?> cls : cc.getClasses()) {
+                String pkg = cls.getPackage().getName();
+                if (!pkgs.contains(pkg)) {
+                    try {
+                        Class fact = Class.forName(pkg + ".SdoFactory", false, cls.getClassLoader());
+                        registerFactory(fact);
+                        pkgs.add(pkg);
+                    } catch (Throwable t) {
+                        //ignore, register the class itself
+                        register(cls);
+                    }
+                }
+            }
+        }
+        for (ServiceInfo serviceInfo : service.getServiceInfos()) {
+            String uri = serviceInfo.getDescription().getBaseURI();
+            ExtendedURIResolver resolver = new ExtendedURIResolver();
+            InputStream ins = resolver.resolve(uri, "").getByteStream();
+            context.getXSDHelper().define(ins, uri);
+            resolver.close();
+        }        
+    }
+    void registerFactory(Class<?> factoryClass) throws Exception {
+        Field field = factoryClass.getField("INSTANCE");
+        Object factory = field.get(null);
+        Method method = factory.getClass().getMethod("register", new Class[] {HelperContext.class});
+        method.invoke(factory, new Object[] {context});
+    }
+    boolean register(Class javaType) {
+        if (javaType == null || DataObject.class == javaType) {
+            return false;
+        }
+        try {
+            Type type = context.getTypeHelper().getType(javaType);
+            if (type != null && (!type.isDataType())) {
+                Method method = type.getClass().getMethod("getEPackage");
+                Object factory = method.invoke(type, new Object[] {});
+                method = factory.getClass().getMethod("register", HelperContext.class);
+                method.invoke(factory, new Object[] {context});
+                return true;
+            }
+            return false;
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return false;
+    }
+    @SuppressWarnings("unchecked")
+    public <T> DataReader<T> createReader(Class<T> c) {
+        DataReader<T> dr = null;
+        if (c == XMLStreamReader.class) {
+            dr = (DataReader<T>)new DataReaderImpl(context);
+        }
+        return dr;
+    }
+    @SuppressWarnings("unchecked")
+    public <T> DataWriter<T> createWriter(Class<T> c) {
+        if (c == XMLStreamWriter.class) {
+            return (DataWriter<T>)new DataWriterImpl(context);
+        } else if (c == Node.class) {
+            return (DataWriter<T>)new NodeDataWriterImpl(context);
+        }
+        return null;
+    }
+    public Class<?>[] getSupportedReaderFormats() {
+        return SUPPORTED_READER_FORMATS;
+    }
+
+    public Class<?>[] getSupportedWriterFormats() {
+        return SUPPORTED_WRITER_FORMATS;
+    }
+
+    
+    
+    public WrapperHelper createWrapperHelper(final Class<?> wrapperType,
+                                             final List<String> partNames,
+                                             final List<String> elTypeNames,
+                                             final List<Class<?>> partClasses) {
+        
+        
+        return new SDOWrapperHelper(partNames, wrapperType);
+    }
+}

Propchange: cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/SDODataBinding.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/SDODataBinding.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/tools/SDODatabinding.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/tools/SDODatabinding.java?rev=796024&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/tools/SDODatabinding.java (added)
+++ cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/tools/SDODatabinding.java Mon Jul 20 21:28:04 2009
@@ -0,0 +1,287 @@
+/**
+ * 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.cxf.sdo.tools;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.tools.common.ToolConstants;
+import org.apache.cxf.tools.common.ToolContext;
+import org.apache.cxf.tools.common.ToolException;
+import org.apache.cxf.tools.common.model.DefaultValueWriter;
+import org.apache.cxf.tools.util.ClassCollector;
+import org.apache.cxf.tools.wsdlto.core.DataBindingProfile;
+import org.apache.tuscany.sdo.api.SDOUtil;
+import org.apache.tuscany.sdo.generate.XSD2JavaGenerator;
+import org.apache.tuscany.sdo.helper.HelperContextImpl;
+import org.eclipse.emf.codegen.ecore.genmodel.GenClass;
+import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
+import org.eclipse.emf.codegen.ecore.genmodel.GenPackage;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.impl.EPackageRegistryImpl;
+import org.eclipse.emf.ecore.util.BasicExtendedMetaData;
+import org.eclipse.emf.ecore.util.ExtendedMetaData;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+import commonj.sdo.Type;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.XSDHelper;
+
+public class SDODatabinding extends XSD2JavaGenerator implements DataBindingProfile {
+    private static final String DATABINDING_DYNAMIC_SDO = "sdo-dynamic";
+
+    private TypeHelper typeHelper;
+    private XSDHelper xsdHelper;
+
+    private boolean dynamic;
+    private ExtendedMetaData extendedMetaData;
+    private GenModel genModel;
+    private Map<EClassifier, GenClass> genClasses = new HashMap<EClassifier, GenClass>();
+
+    public void generate(ToolContext context) throws ToolException {
+        if (dynamic) {
+            // Node XSD2Java is needed for dynamic SDO
+            return;
+        }
+
+        Map<String, String> ns2pkgMap = context.getNamespacePackageMap();
+
+        String outputDir = (String)context.get(ToolConstants.CFG_OUTPUTDIR);
+        String pkg = context.getPackageName();
+
+        String wsdl = (String)context.get(ToolConstants.CFG_WSDLLOCATION);
+
+        // preparing the directories where files to be written.
+        File targetDir;
+        if (outputDir == null) {
+            try {
+                outputDir = new File(new URI(wsdl)).getParentFile().getAbsolutePath();
+            } catch (URISyntaxException e) {
+                outputDir = new File(".").getAbsolutePath();
+            }
+        }
+        targetDir = new File(outputDir);
+        targetDir.mkdirs();
+
+        List<String> argList = new ArrayList<String>();
+        argList.add("-targetDirectory");
+        argList.add(targetDir.getAbsolutePath());
+
+        if (pkg != null) {
+            argList.add("-javaPackage");
+            argList.add(pkg);
+        }
+
+        // We need to copy the wsdl to a local file if it is not
+        argList.add(new File(URI.create(wsdl)).getAbsolutePath());
+
+        String[] args = argList.toArray(new String[argList.size()]);
+        ClassCollector classCollector = context.get(ClassCollector.class);
+
+        try {
+            processArguments(args);
+            genModel = runXSD2Java(args, ns2pkgMap); 
+            
+            List<GenPackage> packages = CastUtils.cast(genModel.getGenPackages());
+            for (Iterator<GenPackage> iter = packages.iterator(); iter.hasNext();) {
+                // loop through the list, once to build up the eclass to genclass mapper
+                GenPackage genPackage = iter.next();
+                List<GenClass> classes = CastUtils.cast(genPackage.getGenClasses());
+                for (Iterator<GenClass> classIter = classes.iterator(); classIter.hasNext();) {
+                    GenClass genClass = classIter.next();
+                    genClasses.put(genClass.getEcoreClass(), genClass);
+
+                    //This gets the "impl" classes, how do we get everything else?
+                    String s = genClass.getQualifiedClassName();
+                    String p = s.substring(0, s.lastIndexOf('.'));
+                    s = s.substring(s.lastIndexOf('.') + 1);
+                    classCollector.addTypesClassName(p, 
+                                                     s,
+                                                     genClass.getQualifiedClassName());
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            printUsage();
+            return;
+        }
+
+        HelperContext hc = new HelperContextImpl(extendedMetaData, false);
+        xsdHelper = hc.getXSDHelper();
+        typeHelper = hc.getTypeHelper();
+    }
+
+    protected GenModel runXSD2Java(String args[], Map<String, String> ns2PkgMap) {
+        String xsdFileName = args[inputIndex];
+        EPackage.Registry packageRegistry = new EPackageRegistryImpl(EPackage.Registry.INSTANCE);
+        extendedMetaData = new BasicExtendedMetaData(packageRegistry);
+        String packageURI = getSchemaNamespace(xsdFileName);
+        Map<String, PackageInfo> packageInfoTable =
+            createPackageInfoTable(packageURI, schemaNamespace, javaPackage, prefix, ns2PkgMap);
+        return generateFromXMLSchema(xsdFileName,
+                                     packageRegistry,
+                                     extendedMetaData,
+                                     targetDirectory,
+                                     new Hashtable<String, PackageInfo>(packageInfoTable),
+                                     genOptions,
+                                     generateBuiltIn,
+                                     allNamespaces);
+    }
+
+    private static Map<String, PackageInfo> createPackageInfoTable(String packageURI,
+                                                                   String schemaNamespace,
+                                                                   String javaPackage,
+                                                                   String prefix,
+                                                                   Map<String, String> ns2PkgMap) {
+        Map<String, PackageInfo> packageInfoTable = new HashMap<String, PackageInfo>();
+
+        if (ns2PkgMap != null && !ns2PkgMap.isEmpty()) {
+            for (Map.Entry<String, String> e : ns2PkgMap.entrySet()) {
+                packageInfoTable.put(e.getKey(), new PackageInfo(e.getValue(), null, e.getKey(), null));
+            }
+        } else {
+            if (schemaNamespace != null) {
+                packageInfoTable.put(schemaNamespace,
+                                     new PackageInfo(javaPackage, prefix, schemaNamespace, null));
+            } else if (packageURI != null) {
+                packageInfoTable.put(packageURI, new PackageInfo(javaPackage, prefix, null, null));
+            }
+        }
+        return packageInfoTable;
+    }
+
+    public void initialize(ToolContext context) throws ToolException {
+        String databinding = (String)context.get(ToolConstants.CFG_DATABINDING);
+        if (DATABINDING_DYNAMIC_SDO.equalsIgnoreCase(databinding)) {
+            dynamic = true;
+        }
+
+        generatedPackages = null;
+        String wsdl = (String)context.get(ToolConstants.CFG_WSDLLOCATION);
+
+        if (dynamic) {
+            HelperContext helperContext = SDOUtil.createHelperContext();
+            xsdHelper = helperContext.getXSDHelper();
+            URL location;
+            try {
+                location = new URL(wsdl);
+                InputStream is = location.openStream();
+                xsdHelper.define(is, wsdl);
+            } catch (IOException e) {
+                throw new ToolException(e);
+            }
+            this.typeHelper = helperContext.getTypeHelper();
+        }
+        
+
+
+    }
+
+    public String getType(QName qName, boolean element) {
+        Type type = null;
+        if (element) {
+            Property property = xsdHelper.getGlobalProperty(qName.getNamespaceURI(),
+                                                            qName.getLocalPart(), true);
+            if (property != null) {
+                type = property.getType();
+            }
+        }
+        if (type == null) {
+            type = typeHelper.getType(qName.getNamespaceURI(), qName.getLocalPart());
+        }
+        if (type != null) {
+            return getClassName(type);
+        }
+        return DataObject.class.getName();
+    }
+
+    private String getClassName(Type type) {
+        EClassifier eClassifier = (EClassifier)type;
+        String name = eClassifier.getInstanceClassName();
+        if (name != null) {
+            return name;
+        }
+
+        if (genModel == null) {
+            return type.getName();
+        }
+
+        if (eClassifier instanceof EClass) {
+            // complex type
+            GenClass genEClass = (GenClass)genClasses.get(eClassifier);
+            if (genEClass != null) {
+                name = genEClass.getGenPackage().getInterfacePackageName() 
+                    + '.' + genEClass.getInterfaceName();
+
+            }
+        } else {
+            // simple type
+            name = eClassifier.getInstanceClass().getName();
+        }
+        return name;
+
+    }
+
+    public String getWrappedElementType(QName wrapperElement, QName item) {
+        Type type = null;
+        Property property =
+            xsdHelper.getGlobalProperty(wrapperElement.getNamespaceURI(), 
+                                        wrapperElement.getLocalPart(), true);
+        if (property != null) {
+            type = property.getType();
+            Property itemProp = type.getProperty(item.getLocalPart());
+            if (itemProp != null) {
+                type = itemProp.getType();
+            }
+        }
+        if (type != null) {
+            return getClassName(type);
+        }
+        return DataObject.class.getName();
+    }
+
+    public DefaultValueWriter createDefaultValueWriter(QName qName, boolean b) {
+        // since we dont need any sample client/server code with default values we return null
+        return null;
+    }
+
+    public DefaultValueWriter createDefaultValueWriterForWrappedElement(QName qName, QName qName1) {
+        // since we dont need any sample client/server code with default values we return null
+        return null;
+    }
+
+}

Propchange: cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/tools/SDODatabinding.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/tools/SDODatabinding.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/rt/databinding/sdo/src/main/resources/META-INF/tools-plugin.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/sdo/src/main/resources/META-INF/tools-plugin.xml?rev=796024&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/sdo/src/main/resources/META-INF/tools-plugin.xml (added)
+++ cxf/trunk/rt/databinding/sdo/src/main/resources/META-INF/tools-plugin.xml Mon Jul 20 21:28:04 2009
@@ -0,0 +1,24 @@
+<?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.
+-->
+<plugin name="sdo" version="" provider="tuscany.apache.org" xmlns="http://cxf.apache.org/tools/plugin">
+    <databinding name="sdo" package="org.apache.cxf.sdo.tools" profile="SDODatabinding" />
+    <databinding name="sdo-dynamic" package="org.apache.cxf.sdo.tools" profile="SDODatabinding" />
+    <databinding name="sdo-static" package="org.apache.cxf.sdo.tools" profile="SDODatabinding" />
+</plugin>
\ No newline at end of file

Propchange: cxf/trunk/rt/databinding/sdo/src/main/resources/META-INF/tools-plugin.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/databinding/sdo/src/main/resources/META-INF/tools-plugin.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/trunk/rt/databinding/sdo/src/main/resources/META-INF/tools-plugin.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cxf/trunk/rt/databinding/sdo/src/test/java/org/apache/cxf/sdo/AbstractSDOTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/sdo/src/test/java/org/apache/cxf/sdo/AbstractSDOTest.java?rev=796024&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/sdo/src/test/java/org/apache/cxf/sdo/AbstractSDOTest.java (added)
+++ cxf/trunk/rt/databinding/sdo/src/test/java/org/apache/cxf/sdo/AbstractSDOTest.java Mon Jul 20 21:28:04 2009
@@ -0,0 +1,214 @@
+/**
+ * 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.cxf.sdo;
+
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Import;
+import javax.wsdl.WSDLException;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLWriter;
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusException;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.binding.BindingFactoryManager;
+import org.apache.cxf.binding.soap.SoapBindingFactory;
+import org.apache.cxf.binding.soap.SoapTransportFactory;
+import org.apache.cxf.bus.extension.ExtensionManagerBus;
+import org.apache.cxf.common.util.SOAPConstants;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.endpoint.ServerRegistry;
+import org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory;
+import org.apache.cxf.frontend.ServerFactoryBean;
+import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.test.AbstractCXFTest;
+import org.apache.cxf.transport.ConduitInitiatorManager;
+import org.apache.cxf.transport.DestinationFactoryManager;
+import org.apache.cxf.transport.local.LocalTransportFactory;
+import org.apache.cxf.wsdl.WSDLManager;
+import org.apache.cxf.wsdl11.ServiceWSDLBuilder;
+import org.apache.cxf.wsdl11.WSDLDefinitionBuilder;
+import org.apache.cxf.wsdl11.WSDLManagerImpl;
+import org.junit.Before;
+
+public abstract class AbstractSDOTest extends AbstractCXFTest {
+    protected LocalTransportFactory localTransport;
+
+
+    @Before
+    public void setUp() throws Exception {
+        super.setUpBus();
+        
+        SoapBindingFactory bindingFactory = new SoapBindingFactory();
+        bindingFactory.setBus(bus);
+
+        bus.getExtension(BindingFactoryManager.class)
+            .registerBindingFactory("http://schemas.xmlsoap.org/wsdl/soap/", bindingFactory);
+
+        DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
+
+        SoapTransportFactory soapDF = new SoapTransportFactory();
+        soapDF.setBus(bus);
+        dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/", soapDF);
+        dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/", soapDF);
+        dfm.registerDestinationFactory("http://cxf.apache.org/transports/local", soapDF);
+        
+        localTransport = new LocalTransportFactory();
+        dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/http", localTransport);
+        dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/http", localTransport);
+        dfm.registerDestinationFactory("http://cxf.apache.org/bindings/xformat", localTransport);
+        dfm.registerDestinationFactory("http://cxf.apache.org/transports/local", localTransport);
+
+        ConduitInitiatorManager extension = bus.getExtension(ConduitInitiatorManager.class);
+        extension.registerConduitInitiator(LocalTransportFactory.TRANSPORT_ID, localTransport);
+        extension.registerConduitInitiator("http://schemas.xmlsoap.org/wsdl/soap/", localTransport);
+        extension.registerConduitInitiator("http://schemas.xmlsoap.org/soap/http", localTransport);
+        extension.registerConduitInitiator("http://schemas.xmlsoap.org/soap/", localTransport);
+        
+        bus.setExtension(new WSDLManagerImpl(), WSDLManager.class);
+        
+
+        addNamespace("wsdl", SOAPConstants.WSDL11_NS);
+        addNamespace("wsdlsoap", SOAPConstants.WSDL11_SOAP_NS);
+        addNamespace("xsd", SOAPConstants.XSD);
+    }
+
+    @Override
+    protected Bus createBus() throws BusException {
+        ExtensionManagerBus bus = new ExtensionManagerBus();
+        BusFactory.setDefaultBus(bus);
+        return bus;
+    }
+    
+    protected Node invoke(String service, String message) throws Exception {
+        return invoke("local://" + service, LocalTransportFactory.TRANSPORT_ID, message);
+    }
+    protected Node invoke(String service, byte[] message) throws Exception {
+        return invoke("local://" + service, LocalTransportFactory.TRANSPORT_ID, message);
+    }
+    
+    public Server createService(Class serviceClass, QName name) {
+        return createService(serviceClass, null, name);
+    }
+    
+    public Server createService(Class serviceClass, Object serviceBean, QName name) {
+        return createService(serviceClass, serviceBean, serviceClass.getSimpleName(), name);
+    }
+    
+    protected Server createService(Class serviceClass, QName name, SDODataBinding binding) {
+        return createService(serviceClass, serviceClass.getSimpleName(), name, binding);
+    }
+
+    protected Server createService(Class serviceClass, 
+                                   String address, QName name, 
+                                   SDODataBinding binding) {
+        ServerFactoryBean sf = createServiceFactory(serviceClass, null, address, name, binding);
+        return sf.create();
+    }
+    
+    public Server createService(Class serviceClass,
+                                Object serviceBean, 
+                                String address,
+                                QName name) {
+        ServerFactoryBean sf = createServiceFactory(serviceClass, serviceBean, address, name, null);
+        return sf.create();
+    }
+
+    protected ServerFactoryBean createServiceFactory(Class serviceClass, 
+                                                     Object serviceBean, 
+                                                     String address, 
+                                                     QName name,
+                                                     SDODataBinding binding) {
+        JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
+        sf.setServiceClass(serviceClass);
+        if (serviceBean != null) {
+            sf.setServiceBean(serviceBean);
+        }    
+        sf.getServiceFactory().setServiceName(name);
+        sf.setAddress("local://" + address);
+        sf.getServiceFactory().setQualifyWrapperSchema(true);
+        setupSDO(sf, binding);
+        return sf;
+    }
+    protected void setupSDO(AbstractWSDLBasedEndpointFactory sf) { 
+        setupSDO(sf, null);
+    }
+    protected void setupSDO(AbstractWSDLBasedEndpointFactory sf, SDODataBinding binding) {
+        if (binding == null) {
+            binding = new SDODataBinding();
+        }
+        sf.getServiceFactory().setDataBinding(binding);
+    }
+
+    protected Collection<Document> getWSDLDocuments(String string) throws WSDLException {
+        WSDLWriter writer = WSDLFactory.newInstance().newWSDLWriter();        
+
+        Collection<Document> docs = new ArrayList<Document>();
+        Definition definition = getWSDLDefinition(string);
+        if (definition == null) {
+            return null;
+        }
+        docs.add(writer.getDocument(definition));
+        
+        for (Import wsdlImport : WSDLDefinitionBuilder.getImports(definition)) {
+            docs.add(writer.getDocument(wsdlImport.getDefinition()));
+        }
+        return docs;
+    }
+
+    protected Definition getWSDLDefinition(String string) throws WSDLException {
+        ServerRegistry svrMan = getBus().getExtension(ServerRegistry.class);
+        for (Server s : svrMan.getServers()) {
+            Service svc = s.getEndpoint().getService();
+            if (svc.getName().getLocalPart().equals(string)) {
+                ServiceWSDLBuilder builder = new ServiceWSDLBuilder(bus, svc.getServiceInfos());
+                return builder.build();
+            }
+        }
+        String localString = "local://" + string;
+        for (Server s : svrMan.getServers()) {
+            String s2 = s.getDestination().getAddress().getAddress().getValue();
+            if (localString.equals(s2)) {
+                Service svc = s.getEndpoint().getService();
+                ServiceWSDLBuilder builder = new ServiceWSDLBuilder(bus, svc.getServiceInfos());
+                return builder.build();
+            }
+        }
+        return null;
+        
+    }
+    
+    protected Document getWSDLDocument(String string) throws WSDLException {
+        Definition definition = getWSDLDefinition(string);
+        if (definition == null) {
+            return null;
+        }
+        WSDLWriter writer = WSDLFactory.newInstance().newWSDLWriter();
+        return writer.getDocument(definition);
+    }
+}

Propchange: cxf/trunk/rt/databinding/sdo/src/test/java/org/apache/cxf/sdo/AbstractSDOTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/databinding/sdo/src/test/java/org/apache/cxf/sdo/AbstractSDOTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/rt/databinding/sdo/src/test/java/org/apache/cxf/sdo/HelloWorldStaticTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/sdo/src/test/java/org/apache/cxf/sdo/HelloWorldStaticTest.java?rev=796024&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/sdo/src/test/java/org/apache/cxf/sdo/HelloWorldStaticTest.java (added)
+++ cxf/trunk/rt/databinding/sdo/src/test/java/org/apache/cxf/sdo/HelloWorldStaticTest.java Mon Jul 20 21:28:04 2009
@@ -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.
+ */
+
+package org.apache.cxf.sdo;
+
+import java.io.File;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+import javax.jws.WebService;
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Node;
+
+import org.apache.cxf.frontend.ServerFactoryBean;
+import org.apache.cxf.helpers.FileUtils;
+import org.apache.cxf.tools.wsdlto.WSDLToJava;
+
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * 
+ */
+public class HelloWorldStaticTest extends AbstractSDOTest {
+    static ClassLoader loader;
+    static File output;
+
+    @AfterClass
+    public static void removeTempStuff() {
+        FileUtils.removeDir(output);
+        output = null;
+    }
+
+    @BeforeClass 
+    public static void generateClasses() throws Exception {
+        URL url = HelloWorldStaticTest.class.getResource(".");
+        output = new File(url.toURI());
+        output = new File(output, "/generated");
+        FileUtils.mkDir(output);
+
+        
+        url = HelloWorldStaticTest.class.getResource("/wsdl_sdo/HelloService.wsdl");
+        String args[] =
+            new String[] {"-db", "sdo", "-compile", "-d", output.getAbsolutePath(), "-p",
+                          "http://apache.org/hello_world_soap_http/types=helloworld.sdo", "-p",
+                          "http://apache.org/hello_world_soap_http=helloworld.ws", url.toString()};
+        WSDLToJava.main(args);
+        loader = new URLClassLoader(new URL[] {output.toURL()});
+    }
+    @Before 
+    public void setUp() throws Exception {
+        super.setUp();
+        ClassLoader orig = Thread.currentThread().getContextClassLoader();
+        try {
+            Thread.currentThread().setContextClassLoader(loader);
+            createService(Server.class, new Server(), "TestService", null);
+        } finally {
+            Thread.currentThread().setContextClassLoader(orig);
+        }
+    }
+    
+    
+    @WebService(targetNamespace = "http://apache.org/hello_world_soap_http",
+                name = "Greeter",
+                serviceName = "TestService",
+                endpointInterface = "helloworld.ws.Greeter")
+    public static class Server {
+        public java.lang.String sayHi() {
+            return "Hi!";
+        }
+
+        public void pingMe() {
+        }
+
+        public void greetMeOneWay(String s) {
+        }
+
+        public java.lang.String greetMe(String s) {
+            return "Hello " + s;            
+        }
+    }
+    
+    
+    protected ServerFactoryBean createServiceFactory(Class serviceClass, 
+                                                     Object serviceBean, 
+                                                     String address, 
+                                                     QName name,
+                                                     SDODataBinding binding) {
+        ServerFactoryBean sf = super.createServiceFactory(serviceClass, serviceBean, address, name, binding);
+        sf.setWsdlLocation(HelloWorldStaticTest.class.getResource("/wsdl_sdo/HelloService.wsdl").toString());
+        sf.setServiceName(new QName("http://apache.org/hello_world_soap_http", "SOAPService"));
+        sf.setEndpointName(new QName("http://apache.org/hello_world_soap_http", "SoapPort"));
+        return sf;
+    }
+    
+    @Test
+    public void testBasicInvoke() throws Exception {
+        Node response = invoke("TestService", "bean11.xml");
+        addNamespace("ns1", "http://apache.org/hello_world_soap_http/types");
+        assertValid("/s:Envelope/s:Body/ns1:greetMeResponse", response);
+        assertValid("//ns1:greetMeResponse/ns1:responseType", response);
+        assertValid("//ns1:greetMeResponse/ns1:responseType[text()='Hello World']", response);
+    }
+    
+    @Test
+    public void testWSDL() throws Exception {
+        Node doc = getWSDLDocument("TestService");
+        assertNotNull(doc);
+        assertValid("/wsdl:definitions/wsdl:types/xsd:schema"
+                    + "[@targetNamespace='http://apache.org/hello_world_soap_http/types']", 
+                    doc);
+    }
+}

Propchange: cxf/trunk/rt/databinding/sdo/src/test/java/org/apache/cxf/sdo/HelloWorldStaticTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/databinding/sdo/src/test/java/org/apache/cxf/sdo/HelloWorldStaticTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/rt/databinding/sdo/src/test/java/org/apache/cxf/sdo/bean11.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/sdo/src/test/java/org/apache/cxf/sdo/bean11.xml?rev=796024&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/sdo/src/test/java/org/apache/cxf/sdo/bean11.xml (added)
+++ cxf/trunk/rt/databinding/sdo/src/test/java/org/apache/cxf/sdo/bean11.xml Mon Jul 20 21:28:04 2009
@@ -0,0 +1,8 @@
+<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
+ <env:Header/>
+ <env:Body>
+  <ns1:greetMe xmlns:ns1="http://apache.org/hello_world_soap_http/types">
+  	<ns1:requestType>World</ns1:requestType>
+  </ns1:greetMe>
+ </env:Body>
+</env:Envelope>
\ No newline at end of file

Propchange: cxf/trunk/rt/databinding/sdo/src/test/java/org/apache/cxf/sdo/bean11.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/databinding/sdo/src/test/java/org/apache/cxf/sdo/bean11.xml
------------------------------------------------------------------------------
    svn:executable = *

Propchange: cxf/trunk/rt/databinding/sdo/src/test/java/org/apache/cxf/sdo/bean11.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/trunk/rt/databinding/sdo/src/test/java/org/apache/cxf/sdo/bean11.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cxf/trunk/rt/databinding/sdo/src/test/resources/wsdl_sdo/HelloService.wsdl
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/sdo/src/test/resources/wsdl_sdo/HelloService.wsdl?rev=796024&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/sdo/src/test/resources/wsdl_sdo/HelloService.wsdl (added)
+++ cxf/trunk/rt/databinding/sdo/src/test/resources/wsdl_sdo/HelloService.wsdl Mon Jul 20 21:28:04 2009
@@ -0,0 +1,174 @@
+<?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.
+ -->      
+<wsdl:definitions name="HelloWorld" targetNamespace="http://apache.org/hello_world_soap_http" xmlns="http://schemas.xmlsoap.org/wsdl/"
+    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://apache.org/hello_world_soap_http" xmlns:x1="http://apache.org/hello_world_soap_http/types"
+    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+    <wsdl:types>
+        <schema targetNamespace="http://apache.org/hello_world_soap_http/types" xmlns="http://www.w3.org/2001/XMLSchema"
+            xmlns:tns="http://apache.org/hello_world_soap_http/types" elementFormDefault="qualified">
+            <simpleType name="MyStringType">
+                <restriction base="string">
+                    <maxLength value="30" />
+                </restriction>
+            </simpleType>
+
+            <element name="sayHi">
+                <complexType />
+            </element>
+            <element name="sayHiResponse">
+                <complexType>
+                    <sequence>
+                        <element name="responseType" type="string" />
+                    </sequence>
+                </complexType>
+            </element>
+            <element name="greetMe">
+                <complexType>
+                    <sequence>
+                        <element name="requestType" type="tns:MyStringType" />
+                    </sequence>
+                </complexType>
+            </element>
+            <element name="greetMeResponse">
+                <complexType>
+                    <sequence>
+                        <element name="responseType" type="string" />
+                    </sequence>
+                </complexType>
+            </element>
+            <element name="greetMeOneWay">
+                <complexType>
+                    <sequence>
+                        <element name="requestType" type="string" />
+                    </sequence>
+                </complexType>
+            </element>
+            <element name="pingMe">
+                <complexType />
+            </element>
+            <element name="pingMeResponse">
+                <complexType />
+            </element>
+            <element name="faultDetail">
+                <complexType>
+                    <sequence>
+                        <element name="minor" type="short" />
+                        <element name="major" type="short" />
+                    </sequence>
+                </complexType>
+            </element>
+        </schema>
+    </wsdl:types>
+    <wsdl:message name="sayHiRequest">
+        <wsdl:part element="x1:sayHi" name="in" />
+    </wsdl:message>
+    <wsdl:message name="sayHiResponse">
+        <wsdl:part element="x1:sayHiResponse" name="out" />
+    </wsdl:message>
+    <wsdl:message name="greetMeRequest">
+        <wsdl:part element="x1:greetMe" name="in" />
+    </wsdl:message>
+    <wsdl:message name="greetMeResponse">
+        <wsdl:part element="x1:greetMeResponse" name="out" />
+    </wsdl:message>
+    <wsdl:message name="greetMeOneWayRequest">
+        <wsdl:part element="x1:greetMeOneWay" name="in" />
+    </wsdl:message>
+    <wsdl:message name="pingMeRequest">
+        <wsdl:part name="in" element="x1:pingMe" />
+    </wsdl:message>
+    <wsdl:message name="pingMeResponse">
+        <wsdl:part name="out" element="x1:pingMeResponse" />
+    </wsdl:message>
+    <wsdl:message name="pingMeFault">
+        <wsdl:part name="faultDetail" element="x1:faultDetail" />
+    </wsdl:message>
+
+    <wsdl:portType name="Greeter">
+        <wsdl:operation name="sayHi">
+            <wsdl:input message="tns:sayHiRequest" name="sayHiRequest" />
+            <wsdl:output message="tns:sayHiResponse" name="sayHiResponse" />
+        </wsdl:operation>
+
+        <wsdl:operation name="greetMe">
+            <wsdl:input message="tns:greetMeRequest" name="greetMeRequest" />
+            <wsdl:output message="tns:greetMeResponse" name="greetMeResponse" />
+        </wsdl:operation>
+
+        <wsdl:operation name="greetMeOneWay">
+            <wsdl:input message="tns:greetMeOneWayRequest" name="greetMeOneWayRequest" />
+        </wsdl:operation>
+
+        <wsdl:operation name="pingMe">
+            <wsdl:input name="pingMeRequest" message="tns:pingMeRequest" />
+            <wsdl:output name="pingMeResponse" message="tns:pingMeResponse" />
+            <wsdl:fault name="pingMeFault" message="tns:pingMeFault" />
+        </wsdl:operation>
+    </wsdl:portType>
+    <wsdl:binding name="Greeter_SOAPBinding" type="tns:Greeter">
+        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
+
+        <wsdl:operation name="sayHi">
+            <soap:operation soapAction="" style="document" />
+            <wsdl:input name="sayHiRequest">
+                <soap:body use="literal" />
+            </wsdl:input>
+            <wsdl:output name="sayHiResponse">
+                <soap:body use="literal" />
+            </wsdl:output>
+        </wsdl:operation>
+
+        <wsdl:operation name="greetMe">
+            <soap:operation soapAction="" style="document" />
+            <wsdl:input name="greetMeRequest">
+                <soap:body use="literal" />
+            </wsdl:input>
+            <wsdl:output name="greetMeResponse">
+                <soap:body use="literal" />
+            </wsdl:output>
+        </wsdl:operation>
+
+        <wsdl:operation name="greetMeOneWay">
+            <soap:operation soapAction="" style="document" />
+            <wsdl:input name="greetMeOneWayRequest">
+                <soap:body use="literal" />
+            </wsdl:input>
+        </wsdl:operation>
+
+        <wsdl:operation name="pingMe">
+            <soap:operation style="document" />
+            <wsdl:input>
+                <soap:body use="literal" />
+            </wsdl:input>
+            <wsdl:output>
+                <soap:body use="literal" />
+            </wsdl:output>
+            <wsdl:fault name="pingMeFault">
+                <soap:fault name="pingMeFault" use="literal" />
+            </wsdl:fault>
+        </wsdl:operation>
+
+    </wsdl:binding>
+    <wsdl:service name="SOAPService">
+        <wsdl:port binding="tns:Greeter_SOAPBinding" name="SoapPort">
+            <soap:address location="http://localhost:9000/SoapContext/SoapPort" />
+        </wsdl:port>
+    </wsdl:service>
+</wsdl:definitions>

Propchange: cxf/trunk/rt/databinding/sdo/src/test/resources/wsdl_sdo/HelloService.wsdl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/databinding/sdo/src/test/resources/wsdl_sdo/HelloService.wsdl
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/trunk/rt/databinding/sdo/src/test/resources/wsdl_sdo/HelloService.wsdl
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message