You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2007/12/04 23:37:40 UTC

svn commit: r601127 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/endpoint/ distribution/src/main/release/samples/ distribution/src/main/release/samples/configuration_interceptor/ rt/core/src/main/java/org/apache/cxf/endpoint/ rt/frontend...

Author: dkulp
Date: Tue Dec  4 14:37:40 2007
New Revision: 601127

URL: http://svn.apache.org/viewvc?rev=601127&view=rev
Log:
[CXF-1244, CXF-973] Fix processing of faultBeans on server side which is enough to fix CXF-1244.  
Add some methods to clients to help out GroovyWS and DynamicClient users.
Add some config to one of the samples to show some of the JMX management stuff (might be cool to  add to more of the demos)


Modified:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/Client.java
    incubator/cxf/trunk/distribution/src/main/release/samples/common_build.xml
    incubator/cxf/trunk/distribution/src/main/release/samples/configuration_interceptor/server.xml
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WebFaultOutInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/Client.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/Client.java?rev=601127&r1=601126&r2=601127&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/Client.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/Client.java Tue Dec  4 14:37:40 2007
@@ -44,6 +44,19 @@
 
     /**
      * Invokes an operation syncronously
+     * @param operationName The name of the operation to be invoked. The service namespace will be used
+     * when looking up the BindingOperationInfo.
+     * @param unwrapped If the operation supports unwrapping, this flag tells whether the params list
+     * is in unwrapped form (true) or wrapped form.
+     * @param params  The params that matches the parts of the input message of the operation
+     * @return The return values that matche the parts of the output message of the operation
+     */
+    Object[] invoke(String operationName,
+                    boolean unwrapped, 
+                    Object... params) throws Exception;
+    
+    /**
+     * Invokes an operation syncronously
      * @param operationName The name of the operation to be invoked
      * @param params  The params that matches the parts of the input message of the operation
      * @return The return values that matche the parts of the output message of the operation
@@ -51,6 +64,18 @@
     Object[] invoke(QName operationName,
                     Object... params) throws Exception;
 
+    /**
+     * Invokes an operation syncronously
+     * @param operationName The name of the operation to be invoked
+     * @param unwrapped If the operation supports unwrapping, this flag tells whether the params list
+     * is in unwrapped form (true) or wrapped form.
+     * @param params  The params that matches the parts of the input message of the operation
+     * @return The return values that matche the parts of the output message of the operation
+     */
+    Object[] invoke(QName operationName,
+                    boolean unwrapped, 
+                    Object... params) throws Exception;
+    
     /**
      * Invokes an operation syncronously
      * @param oi  The operation to be invoked

Modified: incubator/cxf/trunk/distribution/src/main/release/samples/common_build.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/common_build.xml?rev=601127&r1=601126&r2=601127&view=diff
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/common_build.xml (original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/common_build.xml Tue Dec  4 14:37:40 2007
@@ -167,6 +167,7 @@
                 <arg value="@{param3}"/>
                 <arg value="@{param4}"/>
                 <arg value="@{param5}"/>
+                <jvmarg value="-Dcxf.home=${cxf.home}"/>
                 <jvmarg value="@{jvmarg1}"/>
                 <jvmarg value="@{jvmarg2}"/>
                 <jvmarg value="@{jvmarg3}"/>

Modified: incubator/cxf/trunk/distribution/src/main/release/samples/configuration_interceptor/server.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/configuration_interceptor/server.xml?rev=601127&r1=601126&r2=601127&view=diff
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/configuration_interceptor/server.xml (original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/configuration_interceptor/server.xml Tue Dec  4 14:37:40 2007
@@ -47,5 +47,21 @@
                 <ref bean="GZIPStream"/>
             </list>
         </property-->
-    </bean> 
+    </bean>
+
+    <bean id="org.apache.cxf.management.InstrumentationManager"
+          class="org.apache.cxf.management.jmx.InstrumentationManagerImpl">
+      <property name="bus" ref="cxf" />
+      <property name="enabled" value="true"/>
+      <property name="threaded" value="false"/>
+      <property name="daemon" value="false"/>
+      <property name="JMXServiceURL"
+                value="service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi" />
+    </bean>
+
+    <bean id="org.apache.cxf.management.counters.CounterRepository"
+          class="org.apache.cxf.management.counters.CounterRepository">
+      <property name="bus" ref="cxf" />
+    </bean>
+
 </beans>

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java?rev=601127&r1=601126&r2=601127&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java Tue Dec  4 14:37:40 2007
@@ -181,19 +181,25 @@
     }
 
     public Object[] invoke(String operationName, Object... params) throws Exception {
+        return invoke(operationName, true, params);
+    }
+    public Object[] invoke(String operationName, boolean unwrapped, Object... params) throws Exception {
         QName q = new QName(getEndpoint().getService().getName().getNamespaceURI(), operationName);
        
-        return invoke(q, params);
+        return invoke(q, unwrapped, params);
     }
     
     public Object[] invoke(QName operationName, Object... params) throws Exception {
+        return invoke(operationName, true, params);
+    }
+    public Object[] invoke(QName operationName, boolean unwrapped, Object... params) throws Exception {
         BindingOperationInfo op = getEndpoint().getEndpointInfo().getBinding().getOperation(operationName);
         if (op == null) {
             throw new UncheckedException(
                 new org.apache.cxf.common.i18n.Message("NO_OPERATION", LOG, operationName));
         }
         
-        if (op.isUnwrappedCapable()) {
+        if (op.isUnwrappedCapable() && unwrapped) {
             op = op.getUnwrappedOperation();
         }
         

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WebFaultOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WebFaultOutInterceptor.java?rev=601127&r1=601126&r2=601127&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WebFaultOutInterceptor.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WebFaultOutInterceptor.java Tue Dec  4 14:37:40 2007
@@ -30,6 +30,7 @@
 
 import org.w3c.dom.Node;
 
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.common.i18n.BundleUtils;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.StringUtils;
@@ -91,10 +92,8 @@
                 Method method = cause.getClass().getMethod("getFaultInfo", new Class[0]);
                 faultInfo = method.invoke(cause, new Object[0]);
             } catch (NoSuchMethodException e) {
-                faultInfo = cause;
-                LOG.fine("Using @WebFault annotated class "
-                        + faultInfo.getClass().getName() 
-                        + " as faultInfo since getFaultInfo() was not found");
+                faultInfo = createFaultInfoBean(fault, cause);
+                
             } catch (InvocationTargetException e) {
                 throw new Fault(new org.apache.cxf.common.i18n.Message("INVOCATION_TARGET_EXC", BUNDLE), e);
             } catch (IllegalAccessException e) {
@@ -126,6 +125,52 @@
                 super.handleMessage(message);
             }
         }
+    }
+
+    private Object createFaultInfoBean(WebFault fault, Throwable cause) {
+        if (!StringUtils.isEmpty(fault.faultBean())) {
+            try {
+                Class cls = ClassLoaderUtils.loadClass(fault.faultBean(),
+                                                       cause.getClass());
+                if (cls != null) {
+                    Object ret = cls.newInstance();
+                    //copy props
+                    Method meth[] = cause.getClass().getMethods();
+                    for (Method m : meth) {
+                        if (m.getParameterTypes().length == 0
+                            && (m.getName().startsWith("get")
+                            || m.getName().startsWith("is"))) {
+                            try {
+                                Method m2 = cls.getMethod(m.getName(),
+                                                          m.getParameterTypes());
+                                String name;
+                                if (m.getName().startsWith("get")) {
+                                    name = "set" + m.getName().substring(3);
+                                } else {
+                                    name = "set" + m.getName().substring(2);
+                                }
+                                m2 = cls.getMethod(name, m.getReturnType());
+                                m2.invoke(ret, m.invoke(cause));
+                            } catch (Exception e) {
+                                //ignore
+                            }
+                        }
+                    }
+                    return ret;
+                }
+            } catch (ClassNotFoundException e1) {
+                //ignore
+            } catch (InstantiationException e) {
+                //ignore
+            } catch (IllegalAccessException e) {
+                //ignore
+            }
+        }
+
+        LOG.fine("Using @WebFault annotated class "
+                 + cause.getClass().getName() 
+                 + " as faultInfo since getFaultInfo() was not found");
+        return cause;
     }
 
     private MessagePartInfo getFaultMessagePart(QName qname, OperationInfo op) {

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=601127&r1=601126&r2=601127&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 Tue Dec  4 14:37:40 2007
@@ -31,11 +31,14 @@
 import javax.xml.ws.AsyncHandler;
 import javax.xml.ws.Service;
 import javax.xml.ws.Service.Mode;
+import javax.xml.ws.WebFault;
 import javax.xml.ws.WebServiceFeature;
 
 import org.apache.cxf.binding.AbstractBindingFactory;
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.databinding.source.SourceDataBinding;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.endpoint.EndpointException;
@@ -304,8 +307,19 @@
         } catch (SecurityException e) {
             throw new ServiceConstructionException(e);
         } catch (NoSuchMethodException e) {
-            return super.getBeanClass(exClass);
+            //ignore for now
         }
+        WebFault fault = exClass.getAnnotation(WebFault.class);
+        if (fault != null && !StringUtils.isEmpty(fault.faultBean())) {
+            try {
+                return ClassLoaderUtils.loadClass(fault.faultBean(),
+                                                   exClass);
+            } catch (ClassNotFoundException e1) {
+                //ignore
+            }
+        }
+        
+        return super.getBeanClass(exClass);
     }
 
     /**