cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r631828 - in /incubator/cxf/trunk: common/common/src/main/java/org/apache/cxf/jaxb/ distribution/src/main/release/samples/java_first_jaxws/src/demo/hw/client/ distribution/src/main/release/samples/java_first_jaxws/src/demo/hw/server/ rt/dat...
Date Thu, 28 Feb 2008 03:25:41 GMT
Author: dkulp
Date: Wed Feb 27 19:25:39 2008
New Revision: 631828

URL: http://svn.apache.org/viewvc?rev=631828&view=rev
Log:
Update to add a test case and a sample that shows passing an interface through a service method.

Added:
    incubator/cxf/trunk/distribution/src/main/release/samples/java_first_jaxws/src/demo/hw/server/User.java
  (with props)
    incubator/cxf/trunk/distribution/src/main/release/samples/java_first_jaxws/src/demo/hw/server/UserAdapter.java
  (with props)
    incubator/cxf/trunk/distribution/src/main/release/samples/java_first_jaxws/src/demo/hw/server/UserImpl.java
  (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/types/
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/types/Bar.java
  (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/types/BarAdapter.java
  (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/types/BarImpl.java
  (with props)
Modified:
    incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java
    incubator/cxf/trunk/distribution/src/main/release/samples/java_first_jaxws/src/demo/hw/client/Client.java
    incubator/cxf/trunk/distribution/src/main/release/samples/java_first_jaxws/src/demo/hw/server/HelloWorld.java
    incubator/cxf/trunk/distribution/src/main/release/samples/java_first_jaxws/src/demo/hw/server/HelloWorldImpl.java
    incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
    incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
    incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
    incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
    incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java
    incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataWriterImpl.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstService.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstServiceImpl.java

Modified: incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java?rev=631828&r1=631827&r2=631828&view=diff
==============================================================================
--- incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java (original)
+++ incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java Wed
Feb 27 19:25:39 2008
@@ -456,8 +456,10 @@
 
         if (cls == Object.class || cls == String.class || cls == Holder.class) {
             cls = null;
-        } else if (cls.isPrimitive() || cls.isInterface() || cls.isAnnotation()) {
+        } else if (cls.isPrimitive() || cls.isAnnotation()) {
             cls = null;
+        } else if (cls.isInterface()) {
+            return cls;
         }
         if (cls != null) {
             if (cls.getName().equals("javax.xml.ws.wsaddressing.W3CEndpointReference")) {

Modified: incubator/cxf/trunk/distribution/src/main/release/samples/java_first_jaxws/src/demo/hw/client/Client.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/java_first_jaxws/src/demo/hw/client/Client.java?rev=631828&r1=631827&r2=631828&view=diff
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/java_first_jaxws/src/demo/hw/client/Client.java
(original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/java_first_jaxws/src/demo/hw/client/Client.java
Wed Feb 27 19:25:39 2008
@@ -24,6 +24,8 @@
 import javax.xml.ws.soap.SOAPBinding;
 
 import demo.hw.server.HelloWorld;
+import demo.hw.server.User;
+import demo.hw.server.UserImpl;
 
 public final class Client {
 
@@ -47,6 +49,8 @@
         HelloWorld hw = service.getPort(HelloWorld.class);
         System.out.println(hw.sayHi("World"));
 
+        User user = new UserImpl("World");
+        System.out.println(hw.sayHiToUser(user));
     }
 
 }

Modified: incubator/cxf/trunk/distribution/src/main/release/samples/java_first_jaxws/src/demo/hw/server/HelloWorld.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/java_first_jaxws/src/demo/hw/server/HelloWorld.java?rev=631828&r1=631827&r2=631828&view=diff
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/java_first_jaxws/src/demo/hw/server/HelloWorld.java
(original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/java_first_jaxws/src/demo/hw/server/HelloWorld.java
Wed Feb 27 19:25:39 2008
@@ -16,13 +16,20 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-// START SNIPPET: service
 package demo.hw.server;
 
 import javax.jws.WebService;
 
 @WebService
 public interface HelloWorld {
+
     String sayHi(String text);
+
+
+    /* Advanced usecase of passing an Interface in.  JAX-WS/JAXB does not
+     * support interfaces directly.  Special XmlAdapter classes need to
+     * be written to handle them
+     */
+    String sayHiToUser(User user);
 }
 // END SNIPPET: service

Modified: incubator/cxf/trunk/distribution/src/main/release/samples/java_first_jaxws/src/demo/hw/server/HelloWorldImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/java_first_jaxws/src/demo/hw/server/HelloWorldImpl.java?rev=631828&r1=631827&r2=631828&view=diff
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/java_first_jaxws/src/demo/hw/server/HelloWorldImpl.java
(original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/java_first_jaxws/src/demo/hw/server/HelloWorldImpl.java
Wed Feb 27 19:25:39 2008
@@ -28,5 +28,10 @@
     public String sayHi(String text) {
         return "Hello " + text;
     }
+
+    public String sayHiToUser(User user) {
+        return "Hello "  + user.getName();
+    }
+
 }
 // END SNIPPET: service

Added: incubator/cxf/trunk/distribution/src/main/release/samples/java_first_jaxws/src/demo/hw/server/User.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/java_first_jaxws/src/demo/hw/server/User.java?rev=631828&view=auto
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/java_first_jaxws/src/demo/hw/server/User.java
(added)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/java_first_jaxws/src/demo/hw/server/User.java
Wed Feb 27 19:25:39 2008
@@ -0,0 +1,27 @@
+/**
+ * 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 demo.hw.server;
+
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+@XmlJavaTypeAdapter(UserAdapter.class)
+public interface User {
+
+    public String getName();
+}

Propchange: incubator/cxf/trunk/distribution/src/main/release/samples/java_first_jaxws/src/demo/hw/server/User.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/distribution/src/main/release/samples/java_first_jaxws/src/demo/hw/server/User.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/distribution/src/main/release/samples/java_first_jaxws/src/demo/hw/server/UserAdapter.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/java_first_jaxws/src/demo/hw/server/UserAdapter.java?rev=631828&view=auto
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/java_first_jaxws/src/demo/hw/server/UserAdapter.java
(added)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/java_first_jaxws/src/demo/hw/server/UserAdapter.java
Wed Feb 27 19:25:39 2008
@@ -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 demo.hw.server;
+
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
+
+public class UserAdapter extends XmlAdapter<UserImpl, User> {
+    public UserImpl marshal(User v) throws Exception {
+        if (v instanceof UserImpl) {
+            return (UserImpl)v;
+        }
+        return new UserImpl(v.getName());
+    }
+
+    public User unmarshal(UserImpl v) throws Exception {
+        return v;
+    }
+}
+

Propchange: incubator/cxf/trunk/distribution/src/main/release/samples/java_first_jaxws/src/demo/hw/server/UserAdapter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/distribution/src/main/release/samples/java_first_jaxws/src/demo/hw/server/UserAdapter.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/distribution/src/main/release/samples/java_first_jaxws/src/demo/hw/server/UserImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/java_first_jaxws/src/demo/hw/server/UserImpl.java?rev=631828&view=auto
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/java_first_jaxws/src/demo/hw/server/UserImpl.java
(added)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/java_first_jaxws/src/demo/hw/server/UserImpl.java
Wed Feb 27 19:25:39 2008
@@ -0,0 +1,41 @@
+/**
+ * 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 demo.hw.server;
+
+import javax.xml.bind.annotation.XmlType;
+
+
+@XmlType(name = "User")
+public class UserImpl implements User {
+    String name;
+
+    public UserImpl() {
+    }
+    public UserImpl(String s) {
+        name = s;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String s) {
+        name = s;
+    }
+}

Propchange: incubator/cxf/trunk/distribution/src/main/release/samples/java_first_jaxws/src/demo/hw/server/UserImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/distribution/src/main/release/samples/java_first_jaxws/src/demo/hw/server/UserImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java?rev=631828&r1=631827&r2=631828&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
(original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
Wed Feb 27 19:25:39 2008
@@ -33,7 +33,10 @@
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlSeeAlso;
 import javax.xml.bind.annotation.XmlTransient;
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 
 import org.apache.cxf.service.ServiceModelVisitor;
 import org.apache.cxf.service.model.MessageInfo;
@@ -91,8 +94,9 @@
             clazz = clazz.getComponentType();
         }
         
-        
-            
+        Annotation[] a = (Annotation[])part.getProperty("parameter.annotations");
+        checkForAdapter(clazz, a);
+
         Type genericType = (Type) part.getProperty("generic.type");
         if (genericType != null) {
             boolean isList = Collection.class.isAssignableFrom(clazz);
@@ -147,6 +151,21 @@
         }
     }
 
+    private void checkForAdapter(Class<?> clazz, Annotation[] anns) {
+        if (anns != null) {
+            for (Annotation a : anns) {
+                if (XmlJavaTypeAdapter.class.isAssignableFrom(a.annotationType())) {
+                    inspectTypeAdapter(((XmlJavaTypeAdapter)a).value());
+                }
+            }
+        }
+        XmlJavaTypeAdapter xjta = clazz.getAnnotation(XmlJavaTypeAdapter.class);
+        if (xjta != null) {
+            inspectTypeAdapter(xjta.value());
+        }
+        
+    }
+
     private void addType(Type cls) {
         addType(cls, false);
     }
@@ -184,20 +203,46 @@
         } else {
             cls = JAXBUtils.getValidClass(cls);
             if (null != cls) {
-                if (classes.contains(cls)) {
+                if (cls.isInterface()) {
+                    //interfaces cannot be added directly, however, they
+                    //may have some interesting annoations we should consider
+                    XmlSeeAlso xsa = cls.getAnnotation(XmlSeeAlso.class);
+                    if (xsa != null) {
+                        for (Class c : xsa.value()) {
+                            addClass(c);
+                        }
+                    }
+                    XmlJavaTypeAdapter xjta = cls.getAnnotation(XmlJavaTypeAdapter.class);
+                    if (xjta != null) {
+                        Class<? extends XmlAdapter> c2 = xjta.value();
+                        inspectTypeAdapter(c2);
+                    }
+                } else if (classes.contains(cls)) {
                     return;
-                }
-                if (cls.isEnum()) {
-                    // The object factory stuff doesn't work for enums
+                } else {
                     classes.add(cls);
+                    walkReferences(cls);
                 }
-                classes.add(cls);
-                walkReferences(cls);
             }
         }
     }
 
+    private void inspectTypeAdapter(Class<? extends XmlAdapter> aclass) {
+        Class<?> c2 = aclass;
+        Type sp = c2.getGenericSuperclass();
+        while (!XmlAdapter.class.equals(c2) && c2 != null) {
+            sp = c2.getGenericSuperclass();
+            c2 = c2.getSuperclass();
+        }
+        if (sp instanceof ParameterizedType) {
+            addType(((ParameterizedType)sp).getActualTypeArguments()[0]);
+        }
+    }
+
     private void walkReferences(Class<?> cls) {
+        if (cls == null) {
+            return;
+        }
         if (cls.getName().startsWith("java.")
             || cls.getName().startsWith("javax.")) {
             return;

Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java?rev=631828&r1=631827&r2=631828&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
(original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
Wed Feb 27 19:25:39 2008
@@ -167,21 +167,23 @@
         Integer mtomThresholdInt = new Integer(getMtomThreshold());
         if (c == XMLStreamWriter.class) {
             DataWriterImpl<XMLStreamWriter> r = 
-                new DataWriterImpl<XMLStreamWriter>(context, currentMarshallerProperties);
+                new DataWriterImpl<XMLStreamWriter>(context, currentMarshallerProperties,
contextClasses);
             r.setMtomThreshold(mtomThresholdInt);
             return (DataWriter<T>)r;
         } else if (c == OutputStream.class) {
             DataWriterImpl<OutputStream> r = 
-                new DataWriterImpl<OutputStream>(context, currentMarshallerProperties);
+                new DataWriterImpl<OutputStream>(context, currentMarshallerProperties,
contextClasses);
             r.setMtomThreshold(mtomThresholdInt);
             return (DataWriter<T>)r;    
         } else if (c == XMLEventWriter.class) {
             DataWriterImpl<XMLEventWriter> r = new DataWriterImpl<XMLEventWriter>(context,
-                currentMarshallerProperties);
+                currentMarshallerProperties, contextClasses);
             r.setMtomThreshold(mtomThresholdInt);
             return (DataWriter<T>)r;        
         } else if (c == Node.class) {
-            DataWriterImpl<Node> r = new DataWriterImpl<Node>(context, currentMarshallerProperties);
+            DataWriterImpl<Node> r = new DataWriterImpl<Node>(context, 
+                    currentMarshallerProperties,
+                    contextClasses);
             r.setMtomThreshold(mtomThresholdInt);
             return (DataWriter<T>)r;      
         }
@@ -196,11 +198,11 @@
     public <T> DataReader<T> createReader(Class<T> c) {
         DataReader<T> dr = null;
         if (c == XMLStreamReader.class) {
-            dr = (DataReader<T>)new DataReaderImpl<XMLStreamReader>(context);
+            dr = (DataReader<T>)new DataReaderImpl<XMLStreamReader>(context,
contextClasses);
         } else if (c == XMLEventReader.class) {
-            dr = (DataReader<T>)new DataReaderImpl<XMLEventReader>(context);
+            dr = (DataReader<T>)new DataReaderImpl<XMLEventReader>(context, contextClasses);
         } else if (c == Node.class) {
-            dr = (DataReader<T>)new DataReaderImpl<Node>(context);
+            dr = (DataReader<T>)new DataReaderImpl<Node>(context, contextClasses);
         }
         
         return dr;

Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java?rev=631828&r1=631827&r2=631828&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
(original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
Wed Feb 27 19:25:39 2008
@@ -35,7 +35,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.ResourceBundle;
-import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.Set;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -213,12 +213,16 @@
     }
     //TODO: cache the JAXBRIContext
     @SuppressWarnings("unchecked")
-    public static void marshalWithBridge(TypeReference ref, Object elValue,
+    public static void marshalWithBridge(TypeReference ref,
+                                         Set<Class<?>> ctxClasses,
+                                         Object elValue,
                                          Object source, AttachmentMarshaller am) {
-        List<TypeReference> typeRefs = new CopyOnWriteArrayList<TypeReference>();
+        List<TypeReference> typeRefs = new ArrayList<TypeReference>();
         typeRefs.add(ref);
+        List<Class<?>> clses = new ArrayList<Class<?>>(ctxClasses);
+        clses.add(ref.type.getClass());
         try {
-            JAXBRIContext riContext = JAXBRIContext.newInstance(new Class[] {ref.type.getClass()},
+            JAXBRIContext riContext = JAXBRIContext.newInstance(clses.toArray(new Class[clses.size()]),
                                                                     typeRefs, null, null,
true, null);
             Bridge bridge = riContext.createBridge(ref);
 
@@ -252,11 +256,16 @@
     
 //  TODO: cache the JAXBRIContext
     @SuppressWarnings("unchecked")
-    public static Object unmarshalWithBridge(TypeReference ref, Object source, AttachmentUnmarshaller
am) {
-        List<TypeReference> typeRefs = new CopyOnWriteArrayList<TypeReference>();
+    public static Object unmarshalWithBridge(TypeReference ref,
+                                             Set<Class<?>> ctxClasses,
+                                             Object source,
+                                             AttachmentUnmarshaller am) {
+        List<TypeReference> typeRefs = new ArrayList<TypeReference>();
         typeRefs.add(ref);
+        List<Class<?>> clses = new ArrayList<Class<?>>(ctxClasses);
+        clses.add(ref.type.getClass());
         try {
-            JAXBRIContext riContext = JAXBRIContext.newInstance(new Class[] {ref.type.getClass()},
+            JAXBRIContext riContext = JAXBRIContext.newInstance(clses.toArray(new Class[clses.size()]),
                                                                     typeRefs, null, null,
true, null);
             Bridge bridge = riContext.createBridge(ref);
            

Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java?rev=631828&r1=631827&r2=631828&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
(original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
Wed Feb 27 19:25:39 2008
@@ -19,13 +19,18 @@
 
 package org.apache.cxf.jaxb;
 
+import java.lang.annotation.Annotation;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
 import java.util.Iterator;
 import java.util.logging.Logger;
 
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 import javax.xml.namespace.QName;
 
 import com.sun.xml.bind.v2.runtime.JAXBContextImpl;
@@ -90,6 +95,31 @@
 
         JaxBeanInfo<?> beanInfo = context.getBeanInfo(clazz);
         if (beanInfo == null) {
+            Annotation[] anns = (Annotation[])part.getProperty("parameter.annotations");
+            XmlJavaTypeAdapter jta = findFromTypeAdapter(clazz, anns);
+            if (jta != null) {
+                beanInfo = findFromTypeAdapter(jta.value());
+                if (anns == null) {
+                    anns = new Annotation[] {jta};
+                } else {
+                    boolean found = false;
+                    for (Annotation t : anns) {
+                        if (t == jta) {
+                            found = true;
+                        }
+                    }
+                    if (!found) {
+                        Annotation tmp[] = new Annotation[anns.length + 1];
+                        System.arraycopy(anns, 0, tmp, 0, anns.length);
+                        tmp[anns.length] = jta;
+                        anns = tmp;
+                    }
+                }
+                part.setProperty("parameter.annotations", anns);
+                part.setProperty("honor.jaxb.annotations", Boolean.TRUE);
+            }
+        }
+        if (beanInfo == null) {
             if (Exception.class.isAssignableFrom(clazz)) {
                 QName name = (QName)part.getMessageInfo().getProperty("elementName");
                 part.setElementQName(name);
@@ -126,6 +156,44 @@
                 part.setXmlSchema(schemas.getTypeByQName(typeName));
             }
         }
+    }
+
+    private XmlJavaTypeAdapter findFromTypeAdapter(Class<?> clazz, Annotation[] anns)
{
+        JaxBeanInfo<?> ret = null;
+        if (anns != null) {
+            for (Annotation a : anns) {
+                if (XmlJavaTypeAdapter.class.isAssignableFrom(a.annotationType())) {
+                    ret = findFromTypeAdapter(((XmlJavaTypeAdapter)a).value());
+                    if (ret != null) {
+                        return (XmlJavaTypeAdapter)a;
+                    }
+                }
+            }
+        }
+        XmlJavaTypeAdapter xjta = clazz.getAnnotation(XmlJavaTypeAdapter.class);
+        if (xjta != null) {
+            ret = findFromTypeAdapter(xjta.value());
+            if (ret != null) {
+                return xjta;
+            }
+        }
+        return null;
+    }
+
+    private JaxBeanInfo<?> findFromTypeAdapter(Class<? extends XmlAdapter> aclass)
{
+        Class<?> c2 = aclass;
+        Type sp = c2.getGenericSuperclass();
+        while (!XmlAdapter.class.equals(c2) && c2 != null) {
+            sp = c2.getGenericSuperclass();
+            c2 = c2.getSuperclass();
+        }
+        if (sp instanceof ParameterizedType) {
+            Type tp = ((ParameterizedType)sp).getActualTypeArguments()[0];
+            if (tp instanceof Class) {
+                return context.getBeanInfo((Class<?>)tp);
+            }
+        }
+        return null;
     }
 
     private QName getTypeName(JaxBeanInfo<?> beanInfo) {

Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java?rev=631828&r1=631827&r2=631828&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java
(original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataReaderImpl.java
Wed Feb 27 19:25:39 2008
@@ -20,6 +20,7 @@
 package org.apache.cxf.jaxb.io;
 
 import java.lang.annotation.Annotation;
+import java.util.Set;
 
 import javax.xml.bind.JAXBContext;
 import javax.xml.namespace.QName;
@@ -32,8 +33,10 @@
 import org.apache.cxf.service.model.MessagePartInfo;
 
 public class DataReaderImpl<T> extends JAXBDataBase implements DataReader<T>
{
-    public DataReaderImpl(JAXBContext ctx) {
+    Set<Class<?>> contextClasses;
+    public DataReaderImpl(JAXBContext ctx, Set<Class<?>> contextClasses) {
         super(ctx);
+        this.contextClasses = contextClasses;
     }
 
     public Object read(T input) {
@@ -52,7 +55,9 @@
             //TODO:Cache the JAXBRIContext
             QName qname = new QName(null, part.getConcreteName().getLocalPart());
             TypeReference typeReference = new TypeReference(qname, part.getTypeClass(), anns);
-            return JAXBEncoderDecoder.unmarshalWithBridge(typeReference, reader, 
+            return JAXBEncoderDecoder.unmarshalWithBridge(typeReference, 
+                                                          contextClasses,
+                                                          reader,
                                                           getAttachmentUnmarshaller());
         }
         

Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataWriterImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataWriterImpl.java?rev=631828&r1=631827&r2=631828&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataWriterImpl.java
(original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/DataWriterImpl.java
Wed Feb 27 19:25:39 2008
@@ -22,6 +22,7 @@
 import java.lang.annotation.Annotation;
 import java.util.Collections;
 import java.util.Map;
+import java.util.Set;
 
 import javax.xml.bind.JAXBContext;
 import javax.xml.namespace.QName;
@@ -36,16 +37,20 @@
 import org.apache.ws.commons.schema.XmlSchemaElement;
 
 public class DataWriterImpl<T> extends JAXBDataBase implements DataWriter<T>
{
-    
+    private Set<Class<?>> contextClasses;
     private Map<String, Object> marshallerProperties = Collections.emptyMap();
     
-    public DataWriterImpl(JAXBContext ctx) {
+    public DataWriterImpl(JAXBContext ctx, Set<Class<?>> contextClasses) {
         super(ctx);
+        this.contextClasses = contextClasses;
     }
     
-    public DataWriterImpl(JAXBContext ctx, Map<String, Object> marshallerProperties)
{
+    public DataWriterImpl(JAXBContext ctx, 
+                          Map<String, Object> marshallerProperties,
+                          Set<Class<?>> contextClasses) {
         super(ctx);
         this.marshallerProperties = marshallerProperties;
+        this.contextClasses = contextClasses;
     }
     
     public void write(Object obj, T output) {
@@ -79,7 +84,7 @@
                     //TODO:Cache the JAXBRIContext
                     QName qname = new QName(null, part.getConcreteName().getLocalPart());
                     TypeReference typeReference = new TypeReference(qname, part.getTypeClass(),
anns);
-                    JAXBEncoderDecoder.marshalWithBridge(typeReference, obj, 
+                    JAXBEncoderDecoder.marshalWithBridge(typeReference, contextClasses, obj,

                                                          output, getAttachmentMarshaller());
                 }
             }

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java?rev=631828&r1=631827&r2=631828&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
Wed Feb 27 19:25:39 2008
@@ -341,6 +341,7 @@
         assertEquals(3, ints.length);
         assertEquals(1, ints[0]);
         
+        assertEquals("Val", port.createBar("Val").getName());
         testExceptionCases(port);
     }
     

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstService.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstService.java?rev=631828&r1=631827&r2=631828&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstService.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstService.java
Wed Feb 27 19:25:39 2008
@@ -32,6 +32,7 @@
 import javax.xml.ws.ResponseWrapper;
 
 import org.apache.cxf.message.Exchange;
+import org.apache.cxf.systest.jaxws.types.Bar;
 
 @WebService(name = "DocLitWrappedCodeFirstService",
             targetNamespace = "http://cxf.apache.org/systest/jaxws/DocLitWrappedCodeFirstService")
@@ -100,6 +101,8 @@
                           name = "String_1")
                         String msg);
 
+    Bar createBar(String val);
+    
     static class Foo  {
         String name;
         
@@ -114,4 +117,5 @@
         }
     }
     
+
 }

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstServiceImpl.java?rev=631828&r1=631827&r2=631828&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstServiceImpl.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstServiceImpl.java
Wed Feb 27 19:25:39 2008
@@ -26,6 +26,8 @@
 import javax.xml.ws.Holder;
 
 import org.apache.cxf.message.Exchange;
+import org.apache.cxf.systest.jaxws.types.Bar;
+import org.apache.cxf.systest.jaxws.types.BarImpl;
 
 @WebService(endpointInterface = "org.apache.cxf.systest.jaxws.DocLitWrappedCodeFirstService",
             serviceName = "DocLitWrappedCodeFirstService",
@@ -152,4 +154,7 @@
         return i;
     }
 
+    public Bar createBar(String val) {
+        return new BarImpl(val);
+    }
 }

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/types/Bar.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/types/Bar.java?rev=631828&view=auto
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/types/Bar.java
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/types/Bar.java
Wed Feb 27 19:25:39 2008
@@ -0,0 +1,32 @@
+/**
+ * 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.systest.jaxws.types;
+
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+/**
+ * 
+ */
+@XmlJavaTypeAdapter(BarAdapter.class)
+public interface Bar {
+    
+    String getName();
+    void setName(String s);
+}

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/types/Bar.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/types/Bar.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/types/Bar.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/types/BarAdapter.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/types/BarAdapter.java?rev=631828&view=auto
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/types/BarAdapter.java
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/types/BarAdapter.java
Wed Feb 27 19:25:39 2008
@@ -0,0 +1,33 @@
+/**
+ * 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.systest.jaxws.types;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
+
+public class BarAdapter extends XmlAdapter<BarImpl, Bar> {
+    public BarImpl marshal(Bar v) throws Exception {
+        return new BarImpl(v.getName());
+    }
+
+    public Bar unmarshal(BarImpl v) throws Exception {
+        return v;
+    }
+}
+

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/types/BarAdapter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/types/BarAdapter.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/types/BarAdapter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/types/BarImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/types/BarImpl.java?rev=631828&view=auto
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/types/BarImpl.java
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/types/BarImpl.java
Wed Feb 27 19:25:39 2008
@@ -0,0 +1,48 @@
+/**
+ * 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.systest.jaxws.types;
+
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ * 
+ */
+@XmlType(name = "bar")
+public class BarImpl implements Bar {
+    String name;
+    public BarImpl() {
+        
+    }
+    public BarImpl(String s) {
+        name = s;
+    }
+    
+    /** {@inheritDoc}*/
+    public String getName() {
+        // TODO Auto-generated method stub
+        return name;
+    }
+
+    /** {@inheritDoc}*/
+    public void setName(String s) {
+        name = s;
+    }
+
+}

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/types/BarImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/types/BarImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/types/BarImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message