Return-Path: Delivered-To: apmail-ws-axis-dev-archive@www.apache.org Received: (qmail 50055 invoked from network); 1 May 2008 17:21:59 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 1 May 2008 17:21:59 -0000 Received: (qmail 48363 invoked by uid 500); 1 May 2008 17:22:00 -0000 Delivered-To: apmail-ws-axis-dev-archive@ws.apache.org Received: (qmail 48252 invoked by uid 500); 1 May 2008 17:21:59 -0000 Mailing-List: contact axis-cvs-help@ws.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list axis-cvs@ws.apache.org Received: (qmail 48241 invoked by uid 500); 1 May 2008 17:21:59 -0000 Delivered-To: apmail-ws-axis2-cvs@ws.apache.org Received: (qmail 48238 invoked by uid 99); 1 May 2008 17:21:59 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 May 2008 10:21:59 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 May 2008 17:21:13 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 0CD9A238887B; Thu, 1 May 2008 10:21:34 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r652583 - in /webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description: builder/MDQConstants.java impl/DescriptionUtils.java impl/EndpointDescriptionImpl.java impl/ServiceDescriptionImpl.java Date: Thu, 01 May 2008 17:21:33 -0000 To: axis2-cvs@ws.apache.org From: rott@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080501172134.0CD9A238887B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: rott Date: Thu May 1 10:21:31 2008 New Revision: 652583 URL: http://svn.apache.org/viewvc?rev=652583&view=rev Log: JAX-WS EndpointDescription and ServiceDescription code were not accounting for the @HandlerChain annotation appearing in the sparse composite. The *Description code assumed that the HandlerChainsType object would have already been built up by sparse composite, which is not necessarily true. It is possible only the @HandlerChain annotation is available. Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionUtils.java webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java?rev=652583&r1=652582&r2=652583&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java (original) +++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java Thu May 1 10:21:31 2008 @@ -52,6 +52,8 @@ public static final String CLIENT_SERVICE_CLASS = "CLIENT_SERVICE_CLASS"; public static final String CLIENT_SEI_CLASS = "CLIENT_SEI_CLASS"; + public static final String HANDLER_CHAIN_DECLARING_CLASS = "HANDLER_CHAIN_DECLARING_CLASS"; + //Represent SOAP/JMS Bindings //REVIEW: SOAP-JMS may be using the same NS for SOAP11 and SOAP12, // if so we could remove some duplicate values below Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionUtils.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionUtils.java?rev=652583&r1=652582&r2=652583&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionUtils.java (original) +++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionUtils.java Thu May 1 10:21:31 2008 @@ -270,7 +270,7 @@ } if (configStream == null) { if (log.isDebugEnabled()) { - log.debug("@HandlerChain.file attribute referes to a relative location: " + log.debug("@HandlerChain.file attribute refers to a relative location: " + configFile); } className = className.replace(".", "/"); @@ -285,7 +285,7 @@ if (log.isDebugEnabled()) { log.debug("@HandlerChain.file resolved file path location: " + resolvedPath); } - configStream = classLoader.getResourceAsStream(resolvedPath); + configStream = getInputStream(resolvedPath, classLoader); } catch (URISyntaxException e) { throw ExceptionFactory.makeWebServiceException(Messages.getMessage("hcConfigLoadFail", @@ -294,8 +294,14 @@ } } if (configStream == null) { - throw ExceptionFactory.makeWebServiceException(Messages.getMessage("handlerChainNS", - configFile, className)); + //throw ExceptionFactory.makeWebServiceException(Messages.getMessage("handlerChainNS", + // configFile, className)); + // No longer throwing an exception here. This method is best-effort, and the caller may + // change the class to which the path is relative and try again. The caller is responsible + // for determining when to "give up" + if (log.isDebugEnabled()) { + log.debug("@HandlerChain configuration fail: " + configFile + " in class: " + className + " failed to load."); + } } else { if (log.isDebugEnabled()) { log.debug("@HandlerChain configuration file: " + configFile + " in class: " + @@ -304,6 +310,25 @@ } return configStream; } + + private static InputStream getInputStream(String path, ClassLoader classLoader) { + InputStream configStream = classLoader.getResourceAsStream(path); + if (configStream == null) { + // try another classloader + ClassLoader cl = System.class.getClassLoader(); + if (cl != null) { + configStream = cl.getResourceAsStream(path); + } + } + if (configStream == null) { + // and another classloader + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + if (cl != null) { + configStream = cl.getResourceAsStream(path); + } + } + return configStream; + } /** * Determine is this method is an async method Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java?rev=652583&r1=652582&r2=652583&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java (original) +++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java Thu May 1 10:21:31 2008 @@ -1324,19 +1324,23 @@ * */ public HandlerChainsType getHandlerChain(Object sparseCompositeKey) { + + DescriptionBuilderComposite sparseComposite = null; + // If there is a HandlerChainsType in the sparse composite for this ServiceDelegate // (i.e. this sparseCompositeKey), then return that. if (sparseCompositeKey != null) { - DescriptionBuilderComposite sparseComposite = composite.getSparseComposite(sparseCompositeKey); + sparseComposite = composite.getSparseComposite(sparseCompositeKey); if (sparseComposite != null && sparseComposite.getHandlerChainsType() != null) { - return sparseComposite.getHandlerChainsType(); + HandlerChainsType hct = sparseComposite.getHandlerChainsType(); + return hct; } } // If there is no HandlerChainsType in the composite, then read in the file specified // on the HandlerChain annotation if it is present. if (handlerChainsType == null) { - getAnnoHandlerChainAnnotation(); + getAnnoHandlerChainAnnotation(sparseCompositeKey); if (handlerChainAnnotation != null) { String handlerFileName = handlerChainAnnotation.file(); @@ -1364,9 +1368,23 @@ handlerFileName, className, classLoader); + if (is == null) { + // config stream is still null. This may mean the @HandlerChain annotation is on a *driver* class + // next to a @WebServiceRef annotation, so the path is relative to the class declaring @HandlerChain + // and NOT relative to the Service or Endpoint class, which also means we should use the sparseComposite + // since that is where the @HandlerChain annotation info would have been loaded. + if (sparseComposite != null) { + String handlerChainDeclaringClass = (String)sparseComposite.getProperties().get(MDQConstants.HANDLER_CHAIN_DECLARING_CLASS); + if (handlerChainDeclaringClass != null) { + className = handlerChainDeclaringClass; + is = DescriptionUtils.openHandlerConfigStream(handlerFileName, className, classLoader); + } + } + } if(is == null) { - log.warn("Unable to load handlers from file: " + handlerFileName); + throw ExceptionFactory.makeWebServiceException(Messages.getMessage("handlerChainNS", + handlerFileName, className)); } else { ClassLoader classLoader1 = (ClassLoader) AccessController.doPrivileged( new PrivilegedAction() { @@ -1383,7 +1401,7 @@ return handlerChainsType; } - public HandlerChain getAnnoHandlerChainAnnotation() { + public HandlerChain getAnnoHandlerChainAnnotation(Object sparseCompositeKey) { if (this.handlerChainAnnotation == null) { if (composite.isServiceProvider()) { /* @@ -1414,6 +1432,14 @@ handlerChainAnnotation = composite.getHandlerChainAnnot(); } } + if (handlerChainAnnotation == null) { + if (sparseCompositeKey != null) { + DescriptionBuilderComposite sparseComposite = composite.getSparseComposite(sparseCompositeKey); + if (sparseComposite != null && sparseComposite.getHandlerChainAnnot() != null) { + handlerChainAnnotation = sparseComposite.getHandlerChainAnnot(); + } + } + } return handlerChainAnnotation; } Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java?rev=652583&r1=652582&r2=652583&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java (original) +++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java Thu May 1 10:21:31 2008 @@ -1758,10 +1758,12 @@ * @see org.apache.axis2.jaxws.description.ServiceDescription#getHandlerChain(java.lang.Object) */ public HandlerChainsType getHandlerChain(Object sparseCompositeKey) { + DescriptionBuilderComposite sparseComposite = null; + // If there is a HandlerChainsType in the sparse composite for this ServiceDelegate // (i.e. this sparseCompositeKey), then return that. if (sparseCompositeKey != null) { - DescriptionBuilderComposite sparseComposite = composite.getSparseComposite(sparseCompositeKey); + sparseComposite = composite.getSparseComposite(sparseCompositeKey); if (sparseComposite != null && sparseComposite.getHandlerChainsType() != null) { return sparseComposite.getHandlerChainsType(); } @@ -1771,7 +1773,7 @@ // on the HandlerChain annotation if it is present. if (handlerChainsType == null) { - getAnnoHandlerChainAnnotation(); + getAnnoHandlerChainAnnotation(sparseCompositeKey); if (handlerChainAnnotation != null) { String handlerFileName = handlerChainAnnotation.file(); @@ -1789,9 +1791,24 @@ DescriptionUtils.openHandlerConfigStream(handlerFileName, className, classLoader); + if (is == null) { + // config stream is still null. This may mean the @HandlerChain annotation is on a *driver* class + // next to a @WebServiceRef annotation, so the path is relative to the class declaring @HandlerChain + // and NOT relative to the Service or Endpoint class, which also means we should use the sparseComposite + // since that is where the @HandlerChain annotation info would have been loaded. + if (sparseComposite != null) { + String handlerChainDeclaringClass = (String)sparseComposite.getProperties().get(MDQConstants.HANDLER_CHAIN_DECLARING_CLASS); + if (handlerChainDeclaringClass != null) { + className = handlerChainDeclaringClass; + is = DescriptionUtils.openHandlerConfigStream(handlerFileName, className, classLoader); + } + } + } if(is == null) { - log.warn("Unable to load handlers from file: " + handlerFileName); + throw ExceptionFactory.makeWebServiceException(Messages.getMessage("handlerChainNS", + handlerFileName, className)); + } else { handlerChainsType = @@ -1808,7 +1825,7 @@ * This is a client side only method. The generated service class may contain * handler chain annotations */ - public HandlerChain getAnnoHandlerChainAnnotation() { + public HandlerChain getAnnoHandlerChainAnnotation(Object sparseCompositeKey) { if (this.handlerChainAnnotation == null) { Class serviceClass = composite.getCorrespondingClass(); if (serviceClass != null) { @@ -1816,6 +1833,14 @@ (HandlerChain) getAnnotation(serviceClass, HandlerChain.class); } } + if (handlerChainAnnotation == null) { + if (sparseCompositeKey != null) { + DescriptionBuilderComposite sparseComposite = composite.getSparseComposite(sparseCompositeKey); + if (sparseComposite != null && sparseComposite.getHandlerChainAnnot() != null) { + handlerChainAnnotation = sparseComposite.getHandlerChainAnnot(); + } + } + } return handlerChainAnnotation; } --------------------------------------------------------------------- To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org For additional commands, e-mail: axis-cvs-help@ws.apache.org