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());