Loads the CREOLE repositories (aka plugins) that the user has selected for automatic loading. Loads the information about known plugins in memory.
()
| 414 | * automatic loading. Loads the information about known plugins in memory. |
| 415 | */ |
| 416 | protected static void initCreoleRepositories() { |
| 417 | // the logic is: |
| 418 | // get the list of know plugins from gate.xml |
| 419 | // add all the installed plugins (if pluginsHome has been explicitly set) |
| 420 | // get the list of loadable plugins |
| 421 | // load loadable plugins |
| 422 | |
| 423 | Pattern mavenPluginPattern = Pattern.compile("\\[(.*?):(.*?):(.*?)]"); |
| 424 | |
| 425 | // process the known plugins list |
| 426 | String knownPluginsPath = |
| 427 | (String)getUserConfig().get(KNOWN_PLUGIN_PATH_KEY); |
| 428 | if(knownPluginsPath != null) { |
| 429 | knownPluginsPath = knownPluginsPath.trim(); |
| 430 | } |
| 431 | if(knownPluginsPath != null && knownPluginsPath.length() > 0) { |
| 432 | StringTokenizer strTok = |
| 433 | new StringTokenizer(knownPluginsPath, ";", false); |
| 434 | while(strTok.hasMoreTokens()) { |
| 435 | String aKnownPluginPath = strTok.nextToken().trim(); |
| 436 | Matcher m = mavenPluginPattern.matcher(aKnownPluginPath); |
| 437 | if(m.matches()) { |
| 438 | // Maven coordinates [group:artifact:version] |
| 439 | addKnownPlugin(new Plugin.Maven(m.group(1), m.group(2), m.group(3))); |
| 440 | } else { |
| 441 | // assume it's a URL to a directory plugin |
| 442 | try { |
| 443 | URL aPluginURL = new URL(aKnownPluginPath); |
| 444 | addKnownPlugin(new Plugin.Directory(aPluginURL)); |
| 445 | } catch(MalformedURLException mue) { |
| 446 | log.error("Plugin error: " + aKnownPluginPath + " is an invalid URL!"); |
| 447 | } |
| 448 | } |
| 449 | } |
| 450 | } |
| 451 | |
| 452 | if(pluginsHome != null) { |
| 453 | // add all the installed plugins (note pluginsHome will only be set |
| 454 | // if there has been an explicit call to setPluginsHome, it is now |
| 455 | // null by default) |
| 456 | File[] dirs = pluginsHome.listFiles(); |
| 457 | for(int i = 0; i < dirs.length; i++) { |
| 458 | File creoleFile = new File(dirs[i], "creole.xml"); |
| 459 | if(creoleFile.exists()) { |
| 460 | try { |
| 461 | URL pluginURL = dirs[i].toURI().toURL(); |
| 462 | addKnownPlugin(new Plugin.Directory(pluginURL)); |
| 463 | } catch(MalformedURLException mue) { |
| 464 | // this should never happen |
| 465 | throw new GateRuntimeException(mue); |
| 466 | } |
| 467 | } |
| 468 | } |
| 469 | } |
| 470 | |
| 471 | // process the autoload plugins |
| 472 | String pluginPath = getUserConfig().getString(AUTOLOAD_PLUGIN_PATH_KEY); |
| 473 | // can be overridden by system property |
no test coverage detected