JBossWS SVN: r17756 - in common/trunk/src/main/java/org/jboss/ws/common: deployment and 1 other directory.
by jbossws-commits@lists.jboss.org
Author: jim.ma
Date: 2013-07-01 04:29:30 -0400 (Mon, 01 Jul 2013)
New Revision: 17756
Modified:
common/trunk/src/main/java/org/jboss/ws/common/Messages.java
common/trunk/src/main/java/org/jboss/ws/common/deployment/ArchiveDeploymentImpl.java
common/trunk/src/main/java/org/jboss/ws/common/deployment/ResourceResolverImpl.java
Log:
[JBWS-3655]:Enalbe ResourceReolve to resolve resource from classloader
Modified: common/trunk/src/main/java/org/jboss/ws/common/Messages.java
===================================================================
--- common/trunk/src/main/java/org/jboss/ws/common/Messages.java 2013-06-26 10:02:54 UTC (rev 17755)
+++ common/trunk/src/main/java/org/jboss/ws/common/Messages.java 2013-07-01 08:29:30 UTC (rev 17756)
@@ -223,8 +223,8 @@
@Message(id = 22089, value = "Unexpectedly reached end of XML document: %s")
IllegalStateException reachedEndOfXMLDocUnexpectedly(String descriptor);
- @Message(id = 22092, value = "Could not find %s in the additional metadatafiles")
- IOException cannotFindInAdditionalMetaData(String resourcePath);
+ @Message(id = 22092, value = "Could not resolve %s in deployment %s")
+ IOException cannotResolveResource(String resourcePath, String deploymentName);
@Message(id = 22093, value = "Context root expected to start with leading slash: %s")
IllegalStateException contextRootExpectedToStartWithLeadingSlash(String contextRoot);
Modified: common/trunk/src/main/java/org/jboss/ws/common/deployment/ArchiveDeploymentImpl.java
===================================================================
--- common/trunk/src/main/java/org/jboss/ws/common/deployment/ArchiveDeploymentImpl.java 2013-06-26 10:02:54 UTC (rev 17755)
+++ common/trunk/src/main/java/org/jboss/ws/common/deployment/ArchiveDeploymentImpl.java 2013-07-01 08:29:30 UTC (rev 17756)
@@ -31,6 +31,7 @@
* A general web service deployment that is based on an archive.
*
* @author Thomas.Diesler(a)jboss.com
+ * @author ema(a)redhat.com
* @since 20-Apr-2007
*/
public class ArchiveDeploymentImpl extends DefaultDeployment implements ArchiveDeployment
@@ -87,6 +88,6 @@
public ResourceResolver getResourceResolver()
{
- return new ResourceResolverImpl(rootFile, metadataFiles);
+ return new ResourceResolverImpl(this);
}
}
Modified: common/trunk/src/main/java/org/jboss/ws/common/deployment/ResourceResolverImpl.java
===================================================================
--- common/trunk/src/main/java/org/jboss/ws/common/deployment/ResourceResolverImpl.java 2013-06-26 10:02:54 UTC (rev 17755)
+++ common/trunk/src/main/java/org/jboss/ws/common/deployment/ResourceResolverImpl.java 2013-07-01 08:29:30 UTC (rev 17756)
@@ -30,13 +30,16 @@
import java.util.Iterator;
import org.jboss.ws.common.Messages;
+import org.jboss.wsf.spi.deployment.ArchiveDeployment;
import org.jboss.wsf.spi.deployment.ResourceResolver;
import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
/**
- * A resource resolver implementation using unified virtual files
+ * A resource resolver implementation using unified virtual files
+ * and classloader
*
* @author alessio.soldano(a)jboss.com
+ * @author ema(a)redhat.com
* @since 19-Nov-2009
*
*/
@@ -44,11 +47,13 @@
{
private UnifiedVirtualFile rootFile;
private Collection<UnifiedVirtualFile> metadataFiles;
+ private ArchiveDeployment deployment;
- public ResourceResolverImpl(UnifiedVirtualFile rootFile, Collection<UnifiedVirtualFile> metadataFiles)
+ public ResourceResolverImpl(final ArchiveDeployment deployment)
{
- this.rootFile = rootFile;
- this.metadataFiles = metadataFiles;
+ this.deployment = deployment;
+ this.rootFile = deployment.getRootFile();
+ this.metadataFiles = deployment.getMetadataFiles();
}
public URL resolve(String resourcePath) throws IOException
@@ -78,19 +83,13 @@
}
catch (IOException e)
{
- if (metadataFiles == null || metadataFiles.isEmpty())
- {
- throw e;
- }
- else
- {
- ROOT_LOGGER.cannotGetRootFileTryingWithAdditionalMetaData(resourcePath);
- }
+ //ignore this to try metadataFiles and load it from classLoader
}
}
//scan additional metadata files (for instance originally attached to a VFSDeploymentUnit)
if (resourceURL == null && metadataFiles != null && !metadataFiles.isEmpty())
{
+ ROOT_LOGGER.cannotGetRootFileTryingWithAdditionalMetaData(resourcePath);
UnifiedVirtualFile vfResource = null;
for (Iterator<UnifiedVirtualFile> it = metadataFiles.iterator(); it.hasNext() && vfResource == null;)
{
@@ -115,11 +114,23 @@
}
}
}
- if (vfResource == null)
- throw Messages.MESSAGES.cannotFindInAdditionalMetaData(resourcePath);
-
- resourceURL = vfResource.toURL();
+ if (vfResource != null)
+ {
+ resourceURL = vfResource.toURL();
+ }
}
+ if (resourceURL == null && deployment.getRuntimeClassLoader() != null)
+ {
+ resourceURL = deployment.getRuntimeClassLoader().getResource(resourcePath);
+ }
+ if (resourceURL == null && deployment.getInitialClassLoader() != null)
+ {
+ resourceURL = deployment.getInitialClassLoader().getResource(resourcePath);
+ }
+ if (resourceURL == null)
+ {
+ throw Messages.MESSAGES.cannotResolveResource(resourcePath, deployment.getSimpleName());
+ }
}
return resourceURL;
}
11 years, 4 months