|
@@ -98,7 +98,7 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
|
98
|
98
|
/** Map of exports. */
|
99
|
99
|
private final Map<String, ExportInfo> exports = new HashMap<>();
|
100
|
100
|
/** List of configuration providers. */
|
101
|
|
- private final List<ConfigProvider> configProviders = new ArrayList<>();
|
|
101
|
+ private final Collection<ConfigProvider> configProviders = new ArrayList<>();
|
102
|
102
|
/** Event bus to post plugin loaded events to. */
|
103
|
103
|
private final DMDircMBassador eventBus;
|
104
|
104
|
/** File system for the plugin's jar. */
|
|
@@ -196,7 +196,6 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
|
196
|
196
|
* @return The injector used for this plugin
|
197
|
197
|
*/
|
198
|
198
|
public SimpleInjector getInjector() {
|
199
|
|
- final SimpleInjector injector;
|
200
|
199
|
final SimpleInjector[] parents = new SimpleInjector[metaData.getParent() == null ? 0 : 1];
|
201
|
200
|
final Plugin[] plugins = new Plugin[parents.length];
|
202
|
201
|
|
|
@@ -207,7 +206,7 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
|
207
|
206
|
plugins[0] = parent.getPlugin();
|
208
|
207
|
}
|
209
|
208
|
|
210
|
|
- injector = new SimpleInjector(parents);
|
|
209
|
+ final SimpleInjector injector = new SimpleInjector(parents);
|
211
|
210
|
|
212
|
211
|
for (Plugin parentPlugin : plugins) {
|
213
|
212
|
injector.addParameter(parentPlugin);
|
|
@@ -253,7 +252,7 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
|
253
|
252
|
* @throws IOException if there is an error with the ResourceManager.
|
254
|
253
|
*/
|
255
|
254
|
public Map<String, InputStream> getLicenceStreams() throws IOException {
|
256
|
|
- final TreeMap<String, InputStream> licences = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
|
255
|
+ final Map<String, InputStream> licences = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
257
|
256
|
if (!Files.exists(pluginFilesystem.getPath("/META-INF/licenses/"))) {
|
258
|
257
|
return licences;
|
259
|
258
|
}
|
|
@@ -333,13 +332,13 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
|
333
|
332
|
} catch (final InvalidIdentityFileException ex) {
|
334
|
333
|
eventBus.publish(new UserErrorEvent(ErrorLevel.MEDIUM, ex,
|
335
|
334
|
"Error with identity file '" + name + "' in plugin '"
|
336
|
|
- + metaData.getName() + "'", ""));
|
|
335
|
+ + metaData.getName() + '\'', ""));
|
337
|
336
|
}
|
338
|
337
|
}
|
339
|
338
|
}
|
340
|
339
|
} catch (final IOException ioe) {
|
341
|
340
|
eventBus.publish(new UserErrorEvent(ErrorLevel.MEDIUM, ioe,
|
342
|
|
- "Error finding identities in plugin '" + metaData.getName() + "'", ""));
|
|
341
|
+ "Error finding identities in plugin '" + metaData.getName() + '\'', ""));
|
343
|
342
|
}
|
344
|
343
|
}
|
345
|
344
|
|
|
@@ -376,7 +375,7 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
|
376
|
375
|
final String name = bits[0];
|
377
|
376
|
final String type = bits.length > 1 ? bits[1] : "misc";
|
378
|
377
|
|
379
|
|
- if (!name.equalsIgnoreCase("any") && !type.equalsIgnoreCase("export")) {
|
|
378
|
+ if (!"any".equalsIgnoreCase(name) && !"export".equalsIgnoreCase(type)) {
|
380
|
379
|
final Service service = metaData.getManager().getService(type, name, true);
|
381
|
380
|
synchronized (provides) {
|
382
|
381
|
service.addProvider(this);
|
|
@@ -446,7 +445,7 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
|
446
|
445
|
@Override
|
447
|
446
|
public String getProviderName() {
|
448
|
447
|
return "Plugin: " + metaData.getFriendlyName() + " ("
|
449
|
|
- + metaData.getName() + " / " + getFilename() + ")";
|
|
448
|
+ + metaData.getName() + " / " + getFilename() + ')';
|
450
|
449
|
}
|
451
|
450
|
|
452
|
451
|
@Override
|
|
@@ -556,11 +555,7 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
|
556
|
555
|
}
|
557
|
556
|
}
|
558
|
557
|
|
559
|
|
- if (metaData.getParent() != null) {
|
560
|
|
- return loadRequiredPlugin(metaData.getParent());
|
561
|
|
- }
|
562
|
|
-
|
563
|
|
- return true;
|
|
558
|
+ return metaData.getParent() == null || loadRequiredPlugin(metaData.getParent());
|
564
|
559
|
}
|
565
|
560
|
|
566
|
561
|
/**
|
|
@@ -594,7 +589,7 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
|
594
|
589
|
*/
|
595
|
590
|
public void loadPlugin() {
|
596
|
591
|
if (isLoaded() || isLoading) {
|
597
|
|
- lastError = "Not Loading: (" + isLoaded() + "||" + isLoading + ")";
|
|
592
|
+ lastError = "Not Loading: (" + isLoaded() + "||" + isLoading + ')';
|
598
|
593
|
return;
|
599
|
594
|
}
|
600
|
595
|
|
|
@@ -613,7 +608,7 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
|
613
|
608
|
plugin.load(this, getObjectGraph());
|
614
|
609
|
plugin.onLoad();
|
615
|
610
|
} catch (LinkageError | Exception e) {
|
616
|
|
- lastError = "Error in onLoad for " + metaData.getName() + ":"
|
|
611
|
+ lastError = "Error in onLoad for " + metaData.getName() + ':'
|
617
|
612
|
+ e.getMessage();
|
618
|
613
|
eventBus.publishAsync(new AppErrorEvent(ErrorLevel.MEDIUM, e, lastError, ""));
|
619
|
614
|
unloadPlugin();
|
|
@@ -741,7 +736,7 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
|
741
|
736
|
if (prerequisites.isFailure()) {
|
742
|
737
|
if (!tempLoaded) {
|
743
|
738
|
lastError = "Prerequisites for plugin not met. ('"
|
744
|
|
- + filename + ":" + metaData.getMainClass()
|
|
739
|
+ + filename + ':' + metaData.getMainClass()
|
745
|
740
|
+ "' -> '" + prerequisites.getFailureReason() + "') ";
|
746
|
741
|
eventBus.publish(new UserErrorEvent(ErrorLevel.LOW, null, lastError, ""));
|
747
|
742
|
}
|
|
@@ -758,7 +753,7 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
|
758
|
753
|
plugin.onLoad();
|
759
|
754
|
} catch (LinkageError | Exception e) {
|
760
|
755
|
lastError = "Error in onLoad for "
|
761
|
|
- + metaData.getName() + ":" + e.getMessage();
|
|
756
|
+ + metaData.getName() + ':' + e.getMessage();
|
762
|
757
|
eventBus.publishAsync(new AppErrorEvent(ErrorLevel.MEDIUM,
|
763
|
758
|
e, lastError, ""));
|
764
|
759
|
unloadPlugin();
|
|
@@ -768,19 +763,19 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
|
768
|
763
|
}
|
769
|
764
|
}
|
770
|
765
|
} catch (ClassNotFoundException cnfe) {
|
771
|
|
- lastError = "Class not found ('" + filename + ":" + classname + ":"
|
|
766
|
+ lastError = "Class not found ('" + filename + ':' + classname + ':'
|
772
|
767
|
+ classname.equals(metaData.getMainClass()) + "') - "
|
773
|
768
|
+ cnfe.getMessage();
|
774
|
769
|
eventBus.publishAsync(new UserErrorEvent(ErrorLevel.LOW, cnfe, lastError, ""));
|
775
|
770
|
} catch (NoClassDefFoundError ncdf) {
|
776
|
|
- lastError = "Unable to instantiate plugin ('" + filename + ":"
|
777
|
|
- + classname + ":"
|
|
771
|
+ lastError = "Unable to instantiate plugin ('" + filename + ':'
|
|
772
|
+ + classname + ':'
|
778
|
773
|
+ classname.equals(metaData.getMainClass())
|
779
|
774
|
+ "') - Unable to find class: " + ncdf.getMessage();
|
780
|
775
|
eventBus.publishAsync(new UserErrorEvent(ErrorLevel.LOW, ncdf, lastError, ""));
|
781
|
776
|
} catch (VerifyError ve) {
|
782
|
|
- lastError = "Unable to instantiate plugin ('" + filename + ":"
|
783
|
|
- + classname + ":"
|
|
777
|
+ lastError = "Unable to instantiate plugin ('" + filename + ':'
|
|
778
|
+ + classname + ':'
|
784
|
779
|
+ classname.equals(metaData.getMainClass())
|
785
|
780
|
+ "') - Incompatible: " + ve.getMessage();
|
786
|
781
|
eventBus.publishAsync(new UserErrorEvent(ErrorLevel.LOW, ve, lastError, ""));
|
|
@@ -846,7 +841,7 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
|
846
|
841
|
plugin.onUnload();
|
847
|
842
|
} catch (Exception | LinkageError e) {
|
848
|
843
|
lastError = "Error in onUnload for " + metaData.getName()
|
849
|
|
- + ":" + e + " - " + e.getMessage();
|
|
844
|
+ + ':' + e + " - " + e.getMessage();
|
850
|
845
|
eventBus.publishAsync(new AppErrorEvent(ErrorLevel.MEDIUM, e, lastError, ""));
|
851
|
846
|
}
|
852
|
847
|
|