cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t..@apache.org
Subject svn commit: r450397 - in /incubator/cxf/trunk/rt: core/src/main/java/org/apache/cxf/interceptor/ frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/
Date Wed, 27 Sep 2006 11:23:11 GMT
Author: tli
Date: Wed Sep 27 04:23:10 2006
New Revision: 450397

URL: http://svn.apache.org/viewvc?view=rev&rev=450397
Log:
fix minor bugs

Modified:
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/BareInInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBeanTest.java

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/BareInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/BareInInterceptor.java?view=diff&rev=450397&r1=450396&r2=450397
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/BareInInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/BareInInterceptor.java
Wed Sep 27 04:23:10 2006
@@ -49,7 +49,7 @@
     
     static {
         filter.add("void");
-        filter.add("javax.activation.DataHandler");
+        filter.add("javax.activation.DataHandler");        
     }
     
     public BareInInterceptor() {
@@ -87,7 +87,7 @@
                     }
                     if (streamParaQName.equals(paraQName)) {
                         Class cls = (Class)mpi.getProperty(Class.class.getName());
-                        if (cls != null && !filter.contains(cls.getName())) {
+                        if (cls != null && !filter.contains(cls.getName()) &&
!cls.isArray()) {
                             o = dr.read(paraQName, message, cls);
                         } else {
                             o = dr.read(paraQName, message, null);

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?view=diff&rev=450397&r1=450396&r2=450397
==============================================================================
--- 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
Wed Sep 27 04:23:10 2006
@@ -52,22 +52,24 @@
 import org.apache.cxf.transport.ChainInitiationObserver;
 
 public class JaxWsServiceFactoryBean extends ReflectionServiceFactoryBean {
+    
+    public static final String MODE_OUT = "messagepart.mode.out";
 
-    public static final String HOLDER = "messagepart.isholder";
+    public static final String MODE_INOUT = "messagepart.mode.inout";
 
     private JAXBDataBinding dataBinding;
 
     private JaxWsServiceConfiguration jaxWsConfiguration;
 
     private JaxWsImplementorInfo jaxWsImplementorInfo;
-    
+
     private JaxWsMethodDispatcher methodDispatcher = new JaxWsMethodDispatcher();
-    
+
     public JaxWsServiceFactoryBean() {
         jaxWsConfiguration = new JaxWsServiceConfiguration();
         getServiceConfigurations().add(0, jaxWsConfiguration);
     }
-    
+
     public JaxWsServiceFactoryBean(JaxWsImplementorInfo implInfo) {
         this();
         this.jaxWsImplementorInfo = implInfo;
@@ -77,27 +79,25 @@
     @Override
     public Service create() {
         Service service = super.create();
-        
+
         service.put(MethodDispatcher.class.getName(), methodDispatcher);
-        
+
         return service;
     }
 
-    
     @Override
     public void setServiceClass(Class<?> serviceClass) {
         if (jaxWsImplementorInfo == null) {
             jaxWsImplementorInfo = new JaxWsImplementorInfo(serviceClass);
         }
-        
+
         super.setServiceClass(serviceClass);
     }
 
-
     @Override
     protected void initializeDefaultInterceptors() {
         super.initializeDefaultInterceptors();
-        
+
         getService().getOutFaultInterceptors().add(new WebFaultOutInterceptor());
     }
 
@@ -110,7 +110,7 @@
     }
 
     public void activateEndpoint(Service service, EndpointInfo ei) throws BusException, WSDLException,
-                    IOException, EndpointException {
+            IOException, EndpointException {
         JaxWsEndpointImpl ep = new JaxWsEndpointImpl(getBus(), service, ei);
         ChainInitiationObserver observer = new ChainInitiationObserver(ep, getBus());
 
@@ -123,24 +123,22 @@
     @Override
     protected void initializeWSDLOperation(InterfaceInfo intf, OperationInfo o, Method method)
{
         method = jaxWsConfiguration.getDeclaredMethod(method);
-        
+
         super.initializeWSDLOperation(intf, o, method);
 
         intializeWrapping(o, method);
-        
+
         try {
             // Find the Async method which returns a Response
-            Method responseMethod = method.getDeclaringClass().getDeclaredMethod(method.getName()
+ "Async", 
-                                                                              method.getParameterTypes());
+            Method responseMethod = method.getDeclaringClass().getDeclaredMethod(method.getName()
+ "Async",
+                    method.getParameterTypes());
 
-            
             // Find the Async method whic has a Future & AsyncResultHandler
             List<Class<?>> asyncHandlerParams = new ArrayList(Arrays.asList(method.getParameterTypes()));
             asyncHandlerParams.add(AsyncHandler.class);
-            Method futureMethod = method.getDeclaringClass().getDeclaredMethod(method.getName()
+ "Async", 
-                asyncHandlerParams.toArray(new Class<?>[asyncHandlerParams.size()]));
+            Method futureMethod = method.getDeclaringClass().getDeclaredMethod(method.getName()
+ "Async",
+                    asyncHandlerParams.toArray(new Class<?>[asyncHandlerParams.size()]));
 
-            
             methodDispatcher.bind(o, method, responseMethod, futureMethod);
 
         } catch (SecurityException e) {
@@ -148,7 +146,7 @@
         } catch (NoSuchMethodException e) {
             methodDispatcher.bind(o, method);
         }
-        
+
         // rpc out-message-part-info class mapping
         initalizeClassInfo(o, method);
     }
@@ -157,23 +155,23 @@
         Class responseWrapper = getResponseWrapper(selected);
         if (responseWrapper != null) {
             o.getUnwrappedOperation().getOutput().setProperty(WrapperClassOutInterceptor.WRAPPER_CLASS,
-                                                              responseWrapper);
+                    responseWrapper);
         }
         Class<?> requestWrapper = getRequestWrapper(selected);
         if (requestWrapper != null) {
             o.getUnwrappedOperation().getInput().setProperty(WrappedInInterceptor.WRAPPER_CLASS,
-                                                             requestWrapper);
+                    requestWrapper);
         }
     }
 
     @Override
-    protected void initializeDataBindings() {   
+    protected void initializeDataBindings() {
         try {
             dataBinding = new JAXBDataBinding(jaxWsConfiguration.getEndpointClass());
         } catch (JAXBException e) {
             throw new ServiceConstructionException(e);
         }
-        
+
         setDataBinding(dataBinding);
 
         super.initializeDataBindings();
@@ -189,66 +187,92 @@
         if (o.getOutput() == null) {
             return;
         }
+        int outPartCount = o.getOutput().getMessageParts().size();
+        int inPartCount = o.getInput().getMessageParts().size();
         Object[] para = selected.getParameterTypes();
+        int outIdx = 0;
         for (MessagePartInfo mpiOut : o.getOutput().getMessageParts()) {
-            int idx = 0;
-            boolean isHolder = false;
+            int inIdx = 0;
+            boolean isInOut = false;
             MessagePartInfo mpiInHolder = null;
+            Object[] paraType = selected.getGenericParameterTypes();
             for (MessagePartInfo mpiIn : o.getInput().getMessageParts()) {
                 // check for sayHi() type no input param method
                 if (para.length > 0) {
-                    mpiIn.setProperty(Class.class.getName(), para[idx]);
+                    mpiIn.setProperty(Class.class.getName(), para[inIdx]);
                 }
                 if (mpiOut.getName().equals(mpiIn.getName())) {
                     if (mpiOut.isElement() && mpiIn.isElement()
-                                    && mpiOut.getElementQName().equals(mpiIn.getElementQName()))
{
-                        isHolder = true;
-                        mpiInHolder = mpiIn;
-                        break;
+                            && mpiOut.getElementQName().equals(mpiIn.getElementQName()))
{
+                        isInOut = true;
+                        mpiInHolder = mpiIn;                        
                     } else if (!mpiOut.isElement() && !mpiIn.isElement()
-                                    && mpiOut.getTypeQName().equals(mpiIn.getTypeQName()))
{
-                        isHolder = true;
-                        mpiInHolder = mpiIn;
-                        break;
+                            && mpiOut.getTypeQName().equals(mpiIn.getTypeQName()))
{
+                        isInOut = true;
+                        mpiInHolder = mpiIn;                        
                     }
                 }
-                idx++;
-            }
-            if (isHolder) {
-                Object[] paraType = selected.getGenericParameterTypes();
-                ParameterizedType paramType = (ParameterizedType) paraType[idx];
-                if (((Class) paramType.getRawType()).getName().equals("javax.xml.ws.Holder"))
{
-                    Object rawType = paramType.getActualTypeArguments()[0];
-                    Class rawClass;
-                    if (rawType instanceof GenericArrayType) {
-                        rawClass = (Class) ((GenericArrayType) rawType).getGenericComponentType();
-                        rawClass = Array.newInstance(rawClass, 0).getClass();
-                    } else {
-                        rawClass = (Class) rawType;
-                    }
-                    
+                if (isInOut) {
+                    ParameterizedType paramType = (ParameterizedType) paraType[inIdx];
+                    Class rawClass = getHolderClass(paramType, inIdx);
                     mpiOut.setProperty(Class.class.getName(), rawClass);
                     mpiInHolder.setProperty(Class.class.getName(), rawClass);
+                    mpiOut.setProperty(JaxWsServiceFactoryBean.MODE_INOUT, Boolean.TRUE);
+                    mpiInHolder.setProperty(JaxWsServiceFactoryBean.MODE_INOUT, Boolean.TRUE);
+                    break;
+                }
+                inIdx++;
+            }
+            if (!isInOut) {
+                if (((Class) selected.getReturnType()).getName().equals("void")) {      
             
+                    // to avoid <element name="..."><complexType/></element>
in output message part
+                    if (paraType.length > inPartCount + outIdx) {
+                        ParameterizedType paramType = (ParameterizedType) paraType[inPartCount
+ outIdx];
+                        Class rawClass = getHolderClass(paramType, inPartCount + outIdx);
+                        mpiOut.setProperty(Class.class.getName(), rawClass);
+                        mpiOut.setProperty(JaxWsServiceFactoryBean.MODE_OUT, Boolean.TRUE);
+                    }
                 } else {
-                    throw new RuntimeException("Expected Holder at " + idx
-                                    + " parametor of input message");
+                    String local = mpiOut.isElement() ? mpiOut.getElementQName().getLocalPart()
: mpiOut
+                            .getTypeQName().getLocalPart();
+                    if ("return".equalsIgnoreCase(local) || outPartCount == 1) {
+                        mpiOut.setProperty(Class.class.getName(), selected.getReturnType());
+                    }
+                    // revisit, is there any case that multi-out-parts and one part map to
return type, 
+                    // some map to in-out-holder, some map to out-holder?
                 }
-
-                mpiOut.setProperty(JaxWsServiceFactoryBean.HOLDER, Boolean.TRUE);
-                mpiInHolder.setProperty(JaxWsServiceFactoryBean.HOLDER, Boolean.TRUE);
-            } else {
-                mpiOut.setProperty(Class.class.getName(), selected.getReturnType());
             }
+            outIdx++;
         }
         for (FaultInfo fi : o.getFaults()) {
             int i = 0;
             Class<?> cls = selected.getExceptionTypes()[i];
-            fi.getMessagePartByIndex(0).setProperty(Class.class.getName(), cls);        
       
+            fi.getMessagePartByIndex(0).setProperty(Class.class.getName(), cls);
             if (cls.isAnnotationPresent(WebFault.class)) {
                 fi.getMessagePartByIndex(i).setProperty(WebFault.class.getName(), Boolean.TRUE);
             }
             i++;
         }
+    }
+
+    private static Class getHolderClass(ParameterizedType paramType, int idx) {
+        if (((Class) paramType.getRawType()).getName().equals("javax.xml.ws.Holder")) {
+            Object rawType = paramType.getActualTypeArguments()[0];
+            Class rawClass;
+            if (rawType instanceof GenericArrayType) {                
+                rawClass = (Class) ((GenericArrayType) rawType).getGenericComponentType();
+                rawClass = Array.newInstance(rawClass, 0).getClass();
+            } else {
+                if (rawType instanceof ParameterizedType) {
+                    rawType = (Class) ((ParameterizedType) rawType).getRawType();
+                }
+                rawClass = (Class) rawType;
+            }
+            return rawClass;
+        } else {
+            throw new RuntimeException("Expected Holder at " + idx + " parametor of input
message");
+        }
+
     }
 
     public JaxWsImplementorInfo getJaxWsImplementorInfo() {

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBeanTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBeanTest.java?view=diff&rev=450397&r1=450396&r2=450397
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBeanTest.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBeanTest.java
Wed Sep 27 04:23:10 2006
@@ -93,7 +93,7 @@
         
         assertTrue(itr.hasNext());
         part = itr.next();
-        assertEquals(Boolean.TRUE, part.getProperty(JaxWsServiceFactoryBean.HOLDER));
+        assertEquals(Boolean.TRUE, part.getProperty(JaxWsServiceFactoryBean.MODE_INOUT));
         assertEquals(byte[].class, part.getProperty(Class.class.getName(), Class.class));
         
         assertFalse(itr.hasNext());
@@ -103,7 +103,7 @@
 
         assertTrue(itr.hasNext());
         part = itr.next();
-        assertEquals(Boolean.TRUE, part.getProperty(JaxWsServiceFactoryBean.HOLDER));
+        assertEquals(Boolean.TRUE, part.getProperty(JaxWsServiceFactoryBean.MODE_INOUT));
         
         assertFalse(itr.hasNext());
     }



Mime
View raw message