|
@@ -25,13 +25,10 @@ package com.dmdirc.plugins;
|
25
|
25
|
import com.dmdirc.DMDircMBassador;
|
26
|
26
|
import com.dmdirc.config.ConfigFileBackedConfigProvider;
|
27
|
27
|
import com.dmdirc.config.InvalidIdentityFileException;
|
28
|
|
-import com.dmdirc.events.AppErrorEvent;
|
29
|
28
|
import com.dmdirc.events.PluginLoadedEvent;
|
30
|
29
|
import com.dmdirc.events.PluginUnloadedEvent;
|
31
|
|
-import com.dmdirc.events.UserErrorEvent;
|
32
|
30
|
import com.dmdirc.interfaces.config.ConfigProvider;
|
33
|
31
|
import com.dmdirc.interfaces.config.IdentityController;
|
34
|
|
-import com.dmdirc.logger.ErrorLevel;
|
35
|
32
|
import com.dmdirc.util.validators.ValidationResponse;
|
36
|
33
|
|
37
|
34
|
import java.io.IOException;
|
|
@@ -57,6 +54,9 @@ import org.slf4j.LoggerFactory;
|
57
|
54
|
|
58
|
55
|
import dagger.ObjectGraph;
|
59
|
56
|
|
|
57
|
+import static com.dmdirc.util.LogUtils.APP_ERROR;
|
|
58
|
+import static com.dmdirc.util.LogUtils.USER_ERROR;
|
|
59
|
+
|
60
|
60
|
/**
|
61
|
61
|
* Stores plugin metadata and handles loading of plugin resources.
|
62
|
62
|
*/
|
|
@@ -253,8 +253,8 @@ public class PluginInfo implements ServiceProvider {
|
253
|
253
|
directoryStream.forEach(this::loadIdentity);
|
254
|
254
|
}
|
255
|
255
|
} catch (final IOException ioe) {
|
256
|
|
- eventBus.publish(new UserErrorEvent(ErrorLevel.MEDIUM, ioe,
|
257
|
|
- "Error finding identities in plugin '" + metaData.getName() + '\'', ""));
|
|
256
|
+ LOG.warn(USER_ERROR, "Error finding identities in plugin '{}'", metaData.getName(),
|
|
257
|
+ ioe);
|
258
|
258
|
}
|
259
|
259
|
}
|
260
|
260
|
|
|
@@ -271,14 +271,12 @@ public class PluginInfo implements ServiceProvider {
|
271
|
271
|
identityController.addConfigProvider(configProvider);
|
272
|
272
|
configProviders.add(configProvider);
|
273
|
273
|
}
|
274
|
|
- } catch (final InvalidIdentityFileException ex) {
|
275
|
|
- eventBus.publish(new UserErrorEvent(ErrorLevel.MEDIUM, ex,
|
276
|
|
- "Error with identity file '" + path.getFileName() + "' in plugin '" +
|
277
|
|
- metaData.getName() + '\'', ""));
|
|
274
|
+ } catch (InvalidIdentityFileException ex) {
|
|
275
|
+ LOG.warn(USER_ERROR, "Error with identity file '{}' in plugin '{}'",
|
|
276
|
+ path.getFileName(), metaData.getName(), ex);
|
278
|
277
|
} catch (IOException ex) {
|
279
|
|
- eventBus.publish(new UserErrorEvent(ErrorLevel.MEDIUM, ex,
|
280
|
|
- "Unable to load identity file '" + path.getFileName() + "' in plugin '" +
|
281
|
|
- metaData.getName() + '\'', ""));
|
|
278
|
+ LOG.warn(USER_ERROR, "Unable to load identity file '{}' in plugin '{}'",
|
|
279
|
+ path.getFileName(), metaData.getName(), ex);
|
282
|
280
|
}
|
283
|
281
|
}
|
284
|
282
|
|
|
@@ -330,10 +328,10 @@ public class PluginInfo implements ServiceProvider {
|
330
|
328
|
* files.
|
331
|
329
|
*/
|
332
|
330
|
public void pluginUpdated() throws PluginException {
|
333
|
|
- updateClassList();
|
334
|
|
- updateMetaData();
|
335
|
|
- updateProvides();
|
336
|
|
- getDefaults();
|
|
331
|
+ updateClassList();
|
|
332
|
+ updateMetaData();
|
|
333
|
+ updateProvides();
|
|
334
|
+ getDefaults();
|
337
|
335
|
}
|
338
|
336
|
|
339
|
337
|
/**
|
|
@@ -597,23 +595,23 @@ public class PluginInfo implements ServiceProvider {
|
597
|
595
|
lastError = "Class not found ('" + filename + ':' + classname + ':'
|
598
|
596
|
+ classname.equals(metaData.getMainClass()) + "') - "
|
599
|
597
|
+ cnfe.getMessage();
|
600
|
|
- eventBus.publishAsync(new UserErrorEvent(ErrorLevel.LOW, cnfe, lastError, ""));
|
|
598
|
+ LOG.info(USER_ERROR, lastError, cnfe);
|
601
|
599
|
} catch (NoClassDefFoundError ncdf) {
|
602
|
600
|
lastError = "Unable to instantiate plugin ('" + filename + ':'
|
603
|
601
|
+ classname + ':'
|
604
|
602
|
+ classname.equals(metaData.getMainClass())
|
605
|
603
|
+ "') - Unable to find class: " + ncdf.getMessage();
|
606
|
|
- eventBus.publishAsync(new UserErrorEvent(ErrorLevel.LOW, ncdf, lastError, ""));
|
|
604
|
+ LOG.info(USER_ERROR, lastError, ncdf);
|
607
|
605
|
} catch (VerifyError ve) {
|
608
|
606
|
lastError = "Unable to instantiate plugin ('" + filename + ':'
|
609
|
607
|
+ classname + ':'
|
610
|
608
|
+ classname.equals(metaData.getMainClass())
|
611
|
609
|
+ "') - Incompatible: " + ve.getMessage();
|
612
|
|
- eventBus.publishAsync(new UserErrorEvent(ErrorLevel.LOW, ve, lastError, ""));
|
|
610
|
+ LOG.info(USER_ERROR, lastError, ve);
|
613
|
611
|
} catch (IllegalArgumentException | ReflectiveOperationException ex) {
|
614
|
612
|
lastError = "Unable to instantiate class for plugin " + metaData.getName()
|
615
|
613
|
+ ": " + classname;
|
616
|
|
- eventBus.publishAsync(new AppErrorEvent(ErrorLevel.LOW, ex, lastError, ""));
|
|
614
|
+ LOG.info(APP_ERROR, lastError, ex);
|
617
|
615
|
}
|
618
|
616
|
}
|
619
|
617
|
|
|
@@ -626,7 +624,7 @@ public class PluginInfo implements ServiceProvider {
|
626
|
624
|
lastError = "Prerequisites for plugin not met. ('"
|
627
|
625
|
+ filename + ':' + metaData.getMainClass()
|
628
|
626
|
+ "' -> '" + prerequisites.getFailureReason() + "') ";
|
629
|
|
- eventBus.publish(new UserErrorEvent(ErrorLevel.LOW, null, lastError, ""));
|
|
627
|
+ LOG.info(USER_ERROR, lastError);
|
630
|
628
|
} else {
|
631
|
629
|
initialisePlugin((Plugin) temp);
|
632
|
630
|
}
|
|
@@ -640,7 +638,7 @@ public class PluginInfo implements ServiceProvider {
|
640
|
638
|
plugin.onLoad();
|
641
|
639
|
} catch (LinkageError | Exception e) {
|
642
|
640
|
lastError = "Error in onLoad for " + metaData.getName() + ':' + e.getMessage();
|
643
|
|
- eventBus.publishAsync(new AppErrorEvent(ErrorLevel.MEDIUM, e, lastError, ""));
|
|
641
|
+ LOG.warn(APP_ERROR, lastError, e);
|
644
|
642
|
unloadPlugin();
|
645
|
643
|
}
|
646
|
644
|
}
|
|
@@ -698,7 +696,7 @@ public class PluginInfo implements ServiceProvider {
|
698
|
696
|
} catch (Exception | LinkageError e) {
|
699
|
697
|
lastError = "Error in onUnload for " + metaData.getName()
|
700
|
698
|
+ ':' + e + " - " + e.getMessage();
|
701
|
|
- eventBus.publishAsync(new AppErrorEvent(ErrorLevel.MEDIUM, e, lastError, ""));
|
|
699
|
+ LOG.warn(APP_ERROR, lastError, e);
|
702
|
700
|
}
|
703
|
701
|
|
704
|
702
|
//TODO plugin unloading shouldn't be done from here, event bus shouldn't be here.
|