[jboss-cvs] JBoss Messaging SVN: r4491 - branches/Branch_Experimental_JBMESSAGING_1356_2/tests/src/org/jboss/test/messaging/tools/container.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Jun 16 21:26:58 EDT 2008


Author: ovidiu.feodorov at jboss.com
Date: 2008-06-16 21:26:57 -0400 (Mon, 16 Jun 2008)
New Revision: 4491

Modified:
   branches/Branch_Experimental_JBMESSAGING_1356_2/tests/src/org/jboss/test/messaging/tools/container/ServiceConfigHelper.java
Log:
enhanced ServiceConfigHelper.java so if it cannot load a configuration file as a resource relative to the classpath, it falls back to load it as a file

Modified: branches/Branch_Experimental_JBMESSAGING_1356_2/tests/src/org/jboss/test/messaging/tools/container/ServiceConfigHelper.java
===================================================================
--- branches/Branch_Experimental_JBMESSAGING_1356_2/tests/src/org/jboss/test/messaging/tools/container/ServiceConfigHelper.java	2008-06-16 23:31:20 UTC (rev 4490)
+++ branches/Branch_Experimental_JBMESSAGING_1356_2/tests/src/org/jboss/test/messaging/tools/container/ServiceConfigHelper.java	2008-06-17 01:26:57 UTC (rev 4491)
@@ -22,6 +22,7 @@
 package org.jboss.test.messaging.tools.container;
 
 import java.net.URL;
+import java.io.File;
 
 import org.jboss.test.messaging.tools.jboss.MBeanConfigurationElement;
 import org.jboss.test.messaging.tools.jboss.ServiceDeploymentDescriptor;
@@ -47,15 +48,23 @@
    // Public --------------------------------------------------------
 
    /**
-    * Load a service deployment descriptor from the specified file on
-    * the class path.
+    * Load a service deployment descriptor from the specified file. First try to load it as a
+    * resource relative to the classpath and then try to load it directly as a file.
     */
    public static ServiceDeploymentDescriptor loadConfigFile(String configFile) throws Exception
    {
       URL url = ServiceConfigHelper.class.getClassLoader().getResource(configFile);
       if (url == null)
       {
-         throw new Exception("Cannot find " + configFile + " in the classpath");
+          // one more try
+          File f = new File(configFile);
+          if (!f.isFile())
+          {
+              throw new Exception("Cannot find " + configFile +
+                                  " in the classpath or on the filesystem");
+          }
+
+          url = f.toURL();
       }
 
       return new ServiceDeploymentDescriptor(url);




More information about the jboss-cvs-commits mailing list