cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r606670 - in /incubator/cxf/trunk: rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ systests/src/test/java/org/apache/cxf/systest/type_substitution/
Date Mon, 24 Dec 2007 06:27:33 GMT
Author: ema
Date: Sun Dec 23 22:27:32 2007
New Revision: 606670

URL: http://svn.apache.org/viewvc?rev=606670&view=rev
Log:
[CXF-1305]Add the extra classes that @XmlSeeAlao annotated to JAXBDatabinding in runtime

Added:
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_substitution/Apple.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_substitution/AppleAdapter.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_substitution/AppleFindClientServerTest.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_substitution/AppleFinder.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_substitution/AppleFinderImpl.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_substitution/AppleServer.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_substitution/Fruit.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_substitution/Fuji.java
Modified:
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
    incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java?rev=606670&r1=606669&r2=606670&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
Sun Dec 23 22:27:32 2007
@@ -24,9 +24,11 @@
 import java.lang.reflect.Type;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 import javax.wsdl.Operation;
+import javax.xml.bind.annotation.XmlSeeAlso;
 import javax.xml.namespace.QName;
 import javax.xml.ws.Action;
 import javax.xml.ws.AsyncHandler;
@@ -372,10 +374,22 @@
     
     @Override
     protected Set<Class<?>> getExtraClass() {
+        Set<Class<?>> classes = new HashSet<Class<?>>();
         if (!wrapperBeanGenerated) {
             wrapperClasses = generatedWrapperBeanClass();
-        } 
-        return wrapperClasses;
+        }
+        if (wrapperClasses != null) {
+            classes.addAll(wrapperClasses);
+        }
+        
+        XmlSeeAlso xmlSeeAlsoAnno = getServiceClass().getAnnotation(XmlSeeAlso.class);
+        
+        if (xmlSeeAlsoAnno != null && xmlSeeAlsoAnno.value() != null) {
+            for (int i = 0; i < xmlSeeAlsoAnno.value().length; i++) {
+                classes.add(xmlSeeAlsoAnno.value()[i]);
+            }
+        }
+        return classes;
     }
     
     private Set<Class<?>> generatedWrapperBeanClass() {

Modified: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java?rev=606670&r1=606669&r2=606670&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
(original)
+++ incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
Sun Dec 23 22:27:32 2007
@@ -294,7 +294,7 @@
         }
         
         for (ServiceInfo si : getService().getServiceInfos()) {
-            if (getExtraClass() != null) {
+            if (getExtraClass() != null && !getExtraClass().isEmpty()) {
                 si.setProperty(EXTRA_CLASS, getExtraClass());
             }
         }
@@ -324,7 +324,7 @@
 
         for (ServiceInfo si : getService().getServiceInfos()) {
             Set<?> wrapperClasses = this.getExtraClass();
-            if (wrapperClasses != null) {
+            if (wrapperClasses != null && !wrapperClasses.isEmpty()) {
                 si.setProperty(EXTRA_CLASS, wrapperClasses);
             }
         }

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_substitution/Apple.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_substitution/Apple.java?rev=606670&view=auto
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_substitution/Apple.java
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_substitution/Apple.java
Sun Dec 23 22:27:32 2007
@@ -0,0 +1,51 @@
+/**
+ * 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.type_substitution;
+
+
+public abstract class Apple implements Fruit {
+    protected String color;
+    protected String flavor;
+    protected String type;
+
+    public String getColor() {
+        return color;
+    }
+
+    public void setColor(String arg) {
+        this.color = arg;
+    }
+
+    public String getFlavor() {
+        return flavor;
+    }
+
+    public void setFlavor(String fla) {
+        this.flavor = fla;
+    }
+
+    public void setType(String arg) {
+        type = arg;
+    }
+
+    public abstract String getType();
+
+    
+}

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_substitution/AppleAdapter.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_substitution/AppleAdapter.java?rev=606670&view=auto
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_substitution/AppleAdapter.java
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_substitution/AppleAdapter.java
Sun Dec 23 22:27:32 2007
@@ -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.type_substitution;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
+public class AppleAdapter extends XmlAdapter<Apple, Fruit> {
+    public Fruit unmarshal(Apple v) throws Exception {
+        return v;
+    }
+
+    public Apple marshal(Fruit v) throws Exception {
+        return (Apple)v;
+    }
+}
\ No newline at end of file

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_substitution/AppleFindClientServerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_substitution/AppleFindClientServerTest.java?rev=606670&view=auto
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_substitution/AppleFindClientServerTest.java
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_substitution/AppleFindClientServerTest.java
Sun Dec 23 22:27:32 2007
@@ -0,0 +1,58 @@
+/**
+ * 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.type_substitution;
+
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import javax.xml.ws.soap.SOAPBinding;
+
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * 
+ */
+public class AppleFindClientServerTest extends AbstractBusClientServerTestBase {
+
+    @BeforeClass
+    public static void startServers() throws Exception {
+        assertTrue("server did not launch correctly", launchServer(AppleServer.class));
+    }
+
+    @Test
+    public void testBasicConnection() throws Exception {
+        QName serviceName = new QName("http://type_substitution.systest.cxf.apache.org/",
+                                      "AppleFinder");
+        QName portName = new QName("http://type_substitution.systest.cxf.apache.org/", "AppleFinderPort");
+
+        Service service = Service.create(serviceName);
+        String endpointAddress = "http://localhost:9052/appleFind";
+
+        service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, endpointAddress);
+
+       
+        
+        AppleFinder finder = service.getPort(AppleFinder.class);
+        assertEquals(2, finder.getApple("Fuji").size());
+    }
+
+}

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_substitution/AppleFinder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_substitution/AppleFinder.java?rev=606670&view=auto
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_substitution/AppleFinder.java
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_substitution/AppleFinder.java
Sun Dec 23 22:27:32 2007
@@ -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.
+ */
+// START SNIPPET: service
+package org.apache.cxf.systest.type_substitution;
+
+import java.util.List;
+
+import javax.jws.WebService;
+import javax.xml.bind.annotation.XmlSeeAlso;
+
+@WebService
+@XmlSeeAlso({ Apple.class, Fuji.class })
+public interface AppleFinder {
+    List<Apple> getApple(String appType);
+}

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_substitution/AppleFinderImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_substitution/AppleFinderImpl.java?rev=606670&view=auto
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_substitution/AppleFinderImpl.java
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_substitution/AppleFinderImpl.java
Sun Dec 23 22:27:32 2007
@@ -0,0 +1,43 @@
+/**
+ * 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.type_substitution;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jws.WebService;
+
+@WebService(endpointInterface = "org.apache.cxf.systest.type_substitution.AppleFinder", 
+            serviceName = "AppleFinder")
+public class AppleFinderImpl implements AppleFinder {
+
+    public List<Apple> getApple(String appleType) {
+        if (appleType.equalsIgnoreCase("Fuji")) {
+            List<Apple> apples = new ArrayList<Apple>();
+            apples.add(new Fuji("Red", "mild", "Fuji-1"));
+            apples.add(new Fuji("Yellow", "sweet", "Fuji-2"));
+            return apples;
+        } else {
+            return null;
+        }
+        
+    }
+
+    
+}

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_substitution/AppleServer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_substitution/AppleServer.java?rev=606670&view=auto
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_substitution/AppleServer.java
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_substitution/AppleServer.java
Sun Dec 23 22:27:32 2007
@@ -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.type_substitution;
+
+import javax.xml.ws.Endpoint;
+
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+
+/**
+ *
+ */
+public class AppleServer extends AbstractBusTestServerBase {
+
+    protected void run()  {
+        Object implementor = new AppleFinderImpl();
+        Endpoint.publish("http://localhost:9052/appleFind", implementor);
+    }
+
+
+    public static void main(String[] args) {
+        try {
+            AppleServer s = new AppleServer();
+            s.start();
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            System.exit(-1);
+        } finally {
+            System.out.println("done!");
+        }
+    }
+}
\ No newline at end of file

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_substitution/Fruit.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_substitution/Fruit.java?rev=606670&view=auto
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_substitution/Fruit.java
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_substitution/Fruit.java
Sun Dec 23 22:27:32 2007
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.systest.type_substitution;
+
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+@XmlJavaTypeAdapter(AppleAdapter.class)
+public interface Fruit {
+    String getColor();
+    String getFlavor();
+}

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_substitution/Fuji.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_substitution/Fuji.java?rev=606670&view=auto
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_substitution/Fuji.java
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/type_substitution/Fuji.java
Sun Dec 23 22:27:32 2007
@@ -0,0 +1,39 @@
+/**
+ * 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.type_substitution;
+
+public class Fuji extends Apple {
+    private final String type = "Fuji";
+
+    public Fuji() {
+        setType("Fuji");
+    }
+
+    public Fuji(String color, String flavor, String type) {
+        setColor(color);
+        setFlavor(flavor);
+        setType(type);
+    }
+
+    public String getType() {
+        return type;
+    }
+
+}



Mime
View raw message