You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by sc...@apache.org on 2008/05/23 00:35:43 UTC

svn commit: r659291 - in /webservices/axis2/trunk/java/modules/jaxws: src/org/apache/axis2/jaxws/message/databinding/ test/org/apache/axis2/jaxws/message/databinding/ test/org/apache/ws/jaxb/ test/org/apache/ws/jaxb/a/ test/org/apache/ws/jaxb/b/

Author: scheu
Date: Thu May 22 15:35:42 2008
New Revision: 659291

URL: http://svn.apache.org/viewvc?rev=659291&view=rev
Log:
AXIS2-3814
Contributor:Rich Scheuerle
JAXBUtils is improved to handle the scenario where JAXB and non-JAXB classes are exist in the same package.
A test is provided that validates the new code.

Added:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBContextFromClasses.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/databinding/
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/databinding/JAXBUtilsTests.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/ws/jaxb/
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/ws/jaxb/a/
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/ws/jaxb/a/BadData1.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/ws/jaxb/a/BadData2.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/ws/jaxb/a/Data1.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/ws/jaxb/a/Data2.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/ws/jaxb/a/Data3.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/ws/jaxb/b/
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/ws/jaxb/b/BadData3.java
Modified:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBUtils.java

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBContextFromClasses.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBContextFromClasses.java?rev=659291&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBContextFromClasses.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBContextFromClasses.java Thu May 22 15:35:42 2008
@@ -0,0 +1,269 @@
+/*
+ * 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.axis2.jaxws.message.databinding;
+
+import org.apache.axis2.java.security.AccessController;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.namespace.QName;
+
+import java.awt.Image;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.List;
+
+/**
+ * This class provides a utility method, newInstance, which
+ * builds a valid JAXBContext from a series of classes.
+ */
+public class JAXBContextFromClasses {
+
+    private static final Log log = LogFactory.getLog(JAXBContextFromClasses.class);
+    /**
+     * Static utility class.  Constructor is intentionally private
+     */
+    private JAXBContextFromClasses() {
+    }
+
+    /**
+     * Create a JAXBContext from the given class array and class loader.
+     * If errors occur, then the JAXBContext is created from the 
+     * minimal set of valid classes.
+     * 
+     * Note: Sometimes users will intermingle JAXB classes and other
+     * non-JAXB utility classes.  This is not a good practice, but does
+     * happen.  The purpose of this method is to try and build a valid
+     * JAXBContext from only the 'valid' classes. 
+     * 
+     * @param classArray
+     * @param cl
+     * @return JAXBContext
+     * @throws JAXBException
+     */
+    public static JAXBContext newInstance(Class[] classArray, 
+                                   ClassLoader cl) 
+        throws JAXBException {
+        JAXBContext jaxbContext = null;
+        try {
+            if (log.isDebugEnabled()) {
+                if (classArray == null || classArray.length == 0) {
+                    log.debug("JAXBContext is constructed with 0 input classes.");
+                } else {
+                    log.debug("JAXBContext is constructed with " + classArray.length +
+                            " input classes.");
+                }
+            }
+            jaxbContext = _newInstance(classArray, cl);
+        } catch (Throwable t) {
+            // Try finding the best set of classes
+            ArrayList<Class> original = new ArrayList<Class>();
+            for (int i=0; i < classArray.length; i++) {
+                original.add(classArray[i]);
+            }
+            ArrayList<Class> best = new ArrayList<Class>();
+            jaxbContext = findBestSet(original, cl, best);
+            
+        }
+
+        return jaxbContext;
+    }
+    
+    /**
+     * Utility method that creates a JAXBContext from the 
+     * class[] and ClassLoader.
+     * 
+     * @param classArray
+     * @param cl
+     * @return JAXBContext
+     * @throws Throwable
+     */
+    private static JAXBContext _newInstance(final Class[] classArray, 
+                                           final ClassLoader cl) 
+        throws Throwable {
+        JAXBContext jaxbContext;
+        try {
+            jaxbContext = (JAXBContext)AccessController.doPrivileged(
+               new PrivilegedExceptionAction() {
+                   public Object run() throws JAXBException {
+                       // Unlike the JAXBContext.newInstance(Class[]) method
+                       // does now accept a classloader.  To workaround this
+                       // issue, the classloader is temporarily changed to cl
+                       Thread currentThread = Thread.currentThread();
+                       ClassLoader savedClassLoader = currentThread.getContextClassLoader();
+                       try {
+                           currentThread.setContextClassLoader(cl);
+                           return JAXBContext.newInstance(classArray);
+                       } finally {
+                           currentThread.setContextClassLoader(savedClassLoader);
+                       }
+                   }
+               }
+            );
+        } catch (PrivilegedActionException e) {
+            throw ((PrivilegedActionException) e).getException();
+        } catch (Throwable t) {
+            throw t;
+        }
+        return jaxbContext;
+    }
+    
+    /**
+     * Utility class that quickly divides a list of classes into two categories.
+     * The primary category classes contain JAXB annotations.
+     * The secondary category classes do not contain JAXB annotations
+     * @param original
+     * @param primary
+     * @param secondary
+     */
+    static void separate(List<Class> original, List<Class> primary, List<Class> secondary) {
+        for (int i=0; i<original.size(); i++) {
+            Class cls = original.get(i);
+            if (commonArrayClasses.contains(cls)) {
+                if (log.isDebugEnabled()) {
+                    log.debug("This looks like a JAXB common class. Adding it to primary list:" + 
+                                       cls.getName());
+                }
+                primary.add(cls);
+            } else if (getAnnotation(cls, XmlType.class) != null ||
+                    getAnnotation(cls, XmlRootElement.class) != null) {
+                if (log.isDebugEnabled()) {
+                    log.debug("This looks like a JAXB class. Adding it to primary list:" + 
+                                       cls.getName());
+                }
+                primary.add(cls);  // This looks like a JAXB class...add it
+            } else {
+                if (log.isDebugEnabled()) {
+                    log.debug("This may not be a JAXB class. Adding it to secondary list:" + 
+                                       cls.getName());
+                }
+                secondary.add(cls);  // This looks like it might be something else...
+            }            
+        }
+    }
+    
+    /**
+     * Given a list of classes, this method determines the best minimal set
+     * of classes and returns the JAXBContext for this minimal set.
+     * @param original List<Class>
+     * @param cl ClassLoader
+     * @param ListMClass> is populated with the minimal, best set of classes
+     * @return JAXBContext
+     */
+    static JAXBContext findBestSet(List<Class> original,
+                                   ClassLoader cl,
+                                   List<Class> best) {
+        JAXBContext jc = null;
+        Class[] clsArray = new Class[0];
+            
+        // Divide the list into the classes that have JAXB annotations (primary)
+        // and those that do not (secondary)
+        ArrayList<Class> primary = new ArrayList<Class> ();
+        ArrayList<Class> secondary = new ArrayList<Class> ();
+        separate(original, primary, secondary);
+        
+        // Prime the pump
+        // Build a JAXBContext with the primary classes
+        best.addAll(primary);
+        if (best.size() > 0) {
+            try {
+                jc = _newInstance(best.toArray(clsArray), cl);
+            } catch (Throwable t) {
+                return null;
+            }
+        }
+        
+        // Now add secondary classes one at a time.
+        // If the JAXBContext creation is successful, add the class
+        // to the best list.  Otherwise continue.
+        // 
+        // @REVIEW One optimization is to do a toString() on the JAXBContext
+        // and check for the presense of the secondary class.  This would
+        // save time.  However, this also assumes that the toString() 
+        // of JAXBContext does not change.
+        for (int i = 0; i<secondary.size(); i++) {
+            Class cls = secondary.get(i);
+            best.add(cls);
+            try {
+                jc = _newInstance(best.toArray(clsArray), cl);
+            } catch (Throwable t) {
+                if (log.isDebugEnabled()) {
+                    log.debug("The following class is not a JAXB class: " +
+                              cls.getCanonicalName());
+                    log.debug("  JAXBContext creation continues without this class.");
+                    log.debug("  The reason is " + t);
+                }
+                best.remove(cls);
+                
+                // @REVIEW
+                // We could save the exceptions (perhaps in a list) and
+                // return the exceptions.  Then if problems occur later
+                // (i.e. do to missing exceptions) then we could throw
+                // this exception.
+            }
+        }
+        
+        return jc;
+  
+    }
+    
+    /**
+     * Get an annotation.  This is wrappered to avoid a Java2Security violation.
+     * @param cls Class that contains annotation 
+     * @param annotation Class of requrested Annotation
+     * @return annotation or null
+     */
+    private static Annotation getAnnotation(final AnnotatedElement element, final Class annotation) {
+        return (Annotation) AccessController.doPrivileged(new PrivilegedAction() {
+            public Object run() {
+                return element.getAnnotation(annotation);
+            }
+        });
+    }
+    
+    private static List<Class> commonArrayClasses = new ArrayList<Class>();
+    static {
+        commonArrayClasses.add(boolean[].class);
+        commonArrayClasses.add(byte[].class);
+        commonArrayClasses.add(char[].class);
+        commonArrayClasses.add(double[].class);
+        commonArrayClasses.add(float[].class);
+        commonArrayClasses.add(int[].class);
+        commonArrayClasses.add(long[].class);
+        commonArrayClasses.add(short[].class);
+        commonArrayClasses.add(String[].class);
+        commonArrayClasses.add(Object[].class);
+        commonArrayClasses.add(Image[].class);
+        commonArrayClasses.add(BigDecimal[].class);
+        commonArrayClasses.add(BigInteger[].class);
+        commonArrayClasses.add(Calendar[].class);
+        commonArrayClasses.add(QName[].class);
+    }
+}

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBUtils.java?rev=659291&r1=659290&r2=659291&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBUtils.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/JAXBUtils.java Thu May 22 15:35:42 2008
@@ -843,7 +843,7 @@
             // primitives
             "boolean[]",
             "byte[]",
