You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by tl...@apache.org on 2006/09/14 06:02:15 UTC

svn commit: r443217 - in /incubator/cxf/trunk/rt: bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/

Author: tli
Date: Wed Sep 13 21:02:14 2006
New Revision: 443217

URL: http://svn.apache.org/viewvc?view=rev&rev=443217
Log:
refactor the soap RPC interceptor by get Parametor class from message part info

Added:
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsUtils.java   (with props)
Modified:
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCInInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointInvocationHandler.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java

Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCInInterceptor.java?view=diff&rev=443217&r1=443216&r2=443217
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCInInterceptor.java (original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCInInterceptor.java Wed Sep 13 21:02:14 2006
@@ -19,7 +19,6 @@
 
 package org.apache.cxf.binding.soap.interceptor;
 
-import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -27,6 +26,7 @@
 
 import org.apache.cxf.databinding.DataReader;
 import org.apache.cxf.interceptor.AbstractInDatabindingInterceptor;
+import org.apache.cxf.interceptor.BareInInterceptor;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.Phase;
 import org.apache.cxf.service.model.BindingOperationInfo;
@@ -55,9 +55,6 @@
 
         BindingOperationInfo operation = ServiceModelUtil.getOperation(message.getExchange(), new QName(
                         xmlReader.getNamespaceURI(), opName));
-        if (operation == null) {
-            message.setContent(Exception.class, new RuntimeException("Could not find operation:" + opName));
-        }
         return operation;
     }
 
@@ -67,7 +64,10 @@
         BindingOperationInfo operation = null;
         if (message.getExchange().get(BindingOperationInfo.class) == null) {
             operation = getOperation(message, xmlReader);
-            // Store operation into the message.
+            if (operation == null) {
+                // it's doc-lit-bare 
+                new BareInInterceptor().handleMessage(message);
+            }
             message.getExchange().put(BindingOperationInfo.class, operation);
         } else {
             operation = message.getExchange().get(BindingOperationInfo.class);
@@ -76,9 +76,9 @@
         DataReader<Message> dr = getMessageDataReader(message);
 
         if (!isRequestor(message)) {
-            msg = operation.getInput().getMessageInfo();
+            msg = operation.getOperationInfo().getInput();
         } else {
-            msg = operation.getOutput().getMessageInfo();
+            msg = operation.getOperationInfo().getOutput();
         }
 
         List<Object> parameters = new ArrayList<Object>();
@@ -97,23 +97,9 @@
             if (!elName.getLocalPart().equals(name.getLocalPart())) {
                 String expMessage = "Parameter " + name + " does not equal to the name in the servicemodel!";
                 message.setContent(Exception.class, new RuntimeException(expMessage));
-            }
-            Method meth = (Method) operation.getOperationInfo().getProperty(Method.class.getName());
+            }            
             Object param = null;
-            if (!isRequestor(message)) {                
-                if (meth.getParameterTypes() != null && meth.getParameterTypes().length > idx) {
-                    param = dr.read(elName, message, meth.getParameterTypes()[idx]);
-                } else {
-                    throw new RuntimeException("can't match the method param no." + idx
-                                    + " with message part " + p.getName());
-                }
-            } else {
-                if (idx == 0 && meth.getReturnType() != null) {
-                    param = dr.read(elName, message, meth.getReturnType());
-                } else {
-                    // to do, handle holder
-                }
-            }
+            param = dr.read(elName, message, (Class)p.getProperty(Class.class.getName()));                
             if (param != null) {
                 parameters.add(param);
             } else {

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointInvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointInvocationHandler.java?view=diff&rev=443217&r1=443216&r2=443217
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointInvocationHandler.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointInvocationHandler.java Wed Sep 13 21:02:14 2006
@@ -49,6 +49,7 @@
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.interceptor.WrappedInInterceptor;
 import org.apache.cxf.jaxws.interceptors.WrapperClassOutInterceptor;
+import org.apache.cxf.jaxws.support.JaxWsUtils;
 import org.apache.cxf.service.model.BindingOperationInfo;
 import org.apache.cxf.service.model.InterfaceInfo;
 import org.apache.cxf.service.model.OperationInfo;
@@ -85,14 +86,11 @@
             throw new WebServiceException(msg.toString());
         }
 
-        
-
         Object[] params = args;
         if (null == params) {
             params = new Object[0];
         }
