cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r645294 - in /incubator/cxf/trunk/rt/databinding: aegis/src/main/java/org/apache/cxf/aegis/type/basic/ aegis/src/test/java/org/apache/cxf/doclitbare/ jaxb/src/main/java/org/apache/cxf/jaxb/
Date Sun, 06 Apr 2008 19:57:13 GMT
Author: bimargulies
Date: Sun Apr  6 12:57:10 2008
New Revision: 645294

URL: http://svn.apache.org/viewvc?rev=645294&view=rev
Log:
Fix CXF-1504

Added:
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/doclitbare/
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/doclitbare/Course.java
  (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/doclitbare/DocLitBareTest.java
  (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/doclitbare/Teacher.java
  (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/doclitbare/University.java
  (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/doclitbare/UniversityImpl.java
  (with props)
Modified:
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java
    incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java?rev=645294&r1=645293&r2=645294&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java
(original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java
Sun Apr  6 12:57:10 2008
@@ -530,7 +530,11 @@
 
     private String getNameWithPrefix(Element root, String nameNS, String localName) {
         if (!nameNS.equals(getSchemaType().getNamespaceURI())) {
-            String prefix = NamespaceHelper.getUniquePrefix((Element)root.getParent(), nameNS);
+            Element rootElement = (Element)root.getParent();
+            String prefix = null;
+            if (rootElement != null) { // can happen with doc/lit/bare
+                prefix = NamespaceHelper.getUniquePrefix(rootElement, nameNS);
+            }
 
             if (prefix == null || prefix.length() == 0) {
                 prefix = NamespaceHelper.getUniquePrefix(root, nameNS);

Added: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/doclitbare/Course.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/doclitbare/Course.java?rev=645294&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/doclitbare/Course.java
(added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/doclitbare/Course.java
Sun Apr  6 12:57:10 2008
@@ -0,0 +1,60 @@
+/**
+ * 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.doclitbare;
+
+/**
+ * 
+ */
+public class Course {
+    private long id;
+    private String name;
+    private String description;
+    
+    public Course() {
+        id = 0;
+    }
+    
+    public Course(long id, String name, String description) {
+        this.id = id;
+        this.name = name;
+        this.description = description;
+    }
+    
+    public long getId() {
+        return id;
+    }
+    public void setId(long id) {
+        this.id = id;
+    }
+    public String getName() {
+        return name;
+    }
+    public void setName(String name) {
+        this.name = name;
+    }
+    public String getDescription() {
+        return description;
+    }
+    public void setDescription(String description) {
+        this.description = description;
+    }
+    
+
+}

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/doclitbare/Course.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/doclitbare/Course.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/doclitbare/DocLitBareTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/doclitbare/DocLitBareTest.java?rev=645294&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/doclitbare/DocLitBareTest.java
(added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/doclitbare/DocLitBareTest.java
Sun Apr  6 12:57:10 2008
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.doclitbare;
+
+import org.apache.cxf.aegis.databinding.AegisDatabinding;
+import org.apache.cxf.frontend.ClientProxyFactoryBean;
+import org.apache.cxf.frontend.ServerFactoryBean;
+import org.apache.cxf.test.AbstractCXFTest;
+import org.junit.Test;
+
+/**
+ * Test motivated by CXF-1504
+ */
+public class DocLitBareTest extends AbstractCXFTest {
+    
+    @Test
+    public void testNamespaceCrash() {
+        ServerFactoryBean svrFactory = new ServerFactoryBean();
+        svrFactory.setServiceClass(University.class);
+        svrFactory.setAddress("local://dlbTest");
+        svrFactory.setServiceBean(new UniversityImpl());
+        svrFactory.getServiceFactory().setDataBinding(new AegisDatabinding());
+        svrFactory.create(); 
+
+        ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
+        factory.getServiceFactory().setDataBinding(new AegisDatabinding());
+       
+        factory.setServiceClass(University.class);
+        factory.setAddress("local://dlbTest");
+        University client = (University) factory.create();
+       
+        Teacher tr = client.getTeacher(new Course(40, "Intro to CS", "Introductory Comp Sci"));
+        assertNotNull(tr);
+        assertEquals(52, tr.getAge());
+        assertEquals("Mr. Tom", tr.getName());
+    }
+}

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/doclitbare/DocLitBareTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/doclitbare/DocLitBareTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/doclitbare/Teacher.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/doclitbare/Teacher.java?rev=645294&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/doclitbare/Teacher.java
(added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/doclitbare/Teacher.java
Sun Apr  6 12:57:10 2008
@@ -0,0 +1,59 @@
+/**
+ * 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.doclitbare;
+
+/**
+ * 
+ */
+public class Teacher {
+    private int age;
+    private String name;
+    private String department;
+    
+    public Teacher() {
+        age = 0;
+    }
+    
+    public Teacher(int age, String name, String department) {
+        this.age = age;
+        this.name = name;
+        this.department = department;
+    }
+    
+    public int getAge() {
+        return age;
+    }
+    public void setAge(int age) {
+        this.age = age;
+    }
+    public String getName() {
+        return name;
+    }
+    public void setName(String name) {
+        this.name = name;
+    }
+    public String getDepartment() {
+        return department;
+    }
+    public void setDepartment(String department) {
+        this.department = department;
+    }
+    
+}

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/doclitbare/Teacher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/doclitbare/Teacher.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/doclitbare/University.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/doclitbare/University.java?rev=645294&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/doclitbare/University.java
(added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/doclitbare/University.java
Sun Apr  6 12:57:10 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 org.apache.cxf.doclitbare;
+
+/**
+ * 
+ */
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+@WebService(name = "University", targetNamespace = "http://cxf.apache.org/dlb/")
+@SOAPBinding(use = SOAPBinding.Use.LITERAL, style = SOAPBinding.Style.DOCUMENT, 
+             parameterStyle = SOAPBinding.ParameterStyle.BARE)
+public interface University {
+    @WebResult(targetNamespace = "http://education.toorosystems.com/", name = "return", partName
= "return")
+    @WebMethod(operationName = "getTeacher", exclude = false)
+    Teacher getTeacher(
+                              @WebParam(targetNamespace = "http://cxf.apache.org/dlb/", 
+                                        name = "course", mode = WebParam.Mode.IN)
+                              Course course);
+}

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/doclitbare/University.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/doclitbare/University.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/doclitbare/UniversityImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/doclitbare/UniversityImpl.java?rev=645294&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/doclitbare/UniversityImpl.java
(added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/doclitbare/UniversityImpl.java
Sun Apr  6 12:57:10 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.cxf.doclitbare;
+
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+/**
+ * 
+ */
+
+@WebService(name = "University", targetNamespace = "http://cxf.apache.org/dlb/")
+@SOAPBinding(use = SOAPBinding.Use.LITERAL, 
+             style = SOAPBinding.Style.DOCUMENT, 
+             parameterStyle = SOAPBinding.ParameterStyle.BARE)
+public class UniversityImpl implements University {
+
+    public Teacher getTeacher(Course course) {
+        return new Teacher(52, "Mr. Tom", "Computer Science" + course.getName()); 
+    }
+}

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/doclitbare/UniversityImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/doclitbare/UniversityImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

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=645294&r1=645293&r2=645294&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
Sun Apr  6 12:57:10 2008
@@ -112,9 +112,28 @@
         }
 
     }
+    
+    private static final class CachedClassOrNull {
+        private Class<?> cachedClass;
+
+        public CachedClassOrNull(Class<?> cachedClass) {
+            this.cachedClass = cachedClass;
+        }
+
+        public Class<?> getCachedClass() {
+            return cachedClass;
+        }
+
+        public void setCachedClass(Class<?> cachedClass) {
+            this.cachedClass = cachedClass;
+        }
+    }
 
     private static final Map<Set<Class<?>>, CachedContextAndSchemas> JAXBCONTEXT_CACHE

         = new CacheMap<Set<Class<?>>, CachedContextAndSchemas>();
+    
+    private static final Map<String, CachedClassOrNull> OBJECT_FACTORY_CACHE
+        = new CacheMap<String, CachedClassOrNull>();
 
     Class[] extraClass;
 
@@ -418,12 +437,24 @@
             if (!packages.containsKey(pkgName)) {
                 packages.put(pkgName, jcls.getResourceAsStream("jaxb.index"));
                 packageLoaders.put(pkgName, jcls.getClassLoader());
-                try {
-                    Class<?> ofactory = Class.forName(pkgName + "." + "ObjectFactory",
false, jcls
-                        .getClassLoader());
-                    objectFactories.add(ofactory);
-                } catch (ClassNotFoundException e) {
-                    // ignore
+                String objectFactoryClassName = pkgName + "." + "ObjectFactory";
+                Class<?> ofactory = null;
+                CachedClassOrNull cachedFactory = 
+                    OBJECT_FACTORY_CACHE.get(objectFactoryClassName);
+                if (cachedFactory != null) {
+                    ofactory = cachedFactory.getCachedClass();
+                }
+                if (ofactory == null) {
+                    try {
+                        ofactory = Class.forName(objectFactoryClassName, false, jcls
+                                                 .getClassLoader());
+                        objectFactories.add(ofactory);
+                        OBJECT_FACTORY_CACHE.put(objectFactoryClassName, 
+                                                 new CachedClassOrNull(ofactory));
+                    } catch (ClassNotFoundException e) {
+                        OBJECT_FACTORY_CACHE.put(objectFactoryClassName, 
+                                                 new CachedClassOrNull(null));
+                    }
                 }
             }
         }



Mime
View raw message