[hornetq-commits] JBoss hornetq SVN: r8024 - trunk/src/main/org/hornetq/core/deployers/impl.
do-not-reply at jboss.org
do-not-reply at jboss.org
Thu Oct 1 09:22:19 EDT 2009
Author: jmesnil
Date: 2009-10-01 09:22:19 -0400 (Thu, 01 Oct 2009)
New Revision: 8024
Modified:
trunk/src/main/org/hornetq/core/deployers/impl/FileDeploymentManager.java
Log:
HORNETQ-122: FileDeploymentManager does not differentiate between File and Ear supplied hornetq-jms.xml
* do no check file existence using File.exists() as it does not work when the resource is inside an EAR.
Instead, check that the file is in the current thread context classloader's resources
Modified: trunk/src/main/org/hornetq/core/deployers/impl/FileDeploymentManager.java
===================================================================
--- trunk/src/main/org/hornetq/core/deployers/impl/FileDeploymentManager.java 2009-10-01 09:12:08 UTC (rev 8023)
+++ trunk/src/main/org/hornetq/core/deployers/impl/FileDeploymentManager.java 2009-10-01 13:22:19 UTC (rev 8024)
@@ -224,12 +224,12 @@
for (Map.Entry<Pair<URL, Deployer>, DeployInfo> entry : deployed.entrySet())
{
Pair<URL, Deployer> pair = entry.getKey();
- if (!new File(pair.a.getFile()).exists())
+ if (!fileExists(pair.a))
{
try
{
Deployer deployer = entry.getValue().deployer;
- log.debug("Undeploying " + deployer + " with url " + pair.a);
+ log.info("Undeploying " + deployer + " with url " + pair.a);
deployer.undeploy(pair.a);
toRemove.add(pair);
}
@@ -259,6 +259,36 @@
{
return deployed;
}
+
+ // Private -------------------------------------------------------
+
+ /**
+ * Checks if the URL is among the current thread context class loader's resources.
+ *
+ * We do not check that the corresponding file exists using File.exists() directly as it would fail
+ * in the case the resource is loaded from inside an EAR file (see https://jira.jboss.org/jira/browse/HORNETQ-122)
+ */
+ private boolean fileExists(URL resourceURL)
+ {
+ try
+ {
+ File f = new File(resourceURL.getPath());
+ Enumeration<URL> resources = Thread.currentThread().getContextClassLoader().getResources(f.getName());
+ while (resources.hasMoreElements())
+ {
+ URL url = (URL)resources.nextElement();
+ if (url.equals(resourceURL))
+ {
+ return true;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ return false;
+ }
+ return false;
+ }
// Inner classes -------------------------------------------------------------------------------------------
More information about the hornetq-commits
mailing list