-        
-
+        JaxWsUtils.setClassInfo(oi.getOperationInfo(), null, method);
         Object[] paramsWithOutHolder = handleHolder(params);
         Map<String, Object> context = new HashMap<String, Object>();
         //context.put(Method.class.getName(), method);

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=443217&r1=443216&r2=443217
==============================================================================
--- 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 13 21:02:14 2006
@@ -52,9 +52,11 @@
 
 public class JaxWsServiceFactoryBean extends ReflectionServiceFactoryBean {
 
+    public static final String HOLDER = "messagepart.isholer";
+    
     private static final Logger LOG = LogUtils.getL7dLogger(JaxWsServiceFactoryBean.class);
 
-    private static final ResourceBundle BUNDLE = LOG.getResourceBundle();
+    private static final ResourceBundle BUNDLE = LOG.getResourceBundle();      
 
     Class<?> seiClass;
 
@@ -102,7 +104,9 @@
         Class<?> requestWrapper = getRequestWrapper(selected);
         if (requestWrapper != null) {
             o.setProperty(WrappedInInterceptor.SINGLE_WRAPPED_PART, Boolean.TRUE);
-        }
+        }        
+        // rpc out-message-part-info class mapping
+        JaxWsUtils.setClassInfo(o, selected, null);
     }
 
     @Override

Added: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsUtils.java?view=auto&rev=443217
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsUtils.java (added)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsUtils.java Wed Sep 13 21:02:14 2006
@@ -0,0 +1,106 @@
+/**
+ * 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.jaxws.support;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+
+import org.apache.cxf.service.model.MessagePartInfo;
+import org.apache.cxf.service.model.OperationInfo;
+
+public final class JaxWsUtils {
+
+    private JaxWsUtils() {
+    }
+
+    /**
+     * set the holder generic type info into message part info
+     * 
+     * @param o
+     * @param implMethod
+     *            if is null, use seiMethod
+     * @param seiMethod
+     *            if is null, use implMethod
+     */
+    public static void setClassInfo(OperationInfo o, Method implMethod, Method seiMethod) {
+        Method selected = null;
+        if (implMethod == null && seiMethod == null) {
+            throw new RuntimeException("Both implementation method and SEI method are null");
+        }
+        if (o.getOutput() == null) {
+            return;
+        }
+        if (implMethod == null) {
+            selected = seiMethod;
+        } else {
+            selected = implMethod;
+        }
+
+        Object[] para = selected.getParameterTypes();
+        for (MessagePartInfo mpiOut : o.getOutput().getMessageParts()) {
+            int idx = 0;
+            boolean isHolder = false;
+            MessagePartInfo mpiInHolder = null;
+            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]);
+                }
+                if (mpiOut.getName().equals(mpiIn.getName())) {
+                    if (mpiOut.isElement() && mpiIn.isElement()
+                                    && mpiOut.getElementQName().equals(mpiIn.getElementQName())) {
+                        isHolder = true;
+                        mpiInHolder = mpiIn;
+                        break;
+                    } else if (!mpiOut.isElement() && !mpiIn.isElement()
+                                    && mpiOut.getTypeQName().equals(mpiIn.getTypeQName())) {
+                        isHolder = true;
+                        mpiInHolder = mpiIn;
+                        break;
+                    }
+                }
+                idx++;
+            }
+            if (isHolder) {
+                if (selected == seiMethod) {
+                    Object[] paraType = selected.getGenericParameterTypes();
+                    ParameterizedType paramType = (ParameterizedType) paraType[idx];
+                    if (((Class)paramType.getRawType()).getName().equals("javax.xml.ws.Holder")) {
+                        mpiOut.setProperty(Class.class.getName(),
+                                        (Class) paramType.getActualTypeArguments()[0]);
+                        mpiInHolder.setProperty(Class.class.getName(), (Class) paramType
+                                        .getActualTypeArguments()[0]);
+                    } else {
+                        throw new RuntimeException("Expected Holder at " + idx
+                                        + " parametor of input message");
+                    }
+                } else {
+                    mpiOut.setProperty(Class.class.getName(), para[idx]);
+                    mpiInHolder.setProperty(Class.class.getName(), para[idx]);
+                }
+                mpiOut.setProperty(JaxWsServiceFactoryBean.HOLDER, Boolean.TRUE);
+                mpiInHolder.setProperty(JaxWsServiceFactoryBean.HOLDER, Boolean.TRUE);
+            } else {
+                mpiOut.setProperty(Class.class.getName(), selected.getReturnType());
+            }
+        }
+
+    }
+}

Propchange: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native