-            "char[][]",
+            "char[]",
             "double[]",
             "float[]",
             "int[]",
@@ -984,47 +984,22 @@
      */
     private static JAXBContext JAXBContext_newInstance(final Class[] classArray, 
                                                        final ClassLoader cl)
-            throws JAXBException {
+    throws JAXBException {
         // NOTE: This method must remain private because it uses AccessController
         JAXBContext jaxbContext = null;
-        try {
-            if (log.isDebugEnabled()) {
-                if (classArray == null || classArray.length == 0) {
-                    log.debug("JAXBContext is constructed with 0 input classes.");
-                } else {
-                    log.debug("JAXBContext is constructed with " + classArray.length +
-                            " input classes.");
-                }
-            }
-            jaxbContext = (JAXBContext)AccessController.doPrivileged(
-                    new PrivilegedExceptionAction() {
-                        public Object run() throws JAXBException {
-                            // Unlike the JAXBContext.newInstance(Class[]) method
-                            // does now accept a classloader.  To workaround this
-                            // issue, the classloader is temporarily changed to cl
-                            Thread currentThread = Thread.currentThread();
-                            ClassLoader savedClassLoader = currentThread.getContextClassLoader();
-                            try {
-                                currentThread.setContextClassLoader(cl);
-                                return JAXBContext.newInstance(classArray);
-                            } finally {
-                                currentThread.setContextClassLoader(savedClassLoader);
-                            }
-                        }
-                    }
-            );
-        } catch (PrivilegedActionException e) {
-            if (log.isDebugEnabled()) {
-                log.debug("Exception thrown from AccessController: " + e);
-                log.debug("  Exception is " + e.getException());
-            }
-            if (e.getException() instanceof JAXBException) {
-                throw (JAXBException)e.getException();
-            } else if (e.getException() instanceof RuntimeException) {
-                throw ExceptionFactory.makeWebServiceException(e.getException());
+
+        if (log.isDebugEnabled()) {
+            if (classArray == null || classArray.length == 0) {
+                log.debug("JAXBContext is constructed with 0 input classes.");
+            } else {
+                log.debug("JAXBContext is constructed with " + classArray.length +
+                " input classes.");
             }
         }
 
+        // Get JAXBContext from classes
+        jaxbContext = JAXBContextFromClasses.newInstance(classArray, cl);
+
         return jaxbContext;
     }
 

Added: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/databinding/JAXBUtilsTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/databinding/JAXBUtilsTests.java?rev=659291&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/databinding/JAXBUtilsTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/databinding/JAXBUtilsTests.java Thu May 22 15:35:42 2008
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis2.jaxws.message.databinding;
+
+import org.apache.axis2.jaxws.message.databinding.JAXBUtils.CONSTRUCTION_TYPE;
+import org.apache.ws.jaxb.a.BadData1;
+import org.apache.ws.jaxb.a.BadData2;
+import org.apache.ws.jaxb.a.Data1;
+import org.apache.ws.jaxb.a.Data2;
+import org.apache.ws.jaxb.a.Data3;
+import org.apache.ws.jaxb.b.BadData3;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.ws.Holder;
+
+import java.util.TreeSet;
+
+import junit.framework.TestCase;
+
+/**
+ * Test JAXBUtils functionality
+ */
+public class JAXBUtilsTests extends TestCase {
+    
+    /**
+     * We have encountered situations where users have intermingled
+     * JAXB and non-JAXB classes in the same package.  This practice is
+     * strongly discouraged; however it can happen.  
+     * The JAXBUtils code (actually JAXBContextFromClasses) contains 
+     * an algorithm to try and find the minimal set of valid classes 
+     * in these cases.  
+     * 
+     * This test validates the code.  Several good JAXB classes
+     * (all named Data*) are intermingled in packaes with non-JAXB classes
+     * (all named BadData*).  This test passes if the JAXBContext contains
+     * the Data classes and excludes the BadData classes.
+     * @throws Exception
+     */
+    public void testMixedPackages() throws Exception {
+        
+        // Create a JAXBContext
+        TreeSet<String> contextPackages = new TreeSet<String>();
+        contextPackages.add("org.apache.ws.jaxb.a");
+        contextPackages.add("org.apache.ws.jaxb.b");
+        Holder<CONSTRUCTION_TYPE>constructionType = new Holder<CONSTRUCTION_TYPE>();
+        
+        JAXBContext jbc = JAXBUtils.getJAXBContext(contextPackages, constructionType, 
+                                                   contextPackages.toString());
+        
+        // The toString method lists all of the contained classes.
+        String jbcString = jbc.toString();
+        
+        // Make sure the good Data is in the JAXBContext
+        assertTrue(jbcString.indexOf(Data1.class.getName()) > 0);
+        assertTrue(jbcString.indexOf(Data2.class.getName()) > 0);
+        assertTrue(jbcString.indexOf(Data3.class.getName()) > 0);
+        
+        // Make sure the bad Data is not in the JAXBContext
+        assertTrue(jbcString.indexOf(BadData1.class.getName()) < 0);
+        assertTrue(jbcString.indexOf(BadData2.class.getName()) < 0);
+        assertTrue(jbcString.indexOf(BadData3.class.getName()) < 0);
+    }
+}

Added: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/ws/jaxb/a/BadData1.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/ws/jaxb/a/BadData1.java?rev=659291&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/ws/jaxb/a/BadData1.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/ws/jaxb/a/BadData1.java Thu May 22 15:35:42 2008
@@ -0,0 +1,38 @@
+/*
+ * 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.ws.jaxb.a;
+
+import java.io.InputStream;
+
+public class BadData1 {
+    public InputStream is;
+    
+   
+    public BadData1() {
+        super();
+    }
+
+    public InputStream getIs() {
+        return is;
+    }
+
+    public void setIs(InputStream is) {
+        this.is = is;
+    }
+}

Added: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/ws/jaxb/a/BadData2.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/ws/jaxb/a/BadData2.java?rev=659291&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/ws/jaxb/a/BadData2.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/ws/jaxb/a/BadData2.java Thu May 22 15:35:42 2008
@@ -0,0 +1,31 @@
+/*
+ * 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.ws.jaxb.a;
+
+import org.apache.ws.jaxb.b.BadData3;
+
+
+public class BadData2 {
+   public BadData3 data3;
+   
+   public BadData2() {
+       super();
+   }
+
+}

Added: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/ws/jaxb/a/Data1.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/ws/jaxb/a/Data1.java?rev=659291&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/ws/jaxb/a/Data1.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/ws/jaxb/a/Data1.java Thu May 22 15:35:42 2008
@@ -0,0 +1,61 @@
+/*
+ * 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.ws.jaxb.a;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ * Good JAXB element
+ * Data1 contains JAXB annotations.
+ * References Data2
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "data1", namespace="urn://jaxb.a", propOrder = {
+    "text", "data2"
+})
+
+public class Data1 {
+
+    @XmlElement(required = true, nillable = true)
+    protected String text;
+    
+    @XmlElement(required = true, nillable = true)
+    protected Data2 data2;
+
+    public Data2 getData2() {
+        return data2;
+    }
+
+    public void setData2(Data2 data2) {
+        this.data2 = data2;
+    }
+
+    public String getText() {
+        return text;
+    }
+
+    public void setText(String text) {
+        this.text = text;
+    }
+    
+    
+}

Added: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/ws/jaxb/a/Data2.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/ws/jaxb/a/Data2.java?rev=659291&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/ws/jaxb/a/Data2.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/ws/jaxb/a/Data2.java Thu May 22 15:35:42 2008
@@ -0,0 +1,45 @@
+/*
+ * 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.ws.jaxb.a;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ * Good JAXB element
+ * Data2 contains JAXB annotations.
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "data2", namespace="urn://jaxb.a", propOrder = {
+    "text"
+})
+public class Data2 {
+    @XmlElement(required = true, nillable = true)
+    protected String text;
+
+    public String getText() {
+        return text;
+    }
+
+    public void setText(String text) {
+        this.text = text;
+    }
+}

Added: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/ws/jaxb/a/Data3.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/ws/jaxb/a/Data3.java?rev=659291&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/ws/jaxb/a/Data3.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/ws/jaxb/a/Data3.java Thu May 22 15:35:42 2008
@@ -0,0 +1,35 @@
+/*
+ * 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.ws.jaxb.a;
+
+public class Data3 {
+    private String text;
+    
+    public Data3() {
+        super();
+    }
+
+    public String getText() {
+        return text;
+    }
+
+    public void setText(String text) {
+        this.text = text;
+    }
+}

Added: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/ws/jaxb/b/BadData3.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/ws/jaxb/b/BadData3.java?rev=659291&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/ws/jaxb/b/BadData3.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/ws/jaxb/b/BadData3.java Thu May 22 15:35:42 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 org.apache.ws.jaxb.b;
+
+import java.io.InputStream;
+
+public class BadData3 {
+    public InputStream is;
+    
+    public BadData3() {
+        super();
+    }
+
+    public InputStream getIs() {
+        return is;
+    }
+
+    public void setIs(InputStream is) {
+        this.is = is;
+    }
+}