|
@@ -27,12 +27,12 @@ import com.dmdirc.actions.ActionManager;
|
27
|
27
|
import com.dmdirc.actions.ColourActionComparison;
|
28
|
28
|
import com.dmdirc.commandline.CommandLineParser;
|
29
|
29
|
import com.dmdirc.commandparser.CommandManager;
|
30
|
|
-import com.dmdirc.commandparser.aliases.AliasLifecycleManager;
|
31
|
30
|
import com.dmdirc.events.ClientClosedEvent;
|
32
|
31
|
import com.dmdirc.events.ClientOpenedEvent;
|
33
|
32
|
import com.dmdirc.events.FeedbackNagEvent;
|
34
|
33
|
import com.dmdirc.events.FirstRunEvent;
|
35
|
34
|
import com.dmdirc.interfaces.CommandController.CommandDetails;
|
|
35
|
+import com.dmdirc.interfaces.SystemLifecycleComponent;
|
36
|
36
|
import com.dmdirc.interfaces.config.IdentityController;
|
37
|
37
|
import com.dmdirc.interfaces.ui.UIController;
|
38
|
38
|
import com.dmdirc.logger.DMDircExceptionHandler;
|
|
@@ -84,7 +84,8 @@ public class Main {
|
84
|
84
|
private final GlobalWindowManager globalWindowManager;
|
85
|
85
|
/** The colour-based action comparisons. */
|
86
|
86
|
private final ColourActionComparison colourActionComparison;
|
87
|
|
- private final AliasLifecycleManager aliasLifecycleManager;
|
|
87
|
+ /** The set of known lifecycle components. */
|
|
88
|
+ private final Set<SystemLifecycleComponent> lifecycleComponents;
|
88
|
89
|
/** The event bus to dispatch events on. */
|
89
|
90
|
private final EventBus eventBus;
|
90
|
91
|
/** The commands to load into the command manager. */
|
|
@@ -102,7 +103,7 @@ public class Main {
|
102
|
103
|
* @param corePluginExtractor Extractor to use for core plugins.
|
103
|
104
|
* @param globalWindowManager Global window manager to use.
|
104
|
105
|
* @param colourActionComparison The colour-based action comparisons.
|
105
|
|
- * @param aliasLifecycleManager The alias lifecycle manager.
|
|
106
|
+ * @param lifecycleComponents The set of known lifecycle components.
|
106
|
107
|
* @param eventBus The event bus to dispatch events on.
|
107
|
108
|
* @param commands The commands to be loaded into the command manager.
|
108
|
109
|
*/
|
|
@@ -117,7 +118,7 @@ public class Main {
|
117
|
118
|
final CorePluginExtractor corePluginExtractor,
|
118
|
119
|
final GlobalWindowManager globalWindowManager,
|
119
|
120
|
final ColourActionComparison colourActionComparison,
|
120
|
|
- final AliasLifecycleManager aliasLifecycleManager,
|
|
121
|
+ final Set<SystemLifecycleComponent> lifecycleComponents,
|
121
|
122
|
final EventBus eventBus,
|
122
|
123
|
final Set<CommandDetails> commands) {
|
123
|
124
|
this.identityManager = identityManager;
|
|
@@ -129,7 +130,7 @@ public class Main {
|
129
|
130
|
this.commandManager = commandManager;
|
130
|
131
|
this.globalWindowManager = globalWindowManager;
|
131
|
132
|
this.colourActionComparison = colourActionComparison;
|
132
|
|
- this.aliasLifecycleManager = aliasLifecycleManager;
|
|
133
|
+ this.lifecycleComponents = lifecycleComponents;
|
133
|
134
|
this.eventBus = eventBus;
|
134
|
135
|
this.commands = commands;
|
135
|
136
|
}
|
|
@@ -176,13 +177,19 @@ public class Main {
|
176
|
177
|
commandLineParser.processArguments(serverManager);
|
177
|
178
|
|
178
|
179
|
globalWindowManager.init();
|
179
|
|
- aliasLifecycleManager.startUp();
|
|
180
|
+
|
|
181
|
+ for (SystemLifecycleComponent component : lifecycleComponents) {
|
|
182
|
+ component.startUp();
|
|
183
|
+ }
|
180
|
184
|
|
181
|
185
|
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
|
182
|
186
|
|
183
|
187
|
@Override
|
184
|
188
|
public void run() {
|
185
|
|
- aliasLifecycleManager.shutDown();
|
|
189
|
+ for (SystemLifecycleComponent component : lifecycleComponents) {
|
|
190
|
+ component.shutDown();
|
|
191
|
+ }
|
|
192
|
+
|
186
|
193
|
eventBus.post(new ClientClosedEvent());
|
187
|
194
|
serverManager.disconnectAll("Unexpected shutdown");
|
188
|
195
|
identityManager.saveAll();
|