Revision: 17598
http://sourceforge.net/p/gate/code/17598
Author: johann_p
Date: 2014-03-08 16:25:35 +0000 (Sat, 08 Mar 2014)
Log Message:
-----------
add methods to simplify loading plugins
Modified Paths:
--------------
gate/trunk/src/main/gate/Utils.java
Modified: gate/trunk/src/main/gate/Utils.java
===================================================================
--- gate/trunk/src/main/gate/Utils.java 2014-03-08 15:19:43 UTC (rev 17597)
+++ gate/trunk/src/main/gate/Utils.java 2014-03-08 16:25:35 UTC (rev 17598)
@@ -19,9 +19,12 @@
import gate.creole.ConditionalSerialController;
import gate.creole.RunningStrategy;
import gate.util.FeatureBearer;
+import gate.util.GateException;
import gate.util.GateRuntimeException;
import gate.util.InvalidOffsetException;
import gate.util.OffsetComparator;
+import java.io.File;
+import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.Collection;
@@ -1165,6 +1168,34 @@
}
static private Pattern varnamePattern =
Pattern.compile("(\\$\\$?)([a-zA-Z]*)\\{([^}]+)\\}");
+ /**
+ * Load a plugin from the default GATE plugins directory.
+ *
+ * This will load the plugin with the specified directory name from the
+ * default GATE plugins path, if GATE knows its own location.
+ *
+ */
+ public static void loadPlugin(String dirName) {
+ File gatehome = Gate.getGateHome();
+ if(gatehome == null) {
+ throw new GateRuntimeException("Cannot load Plugin, Gate home location
not known");
+ }
+ File pluginDir = new File(new File(gatehome,"plugins"),dirName);
+ loadPlugin(pluginDir);
+ }
-
+ /**
+ * Load a plugin from the specified directory.
+ *
+ * This will load the plugin from the directory path specified as a File
object.
+ *
+ */
+ public static void loadPlugin(File pluginDir) {
+ try {
+ Gate.getCreoleRegister().registerDirectories(pluginDir.toURI().toURL());
+ } catch (Exception ex) {
+ throw new GateRuntimeException("Could not register plugin directory
"+pluginDir,ex);
+ }
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce.
With Perforce, you get hassle-free workflows. Merge that actually works.
Faster operations. Version large binaries. Built-in WAN optimization and the
freedom to use Git, Perforce or both. Make the move to Perforce.
http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs