Revision: 15266
http://gate.svn.sourceforge.net/gate/?rev=15266&view=rev
Author: ian_roberts
Date: 2012-01-30 15:49:27 +0000 (Mon, 30 Jan 2012)
Log Message:
-----------
Launcher now accepts a system property "gate.class.path" or (if this is not
set) an environment variable "GATE_CLASSPATH" containing extra classpath
entries to prepend to the ClassLoader that will load gate.jar etc. The
property/variable is in the normal format for a classpath on the host platform
(i.e. semicolon separated on Windows, colon separated elsewhere) and supports
the some/dir/* shorthand introduced with Java 6 to add all .jar files in a
particular directory.
Modified Paths:
--------------
gate/trunk/build/launcher/src/gate/Launcher.java
Modified: gate/trunk/build/launcher/src/gate/Launcher.java
===================================================================
--- gate/trunk/build/launcher/src/gate/Launcher.java 2012-01-30 14:19:19 UTC
(rev 15265)
+++ gate/trunk/build/launcher/src/gate/Launcher.java 2012-01-30 15:49:27 UTC
(rev 15266)
@@ -46,8 +46,14 @@
public static final String GATE_HOME_PROPERTY_NAME = "gate.home";
protected static final Pattern PLACEHOLDER =
Pattern.compile("\\$\\{(.*?)\\}");
+
+ protected static final FilenameFilter JAR_FILTER = new FilenameFilter() {
+ @Override
+ public boolean accept(File dir, String name) {
+ return name.toLowerCase().endsWith(".jar");
+ }
+ };
-
protected File gateHome;
protected URLClassLoader classLoader;
@@ -85,21 +91,43 @@
}
}
+ protected void addUrlsForFile(File file, List<URL> urls) throws
+ MalformedURLException {
+ if(file != null) {
+ if("*".equals(file.getName())) {
+ // Java 6 style "/path/to/directory/*" entry
+ for(File f : file.getParentFile().listFiles(JAR_FILTER)) {
+ addUrlsForFile(f, urls);
+ }
+ } else {
+ urls.add(file.toURI().toURL());
+ }
+ }
+ }
+
protected void buildClassPath() throws MalformedURLException {
List<URL> urls = new LinkedList<URL>();
+ // start with any externally-specified entries - gate.class.path system
+ // property wins if it is specified, otherwise GATE_CLASSPATH environment
+ // variable.
+ String extraClassPath = System.getProperty("gate.class.path",
+ System.getenv("GATE_CLASSPATH"));
+ if(extraClassPath != null) {
+ String[] extraEntries = extraClassPath.split(
+ Pattern.quote(File.pathSeparator));
+ for(String entry : extraEntries) {
+ if(!"".equals(entry)) addUrlsForFile(new File(entry), urls);
+ }
+ }
File binDir = new File(gateHome, "bin");
- urls.add(binDir.toURI().toURL());
- urls.add(new File(binDir, "gate.jar").toURI().toURL());
+ // gate/bin (for log4j.properties)
+ addUrlsForFile(binDir, urls);
+ // bin/gate.jar
+ addUrlsForFile(new File(binDir, "gate.jar"), urls);
+ // and lib/*.jar
File libDir = new File(gateHome, "lib");
- FilenameFilter jarFinder = new FilenameFilter() {
- @Override
- public boolean accept(File dir, String name) {
- return name.toLowerCase().endsWith(".jar");
- }
- };
- for(File aJar : libDir.listFiles(jarFinder)) {
- urls.add(aJar.toURI().toURL());
- }
+ addUrlsForFile(new File(libDir, "*"), urls);
+
classLoader = new URLClassLoader(urls.toArray(new URL[urls.size()]),
Launcher.class.getClassLoader());
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs