|
@@ -97,18 +97,6 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
|
97
|
97
|
|
98
|
98
|
ResourceManager res;
|
99
|
99
|
|
100
|
|
- // Check for updates.
|
101
|
|
- if (new File(getFullFilename() + ".update").exists() && new File(getFullFilename()).delete()) {
|
102
|
|
- new File(getFullFilename() + ".update").renameTo(new File(getFullFilename()));
|
103
|
|
-
|
104
|
|
- updateMetaData();
|
105
|
|
- }
|
106
|
|
-
|
107
|
|
- if (metadata.hasErrors()) {
|
108
|
|
- throw new PluginException("Plugin " + filename + " has metadata "
|
109
|
|
- + "errors: " + metadata.getErrors());
|
110
|
|
- }
|
111
|
|
-
|
112
|
100
|
try {
|
113
|
101
|
res = getResourceManager();
|
114
|
102
|
} catch (IOException ioe) {
|
|
@@ -116,22 +104,30 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
|
116
|
104
|
throw new PluginException("Plugin " + filename + " failed to load. " + lastError, ioe);
|
117
|
105
|
}
|
118
|
106
|
|
119
|
|
- final String mainClass = metadata.getMainClass().replace('.', '/') + ".class";
|
120
|
|
- if (!res.resourceExists(mainClass)) {
|
121
|
|
- lastError = "main class file (" + mainClass + ") not found in jar.";
|
|
107
|
+ updateClassList(res);
|
|
108
|
+
|
|
109
|
+ if (!myClasses.contains(metadata.getMainClass())) {
|
|
110
|
+ lastError = "main class file (" + metadata.getMainClass() + ") not found in jar.";
|
122
|
111
|
throw new PluginException("Plugin " + filename + " failed to load. " + lastError);
|
123
|
112
|
}
|
124
|
113
|
|
|
114
|
+ updateProvides();
|
|
115
|
+ getDefaults();
|
|
116
|
+ }
|
|
117
|
+
|
|
118
|
+ /**
|
|
119
|
+ * Updates the list of known classes within this plugin from the specified
|
|
120
|
+ * resource manager.
|
|
121
|
+ */
|
|
122
|
+ private void updateClassList(final ResourceManager res) {
|
|
123
|
+ myClasses.clear();
|
|
124
|
+
|
125
|
125
|
for (final String classfilename : res.getResourcesStartingWith("")) {
|
126
|
|
- String classname = classfilename.replace('/', '.');
|
127
|
|
- if (classname.matches("^.*\\.class$")) {
|
128
|
|
- classname = classname.replaceAll("\\.class$", "");
|
129
|
|
- myClasses.add(classname);
|
|
126
|
+ final String classname = classfilename.replace('/', '.');
|
|
127
|
+ if (classname.endsWith(".class")) {
|
|
128
|
+ myClasses.add(classname.substring(0, classname.length() - 6));
|
130
|
129
|
}
|
131
|
130
|
}
|
132
|
|
-
|
133
|
|
- updateProvides();
|
134
|
|
- getDefaults();
|
135
|
131
|
}
|
136
|
132
|
|
137
|
133
|
/**
|
|
@@ -297,21 +293,14 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
|
297
|
293
|
public void pluginUpdated() {
|
298
|
294
|
try {
|
299
|
295
|
// Force a new resourcemanager just incase.
|
300
|
|
- final ResourceManager res = getResourceManager(true);
|
301
|
|
-
|
302
|
|
- myClasses.clear();
|
303
|
|
- for (final String classfilename : res.getResourcesStartingWith("")) {
|
304
|
|
- String classname = classfilename.replace('/', '.');
|
305
|
|
- if (classname.matches("^.*\\.class$")) {
|
306
|
|
- classname = classname.replaceAll("\\.class$", "");
|
307
|
|
- myClasses.add(classname);
|
308
|
|
- }
|
309
|
|
- }
|
|
296
|
+ updateClassList(getResourceManager(true));
|
|
297
|
+
|
310
|
298
|
updateMetaData();
|
311
|
299
|
updateProvides();
|
312
|
300
|
getDefaults();
|
313
|
301
|
} catch (IOException ioe) {
|
314
|
|
- Logger.userError(ErrorLevel.MEDIUM, "There was an error updating "+getName(), ioe);
|
|
302
|
+ Logger.userError(ErrorLevel.MEDIUM, "There was an error updating "
|
|
303
|
+ + metadata.getName(), ioe);
|
315
|
304
|
}
|
316
|
305
|
}
|
317
|
306
|
|
|
@@ -573,7 +562,7 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
|
573
|
562
|
|
574
|
563
|
final Class<?> clazz = classloader.loadClass(classname);
|
575
|
564
|
if (clazz == null) {
|
576
|
|
- lastError = "Class '"+classname+"' was not able to load.";
|
|
565
|
+ lastError = "Class '" + classname + "' was not able to load.";
|
577
|
566
|
return;
|
578
|
567
|
}
|
579
|
568
|
|
|
@@ -824,23 +813,11 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
|
824
|
813
|
* @return List of all persistent classes in this plugin
|
825
|
814
|
*/
|
826
|
815
|
public Collection<String> getPersistentClasses() {
|
827
|
|
- final Collection<String> result = new ArrayList<String>();
|
828
|
|
-
|
829
|
816
|
if (isPersistent()) {
|
830
|
|
- try {
|
831
|
|
- final ResourceManager res = getResourceManager();
|
832
|
|
-
|
833
|
|
- for (final String resourceFilename : res.getResourcesStartingWith("")) {
|
834
|
|
- if (resourceFilename.matches("^.*\\.class$")) {
|
835
|
|
- result.add(resourceFilename.replaceAll("\\.class$", "").replace('/', '.'));
|
836
|
|
- }
|
837
|
|
- }
|
838
|
|
- } catch (IOException e) {
|
839
|
|
- // Jar no longer exists?
|
840
|
|
- }
|
|
817
|
+ return getClassList();
|
|
818
|
+ } else {
|
|
819
|
+ return metadata.getPersistentClasses();
|
841
|
820
|
}
|
842
|
|
-
|
843
|
|
- return metadata.getPersistentClasses();
|
844
|
821
|
}
|
845
|
822
|
|
846
|
823
|
/**
|
|
@@ -850,11 +827,7 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
|
850
|
827
|
* @return true if file (or whole plugin) is persistent, else false
|
851
|
828
|
*/
|
852
|
829
|
public boolean isPersistent(final String classname) {
|
853
|
|
- if (isPersistent()) {
|
854
|
|
- return true;
|
855
|
|
- } else {
|
856
|
|
- return metadata.getPersistentClasses().contains(classname);
|
857
|
|
- }
|
|
830
|
+ return isPersistent() || metadata.getPersistentClasses().contains(classname);
|
858
|
831
|
}
|
859
|
832
|
|
860
|
833
|
/**
|
|
@@ -941,7 +914,7 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
|
941
|
914
|
*/
|
942
|
915
|
@Override
|
943
|
916
|
public String toString() {
|
944
|
|
- return getNiceName() + " - " + filename;
|
|
917
|
+ return metadata.getFriendlyName() + " - " + filename;
|
945
|
918
|
}
|
946
|
919
|
|
947
|
920
|
/** {@inheritDoc} */
|
|
@@ -992,7 +965,7 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
|
992
|
965
|
*
|
993
|
966
|
* @param name Name of the service to check
|
994
|
967
|
*
|
995
|
|
- * @return true iif the plugin exports the service
|
|
968
|
+ * @return true iff the plugin exports the service
|
996
|
969
|
*/
|
997
|
970
|
public boolean hasExportedService(final String name) {
|
998
|
971
|
return exports.containsKey(name);
|