cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r954562 - in /cxf/branches/2.2.x-fixes: ./ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ systests/jaxws/src/...
Date Mon, 14 Jun 2010 17:30:16 GMT
Author: sergeyb
Date: Mon Jun 14 17:30:16 2010
New Revision: 954562

URL: http://svn.apache.org/viewvc?rev=954562&view=rev
Log:
Merged revisions 954552,954559 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r954552 | sergeyb | 2010-06-14 17:49:43 +0100 (Mon, 14 Jun 2010) | 1 line
  
  CXF-2846 : support for superclasses implementing or superinterfaces extending JAXWS Provider
........
  r954559 | sergeyb | 2010-06-14 18:13:04 +0100 (Mon, 14 Jun 2010) | 1 line
  
  CXF-2846 : minor update to make it easier to merge to 2.2.x
........

Added:
    cxf/branches/2.2.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/AbstractSourcePayloadProvider.java
      - copied unchanged from r954559, cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/AbstractSourcePayloadProvider.java
    cxf/branches/2.2.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/SourceProvider.java
      - copied unchanged from r954559, cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/SourceProvider.java
Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointUtils.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilder.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsImplementorInfo.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/Messages.properties
    cxf/branches/2.2.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/HWSourcePayloadProvider.java

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
    svn:mergeinfo = /cxf/trunk:954552-954559

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointUtils.java?rev=954562&r1=954561&r2=954562&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointUtils.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointUtils.java
Mon Jun 14 17:30:16 2010
@@ -52,11 +52,18 @@ public final class EndpointUtils {
     }
     
     private static boolean hasWebServiceProviderAnnotation(Class<?> cls) {
-        if (cls != null) {
-            return cls.isAnnotationPresent(WebServiceProvider.class);
+        if (cls == null) {
+            return false;
         }
-        
-        return false;
+        if (null != cls.getAnnotation(WebServiceProvider.class)) {
+            return true;
+        }
+        for (Class<?> inf : cls.getInterfaces()) {
+            if (null != inf.getAnnotation(WebServiceProvider.class)) {
+                return true;
+            }
+        }
+        return hasWebServiceProviderAnnotation(cls.getSuperclass());
     }
     
     public static boolean isValidImplementor(Object implementor) {
@@ -76,4 +83,6 @@ public final class EndpointUtils {
         LOG.info("Implementor is not annotated with WebService annotation.");
         return false;
     } 
+    
+    
 }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilder.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilder.java?rev=954562&r1=954561&r2=954562&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilder.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AnnotationHandlerChainBuilder.java
Mon Jun 14 17:30:16 2010
@@ -288,7 +288,10 @@ public class AnnotationHandlerChainBuild
         return clazz.getResource(name);
     }
     
-    private HandlerChainAnnotation findHandlerChainAnnotation(Class<?> clz, boolean
searchSEI) {        
+    private HandlerChainAnnotation findHandlerChainAnnotation(Class<?> clz, boolean
searchSEI) {
+        if (clz == null) {
+            return null;
+        }
         if (LOG.isLoggable(Level.FINE)) {
             LOG.fine("Checking for HandlerChain annotation on " + clz.getName());
         }
@@ -325,6 +328,9 @@ public class AnnotationHandlerChainBuild
                         break;
                     }
                 }
+                if (hcAnn == null) {
+                    hcAnn = findHandlerChainAnnotation(clz.getSuperclass(), false);
+                }
             }
         } else {
             hcAnn = new HandlerChainAnnotation(ann, clz);

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsImplementorInfo.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsImplementorInfo.java?rev=954562&r1=954561&r2=954562&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsImplementorInfo.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsImplementorInfo.java
Mon Jun 14 17:30:16 2010
@@ -301,9 +301,26 @@ public class JaxWsImplementorInfo {
                 }
             }
         }
-        wsProviderAnnotation = implementorClass.getAnnotation(WebServiceProvider.class);
+        
+        wsProviderAnnotation = getWebServiceProviderAnnotation(implementorClass);
     }
 
+    private static WebServiceProvider getWebServiceProviderAnnotation(Class<?> cls)
{
+        if (cls == null) {
+            return null;
+        }
+        WebServiceProvider ann = cls.getAnnotation(WebServiceProvider.class);
+        if (null != ann) {
+            return ann;
+        }
+        for (Class<?> inf : cls.getInterfaces()) {
+            if (null != inf.getAnnotation(WebServiceProvider.class)) {
+                return inf.getAnnotation(WebServiceProvider.class);
+            }
+        }
+        return getWebServiceProviderAnnotation(cls.getSuperclass());
+    }
+    
     public boolean isWebServiceProvider() {
         return Provider.class.isAssignableFrom(implementorClass);
     }
@@ -321,22 +338,28 @@ public class JaxWsImplementorInfo {
     }
 
     public Class<?> getProviderParameterType() {
-        // The Provider Implementor inherits out of Provider<T>
-        Class<?> c = implementorClass;
+        return doGetProviderParameterType(implementorClass);
+    }
+
+    private static Class<?> doGetProviderParameterType(Class<?> c) {
         while (c != null) {
             Type intfTypes[] = c.getGenericInterfaces();
             for (Type t : intfTypes) {
                 Class<?> clazz = JAXBEncoderDecoder.getClassFromType(t);
-                if (Provider.class == clazz) {
-                    Type paramTypes[] = ((ParameterizedType)t).getActualTypeArguments();
-                    return JAXBEncoderDecoder.getClassFromType(paramTypes[0]);
+                if (Provider.class.isAssignableFrom(clazz)) {
+                    if (Provider.class == clazz) {
+                        Type paramTypes[] = ((ParameterizedType)t).getActualTypeArguments();
+                        return JAXBEncoderDecoder.getClassFromType(paramTypes[0]);
+                    } else {
+                        return doGetProviderParameterType(clazz);
+                    }
                 }
             }
             c = c.getSuperclass();
         }
         return null;
     }
-
+    
     public String getBindingType() {
         BindingType bType = implementorClass.getAnnotation(BindingType.class);
         if (bType != null) {

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java?rev=954562&r1=954561&r2=954562&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
Mon Jun 14 17:30:16 2010
@@ -41,6 +41,7 @@ import javax.xml.ws.Action;
 import javax.xml.ws.AsyncHandler;
 import javax.xml.ws.BindingType;
 import javax.xml.ws.FaultAction;
+import javax.xml.ws.Provider;
 import javax.xml.ws.Service;
 import javax.xml.ws.WebFault;
 import javax.xml.ws.WebServiceFeature;
@@ -261,10 +262,11 @@ public class JaxWsServiceFactoryBean ext
     }
 
     protected void initializeWSDLOperationsForProvider() {
-        Type[] genericInterfaces = getServiceClass().getGenericInterfaces();
-        ParameterizedType pt = (ParameterizedType)genericInterfaces[0];
-        Class c = (Class)pt.getActualTypeArguments()[0];
-
+        Class c = getProviderParameterType(getServiceClass());
+        if (c == null) {
+            throw new ServiceConstructionException(new Message("INVALID_PROVIDER_EXC", LOG));
+        }
+        
         if (getEndpointInfo() == null
             && isFromWsdl()) {
             //most likely, they specified a WSDL, but for some reason
@@ -359,6 +361,24 @@ public class JaxWsServiceFactoryBean ext
         
     }
 
+    protected Class<?> getProviderParameterType(Class<?> cls) {
+        if (cls == null) {
+            return null;
+        }
+        Type[] genericInterfaces = cls.getGenericInterfaces();
+        for (Type type : genericInterfaces) {
+            if (type instanceof ParameterizedType) { 
+                Class<?> rawCls = (Class<?>)((ParameterizedType)type).getRawType();
+                if (Provider.class == rawCls) {
+                    return (Class<?>)((ParameterizedType)type).getActualTypeArguments()[0];
+                }
+            } else if (type instanceof Class && Provider.class.isAssignableFrom((Class)type))
{
+                return getProviderParameterType((Class)type);
+            }
+        }
+        return getProviderParameterType(cls.getSuperclass());
+    }
+    
     void initializeWrapping(OperationInfo o, Method selected) {
         Class responseWrapper = getResponseWrapper(selected);
         if (responseWrapper != null) {

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/Messages.properties
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/Messages.properties?rev=954562&r1=954561&r2=954562&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/Messages.properties
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/Messages.properties
Mon Jun 14 17:30:16 2010
@@ -19,6 +19,7 @@
 #
 #
 SEI_LOAD_FAILURE_EXC = Failed to load service endpoint interface.
+INVALID_PROVIDER_EXC = {0} is not a valid JAXWS Provider.
 SEI_LOAD_FAILURE_MSG = Could not load Webservice SEI
 SEI_WITHOUT_WEBSERVICE_ANNOTATION_EXC = Service endpoint interface does not have a @WebService
annotation.
 ILLEGAL_ATTRIBUTE_IN_SEI_ANNOTATION_EXC = Attributes portName, serviceName and endpointInterface
are not allowed in the @WebService annotation of an SEI.

Modified: cxf/branches/2.2.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/HWSourcePayloadProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/HWSourcePayloadProvider.java?rev=954562&r1=954561&r2=954562&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/HWSourcePayloadProvider.java
(original)
+++ cxf/branches/2.2.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/HWSourcePayloadProvider.java
Mon Jun 14 17:30:16 2010
@@ -18,120 +18,13 @@
  */
 
 package org.apache.cxf.systest.provider;
-import java.io.InputStream;
-import java.io.StringWriter;
-import java.io.Writer;
 
-import javax.annotation.Resource;
-import javax.jws.HandlerChain;
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.sax.SAXSource;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.ws.Provider;
-import javax.xml.ws.ServiceMode;
-import javax.xml.ws.WebServiceContext;
-import javax.xml.ws.WebServiceProvider;
-import javax.xml.ws.handler.MessageContext;
-
-import org.xml.sax.InputSource;
-import org.xml.sax.XMLReader;
-import org.xml.sax.helpers.XMLReaderFactory;
-
-import org.apache.cxf.helpers.XMLUtils;
-import org.apache.cxf.staxutils.StaxSource;
-import org.apache.cxf.staxutils.StaxUtils;
-
-//The following wsdl file is used.
-//wsdlLocation = "/trunk/testutils/src/main/resources/wsdl/hello_world_rpc_lit.wsdl"
-@WebServiceProvider(portName = "SoapPortProviderRPCLit3", serviceName = "SOAPServiceProviderRPCLit",
-                      targetNamespace = "http://apache.org/hello_world_rpclit",
- wsdlLocation = "/wsdl/hello_world_rpc_lit.wsdl")
-@ServiceMode (value = javax.xml.ws.Service.Mode.PAYLOAD)
-@HandlerChain(file = "./handlers_invocation.xml", name = "TestHandlerChain")
-public class HWSourcePayloadProvider implements Provider<Source> {
-    boolean doneStax;
-    @Resource 
-    WebServiceContext ctx;
-
-    public HWSourcePayloadProvider() {
-    
+public class HWSourcePayloadProvider extends AbstractSourcePayloadProvider
+    implements Comparable<HWSourcePayloadProvider> {
+ 
+    @Override
+    public int compareTo(HWSourcePayloadProvider p) {
+        return p == this ? 0 : -1;
     }
     
-    public Source invoke(Source request) {   
-        QName qn = (QName)ctx.getMessageContext().get(MessageContext.WSDL_OPERATION);
-        if (qn == null) {
-            throw new RuntimeException("No Operation Name");
-        }
-        
-        try {
-            System.out.println(request.getClass().getName());
-            String input = getSourceAsString(request);
-            System.out.println(input);  
-            
-            if (input.indexOf("ServerLogicalHandler") >= 0) {
-                return map(request.getClass());
-            }
-
-        } catch (Exception e) {
-            System.out.println("Received an exception while parsing the source");
-            e.printStackTrace();
-        }
-        return null;
-    }
-    
-    private Source map(Class<? extends Source> class1) 
-        throws Exception {
-        
-        InputStream greetMeInputStream = getClass()
-            .getResourceAsStream("resources/GreetMeRpcLiteralRespBody.xml");
-        if (DOMSource.class.equals(class1)) {
-            return new DOMSource(XMLUtils.parse(greetMeInputStream));
-        } else if (StaxSource.class.equals(class1)) {
-            if (doneStax) {
-                XMLReader reader = XMLReaderFactory.createXMLReader();
-                return new SAXSource(reader, new InputSource(greetMeInputStream));
-            } else {
-                doneStax = true;
-                return new StaxSource(StaxUtils.createXMLStreamReader(greetMeInputStream));
-            }
-        } else if (StreamSource.class.equals(class1)) {
-            StreamSource source = new StreamSource();
-            source.setInputStream(greetMeInputStream);
-            return source;
-        }
-        //java 6 javax.xml.transform.stax.StAXSource
-        XMLStreamReader reader = StaxUtils.createXMLStreamReader(greetMeInputStream);
-        return class1.getConstructor(XMLStreamReader.class).newInstance(reader);
-    }
-
-    public static String getSourceAsString(Source s) throws Exception {
-        try {
-            Transformer transformer = TransformerFactory.newInstance().newTransformer();
-            transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
-            transformer.setOutputProperty(OutputKeys.METHOD, "xml");
-            Writer out = new StringWriter();
-            StreamResult streamResult = new StreamResult();
-            streamResult.setWriter(out);
-            transformer.transform(s, streamResult);
-            return streamResult.getWriter().toString();
-            
-        } catch (TransformerException te) {
-            if ("javax.xml.transform.stax.StAXSource".equals(s.getClass().getName())) {
-                //on java6, we will get this class if "stax" is configured
-                //for the preferred type. However, older xalans don't know about it
-                //we'll manually do it
-                XMLStreamReader r = (XMLStreamReader)s.getClass().getMethod("getXMLStreamReader").invoke(s);
-                return XMLUtils.toString(StaxUtils.read(r).getDocumentElement());
-            }
-            throw te;
-        }
-    }
 }



Mime
View raw message