Revision: 19190
http://sourceforge.net/p/gate/code/19190
Author: markagreenwood
Date: 2016-04-03 18:34:50 +0000 (Sun, 03 Apr 2016)
Log Message:
-----------
unregistering a plugin (not a directory) now seems to work
Modified Paths:
--------------
gate/branches/sawdust2/src/main/gate/creole/CreoleRegisterImpl.java
Modified: gate/branches/sawdust2/src/main/gate/creole/CreoleRegisterImpl.java
===================================================================
--- gate/branches/sawdust2/src/main/gate/creole/CreoleRegisterImpl.java
2016-04-03 18:29:01 UTC (rev 19189)
+++ gate/branches/sawdust2/src/main/gate/creole/CreoleRegisterImpl.java
2016-04-03 18:34:50 UTC (rev 19190)
@@ -18,7 +18,9 @@
import gate.Controller;
import gate.CreoleRegister;
+import gate.Factory;
import gate.Gate;
+import gate.Gate.ResourceInfo;
import gate.LanguageResource;
import gate.Plugin;
import gate.ProcessingResource;
@@ -421,6 +423,48 @@
return super.put(key, rd);
} // put(key, value)
+ @Override
+ public void unregisterPlugin(Plugin plugin) {
+ if (plugins.remove(plugin)) {
+ int prCount = 0;
+
+ for(ResourceInfo rInfo : plugin.getResourceInfoList()) {
+ ResourceData rData = get(rInfo.getResourceClassName());
+ if (rData != null && rData.getReferenceCount() == 1) {
+ // we only need to remove resources if we are actually going to
+ // remove the plugin
+ try {
+ List<Resource> loaded =
+ getAllInstances(rInfo.getResourceClassName(),true);
+ prCount += loaded.size();
+ for(Resource r : loaded) {
+ //System.out.println(r);
+ Factory.deleteResource(r);
+ }
+ } catch(GateException e) {
+ // not much we can do here other than dump the exception
+ e.printStackTrace();
+ }
+ }
+
+ remove(rInfo.getResourceClassName());
+ }
+
+ try {
+ Gate.getClassLoader().forgetClassLoader(new
URL(plugin.getBaseURL(),"creole.xml").toExternalForm(), plugin);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ log.info("CREOLE plugin unloaded: " + plugin.getName());
+ if (prCount > 0)
+ log.warn(prCount+" resources were deleted as they relied on the " +
plugin.getName() +" plugin");
+
+ firePluginUnloaded(plugin);
+ }
+ }
+
/**
* Removes a CREOLE directory from the set of loaded directories.
*
@@ -1056,9 +1100,9 @@
}
}
- protected void firePluginUnloaded(URL url) {
+ protected void firePluginUnloaded(Plugin plugin) {
for (PluginListener listener : pluginListeners) {
- listener.pluginUnloaded(url);
+ listener.pluginUnloaded(plugin.getBaseURL());
}
}
@@ -1195,10 +1239,4 @@
return Collections.unmodifiableList(plugins);
}
- @Override
- public void unregisterPlugin(Plugin plugin) {
- // TODO Auto-generated method stub
-
- }
-
} // class CreoleRegisterImpl
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785471&iu=/4140
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs