MCPcopy Create free account
hub / github.com/GateNLP/gate-core / initLocalPaths

Method initLocalPaths

src/main/java/gate/Gate.java:296–410  ·  view source on GitHub ↗

Initialises the paths to local files of interest like the GATE home, the installed plugins home and site and user configuration files.

()

Source from the content-addressed store, hash-verified

294 * installed plugins home and site and user configuration files.
295 */
296 protected static void initLocalPaths() {
297 // GATE Home
298 //TODO check if we need any of this now we don't have a GATE home
299 /*if(gateHome == null) {
300 String gateHomeStr = System.getProperty(GATE_HOME_PROPERTY_NAME);
301 if(gateHomeStr != null && gateHomeStr.length() > 0) {
302 gateHome = new File(gateHomeStr);
303 }
304 // if failed, try to guess
305 if(gateHome == null || !gateHome.exists()) {
306 log.warn("GATE home system property (\"" + GATE_HOME_PROPERTY_NAME
307 + "\") not set.\nAttempting to guess...");
308 URL gateURL =
309 Thread.currentThread().getContextClassLoader().getResource(
310 "gate/Gate.class");
311 try {
312 if(gateURL.getProtocol().equals("jar")) {
313 // running from gate.jar
314 String gateURLStr = gateURL.getFile();
315 File gateJarFile =
316 new File(
317 new URI(gateURLStr.substring(0, gateURLStr.indexOf('!'))));
318 gateHome = gateJarFile.getParentFile().getParentFile();
319 }
320 else if(gateURL.getProtocol().equals("file")) {
321 // running from classes directory
322 File gateClassFile = Files.fileFromURL(gateURL);
323 gateHome =
324 gateClassFile.getParentFile().getParentFile().getParentFile();
325 }
326 log.warn("Using \"" + gateHome.getCanonicalPath()
327 + "\" as GATE Home.\nIf this is not correct please set it manually"
328 + " using the -D" + GATE_HOME_PROPERTY_NAME
329 + " option in your start-up script");
330 }
331 catch(Throwable thr) {
332 throw new GateRuntimeException(
333 "Cannot guess GATE Home. Pease set it manually!", thr);
334 }
335 }
336 }
337 log.info("Using " + gateHome.toString() + " as GATE home");
338
339 // Plugins home
340 if(pluginsHome == null) {
341 String pluginsHomeStr = System.getProperty(PLUGINS_HOME_PROPERTY_NAME);
342 if(pluginsHomeStr != null && pluginsHomeStr.length() > 0) {
343 File homeFile = new File(pluginsHomeStr);
344 if(homeFile.exists() && homeFile.isDirectory()) {
345 pluginsHome = homeFile;
346 }
347 }
348 // if not set, use the GATE Home as a base directory
349 if(pluginsHome == null) {
350 File homeFile = new File(gateHome, PLUGINS);
351 if(homeFile.exists() && homeFile.isDirectory()) {
352 pluginsHome = homeFile;
353 }

Callers 1

initMethod · 0.95

Calls 5

infoMethod · 0.80
getPropertyMethod · 0.65
lengthMethod · 0.45

Tested by

no test coverage detected