You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ro...@apache.org on 2008/05/01 19:21:33 UTC
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
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