Hi there is an issue doing it this way, FileUtils.getFile throw an exception if the "jar" is a directory which is useful for resources to put resource dedicated configuration (think of using ha-jdbc proxies for instance)
maybe we should use getFile(path, false) Romain Manni-Bucau Twitter: @rmannibucau Blog: http://rmannibucau.wordpress.com/ LinkedIn: http://fr.linkedin.com/in/rmannibucau Github: https://github.com/rmannibucau ---------- Forwarded message ---------- From: <[email protected]> Date: 2014-05-14 2:13 GMT+02:00 Subject: svn commit: r1594420 - in /tomee/tomee/trunk/container: openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java openejb-loader/src/main/java/org/apache/openejb/loader/Files.java To: [email protected] Author: dblevins Date: Wed May 14 00:13:33 2014 New Revision: 1594420 URL: http://svn.apache.org/r1594420 Log: Re-adding support for relative paths in <Resource classpath=""> element Test case forthcoming Modified: tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java tomee/tomee/trunk/container/openejb-loader/src/main/java/org/apache/openejb/loader/Files.java Modified: tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java?rev=1594420&r1=1594419&r2=1594420&view=diff ============================================================================== --- tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java (original) +++ tomee/tomee/trunk/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java Wed May 14 00:13:33 2014 @@ -97,6 +97,7 @@ import org.apache.xbean.finder.ResourceF import javax.ejb.embeddable.EJBContainer; import java.io.File; +import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URI; @@ -1166,16 +1167,7 @@ public class ConfigurationFactory implem } if (service.getClasspath() != null && service.getClasspath().length() > 0) { - final String[] strings = service.getClasspath().split(File.pathSeparator); - final URI[] classpath = new URI[strings.length]; - for (int i = 0; i < strings.length; i++) { - final String string = strings[i]; - final String pathname = PropertyPlaceHolderHelper.simpleValue(ProvisioningUtil.realLocation(string)); - final File file = new File(pathname); - classpath[i] = file.toURI(); - } - - info.classpath = classpath; + info.classpath = resolveClasspath(service.getClasspath()); } specialProcessing(info); @@ -1190,6 +1182,33 @@ public class ConfigurationFactory implem } } + /** + * Takes a raw unparsed string expected to be in jvm classpath syntax + * and parses it, producing a collection of URIs representing the absolute + * file paths of the classpath to be created. + * + * OS specific delimiters are supported. + * + * @param rawstring unparsed string in "classpath" syntax + * @return + * @throws IOException if path cannot be resolved or file referenced does not exist + */ + public static URI[] resolveClasspath(String rawstring) throws IOException { + + final FileUtils base = SystemInstance.get().getBase(); + final String[] strings = rawstring.split(File.pathSeparator); + final URI[] classpath = new URI[strings.length]; + + for (int i = 0; i < strings.length; i++) { + final String string = strings[i]; + final String pathname = PropertyPlaceHolderHelper.simpleValue(ProvisioningUtil.realLocation(string)); + final File file = base.getFile(pathname); + classpath[i] = file.toURI(); + } + + return classpath; + } + private String overrideKey(final org.apache.openejb.config.Service service) { final String origin = String.class.cast(service.getProperties().remove(AutoConfig.ORIGINAL_ID)); if (origin != null) { Modified: tomee/tomee/trunk/container/openejb-loader/src/main/java/org/apache/openejb/loader/Files.java URL: http://svn.apache.org/viewvc/tomee/tomee/trunk/container/openejb-loader/src/main/java/org/apache/openejb/loader/Files.java?rev=1594420&r1=1594419&r2=1594420&view=diff ============================================================================== --- tomee/tomee/trunk/container/openejb-loader/src/main/java/org/apache/openejb/loader/Files.java (original) +++ tomee/tomee/trunk/container/openejb-loader/src/main/java/org/apache/openejb/loader/Files.java Wed May 14 00:13:33 2014 @@ -112,6 +112,11 @@ public class Files { return file; } + public static File touch(final File file) throws IOException { + if (!file.createNewFile()) throw new FileRuntimeException("Cannot create file: " + file.getAbsolutePath()); + return file; + } + public static File file(final File file) { exists(file); if (!file.isFile()) throw new FileRuntimeException("Not a file: " + file.getAbsolutePath());
