Return-Path: Delivered-To: apmail-incubator-cxf-commits-archive@locus.apache.org Received: (qmail 536 invoked from network); 4 Dec 2007 22:38:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 4 Dec 2007 22:38:07 -0000 Received: (qmail 55160 invoked by uid 500); 4 Dec 2007 22:37:55 -0000 Delivered-To: apmail-incubator-cxf-commits-archive@incubator.apache.org Received: (qmail 55028 invoked by uid 500); 4 Dec 2007 22:37:55 -0000 Mailing-List: contact cxf-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cxf-dev@incubator.apache.org Delivered-To: mailing list cxf-commits@incubator.apache.org Received: (qmail 55018 invoked by uid 99); 4 Dec 2007 22:37:55 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Dec 2007 14:37:55 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Dec 2007 22:38:03 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id CC3331A983A; Tue, 4 Dec 2007 14:37:41 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 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... Date: Tue, 04 Dec 2007 22:37:40 -0000 To: cxf-commits@incubator.apache.org From: dkulp@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071204223741.CC3331A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 @@ + 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 @@ - + + + + + + + + + + + + + + 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); } /**