Return-Path: Delivered-To: apmail-incubator-cxf-dev-archive@locus.apache.org Received: (qmail 44027 invoked from network); 29 Sep 2006 14:58:11 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 29 Sep 2006 14:58:11 -0000 Received: (qmail 58283 invoked by uid 500); 29 Sep 2006 14:58:11 -0000 Delivered-To: apmail-incubator-cxf-dev-archive@incubator.apache.org Received: (qmail 58173 invoked by uid 500); 29 Sep 2006 14:58:11 -0000 Mailing-List: contact cxf-dev-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-dev@incubator.apache.org Received: (qmail 58164 invoked by uid 99); 29 Sep 2006 14:58:10 -0000 Received: from idunn.apache.osuosl.org (HELO idunn.apache.osuosl.org) (140.211.166.84) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 Sep 2006 07:58:10 -0700 X-ASF-Spam-Status: No, hits=0.8 required=5.0 tests=INFO_TLD Received: from [62.221.12.33] ([62.221.12.33:56031] helo=emea-smg1.iona.com) by idunn.apache.osuosl.org (ecelerity 2.1.1.8 r(12930)) with ESMTP id F5/C5-13110-A743D154 for ; Fri, 29 Sep 2006 07:58:05 -0700 Received: from emea-ems1.ionaglobal.com (dutec.ie [10.2.1.125]) by emea-smg1.iona.com (Switch-3.1.7/Switch-3.1.7) with ESMTP id k8TFvfo4011737 for ; Fri, 29 Sep 2006 15:57:41 GMT Received: from [10.5.2.11] ([10.5.2.11]) by emea-ems1.ionaglobal.com with Microsoft SMTPSVC(5.0.2195.6713); Fri, 29 Sep 2006 15:57:58 +0100 Message-ID: <451D344E.6060201@iona.com> Date: Fri, 29 Sep 2006 15:57:18 +0100 From: Andrea Smyth User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: cxf-dev@incubator.apache.org Subject: Re: svn commit: r450934 - in /incubator/cxf/trunk: rt/frontend/jaxws/ 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/resources/META-INF/cxf/ rt/frontend/jaxws/ References: <244F5835C09CB641AE1D928BB2B0B9D8021CCD50@amereast-ems2.IONAGLOBAL.COM> In-Reply-To: <244F5835C09CB641AE1D928BB2B0B9D8021CCD50@amereast-ems2.IONAGLOBAL.COM> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 29 Sep 2006 14:57:58.0360 (UTC) FILETIME=[A6DCCD80:01C6E3D7] X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Liu, Jervis wrote: >Hi Andrea, thanks for pointing this out. I am actually working on this to replace @HandlerChain file schema with the handler schema specified in JSR181, the code I checked in using spring bean just a temporary short cut to make whole things working first. > >However one thing I am not sure is where you got this javaee_web_services_1_2.xsd. It is very similiar to handler schema in JSR181, but with some minor differences, for example, there is no defined in javaee_web_services_1_2.xsd. Are we supposed to use javaee_web_services_1_2.xsd as the handler schema or we should create a handler.xsd by ourself using content copied from jsr181 spec? > > Hi Jervis, I downloaded all javaee*.xsd from http://java.sun.com/xml/ns/javaee/ The schema that should be used to support @HandlerChain annotations is the one with namespace http://www.bea.com/xml/ns/jws. Unfortunately I could not find it online (but I did not look too hard) - c&p it from the JSR 181 spec would be the next best option (Appendix B). The root element of a handler chain config file should be of type jms:handler-configType xmlns:jws=http://www.bea.com/xml/ns/jws. Andrea. > >Thanks, >Jervis > > > > >>-----Original Message----- >>From: Smyth, Andrea >>Sent: Friday, September 29, 2006 9:55 PM >>To: cxf-dev@incubator.apache.org >>Subject: Re: svn commit: r450934 - in /incubator/cxf/trunk: >>rt/frontend/jaxws/ >>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/resources/META-INF/cxf/ rt/frontend/jaxws/ >> >> >>Some comments on this commit: >> >>The files referenced by the @HandlerChain annotation cannot be Spring >>bean config files - according to JSR 181 they should comply >>with schema >>http://www.bea.com/xml/ns.jws. That does not mean that the >>types defined >>there and in the javaee* schemas can't be used for bean >>properties but >>that's another issue (i.e. a question of whether the >>JaxwsEndpointImpl >>class should have a configurable property of this type, that would be >>used if no @HandlerChain annotation is present or else would >>supersede >>such an annotation annotation). >> >> Introducing direct Spring dependencies in the jaxws >>implementation is >>not a good idea IMO. So far, the use of Spring is entirely >>encapsulated >>in the implementations of the bus and/or the Configurer >>interfaces, and >>I think it should stay that way. >> >>Also, I think it is good practice to leave third party schemas >>(javaee_web_services_1_2.xsd) unchanged. Using external >>binding files >>and/or importing them in other schemas should normally be sufficient. >> >>Andrea. >> >> >>jliu@apache.org wrote: >> >> >> >>>Author: jliu >>>Date: Thu Sep 28 10:33:57 2006 >>>New Revision: 450934 >>> >>>URL: http://svn.apache.org/viewvc?view=rev&rev=450934 >>>Log: >>>[CXF-105] The HandlerChain annotation processing in the >>> >>> >>JAX-WS frontend. >> >> >>>Added: >>> >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache >>/cxf/jaxws/handler/AnnotationHandlerChainBuilder.java (with props) >> >> >>> >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache >>/cxf/jaxws/handler/HandlerChainBuilder.java (with props) >> >> >>> >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/META- >>INF/cxf/cxf-property-editors.xml (with props) >> >> >>> >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache >>/cxf/jaxws/handler/AnnotationHandlerChainBuilderTest.java >>(with props) >> >> >>> >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache >>/cxf/jaxws/handler/HandlerChainBuilderTest.java (with props) >> >> >>> incubator/cxf/trunk/rt/frontend/jaxws/src/test/resources/ >>> >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/test/resources/handl >>ers.xml (with props) >> >> >>>Modified: >>> incubator/cxf/trunk/rt/frontend/jaxws/pom.xml >>> >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache >>/cxf/jaxws/EndpointImpl.java >> >> >>> >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache >>/cxf/jaxws/handler/Messages.properties >> >> >>> >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/schem >>as/configuration/javaee_web_services_1_2.xsd >> >> >>> >>> >>> >>incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/syst >>est/handlers/HandlerTestImpl.java >> >> >>> >>> >>> >>incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/syst >>est/handlers/handlers.xml >> >> >>>Modified: incubator/cxf/trunk/rt/frontend/jaxws/pom.xml >>>URL: >>> >>> >>http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/j >>axws/pom.xml?view=diff&rev=450934&r1=450933&r2=450934 >> >> >>>============================================================= >>> >>> >>================= >> >> >>>--- incubator/cxf/trunk/rt/frontend/jaxws/pom.xml (original) >>>+++ incubator/cxf/trunk/rt/frontend/jaxws/pom.xml Thu Sep 28 >>> >>> >>10:33:57 2006 >> >> >>>@@ -117,6 +117,10 @@ >>> >>> >>> >>> >>${basedir}/src/main/resources/schemas/configuration/javae >>e_web_services_1_2.xsd >> >> >>> >>> >>> >>${basedir}/src/main/resources/schemas/configurati >>on/javaee_5.xjb >> >> >>>+ true >>>+ >>>+ >>> >>> >>-Xcfg >> >> >>>+ >>> >>> >>> >>>@@ -125,6 +129,23 @@ >>> >>> >>> >>>+ >>>+ >>>+ org.apache.cxf >>>+ cxf-tools-xjc-cfg >>>+ ${project.version} >>>+ >>>+ >>>+ org.apache.cxf >>>+ cxf-tools-xjc-dv >>>+ ${project.version} >>>+ >>>+ >>>+ org.apache.cxf >>>+ >>> >>> >>cxf-common-utilities >> >> >>>+ ${project.version} >>>+ >>>+ >>> >>> >>> >>> >>>Modified: >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache >>/cxf/jaxws/EndpointImpl.java >> >> >>>URL: >>> >>> >>http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/j >>axws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java?view >>=diff&rev=450934&r1=450933&r2=450934 >> >> >>>============================================================= >>> >>> >>================= >> >> >>>--- >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache >>/cxf/jaxws/EndpointImpl.java (original) >> >> >>>+++ >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache >>/cxf/jaxws/EndpointImpl.java Thu Sep 28 10:33:57 2006 >> >> >>>@@ -32,6 +32,7 @@ >>>import javax.xml.ws.Binding; >>>import javax.xml.ws.Provider; >>>import javax.xml.ws.WebServiceException; >>>+import javax.xml.ws.handler.Handler; >>> >>>import org.apache.cxf.Bus; >>>import org.apache.cxf.BusException; >>>@@ -43,6 +44,8 @@ >>>import org.apache.cxf.jaxb.JAXBDataReaderFactory; >>>import org.apache.cxf.jaxb.JAXBDataWriterFactory; >>>import org.apache.cxf.jaxws.context.WebContextResourceResolver; >>>+import org.apache.cxf.jaxws.handler.AnnotationHandlerChainBuilder; >>>+//import org.apache.cxf.jaxws.javaee.HandlerChainType; >>>import org.apache.cxf.jaxws.support.JaxWsEndpointImpl; >>>import org.apache.cxf.jaxws.support.JaxWsImplementorInfo; >>>import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean; >>>@@ -56,7 +59,7 @@ >>>import org.apache.cxf.wsdl.EndpointReferenceUtils; >>> >>>public class EndpointImpl extends javax.xml.ws.Endpoint { >>>- >>>+ >>> private static final Logger LOG = >>> >>> >>LogUtils.getL7dLogger(JaxWsServiceFactoryBean.class); >> >> >>> private static final ResourceBundle BUNDLE = >>> >>> >>LOG.getResourceBundle(); >> >> >>>@@ -69,7 +72,7 @@ >>> private Service service; >>> private JaxWsEndpointImpl endpoint; >>> private JaxWsImplementorInfo implInfo; >>>- >>>+ >>> @SuppressWarnings("unchecked") >>> public EndpointImpl(Bus b, Object i, String uri) { >>> bus = b; >>>@@ -77,7 +80,7 @@ >>> // bindingURI = uri; >>> // build up the Service model >>> implInfo = new JaxWsImplementorInfo(implementor.getClass()); >>>- >>>+ >>> AbstractServiceFactoryBean serviceFactory; >>> if (implInfo.isWebServiceProvider()) { >>> serviceFactory = new >>> >>> >>ProviderServiceFactoryBean(implInfo); >> >> >>>@@ -94,26 +97,26 @@ >>> if (ei == null) { >>> throw new NullPointerException("Could not find >>> >>> >>endpoint " + endpointName + " in Service."); >> >> >>> } >>>- >>>+ >>> // revisit: should get enableSchemaValidation from >>> >>> >>configuration >> >> >>> if (false) { >>> addSchemaValidation(); >>> } >>>- >>>+ >>> if (implInfo.isWebServiceProvider()) { >>> service.setInvoker(new ProviderInvoker((Provider)i)); >>> } else { >>> service.setInvoker(new JAXWSMethodInvoker(i)); >>> } >>>- >>>+ >>> // TODO: use bindigURI >>> try { >>>- endpoint = new JaxWsEndpointImpl(bus, service, >>> >>> >>ei); >> >> >>>+ endpoint = new JaxWsEndpointImpl(bus, service, ei); >>> } catch (EndpointException e) { >>> throw new WebServiceException(e); >>> } >>> configureObject(endpoint); >>>- >>>+ >>> doInit = true; >>> } >>> >>>@@ -183,7 +186,6 @@ >>> public ServerImpl getServer() { >>> return server; >>> } >>>- >>> >>> /** >>> * inject resources into servant. The resources are injected >>>@@ -204,11 +206,11 @@ >>> >>> protected void doPublish(String address) { >>> init(); >>>- >>>+ >>> if (null != address) { >>> endpoint.getEndpointInfo().setAddress(address); >>> } >>>- >>>+ >>> try { >>> MessageObserver observer; >>> if (implInfo.isWebServiceProvider()) { >>>@@ -216,7 +218,7 @@ >>> } else { >>> observer = new >>> >>> >>ChainInitiationObserver(endpoint, bus); >> >> >>> } >>>- >>>+ >>> server = new ServerImpl(bus, endpoint, observer); >>> server.start(); >>> } catch (BusException ex) { >>>@@ -225,25 +227,25 @@ >>> throw new >>> >>> >>WebServiceException(BUNDLE.getString("FAILED_TO_PUBLISH_ENDPOI >>NT_EXC"), ex); >> >> >>> } >>> } >>>- >>>+ >>> org.apache.cxf.endpoint.Endpoint getEndpoint() { >>> return endpoint; >>> } >>>- >>>+ >>> private void configureObject(Object instance) { >>> Configurer configurer = bus.getExtension(Configurer.class); >>> if (null != configurer) { >>> configurer.configureBean(instance); >>> } >>> } >>>- >>>+ >>> private void addSchemaValidation() { >>> Schema schema = >>> >>> >>EndpointReferenceUtils.getSchema(service.getServiceInfo()); >> >> >>>- >>>+ >>> if (service.getDataBinding().getDataReaderFactory() >>> >>> >>instanceof JAXBDataReaderFactory) { >> >> >>> >>> >>> >>((JAXBDataReaderFactory)service.getDataBinding().getDataReader >>Factory()).setSchema(schema); >> >> >>> } >>>- >>>+ >>> if (service.getDataBinding().getDataWriterFactory() >>> >>> >>instanceof JAXBDataWriterFactory) { >> >> >>> >>> >>> >>((JAXBDataWriterFactory)service.getDataBinding().getDataWriter >>Factory()).setSchema(schema); >> >> >>> } >>>@@ -253,15 +255,36 @@ >>> if (doInit) { >>> try { >>> injectResources(implementor); >>>- >>>+ configureHandlers(); >>>+ >>> } catch (Exception ex) { >>> ex.printStackTrace(); >>>- if (ex instanceof WebServiceException) { >>>- throw (WebServiceException)ex; >>>+ if (ex instanceof WebServiceException) { >>>+ throw (WebServiceException)ex; >>> } >>> throw new WebServiceException("Creation of >>> >>> >>Endpoint failed", ex); >> >> >>> } >>> } >>> doInit = false; >>>+ } >>>+ >>>+ /** >>>+ * Obtain handler chain from configuration first. If >>> >>> >>none is specified, >> >> >>>+ * default to the chain configured in the code, i.e. in >>> >>> >>annotations. >> >> >>>+ * >>>+ */ >>>+ private void configureHandlers() { >>>+ LOG.fine("loading handler chain for endpoint"); >>>+ AnnotationHandlerChainBuilder builder = new >>> >>> >>AnnotationHandlerChainBuilder(); >> >> >>>+ >>>+ //TBD: get configuratoin from config file >>>+ //List chain = >>> >>> >>builder.buildHandlerChainFromConfiguration(hc); >> >> >>>+ >>> >>> >>//builder.setHandlerInitEnabled(configuration.getBoolean(ENABL >> >> >E_HANDLER_INIT)); > > >>>+ List chain = null; >>>+ >>>+ if (null == chain || chain.size() == 0) { >>>+ chain = >>> >>> >>builder.buildHandlerChainFromClass(implementor.getClass()); >> >> >>>+ } >>>+ getBinding().setHandlerChain(chain); >>> } >>>} >>> >>>Added: >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache >>/cxf/jaxws/handler/AnnotationHandlerChainBuilder.java >> >> >>>URL: >>> >>> >>http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/j >>axws/src/main/java/org/apache/cxf/jaxws/handler/AnnotationHand >>lerChainBuilder.java?view=auto&rev=450934 >> >> >>>============================================================= >>> >>> >>================= >> >> >>>--- >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache >>/cxf/jaxws/handler/AnnotationHandlerChainBuilder.java (added) >> >> >>>+++ >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache >>/cxf/jaxws/handler/AnnotationHandlerChainBuilder.java Thu Sep >>28 10:33:57 2006 >> >> >>>@@ -0,0 +1,156 @@ >>>+/** >>>+ * 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.handler; >>>+ >>>+import java.util.ArrayList; >>>+import java.util.List; >>>+import java.util.ResourceBundle; >>>+import java.util.logging.Level; >>>+import java.util.logging.Logger; >>>+ >>>+import javax.jws.HandlerChain; >>>+import javax.xml.ws.WebServiceException; >>>+import javax.xml.ws.handler.Handler; >>>+ >>>+import org.apache.cxf.Bus; >>>+import org.apache.cxf.common.logging.LogUtils; >>>+import org.apache.cxf.configuration.Configurer; >>>+import org.apache.cxf.configuration.spring.ConfigurerImpl; >>>+import >>> >>> >>org.apache.cxf.configuration.spring.JaxbClassPathXmlApplicatio >>nContext; >> >> >>>+import org.apache.cxf.jaxws.javaee.HandlerChainType; >>>+import org.apache.cxf.jaxws.javaee.HandlerConfigBean; >>>+import org.springframework.context.ApplicationContext; >>>+ >>>+public class AnnotationHandlerChainBuilder extends >>> >>> >>HandlerChainBuilder { >> >> >>>+ >>>+ private static final Logger LOG = >>> >>> >>LogUtils.getL7dLogger(AnnotationHandlerChainBuilder.class); >> >> >>>+ private static final ResourceBundle BUNDLE = >>> >>> >>LOG.getResourceBundle(); >> >> >>>+ >>>+ public AnnotationHandlerChainBuilder() { >>>+ } >>>+ >>>+ public AnnotationHandlerChainBuilder(Bus bus) { >>>+ super(bus); >>>+ } >>>+ >>>+ /** >>>+ * @param clz >>>+ * @param existingHandlers >>>+ * @return >>>+ */ >>>+ public List >>> >>> >>buildHandlerChainFromClass(Class clz, List >>existingHandlers) { >> >> >>>+ >>>+ LOG.fine("building handler chain"); >>>+ HandlerChainAnnotation hcAnn = >>> >>> >>findHandlerChainAnnotation(clz); >> >> >>>+ List chain = null; >>>+ if (hcAnn == null) { >>>+ LOG.fine("no HandlerChain annotation on " + clz); >>>+ chain = new ArrayList(); >>>+ } else { >>>+ hcAnn.validate(); >>>+ String handlerFile = hcAnn.getFileName(); >>>+ >>>+ // This Configurer needs to be different from >>> >>> >>system configurer as >> >> >>>+ // it is only aware of handler configure file. >>>+ ApplicationContext ac = new >>> >>> >>JaxbClassPathXmlApplicationContext(new String[] { >> >> >>>+ handlerFile, >>>+ "META-INF/cxf/cxf-property-editors.xml"}); >>>+ Configurer configurer = new ConfigurerImpl(ac); >>>+ >>>+ HandlerConfigBean hcb = new HandlerConfigBean(); >>>+ configurer.configureBean(hcb); >>>+ HandlerChainType hc = hcb.getJaxwshandler(); >>>+ >>>+ if (null == hc) { >>>+ throw new >>> >>> >>WebServiceException(BUNDLE.getString("CHAIN_NOT_SPECIFIED_EXC")); >> >> >>>+ } >>>+ >>>+ chain = buildHandlerChain(hc, clz.getClassLoader()); >>>+ } >>>+ assert chain != null; >>>+ if (existingHandlers != null) { >>>+ chain.addAll(existingHandlers); >>>+ } >>>+ return sortHandlers(chain); >>>+ } >>>+ >>>+ public List buildHandlerChainFromClass(Class clz) { >>>+ return buildHandlerChainFromClass(clz, null); >>>+ } >>>+ >>>+ private HandlerChainAnnotation >>> >>> >>findHandlerChainAnnotation(Class clz) { >> >> >>>+ >>>+ HandlerChain ann = clz.getAnnotation(HandlerChain.class); >>>+ Class declaringClass = clz; >>>+ >>>+ if (ann == null) { >>>+ for (Class iface : clz.getInterfaces()) { >>>+ if (LOG.isLoggable(Level.FINE)) { >>>+ LOG.fine("checking for HandlerChain >>> >>> >>annotation on " + iface.getName()); >> >> >>>+ } >>>+ ann = iface.getAnnotation(HandlerChain.class); >>>+ if (ann != null) { >>>+ declaringClass = iface; >>>+ break; >>>+ } >>>+ } >>>+ } >>>+ if (ann != null) { >>>+ return new HandlerChainAnnotation(ann, declaringClass); >>>+ } else { >>>+ return null; >>>+ } >>>+ } >>>+ >>>+ private static class HandlerChainAnnotation { >>>+ private final Class declaringClass; >>>+ private final HandlerChain ann; >>>+ >>>+ HandlerChainAnnotation(HandlerChain hc, Class clz) { >>>+ ann = hc; >>>+ declaringClass = clz; >>>+ } >>>+ >>>+ public Class getDeclaringClass() { >>>+ return declaringClass; >>>+ } >>>+ >>>+ public String getFileName() { >>>+ return ann.file(); >>>+ } >>>+ >>>+ public String getChainName() { >>>+ return ann.name(); >>>+ } >>>+ >>>+ public void validate() { >>>+ if (null == ann.file() || "".equals(ann.file())) { >>>+ throw new >>> >>> >>WebServiceException(BUNDLE.getString("ANNOTATION_WITHOUT_URL_EXC")); >> >> >>>+ } >>>+ if (null == ann.name() || "".equals(ann.name())) { >>>+ LOG.fine("no handler name specified, >>> >>> >>defaulting to first declared"); >> >> >>>+ } >>>+ } >>>+ >>>+ public String toString() { >>>+ return "[" + declaringClass + "," + ann + "]"; >>>+ } >>>+ } >>>+} >>> >>>Propchange: >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache >>/cxf/jaxws/handler/AnnotationHandlerChainBuilder.java >> >> >>>------------------------------------------------------------- >>> >>> >>----------------- >> >> >>> svn:eol-style = native >>> >>>Propchange: >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache >>/cxf/jaxws/handler/AnnotationHandlerChainBuilder.java >> >> >>>------------------------------------------------------------- >>> >>> >>----------------- >> >> >>> svn:keywords = Rev Date >>> >>>Added: >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache >>/cxf/jaxws/handler/HandlerChainBuilder.java >> >> >>>URL: >>> >>> >>http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/j >>axws/src/main/java/org/apache/cxf/jaxws/handler/HandlerChainBu >>ilder.java?view=auto&rev=450934 >> >> >>>============================================================= >>> >>> >>================= >> >> >>>--- >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache >>/cxf/jaxws/handler/HandlerChainBuilder.java (added) >> >> >>>+++ >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache >>/cxf/jaxws/handler/HandlerChainBuilder.java Thu Sep 28 10:33:57 2006 >> >> >>>@@ -0,0 +1,184 @@ >>>+/** >>>+ * 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.handler; >>>+ >>>+import java.lang.reflect.InvocationTargetException; >>>+import java.lang.reflect.Method; >>>+import java.util.ArrayList; >>>+import java.util.HashMap; >>>+import java.util.List; >>>+import java.util.Map; >>>+import java.util.ResourceBundle; >>>+import java.util.logging.Level; >>>+import java.util.logging.Logger; >>>+ >>>+import javax.xml.ws.WebServiceException; >>>+import javax.xml.ws.handler.Handler; >>>+import javax.xml.ws.handler.LogicalHandler; >>>+ >>>+import org.apache.cxf.Bus; >>>+import org.apache.cxf.common.injection.ResourceInjector; >>>+import org.apache.cxf.common.logging.LogUtils; >>>+import org.apache.cxf.jaxws.javaee.HandlerChainType; >>>+import org.apache.cxf.jaxws.javaee.ParamValueType; >>>+import org.apache.cxf.jaxws.javaee.PortComponentHandlerType; >>>+import org.apache.cxf.resource.ResourceManager; >>>+import org.apache.cxf.resource.ResourceResolver; >>>+ >>>+public class HandlerChainBuilder { >>>+ static final Logger LOG = >>> >>> >>LogUtils.getL7dLogger(HandlerChainBuilder.class); >> >> >>>+ private static final ResourceBundle BUNDLE = >>> >>> >>LOG.getResourceBundle(); >> >> >>>+ >>>+ private Bus bus; >>>+ >>>+ private boolean handlerInitEnabled; >>>+ >>>+ public HandlerChainBuilder(Bus aBus) { >>>+ bus = aBus; >>>+ } >>>+ >>>+ public HandlerChainBuilder() { >>>+ this(null); >>>+ } >>>+ >>>+ public List >>> >>> >>buildHandlerChainFromConfiguration(HandlerChainType hc) { >> >> >>>+ if (null == hc) { >>>+ return null; >>>+ } >>>+ return sortHandlers(buildHandlerChain(hc, >>> >>> >>getHandlerClassLoader())); >> >> >>>+ } >>>+ >>>+ /** >>>+ * sorts the handlers into correct order. All of the >>> >>> >>logical handlers first >> >> >>>+ * followed by the protocol handlers >>>+ * >>>+ * @param handlers >>>+ * @return sorted list of handlers >>>+ */ >>>+ public List sortHandlers(List handlers) { >>>+ >>>+ List logicalHandlers = new >>> >>> >>ArrayList(); >> >> >>>+ List protocolHandlers = new ArrayList(); >>>+ >>>+ for (Handler handler : handlers) { >>>+ if (handler instanceof LogicalHandler) { >>>+ logicalHandlers.add((LogicalHandler)handler); >>>+ } else { >>>+ protocolHandlers.add(handler); >>>+ } >>>+ } >>>+ >>>+ List sortedHandlers = new ArrayList(); >>>+ sortedHandlers.addAll(logicalHandlers); >>>+ sortedHandlers.addAll(protocolHandlers); >>>+ return sortedHandlers; >>>+ } >>>+ >>>+ public void setHandlerInitEnabled(boolean b) { >>>+ handlerInitEnabled = b; >>>+ } >>>+ >>>+ public boolean isHandlerInitEnabled() { >>>+ return handlerInitEnabled; >>>+ } >>>+ >>>+ protected ClassLoader getHandlerClassLoader() { >>>+ return getClass().getClassLoader(); >>>+ } >>>+ >>>+ protected List >>> >>> >>buildHandlerChain(HandlerChainType hc, ClassLoader classLoader) { >> >> >>>+ List handlerChain = new ArrayList(); >>>+ for (PortComponentHandlerType ht : hc.getHandler()) { >>>+ try { >>>+ LOG.log(Level.FINE, "loading handler", >>> >>> >>trimString(ht.getHandlerName().getValue())); >> >> >>>+ >>>+ Class handlerClass = >>> >>> >>Class.forName( >> >> >>>+ >>> >>> >> trimString(ht.getHandlerClass() >> >> >>>+ >>> >>> >> .getValue()), true, classLoader) >> >> >>>+ .asSubclass(Handler.class); >>>+ >>>+ Handler handler = handlerClass.newInstance(); >>>+ LOG.fine("adding handler to chain: " + handler); >>>+ configureHandler(handler, ht); >>>+ handlerChain.add(handler); >>>+ } catch (Exception e) { >>>+ throw new >>> >>> >>WebServiceException(BUNDLE.getString("HANDLER_INSTANTIATION_EXC"), e); >> >> >>>+ } >>>+ } >>>+ return handlerChain; >>>+ } >>>+ >>>+ private void configureHandler(Handler handler, >>> >>> >>PortComponentHandlerType h) { >> >> >>>+ if (!handlerInitEnabled) { >>>+ return; >>>+ } >>>+ >>>+ if (h.getInitParam().size() == 0) { >>>+ return; >>>+ } >>>+ >>>+ Map params = new HashMap(); >>>+ >>>+ for (ParamValueType param : h.getInitParam()) { >>>+ params.put(trimString(param.getParamName() == >>> >>> >>null ? null : param.getParamName().getValue()), >> >> >>>+ trimString(param.getParamValue() == >>> >>> >>null ? null : param.getParamValue().getValue())); >> >> >>>+ } >>>+ >>>+ Method initMethod = getInitMethod(handler); >>>+ if (initMethod != null) { >>>+ initializeViaInitMethod(handler, params, initMethod); >>>+ } else { >>>+ initializeViaInjection(handler, params); >>>+ } >>>+ } >>>+ >>>+ private void initializeViaInjection(Handler handler, >>> >>> >>final Map params) { >> >> >>>+ ResourceManager resMgr = >>> >>> >>bus.getExtension(ResourceManager.class); >> >> >>>+ List resolvers = >>> >>> >>resMgr.getResourceResolvers(); >> >> >>>+ resolvers.add(new InitParamResourceResolver(params)); >>>+ ResourceInjector resInj = new >>> >>> >>ResourceInjector(resMgr, resolvers); >> >> >>>+ resInj.inject(handler); >>>+ } >>>+ >>>+ private void initializeViaInitMethod(Handler handler, >>> >>> >>Map params, Method init) { >> >> >>>+ try { >>>+ init.invoke(handler, params); >>>+ } catch (InvocationTargetException ex) { >>>+ Throwable t = ex.getCause() != null ? >>> >>> >>ex.getCause() : ex; >> >> >>>+ LogUtils.log(LOG, Level.WARNING, >>> >>> >>"INIT_METHOD_THREW_EXCEPTION", t, handler.getClass()); >> >> >>>+ } catch (IllegalAccessException ex) { >>>+ LOG.log(Level.SEVERE, "CANNOT_ACCESS_INIT", >>> >>> >>handler.getClass()); >> >> >>>+ } >>>+ } >>>+ >>>+ private Method getInitMethod(Handler handler) { >>>+ Method m = null; >>>+ try { >>>+ m = handler.getClass().getMethod("init", Map.class); >>>+ } catch (NoSuchMethodException ex) { >>>+ // emtpy >>>+ } >>>+ return m; >>>+ } >>>+ >>>+ private String trimString(String str) { >>>+ return str != null ? str.trim() : null; >>>+ } >>>+} >>> >>>Propchange: >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache >>/cxf/jaxws/handler/HandlerChainBuilder.java >> >> >>>------------------------------------------------------------- >>> >>> >>----------------- >> >> >>> svn:eol-style = native >>> >>>Propchange: >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache >>/cxf/jaxws/handler/HandlerChainBuilder.java >> >> >>>------------------------------------------------------------- >>> >>> >>----------------- >> >> >>> svn:keywords = Rev Date >>> >>>Modified: >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache >>/cxf/jaxws/handler/Messages.properties >> >> >>>URL: >>> >>> >>http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/j >>axws/src/main/java/org/apache/cxf/jaxws/handler/Messages.prope >>rties?view=diff&rev=450934&r1=450933&r2=450934 >> >> >>>============================================================= >>> >>> >>================= >> >> >>>--- >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache >>/cxf/jaxws/handler/Messages.properties (original) >> >> >>>+++ >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache >>/cxf/jaxws/handler/Messages.properties Thu Sep 28 10:33:57 2006 >> >> >>>@@ -1,4 +1,7 @@ >>>NO_INPUT_STREAM_EXC = No input stream available. >>>NO_OUTPUT_STREAM_EXC = No output stream available. >>>ANNOTATION_WITHOUT_URL_EXC = @HandlerChain annotation does >>> >>> >>not contain a file name or url. >> >> >>>-HANDLER_CFG_FILE_NOT_FOUND_EXC = Unable to load handler >>> >>> >>configuration {0} specified by annotation, file not found." >> >> >>>\ No newline at end of file >>>+HANDLER_CFG_FILE_NOT_FOUND_EXC = Unable to load handler >>> >>> >>configuration {0} specified by annotation, file not found." >> >> >>>+HANDLER_INSTANTIATION_EXC = Failed to instantiate handler >>>+CHAIN_NOT_SPECIFIED_EXC = Chain not specified >>>+ >>> >>>Added: >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/META- >>INF/cxf/cxf-property-editors.xml >> >> >>>URL: >>> >>> >>http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/j >>axws/src/main/resources/META-INF/cxf/cxf-property-editors.xml? >>view=auto&rev=450934 >> >> >>>============================================================= >>> >>> >>================= >> >> >>>--- >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/META- >>INF/cxf/cxf-property-editors.xml (added) >> >> >>>+++ >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/META- >>INF/cxf/cxf-property-editors.xml Thu Sep 28 10:33:57 2006 >> >> >>>@@ -0,0 +1,49 @@ >>>+ >>>+ >>>+>>+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >>>+ xsi:schemaLocation=" >>>+http://www.springframework.org/schema/beans >>> >>> >>http://www.springframework.org/schema/beans/spring-beans.xsd"> >> >> >>>+ >>>+ >> >>> >>id="org.apache.cxf.jaxws.javaee.customEditorConfigurer" >>class="org.springframework.beans.factory.config.CustomEditorCo >>nfigurer"> >> >> >>>+ >>>+ >>>+ >>>+ >> >>> >>class="org.apache.cxf.configuration.spring.JaxbPropertyEditorR >>egistrar"> >> >> >>>+ >> >>> >>value="org.apache.cxf.jaxws.javaee"/> >> >> >>>+ >>>+ >>>+ HandlerChainType >>>+ PortComponentHandlerType >>>+ DisplayNameType >>>+ IconType >>>+ FullyQualifiedClassType >>>+ ParamValueType >>>+ XsdQNameType >>>+ String >>>+ >>>+ >>>+ >>>+ >>>+ >>>+ >>>+ >>>\ No newline at end of file >>> >>>Propchange: >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/META- >>INF/cxf/cxf-property-editors.xml >> >> >>>------------------------------------------------------------- >>> >>> >>----------------- >> >> >>> svn:eol-style = native >>> >>>Propchange: >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/META- >>INF/cxf/cxf-property-editors.xml >> >> >>>------------------------------------------------------------- >>> >>> >>----------------- >> >> >>> svn:keywords = Rev Date >>> >>>Propchange: >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/META- >>INF/cxf/cxf-property-editors.xml >> >> >>>------------------------------------------------------------- >>> >>> >>----------------- >> >> >>> svn:mime-type = text/xml >>> >>>Modified: >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/schem >>as/configuration/javaee_web_services_1_2.xsd >> >> >>>URL: >>> >>> >>http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/j >>axws/src/main/resources/schemas/configuration/javaee_web_servi >>ces_1_2.xsd?view=diff&rev=450934&r1=450933&r2=450934 >> >> >>>============================================================= >>> >>> >>================= >> >> >>>--- >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/schem >>as/configuration/javaee_web_services_1_2.xsd (original) >> >> >>>+++ >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/main/resources/schem >>as/configuration/javaee_web_services_1_2.xsd Thu Sep 28 10:33:57 2006 >> >> >>>@@ -3,8 +3,12 @@ >>> targetNamespace="http://java.sun.com/xml/ns/javaee" >>> xmlns:javaee="http://java.sun.com/xml/ns/javaee" >>> xmlns:xsd="http://www.w3.org/2001/XMLSchema" >>>+ xmlns:cfg="http://cxf.apache.org/configuration/cfg" >>>+ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" >>> elementFormDefault="qualified" >>> attributeFormDefault="unqualified" >>>+ jaxb:extensionBindingPrefixes="cfg" >>>+ jaxb:version="2.0" >>> version="1.2"> >>> >>> >>>@@ -743,5 +747,16 @@ >>> >>> >>> >>>+ >>>+ >>>+ >>>+ >>>+ >>>+ >>>+ >>>+ >>>+ >>>+ >>>+ >>> >>> >>> >>>Added: >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache >>/cxf/jaxws/handler/AnnotationHandlerChainBuilderTest.java >> >> >>>URL: >>> >>> >>http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/j >>axws/src/test/java/org/apache/cxf/jaxws/handler/AnnotationHand >>lerChainBuilderTest.java?view=auto&rev=450934 >> >> >>>============================================================= >>> >>> >>================= >> >> >>>--- >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache >>/cxf/jaxws/handler/AnnotationHandlerChainBuilderTest.java (added) >> >> >>>+++ >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache >>/cxf/jaxws/handler/AnnotationHandlerChainBuilderTest.java Thu >>Sep 28 10:33:57 2006 >> >> >>>@@ -0,0 +1,76 @@ >>>+/** >>>+ * 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.handler; >>>+ >>>+import java.util.List; >>>+import java.util.Map; >>>+ >>>+import javax.jws.HandlerChain; >>>+import javax.jws.WebService; >>>+import javax.xml.ws.handler.Handler; >>>+import javax.xml.ws.handler.LogicalHandler; >>>+import javax.xml.ws.handler.MessageContext; >>>+ >>>+import junit.framework.TestCase; >>>+ >>>+public class AnnotationHandlerChainBuilderTest extends TestCase { >>>+ >>>+ public void setUp() { >>>+ } >>>+ >>>+ public void testFindHandlerChainAnnotation() { >>>+ HandlerTestImpl handlerTestImpl = new HandlerTestImpl(); >>>+ System.out.println(TestLogicalHandler.class.getName()); >>>+ AnnotationHandlerChainBuilder chainBuilder = new >>> >>> >>AnnotationHandlerChainBuilder(); >> >> >>>+ List handlers = >>> >>> >>chainBuilder.buildHandlerChainFromClass(handlerTestImpl.getClass()); >> >> >>>+ assertNotNull(handlers); >>>+ assertEquals(2, handlers.size()); >>>+ assertEquals(TestLogicalHandler.class, >>> >>> >>handlers.get(0).getClass()); >> >> >>>+ assertEquals(TestLogicalHandler.class, >>> >>> >>handlers.get(1).getClass()); >> >> >>>+ } >>>+ >>>+ public static class TestLogicalHandler implements >>> >>> >>LogicalHandler { >> >> >>>+ Map config; >>>+ boolean initCalled; >>>+ >>>+ public void close(MessageContext arg0) { >>>+ } >>>+ >>>+ public boolean handleFault(MessageContext arg0) { >>>+ return false; >>>+ } >>>+ >>>+ public boolean handleMessage(MessageContext arg0) { >>>+ return false; >>>+ } >>>+ >>>+ public final void init(final Map map) { >>>+ config = map; >>>+ initCalled = true; >>>+ } >>>+ } >>>+ >>>+ @WebService() >>>+ @HandlerChain(file = "./handlers.xml", name = >>> >>> >>"TestHandlerChain") >> >> >>>+ public class HandlerTestImpl { >>>+ >>>+ } >>>+ >>>+} >>> >>>Propchange: >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache >>/cxf/jaxws/handler/AnnotationHandlerChainBuilderTest.java >> >> >>>------------------------------------------------------------- >>> >>> >>----------------- >> >> >>> svn:eol-style = native >>> >>>Propchange: >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache >>/cxf/jaxws/handler/AnnotationHandlerChainBuilderTest.java >> >> >>>------------------------------------------------------------- >>> >>> >>----------------- >> >> >>> svn:keywords = Rev Date >>> >>>Added: >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache >>/cxf/jaxws/handler/HandlerChainBuilderTest.java >> >> >>>URL: >>> >>> >>http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/j >>axws/src/test/java/org/apache/cxf/jaxws/handler/HandlerChainBu >>ilderTest.java?view=auto&rev=450934 >> >> >>>============================================================= >>> >>> >>================= >> >> >>>--- >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache >>/cxf/jaxws/handler/HandlerChainBuilderTest.java (added) >> >> >>>+++ >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache >>/cxf/jaxws/handler/HandlerChainBuilderTest.java Thu Sep 28 >>10:33:57 2006 >> >> >>>@@ -0,0 +1,240 @@ >>>+/** >>>+ * 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.handler; >>>+ >>>+import java.util.Arrays; >>>+import java.util.List; >>>+import java.util.Map; >>>+ >>>+import javax.xml.ws.WebServiceException; >>>+import javax.xml.ws.handler.Handler; >>>+import javax.xml.ws.handler.LogicalHandler; >>>+import javax.xml.ws.handler.MessageContext; >>>+ >>>+import junit.framework.TestCase; >>>+ >>>+import org.apache.cxf.Bus; >>>+import org.apache.cxf.jaxws.javaee.FullyQualifiedClassType; >>>+import org.apache.cxf.jaxws.javaee.HandlerChainType; >>>+import org.apache.cxf.jaxws.javaee.ParamValueType; >>>+import org.apache.cxf.jaxws.javaee.PortComponentHandlerType; >>>+import org.easymock.classextension.EasyMock; >>>+ >>>+public class HandlerChainBuilderTest extends TestCase { >>>+ >>>+ Handler[] allHandlers = >>> >>> >>{EasyMock.createMock(LogicalHandler.class), >>EasyMock.createMock(Handler.class), >> >> >>>+ >>> >>> >>EasyMock.createMock(Handler.class), >>EasyMock.createMock(LogicalHandler.class)}; >> >> >>>+ Handler[] logicalHandlers = {allHandlers[0], allHandlers[3]}; >>>+ Handler[] protocolHandlers = {allHandlers[1], allHandlers[2]}; >>>+ >>>+ HandlerChainBuilder builder = new >>> >>> >>HandlerChainBuilder(EasyMock.createNiceMock(Bus.class)); >> >> >>>+ >>>+ public void setUp() { >>>+ builder.setHandlerInitEnabled(true); >>>+ } >>>+ >>>+ public void testChainSorting() { >>>+ List sortedHandlerChain = >>> >>> >>builder.sortHandlers(Arrays.asList(allHandlers)); >> >> >>>+ assertSame(logicalHandlers[0], sortedHandlerChain.get(0)); >>>+ assertSame(logicalHandlers[1], sortedHandlerChain.get(1)); >>>+ assertSame(protocolHandlers[0], sortedHandlerChain.get(2)); >>>+ assertSame(protocolHandlers[1], sortedHandlerChain.get(3)); >>>+ } >>>+ >>>+ public void testBuildHandlerChainFromConfiguration() { >>>+ >>>+ HandlerChainType hc = createHandlerChainType(); >>>+ List chain = >>> >>> >>builder.buildHandlerChainFromConfiguration(hc); >> >> >>>+ >>>+ assertNotNull(chain); >>>+ assertEquals(4, chain.size()); >>>+ assertEquals(TestLogicalHandler.class, >>> >>> >>chain.get(0).getClass()); >> >> >>>+ assertEquals(TestLogicalHandler.class, >>> >>> >>chain.get(1).getClass()); >> >> >>>+ assertEquals(TestProtocolHandler.class, >>> >>> >>chain.get(2).getClass()); >> >> >>>+ assertEquals(TestProtocolHandler.class, >>> >>> >>chain.get(3).getClass()); >> >> >>>+ >>>+ TestLogicalHandler tlh = (TestLogicalHandler)chain.get(0); >>>+ assertTrue(!tlh.initCalled); >>>+ assertNull(tlh.config); >>>+ } >>>+ >>>+ public void testBuilderCallsInit() { >>>+ HandlerChainType hc = createHandlerChainType(); >>>+ hc.getHandler().remove(3); >>>+ hc.getHandler().remove(2); >>>+ hc.getHandler().remove(1); >>>+ >>>+ PortComponentHandlerType h = hc.getHandler().get(0); >>>+ List params = h.getInitParam(); >>>+ >>>+ ParamValueType p = new ParamValueType(); >>>+ org.apache.cxf.jaxws.javaee.String pName = new >>> >>> >>org.apache.cxf.jaxws.javaee.String(); >> >> >>>+ pName.setValue("foo"); >>>+ p.setParamName(pName); >>>+ org.apache.cxf.jaxws.javaee.XsdStringType pValue = >>> >>> >>new org.apache.cxf.jaxws.javaee.XsdStringType(); >> >> >>>+ pValue.setValue("1"); >>>+ p.setParamValue(pValue); >>>+ params.add(p); >>>+ >>>+ p = new ParamValueType(); >>>+ pName = new org.apache.cxf.jaxws.javaee.String(); >>>+ pName.setValue("bar"); >>>+ p.setParamName(pName); >>>+ pValue = new org.apache.cxf.jaxws.javaee.XsdStringType(); >>>+ pValue.setValue("2"); >>>+ p.setParamValue(pValue); >>>+ params.add(p); >>>+ >>>+ List chain = >>> >>> >>builder.buildHandlerChainFromConfiguration(hc); >> >> >>>+ assertEquals(1, chain.size()); >>>+ TestLogicalHandler tlh = (TestLogicalHandler)chain.get(0); >>>+ >>>+ assertTrue(tlh.initCalled); >>>+ Map cfg = tlh.config; >>>+ assertNotNull(tlh.config); >>>+ >>>+ assertEquals(2, cfg.keySet().size()); >>>+ assertEquals("1", cfg.get("foo")); >>>+ assertEquals("2", cfg.get("bar")); >>>+ } >>>+ >>>+ public void testBuilderCallsInitWithNoInitParamValues() { >>>+ HandlerChainType hc = createHandlerChainType(); >>>+ hc.getHandler().remove(3); >>>+ hc.getHandler().remove(2); >>>+ hc.getHandler().remove(1); >>>+ >>>+ PortComponentHandlerType h = hc.getHandler().get(0); >>>+ List params = h.getInitParam(); >>>+ >>>+ ParamValueType p = new ParamValueType(); >>>+ org.apache.cxf.jaxws.javaee.String pName = new >>> >>> >>org.apache.cxf.jaxws.javaee.String(); >> >> >>>+ pName.setValue("foo"); >>>+ p.setParamName(pName); >>>+ params.add(p); >>>+ >>>+ List chain = >>> >>> >>builder.buildHandlerChainFromConfiguration(hc); >> >> >>>+ assertEquals(1, chain.size()); >>>+ TestLogicalHandler tlh = (TestLogicalHandler)chain.get(0); >>>+ >>>+ assertTrue(tlh.initCalled); >>>+ Map cfg = tlh.config; >>>+ assertNotNull(tlh.config); >>>+ assertEquals(1, cfg.keySet().size()); >>>+ } >>>+ >>>+ public void testBuilderCannotLoadHandlerClass() { >>>+ HandlerChainType hc = createHandlerChainType(); >>>+ hc.getHandler().remove(3); >>>+ hc.getHandler().remove(2); >>>+ hc.getHandler().remove(1); >>>+ FullyQualifiedClassType type = new >>> >>> >>FullyQualifiedClassType(); >> >> >>>+ type.setValue("no.such.class"); >>>+ hc.getHandler().get(0).setHandlerClass(type); >>>+ >>>+ try { >>>+ builder.buildHandlerChainFromConfiguration(hc); >>>+ fail("did not get expected exception"); >>>+ } catch (WebServiceException ex) { >>>+ // ex.printStackTrace(); >>>+ assertNotNull(ex.getCause()); >>>+ assertEquals(ClassNotFoundException.class, >>> >>> >>ex.getCause().getClass()); >> >> >>>+ } >>>+ } >>>+ >>>+ private HandlerChainType createHandlerChainType() { >>>+ HandlerChainType hc = new HandlerChainType(); >>>+ List handlers = hc.getHandler(); >>>+ >>>+ PortComponentHandlerType h = new PortComponentHandlerType(); >>>+ org.apache.cxf.jaxws.javaee.String name = new >>> >>> >>org.apache.cxf.jaxws.javaee.String(); >> >> >>>+ name.setValue("lh1"); >>>+ h.setHandlerName(name); >>>+ FullyQualifiedClassType type = new >>> >>> >>FullyQualifiedClassType(); >> >> >>>+ type.setValue(TestLogicalHandler.class.getName()); >>>+ h.setHandlerClass(type); >>>+ handlers.add(h); >>>+ >>>+ h = new PortComponentHandlerType(); >>>+ name = new org.apache.cxf.jaxws.javaee.String(); >>>+ name.setValue("ph1"); >>>+ h.setHandlerName(name); >>>+ type = new FullyQualifiedClassType(); >>>+ type.setValue(TestProtocolHandler.class.getName()); >>>+ h.setHandlerClass(type); >>>+ handlers.add(h); >>>+ >>>+ h = new PortComponentHandlerType(); >>>+ name = new org.apache.cxf.jaxws.javaee.String(); >>>+ name.setValue("ph2"); >>>+ h.setHandlerName(name); >>>+ type = new FullyQualifiedClassType(); >>>+ type.setValue(TestProtocolHandler.class.getName()); >>>+ h.setHandlerClass(type); >>>+ handlers.add(h); >>>+ >>>+ h = new PortComponentHandlerType(); >>>+ name = new org.apache.cxf.jaxws.javaee.String(); >>>+ name.setValue("lh2"); >>>+ h.setHandlerName(name); >>>+ type = new FullyQualifiedClassType(); >>>+ type.setValue(TestLogicalHandler.class.getName()); >>>+ h.setHandlerClass(type); >>>+ handlers.add(h); >>>+ >>>+ return hc; >>>+ } >>>+ >>>+ public static class TestLogicalHandler implements >>> >>> >>LogicalHandler { >> >> >>>+ >>>+ Map config; >>>+ boolean initCalled; >>>+ >>>+ public void close(MessageContext arg0) { >>>+ } >>>+ >>>+ public boolean handleFault(MessageContext arg0) { >>>+ return false; >>>+ } >>>+ >>>+ public boolean handleMessage(MessageContext arg0) { >>>+ return false; >>>+ } >>>+ >>>+ public final void init(final Map map) { >>>+ config = map; >>>+ initCalled = true; >>>+ } >>>+ } >>>+ >>>+ public static class TestProtocolHandler implements Handler { >>>+ >>>+ public void close(MessageContext arg0) { >>>+ } >>>+ >>>+ public boolean handleFault(MessageContext arg0) { >>>+ return false; >>>+ } >>>+ >>>+ public boolean handleMessage(MessageContext arg0) { >>>+ return false; >>>+ } >>>+ } >>>+} >>> >>>Propchange: >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache >>/cxf/jaxws/handler/HandlerChainBuilderTest.java >> >> >>>------------------------------------------------------------- >>> >>> >>----------------- >> >> >>> svn:eol-style = native >>> >>>Propchange: >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache >>/cxf/jaxws/handler/HandlerChainBuilderTest.java >> >> >>>------------------------------------------------------------- >>> >>> >>----------------- >> >> >>> svn:keywords = Rev Date >>> >>>Added: >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/test/resources/handlers.xml >> >> >>>URL: >>> >>> >>http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/j >>axws/src/test/resources/handlers.xml?view=auto&rev=450934 >> >> >>>============================================================= >>> >>> >>================= >> >> >>>--- >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/test/resources/handl >>ers.xml (added) >> >> >>>+++ >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/test/resources/handl >>ers.xml Thu Sep 28 10:33:57 2006 >> >> >>>@@ -0,0 +1,50 @@ >>>+ >>>+ >>>+>>+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >>>+ xmlns:javaee="http://java.sun.com/xml/ns/javaee" >>>+ >>> >>> >>xsi:schemaLocation="http://www.springframework.org/schema/bean >>s http://www.springframework.org/schema/beans/spring-beans.xsd"> >> >> >>>+ >>>+ >> >>> >>id="org.apache.cxf.jaxws.javaee.HandlerConfigBean" abstract="true"> >> >> >>>+ >>>+ >>>+ >>>+ >>>+ >>> >>> >>lh1 >> >> >>>+ >>> >>> >>org.apache.cxf.jaxws.handler.AnnotationH >>andlerChainBuilderTest$TestLogicalHandler >> >> >>>+ >>>+ >>> >>> >>token >> >> >>>+ >>> >>> >>String >> >> >>>+ >>>+ >>>+ >>>+ >>> >>> >>lh2 >> >> >>>+ >>> >>> >>org.apache.cxf.jaxws.handler.AnnotationH >>andlerChainBuilderTest$TestLogicalHandler >> >> >>>+ >>>+ >>> >>> >>token >> >> >>>+ >>> >>> >>String >> >> >>>+ >>>+ >>>+ >>>+ >>>+ >>>+ >>>+ >>>+ >>>\ No newline at end of file >>> >>>Propchange: >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/test/resources/handlers.xml >> >> >>>------------------------------------------------------------- >>> >>> >>----------------- >> >> >>> svn:eol-style = native >>> >>>Propchange: >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/test/resources/handlers.xml >> >> >>>------------------------------------------------------------- >>> >>> >>----------------- >> >> >>> svn:keywords = Rev Date >>> >>>Propchange: >>> >>> >>incubator/cxf/trunk/rt/frontend/jaxws/src/test/resources/handlers.xml >> >> >>>------------------------------------------------------------- >>> >>> >>----------------- >> >> >>> svn:mime-type = text/xml >>> >>>Modified: >>> >>> >>incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/syst >>est/handlers/HandlerTestImpl.java >> >> >>>URL: >>> >>> >>http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/ >>test/java/org/apache/cxf/systest/handlers/HandlerTestImpl.java >>?view=diff&rev=450934&r1=450933&r2=450934 >> >> >>>============================================================= >>> >>> >>================= >> >> >>>--- >>> >>> >>incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/syst >>est/handlers/HandlerTestImpl.java (original) >> >> >>>+++ >>> >>> >>incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/syst >>est/handlers/HandlerTestImpl.java Thu Sep 28 10:33:57 2006 >> >> >>>@@ -22,7 +22,7 @@ >>>import java.util.ArrayList; >>>import java.util.List; >>>import javax.annotation.Resource; >>>-import javax.jws.HandlerChain; >>>+//import javax.jws.HandlerChain; >>>import javax.jws.WebService; >>>import javax.xml.ws.WebServiceContext; >>>import javax.xml.ws.handler.MessageContext; >>>@@ -30,15 +30,14 @@ >>>import org.apache.handler_test.PingException; >>>import org.apache.handler_test.types.PingFaultDetails; >>> >>>-@WebService(serviceName = "HandlerTestService", >>>- portName = "SoapPort", >>>- endpointInterface = >>> >>> >>"org.apache.handler_test.HandlerTest", >> >> >>>+@WebService(serviceName = "HandlerTestService", >>>+ portName = "SoapPort", >>>+ endpointInterface = >>> >>> >>"org.apache.handler_test.HandlerTest", >> >> >>> targetNamespace = "http://apache.org/handler_test") >>>-@HandlerChain(file = "./handlers.xml", name = "TestHandlerChain") >>>public class HandlerTestImpl implements HandlerTest { >>> >>>- private WebServiceContext context; >>>- >>>+ private WebServiceContext context; >>>+ >>> public final List ping() { >>> >>> try { >>>@@ -51,40 +50,40 @@ >>> } catch (Exception e) { >>> e.printStackTrace(); >>> >>>- } >>>+ } >>> return null; >>> } >>> >>> public final void pingOneWay() { >>>- } >>>+ } >>> >>> public final List pingWithArgs(String >>> >>> >>handlerCommand) throws PingException { >> >> >>>- List ret = new ArrayList(); >>>- ret.add(handlerCommand); >>>+ List ret = new ArrayList(); >>>+ ret.add(handlerCommand); >>> //ret.addAll(getHandlersInfo(context.getMessageContext())); >>> >>> if (handlerCommand.contains("throw exception")) { >>>- PingFaultDetails details = new PingFaultDetails(); >>>+ PingFaultDetails details = new PingFaultDetails(); >>> details.setDetail(ret.toString()); >>>- throw new PingException("from servant", details); >>>+ throw new PingException("from servant", details); >>> } >>> >>> return ret; >>>- } >>>+ } >>> >>> >>>- @Resource public void >>> >>> >>setWebServiceContext(WebServiceContext ctx) { >> >> >>>+ @Resource public void >>> >>> >>setWebServiceContext(WebServiceContext ctx) { >> >> >>> context = ctx; >>> } >>> >>> @SuppressWarnings("unchecked") >>>- private List getHandlersInfo(MessageContext ctx) { >>>- List ret = (List)ctx.get("handler.info"); >>>+ private List getHandlersInfo(MessageContext ctx) { >>>+ List ret = (List)ctx.get("handler.info"); >>> if (ret == null) { >>>- ret = new ArrayList(); >>>+ ret = new ArrayList(); >>> } >>> return ret; >>>- } >>>+ } >>> >>>} >>> >>>Modified: >>> >>> >>incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/syst >>est/handlers/handlers.xml >> >> >>>URL: >>> >>> >>http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/ >>test/java/org/apache/cxf/systest/handlers/handlers.xml?view=di >>ff&rev=450934&r1=450933&r2=450934 >> >> >>>============================================================= >>> >>> >>================= >> >> >>>--- >>> >>> >>incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/syst >>est/handlers/handlers.xml (original) >> >> >>>+++ >>> >>> >>incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/syst >>est/handlers/handlers.xml Thu Sep 28 10:33:57 2006 >> >> >>>@@ -1,4 +1,5 @@ >>>- >>>- >>>- >>>- TestHandlerChain >>>- >>>- Handler1 >>>- >>> >>> >>org.apache.cxf.systest.handlers.TestHandler>ndler-class> >> >> >>>- >>>- >>>- Handler2 >>>- >>> >>> >>org.apache.cxf.systest.handlers.TestHandler>ndler-class> >> >> >>>- >>>- >>>- ProtocolHandler1 >>>- >>> >>> >>org.apache.cxf.systest.handlers.TestSOAPHandler >> >> >> >>>- >>>- >>>- ProtocolHandler2 >>>- >>> >>> >>org.apache.cxf.systest.handlers.TestSOAPHandler >> >> >> >>>- >>>- >>>- StreamHandler1 >>>- >>> >>> >>org.apache.cxf.systest.handlers.TestStreamHandl >>er >> >> >>>- >>>- >>>- >>>- SingleHandlerChain >>>- >>>- SingleHandler >>>- >>> >>> >>org.apache.cxf.systest.handlers.TestHandler>ndler-class> >> >> >>>- >>>- >>>- >>>+>>+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >>>+ xmlns:javaee="http://java.sun.com/xml/ns/javaee" >>>+ >>> >>> >>xsi:schemaLocation="http://www.springframework.org/schema/bean >>s http://www.springframework.org/schema/beans/spring-beans.xsd"> >> >> >>>+ >>>+ >> >>> >>id="org.apache.cxf.jaxws.javaee.HandlerConfigBean" abstract="true"> >> >> >>>+ >>>+ >>>+ >>>+ >>>+ >>> >>> >>lh1 >> >> >>>+ >>> >>> >>org.apache.cxf.systest.handlers.TestSOAP >>Handler >> >> >>>+ >>>+ >>> >>> >>token >> >> >>>+ >>> >>> >>String >> >> >>>+ >>>+ >>>+ >>>+ >>> >>> >>lh2 >> >> >>>+ >>> >>> >>org.apache.cxf.systest.handlers.TestSOAP >>Handler >> >> >>>+ >>>+ >>> >>> >>token >> >> >>>+ >>> >>> >>String >> >> >>>+ >>>+ >>>+ >>>+ >>>+ >>>+ >>>+ >>>+ >>>\ No newline at end of file >>> >>> >>> >>> >>> >>> >> >>