Browse Source

Desingleton PluginManager (and as a side-effect, ServerManager).

Depends-On: I72fe837b5ea2352ae0c695948336efcdd92c09c8
Change-Id: I4a3d9b78a5f80aab0330d0906e8c76d00813c97c
Reviewed-on: http://gerrit.dmdirc.com/2523
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Greg Holmes <greg@dmdirc.com>
tags/0.7rc1
Shane Mc Cormack 11 years ago
parent
commit
4edc853bbf
42 changed files with 390 additions and 254 deletions
  1. 41
    13
      src/com/dmdirc/Main.java
  2. 6
    1
      src/com/dmdirc/ParserFactory.java
  3. 14
    5
      src/com/dmdirc/Server.java
  4. 20
    13
      src/com/dmdirc/ServerManager.java
  5. 5
    4
      src/com/dmdirc/actions/ActionComponentChain.java
  6. 2
    1
      src/com/dmdirc/actions/ActionCondition.java
  7. 51
    9
      src/com/dmdirc/actions/ActionManager.java
  8. 3
    3
      src/com/dmdirc/actions/ActionModel.java
  9. 2
    1
      src/com/dmdirc/actions/ActionSubstitutor.java
  10. 37
    36
      src/com/dmdirc/actions/CoreActionComponent.java
  11. 9
    4
      src/com/dmdirc/actions/wrappers/AliasWrapper.java
  12. 2
    3
      src/com/dmdirc/commandline/CommandLineParser.java
  13. 14
    5
      src/com/dmdirc/commandline/RemoteServer.java
  14. 1
    2
      src/com/dmdirc/commandparser/CommandLoader.java
  15. 1
    2
      src/com/dmdirc/commandparser/CommandManager.java
  16. 1
    2
      src/com/dmdirc/commandparser/commands/global/AllServers.java
  17. 2
    3
      src/com/dmdirc/commandparser/commands/global/Ifplugin.java
  18. 4
    5
      src/com/dmdirc/commandparser/commands/global/LoadPlugin.java
  19. 1
    2
      src/com/dmdirc/commandparser/commands/global/NewServer.java
  20. 3
    4
      src/com/dmdirc/commandparser/commands/global/ReloadPlugin.java
  21. 4
    5
      src/com/dmdirc/commandparser/commands/global/UnloadPlugin.java
  22. 2
    2
      src/com/dmdirc/interfaces/actions/ActionComponent.java
  23. 14
    14
      src/com/dmdirc/interfaces/actions/ActionComponentArgument.java
  24. 10
    0
      src/com/dmdirc/interfaces/ui/UIController.java
  25. 1
    2
      src/com/dmdirc/plugins/BaseFileDependantPlugin.java
  26. 8
    18
      src/com/dmdirc/plugins/GlobalClassLoader.java
  27. 11
    6
      src/com/dmdirc/plugins/PluginClassLoader.java
  28. 11
    11
      src/com/dmdirc/plugins/PluginInfo.java
  29. 20
    27
      src/com/dmdirc/plugins/PluginManager.java
  30. 15
    2
      src/com/dmdirc/plugins/PluginMetaData.java
  31. 6
    3
      src/com/dmdirc/ui/UIAttachDialog.java
  32. 1
    2
      src/com/dmdirc/ui/core/util/URLHandler.java
  33. 6
    3
      src/com/dmdirc/ui/input/InputHandler.java
  34. 11
    3
      src/com/dmdirc/util/URLBuilder.java
  35. 23
    23
      test/com/dmdirc/ServerManagerTest.java
  36. 1
    1
      test/com/dmdirc/ServerTest.java
  37. 4
    1
      test/com/dmdirc/TestMain.java
  38. 3
    2
      test/com/dmdirc/actions/ActionComponentChainTest.java
  39. 7
    0
      test/com/dmdirc/actions/ActionModelTest.java
  40. 2
    2
      test/com/dmdirc/actions/wrappers/AliasWrapperTest.java
  41. 2
    1
      test/com/dmdirc/commandparser/parsers/CommandParserTest.java
  42. 9
    8
      test/com/dmdirc/ui/WindowManagerTest.java

+ 41
- 13
src/com/dmdirc/Main.java View File

@@ -74,6 +74,12 @@ public class Main {
74 74
     /** Instance of main, protected to allow subclasses direct access. */
75 75
     protected static Main mainInstance;
76 76
 
77
+    /** Instance of pluginmanager used by this Main. */
78
+    protected PluginManager pluginManager;
79
+
80
+    /** Our ServerManager. */
81
+    protected ServerManager serverManager;
82
+
77 83
     /**
78 84
      * Entry procedure.
79 85
      *
@@ -98,6 +104,8 @@ public class Main {
98 104
         Thread.setDefaultUncaughtExceptionHandler(new DMDircExceptionHandler());
99 105
 
100 106
         IdentityManager.getIdentityManager().loadVersionIdentity();
107
+        serverManager = new ServerManager(this);
108
+        ActionManager.initActionManager(this, serverManager, IdentityManager.getIdentityManager());
101 109
 
102 110
         final CommandLineParser clp = new CommandLineParser(this, args);
103 111
 
@@ -111,8 +119,8 @@ public class Main {
111 119
 
112 120
         MessageSinkManager.getManager().loadDefaultSinks();
113 121
 
114
-        final PluginManager pm = PluginManager.initPluginManager(IdentityManager.getIdentityManager(), this);
115
-        checkBundledPlugins(pm, IdentityManager.getIdentityManager().getGlobalConfiguration());
122
+        pluginManager = new PluginManager(IdentityManager.getIdentityManager(), this);
123
+        checkBundledPlugins(pluginManager, IdentityManager.getIdentityManager().getGlobalConfiguration());
116 124
 
117 125
         ThemeManager.loadThemes();
118 126
 
@@ -121,22 +129,22 @@ public class Main {
121 129
         new CommandLoader().loadCommands(CommandManager.initCommandManager(IdentityManager.getIdentityManager(), this));
122 130
 
123 131
         for (String service : new String[]{"ui", "tabcompletion", "parser"}) {
124
-            ensureExists(pm, service);
132
+            ensureExists(pluginManager, service);
125 133
         }
126 134
 
127 135
         // The user may have an existing parser plugin (e.g. twitter) which
128 136
         // will satisfy the service existance check above, but will render the
129 137
         // client pretty useless, so we'll force IRC extraction for now.
130 138
         extractCorePlugins("parser_irc");
131
-        pm.refreshPlugins();
139
+        pluginManager.refreshPlugins();
132 140
 
133
-        loadUIs(pm);
141
+        loadUIs(pluginManager);
134 142
 
135 143
         doFirstRun();
136 144
 
137 145
         ActionManager.getActionManager().initialise();
138 146
 
139
-        pm.doAutoLoad();
147
+        pluginManager.doAutoLoad();
140 148
 
141 149
         ActionManager.getActionManager().loadUserActions();
142 150
 
@@ -153,12 +161,34 @@ public class Main {
153 161
             public void run() {
154 162
                 ActionManager.getActionManager().triggerEvent(
155 163
                         CoreActionType.CLIENT_CLOSED, null);
156
-                ServerManager.getServerManager().disconnectAll("Unexpected shutdown");
164
+                serverManager.disconnectAll("Unexpected shutdown");
157 165
                 IdentityManager.getIdentityManager().saveAll();
158 166
             }
159 167
         }, "Shutdown thread"));
160 168
     }
161 169
 
170
+    /**
171
+     * Get the plugin manager for this instance of main.
172
+     *
173
+     * @return PluginManager in use.
174
+     * @Deprecated Global state is bad.
175
+     */
176
+    @Deprecated
177
+    public PluginManager getPluginManager() {
178
+        return pluginManager;
179
+    }
180
+
181
+    /**
182
+     * Get our ServerManager
183
+     *
184
+     * @return ServerManager controlled by this Main.
185
+     * @Deprecated Global state is bad.
186
+     */
187
+    @Deprecated
188
+    public ServerManager getServerManager() {
189
+        return serverManager;
190
+    }
191
+
162 192
     /**
163 193
      * Called when the UI has failed to initialise correctly. This method
164 194
      * attempts to extract any and all UI plugins bundled with the client, and
@@ -270,7 +300,7 @@ public class Main {
270 300
 
271 301
                 if (installed.compareTo(bundled) < 0) {
272 302
                     extractCorePlugins(plugin.getMetaData().getName());
273
-                    PluginManager.getPluginManager().reloadPlugin(plugin.getFilename());
303
+                    pm.reloadPlugin(plugin.getFilename());
274 304
                 }
275 305
             }
276 306
         }
@@ -368,7 +398,7 @@ public class Main {
368 398
      *                  operating system when the client exits
369 399
      */
370 400
     public void quit(final String reason, final int exitCode) {
371
-        ServerManager.getServerManager().disconnectAll(reason);
401
+        serverManager.disconnectAll(reason);
372 402
 
373 403
         System.exit(exitCode);
374 404
     }
@@ -470,13 +500,11 @@ public class Main {
470 500
                         resourceName.length()));
471 501
 
472 502
                 if (!newFile.isDirectory()) {
473
-                    final PluginManager pm = PluginManager.getPluginManager();
474
-
475 503
                     ResourceManager.getResourceManager().
476 504
                             resourceToFile(resource.getValue(), newFile);
477 505
 
478
-                    final PluginInfo plugin = pm.getPluginInfo(newFile
479
-                            .getAbsolutePath().substring(pm.getDirectory().length()));
506
+                    final PluginInfo plugin = pluginManager.getPluginInfo(newFile
507
+                            .getAbsolutePath().substring(pluginManager.getDirectory().length()));
480 508
 
481 509
                     if (plugin != null) {
482 510
                         plugin.pluginUpdated();

+ 6
- 1
src/com/dmdirc/ParserFactory.java View File

@@ -33,14 +33,19 @@ import com.dmdirc.plugins.Service;
33 33
 import com.dmdirc.plugins.ServiceProvider;
34 34
 
35 35
 import java.net.URI;
36
+import lombok.RequiredArgsConstructor;
36 37
 
37 38
 /**
38 39
  * Provides a method to retrieve a parser.
39 40
  *
40 41
  * @since 0.6
41 42
  */
43
+@RequiredArgsConstructor
42 44
 public class ParserFactory {
43 45
 
46
+    /** PluginManager used by this ParserFactory */
47
+    private final PluginManager pluginManager;
48
+
44 49
     /**
45 50
      * Retrieves a parser instance.
46 51
      *
@@ -102,7 +107,7 @@ public class ParserFactory {
102 107
         final String scheme = address.getScheme() == null ? "irc" : address.getScheme();
103 108
 
104 109
         try {
105
-            final Service service = PluginManager.getPluginManager().getService("parser", scheme);
110
+            final Service service = pluginManager.getService("parser", scheme);
106 111
 
107 112
             if (service != null && !service.getProviders().isEmpty()) {
108 113
                 final ServiceProvider provider = service.getProviders().get(0);

+ 14
- 5
src/com/dmdirc/Server.java View File

@@ -177,6 +177,12 @@ public class Server extends WritableFrameContainer
177 177
     /** The certificate manager in use, if any. */
178 178
     private CertificateManager certificateManager;
179 179
 
180
+    /** ParserFactory we use for creating parsers. */
181
+    private final ParserFactory parserFactory;
182
+
183
+    /** ServerManager that created us. */
184
+    private final ServerManager manager;
185
+
180 186
     // </editor-fold>
181 187
 
182 188
     // </editor-fold>
@@ -188,10 +194,11 @@ public class Server extends WritableFrameContainer
188 194
      * the specified profile.
189 195
      *
190 196
      * @since 0.6.3
197
+     * @param manager The servermanager that owns this server.
191 198
      * @param uri The address of the server to connect to
192 199
      * @param profile The profile to use
193 200
      */
194
-    public Server(final URI uri, final Identity profile) {
201
+    public Server(final ServerManager manager, final URI uri, final Identity profile) {
195 202
         super("server-disconnected", getHost(uri), getHost(uri),
196 203
                 new ConfigManager(uri.getScheme(), "", "", uri.getHost()),
197 204
                 new ServerCommandParser(
@@ -200,9 +207,11 @@ public class Server extends WritableFrameContainer
200 207
                 WindowComponent.INPUTFIELD.getIdentifier(),
201 208
                 WindowComponent.CERTIFICATE_VIEWER.getIdentifier()));
202 209
 
210
+        this.manager = manager;
211
+        parserFactory = new ParserFactory(manager.getMain().getPluginManager());
203 212
         setConnectionDetails(uri, profile);
204 213
 
205
-        ServerManager.getServerManager().registerServer(this);
214
+        manager.registerServer(this);
206 215
         WindowManager.getWindowManager().addWindow(this);
207 216
 
208 217
         tabCompleter.addEntries(TabCompletionType.COMMAND,
@@ -246,7 +255,7 @@ public class Server extends WritableFrameContainer
246 255
      */
247 256
     private void setConnectionDetails(final URI uri, final Identity profile) {
248 257
         this.address = uri;
249
-        this.protocolDescription = new ParserFactory().getDescription(uri);
258
+        this.protocolDescription = parserFactory.getDescription(uri);
250 259
         this.profile = profile;
251 260
 
252 261
         if (uri.getPort() == -1 && protocolDescription != null) {
@@ -676,7 +685,7 @@ public class Server extends WritableFrameContainer
676 685
      */
677 686
     private Parser buildParser() {
678 687
         final MyInfo myInfo = buildMyInfo();
679
-        final Parser myParser = new ParserFactory().getParser(myInfo, address);
688
+        final Parser myParser = parserFactory.getParser(myInfo, address);
680 689
 
681 690
         if (myParser instanceof SecureParser) {
682 691
             certificateManager = new CertificateManager(address.getHost(), getConfigManager());
@@ -1060,7 +1069,7 @@ public class Server extends WritableFrameContainer
1060 1069
 
1061 1070
         // 4: Trigger action for the window closing
1062 1071
         // 5: Inform any parents that the window is closing
1063
-        ServerManager.getServerManager().unregisterServer(this);
1072
+        manager.unregisterServer(this);
1064 1073
     }
1065 1074
 
1066 1075
     /** {@inheritDoc} */

+ 20
- 13
src/com/dmdirc/ServerManager.java View File

@@ -24,6 +24,7 @@ package com.dmdirc;
24 24
 
25 25
 import com.dmdirc.config.Identity;
26 26
 import com.dmdirc.config.IdentityManager;
27
+import com.dmdirc.interfaces.ServerFactory;
27 28
 import com.dmdirc.logger.ErrorLevel;
28 29
 import com.dmdirc.logger.Logger;
29 30
 import com.dmdirc.parser.common.ChannelJoinRequest;
@@ -39,10 +40,10 @@ import java.util.concurrent.CopyOnWriteArraySet;
39 40
  * The ServerManager maintains a list of all servers, and provides methods to
40 41
  * search or iterate over them.
41 42
  */
42
-public class ServerManager {
43
+public class ServerManager implements ServerFactory {
43 44
 
44
-    /** Singleton instance of ServerManager. */
45
-    private static ServerManager me;
45
+    /** Main that owns this ServerManager. */
46
+    private final Main main;
46 47
 
47 48
     /** All servers that currently exist. */
48 49
     private final Set<Server> servers = new CopyOnWriteArraySet<Server>();
@@ -50,19 +51,25 @@ public class ServerManager {
50 51
     /**
51 52
      * Creates a new instance of ServerManager.
52 53
      */
53
-    private ServerManager() {
54
+    public ServerManager(final Main main) {
55
+        this.main = main;
54 56
     }
55 57
 
56 58
     /**
57
-     * Returns the singleton instance of ServerManager.
59
+     * Get the Main that owns this ServerManager.
58 60
      *
59
-     * @return Instance of ServerManager
61
+     * @return The Main that owns this ServerManager.
62
+     * @Deprecated Global state is bad.
60 63
      */
61
-    public static synchronized ServerManager getServerManager() {
62
-        if (me == null) {
63
-            me = new ServerManager();
64
-        }
65
-        return me;
64
+    @Deprecated
65
+    public Main getMain() {
66
+        return main;
67
+    }
68
+
69
+    /** {@inheritDoc} */
70
+    @Override
71
+    public Server createServer(final URI uri, final Identity profile) {
72
+        return new Server(this, uri, profile);
66 73
     }
67 74
 
68 75
     /**
@@ -205,7 +212,7 @@ public class ServerManager {
205 212
         }
206 213
 
207 214
         if (server == null) {
208
-            server = new Server(uri, profile);
215
+            server = new Server(this, uri, profile);
209 216
             server.connect();
210 217
             return server;
211 218
         }
@@ -241,7 +248,7 @@ public class ServerManager {
241 248
 
242 249
         if (connectedServer == null) {
243 250
             try {
244
-                final Server server = new Server(new URI("irc://irc.quakenet.org/DMDirc"),
251
+                final Server server = new Server(this, new URI("irc://irc.quakenet.org/DMDirc"),
245 252
                         IdentityManager.getIdentityManager()
246 253
                         .getIdentitiesByType("profile").get(0));
247 254
                 server.connect();

+ 5
- 4
src/com/dmdirc/actions/ActionComponentChain.java View File

@@ -24,6 +24,7 @@ package com.dmdirc.actions;
24 24
 
25 25
 import com.dmdirc.Precondition;
26 26
 import com.dmdirc.interfaces.actions.ActionComponent;
27
+import com.dmdirc.interfaces.actions.ActionComponentArgument;
27 28
 import com.dmdirc.logger.Logger;
28 29
 
29 30
 import java.util.ArrayList;
@@ -81,15 +82,15 @@ public class ActionComponentChain implements ActionComponent {
81 82
 
82 83
     /** {@inheritDoc} */
83 84
     @Override
84
-    public Object get(final Object argument) {
85
-        Object res = argument;
85
+    public Object get(final ActionComponentArgument arg) {
86
+        Object res = arg.getObject();
86 87
 
87 88
         for (ActionComponent component : components) {
88 89
             if (res == null) {
89 90
                 return null;
90 91
             }
91 92
 
92
-            res = component.get(res);
93
+            res = component.get(new ActionComponentArgument(arg.getMain(), res));
93 94
         }
94 95
 
95 96
         return res;
@@ -164,7 +165,7 @@ public class ActionComponentChain implements ActionComponent {
164 165
         for (ActionComponent component : components) {
165 166
             try {
166 167
                 final ComponentOptions options = component.getClass()
167
-                        .getMethod("get", Object.class).getAnnotation(ComponentOptions.class);
168
+                        .getMethod("get", ActionComponentArgument.class).getAnnotation(ComponentOptions.class);
168 169
                 if (options != null) {
169 170
                     res |= options.requireConnected();
170 171
                 }

+ 2
- 1
src/com/dmdirc/actions/ActionCondition.java View File

@@ -24,6 +24,7 @@ package com.dmdirc.actions;
24 24
 
25 25
 import com.dmdirc.interfaces.actions.ActionComparison;
26 26
 import com.dmdirc.interfaces.actions.ActionComponent;
27
+import com.dmdirc.interfaces.actions.ActionComponentArgument;
27 28
 
28 29
 /**
29 30
  * An action condition represents one condition within an action.
@@ -95,7 +96,7 @@ public class ActionCondition {
95 96
             final String thisStarget = sub.doSubstitution(starget, args);
96 97
             return getComparison().test(thisStarget, thisTarget);
97 98
         } else {
98
-            return getComparison().test(getComponent().get(args[getArg()]), thisTarget);
99
+            return getComparison().test(getComponent().get(new ActionComponentArgument(ActionManager.getActionManager().getMain(), args[getArg()])), thisTarget);
99 100
         }
100 101
     }
101 102
 

+ 51
- 9
src/com/dmdirc/actions/ActionManager.java View File

@@ -22,12 +22,13 @@
22 22
 
23 23
 package com.dmdirc.actions;
24 24
 
25
+import com.dmdirc.Main;
25 26
 import com.dmdirc.Precondition;
27
+import com.dmdirc.ServerManager;
26 28
 import com.dmdirc.actions.internal.WhoisNumericFormatter;
27 29
 import com.dmdirc.actions.wrappers.AliasWrapper;
28 30
 import com.dmdirc.actions.wrappers.PerformWrapper;
29 31
 import com.dmdirc.config.ConfigBinding;
30
-import com.dmdirc.config.IdentityManager;
31 32
 import com.dmdirc.interfaces.ActionController;
32 33
 import com.dmdirc.interfaces.ActionListener;
33 34
 import com.dmdirc.interfaces.IdentityController;
@@ -58,13 +59,18 @@ import lombok.extern.slf4j.Slf4j;
58 59
 @Slf4j
59 60
 public class ActionManager implements ActionController {
60 61
 
61
-    /** A singleton instance of the ActionManager. */
62
-    private static final ActionManager INSTANCE
63
-            = new ActionManager(IdentityManager.getIdentityManager());
64
-
65 62
     /** The identity manager to load configuration from. */
66 63
     private final IdentityController identityManager;
67 64
 
65
+    /** The ActionManager Instance. */
66
+    private static ActionManager me;
67
+
68
+    /** The instance of main that owns this Action Manager. */
69
+    private final Main main;
70
+
71
+    /** The ServerManager currently in use. */
72
+    private final ServerManager serverManager;
73
+
68 74
     /** A list of registered action types. */
69 75
     private final List<ActionType> types
70 76
             = new ArrayList<ActionType>();
@@ -104,20 +110,56 @@ public class ActionManager implements ActionController {
104 110
     /**
105 111
      * Creates a new instance of ActionManager.
106 112
      *
113
+     * @param main Main that created this action manager.
114
+     * @param serverManager The ServerManager in use.
107 115
      * @param identityManager The IdentityManager to load configuration from.
108 116
      */
109
-    public ActionManager(final IdentityController identityManager) {
117
+    private ActionManager(final Main main, final ServerManager serverManager, final IdentityController identityManager) {
118
+        // TODO: We shouldn't need a main.
119
+        this.main = main;
120
+        this.serverManager = serverManager;
110 121
         this.identityManager = identityManager;
111 122
         this.identityManager.getGlobalConfiguration().getBinder().bind(this, ActionManager.class);
112 123
     }
113 124
 
125
+    /**
126
+     * Get the instance of Main that owns this.
127
+     *
128
+     * @return Instance of main.
129
+     * @Deprecated Global state is bad.
130
+     */
131
+    @Deprecated
132
+    public Main getMain() {
133
+        return main;
134
+    }
135
+
136
+    /**
137
+     * Get the server manager.
138
+     *
139
+     * @return ServerManager
140
+     */
141
+    public ServerManager getServerManager() {
142
+        return serverManager;
143
+    }
144
+
145
+    /**
146
+     * Create the singleton instance of the Action Manager.
147
+     *
148
+     * @return The singleton ActionManager instance
149
+     */
150
+    @Deprecated
151
+    public static ActionManager initActionManager(final Main main, final ServerManager serverManager, final IdentityController identityManager) {
152
+        me = new ActionManager(main, serverManager, identityManager);
153
+        return me;
154
+    }
155
+
114 156
     /**
115 157
      * Returns a singleton instance of the Action Manager.
116 158
      *
117 159
      * @return A singleton ActionManager instance
118 160
      */
119 161
     public static ActionManager getActionManager() {
120
-        return INSTANCE;
162
+        return me;
121 163
     }
122 164
 
123 165
     /** {@inheritDoc} */
@@ -381,7 +423,7 @@ public class ActionManager implements ActionController {
381 423
             for (Action action : new ArrayList<Action>(actions.get(type))) {
382 424
                 try {
383 425
                     if (action.getConcurrencyGroup() == null) {
384
-                        res |= action.trigger(format, arguments);
426
+                        res |= action.trigger(getServerManager(), format, arguments);
385 427
                     } else {
386 428
                         synchronized (locks) {
387 429
                             if (!locks.containsKey(action.getConcurrencyGroup())) {
@@ -390,7 +432,7 @@ public class ActionManager implements ActionController {
390 432
                         }
391 433
 
392 434
                         synchronized (locks.get(action.getConcurrencyGroup())) {
393
-                            res |= action.trigger(format, arguments);
435
+                            res |= action.trigger(getServerManager(), format, arguments);
394 436
                         }
395 437
                     }
396 438
                 } catch (LinkageError e) {

+ 3
- 3
src/com/dmdirc/actions/ActionModel.java View File

@@ -127,7 +127,7 @@ public class ActionModel {
127 127
         "This action has at least one trigger",
128 128
         "This action's primary trigger is non-null"
129 129
     })
130
-    public boolean trigger(final StringBuffer format,
130
+    public boolean trigger(final ServerManager serverManager, final StringBuffer format,
131 131
             final Object... arguments) {
132 132
         assert triggers.length > 0;
133 133
         assert triggers[0] != null;
@@ -148,8 +148,8 @@ public class ActionModel {
148 148
         if (arguments.length > 0
149 149
                 && arguments[0] instanceof WritableFrameContainer) {
150 150
             container = (WritableFrameContainer) arguments[0];
151
-        } else if (ServerManager.getServerManager().numServers() > 0) {
152
-            container = ServerManager.getServerManager().getServers().get(0);
151
+        } else if (serverManager.numServers() > 0) {
152
+            container = serverManager.getServers().get(0);
153 153
         }
154 154
 
155 155
         if (container == null) {

+ 2
- 1
src/com/dmdirc/actions/ActionSubstitutor.java View File

@@ -30,6 +30,7 @@ import com.dmdirc.commandparser.CommandArguments;
30 30
 import com.dmdirc.config.ConfigManager;
31 31
 import com.dmdirc.config.IdentityManager;
32 32
 import com.dmdirc.interfaces.actions.ActionComponent;
33
+import com.dmdirc.interfaces.actions.ActionComponentArgument;
33 34
 import com.dmdirc.interfaces.actions.ActionType;
34 35
 import com.dmdirc.interfaces.ui.Window;
35 36
 
@@ -296,7 +297,7 @@ public class ActionSubstitutor {
296 297
         if ((chain.requiresConnection() && args[0] instanceof FrameContainer
297 298
                     && ((FrameContainer) args[0]).getServer().getState()
298 299
                     == ServerState.CONNECTED) || !chain.requiresConnection()) {
299
-            final Object res = chain.get(argument);
300
+            final Object res = chain.get(new ActionComponentArgument(ActionManager.getActionManager().getMain(), argument));
300 301
             return res == null ? ERR_NULL_CHAIN : res.toString();
301 302
         }
302 303
 

+ 37
- 36
src/com/dmdirc/actions/CoreActionComponent.java View File

@@ -28,6 +28,7 @@ import com.dmdirc.Query;
28 28
 import com.dmdirc.Server;
29 29
 import com.dmdirc.config.Identity;
30 30
 import com.dmdirc.interfaces.actions.ActionComponent;
31
+import com.dmdirc.interfaces.actions.ActionComponentArgument;
31 32
 import com.dmdirc.interfaces.ui.Window;
32 33
 import com.dmdirc.logger.ErrorLevel;
33 34
 import com.dmdirc.logger.Logger;
@@ -52,7 +53,7 @@ public enum CoreActionComponent implements ActionComponent {
52 53
     SERVER_NAME {
53 54
         /** {@inheritDoc} */
54 55
         @Override
55
-        public Object get(final Object argument) { return ((Server) argument).getAddress(); }
56
+        public Object get(final ActionComponentArgument arg) { return ((Server) arg.getObject()).getAddress(); }
56 57
         /** {@inheritDoc} */
57 58
         @Override
58 59
         public Class<?> appliesTo() { return Server.class; }
@@ -69,7 +70,7 @@ public enum CoreActionComponent implements ActionComponent {
69 70
         /** {@inheritDoc} */
70 71
         @Override
71 72
         @ComponentOptions(requireConnected = true)
72
-        public Object get(final Object argument) { return ((Server) argument).getNetwork(); }
73
+        public Object get(final ActionComponentArgument arg) { return ((Server) arg.getObject()).getNetwork(); }
73 74
         /** {@inheritDoc} */
74 75
         @Override
75 76
         public Class<?> appliesTo() { return Server.class; }
@@ -89,7 +90,7 @@ public enum CoreActionComponent implements ActionComponent {
89 90
     SERVER_PROTOCOL {
90 91
         /** {@inheritDoc} */
91 92
         @Override
92
-        public Object get(final Object argument) { return ((Server) argument).getProtocol(); }
93
+        public Object get(final ActionComponentArgument arg) { return ((Server) arg.getObject()).getProtocol(); }
93 94
         /** {@inheritDoc} */
94 95
         @Override
95 96
         public Class<?> appliesTo() { return Server.class; }
@@ -105,7 +106,7 @@ public enum CoreActionComponent implements ActionComponent {
105 106
     SERVER_MYAWAYREASON {
106 107
         /** {@inheritDoc} */
107 108
         @Override
108
-        public Object get(final Object argument) { return ((Server) argument).getAwayMessage(); }
109
+        public Object get(final ActionComponentArgument arg) { return ((Server) arg.getObject()).getAwayMessage(); }
109 110
         /** {@inheritDoc} */
110 111
         @Override
111 112
         public Class<?> appliesTo() { return Server.class; }
@@ -122,7 +123,7 @@ public enum CoreActionComponent implements ActionComponent {
122 123
         /** {@inheritDoc} */
123 124
         @Override
124 125
         @ComponentOptions(requireConnected = true)
125
-        public Object get(final Object argument) { return ((Server) argument).getParser().getChannelUserModes(); }
126
+        public Object get(final ActionComponentArgument arg) { return ((Server) arg.getObject()).getParser().getChannelUserModes(); }
126 127
         /** {@inheritDoc} */
127 128
         @Override
128 129
         public Class<?> appliesTo() { return Server.class; }
@@ -139,8 +140,8 @@ public enum CoreActionComponent implements ActionComponent {
139 140
         /** {@inheritDoc} */
140 141
         @Override
141 142
         @ComponentOptions(requireConnected = true)
142
-        public Object get(final Object argument) {
143
-            final Server server = (Server) argument;
143
+        public Object get(final ActionComponentArgument arg) {
144
+            final Server server = (Server) arg.getObject();
144 145
 
145 146
             if (server == null || server.getParser() == null) {
146 147
                 Logger.appError(ErrorLevel.LOW, "SERVER_MYNICKNAME.get() called with null element",
@@ -170,7 +171,7 @@ public enum CoreActionComponent implements ActionComponent {
170 171
     SERVER_PROFILE {
171 172
         /** {@inheritDoc} */
172 173
         @Override
173
-        public Object get(final Object argument) { return ((Server) argument).getProfile(); }
174
+        public Object get(final ActionComponentArgument arg) { return ((Server) arg.getObject()).getProfile(); }
174 175
         /** {@inheritDoc} */
175 176
         @Override
176 177
         public Class<?> appliesTo() { return Server.class; }
@@ -186,7 +187,7 @@ public enum CoreActionComponent implements ActionComponent {
186 187
     CHANNEL_NAME {
187 188
         /** {@inheritDoc} */
188 189
         @Override
189
-        public Object get(final Object argument) { return ((Channel) argument).getChannelInfo().getName(); }
190
+        public Object get(final ActionComponentArgument arg) { return ((Channel) arg.getObject()).getChannelInfo().getName(); }
190 191
         /** {@inheritDoc} */
191 192
         @Override
192 193
         public Class<?> appliesTo() { return Channel.class; }
@@ -202,7 +203,7 @@ public enum CoreActionComponent implements ActionComponent {
202 203
     CHANNEL_COLOUR {
203 204
         /** {@inheritDoc} */
204 205
         @Override
205
-        public Object get(final Object argument) { return ((Channel) argument).getNotification(); }
206
+        public Object get(final ActionComponentArgument arg) { return ((Channel) arg.getObject()).getNotification(); }
206 207
         /** {@inheritDoc} */
207 208
         @Override
208 209
         public Class<?> appliesTo() { return Channel.class; }
@@ -218,7 +219,7 @@ public enum CoreActionComponent implements ActionComponent {
218 219
     CLIENT_NAME {
219 220
         /** {@inheritDoc} */
220 221
         @Override
221
-        public Object get(final Object argument) { return ((ClientInfo) argument).getNickname(); }
222
+        public Object get(final ActionComponentArgument arg) { return ((ClientInfo) arg.getObject()).getNickname(); }
222 223
         /** {@inheritDoc} */
223 224
         @Override
224 225
         public Class<?> appliesTo() { return ClientInfo.class; }
@@ -234,7 +235,7 @@ public enum CoreActionComponent implements ActionComponent {
234 235
     CLIENT_HOST {
235 236
         /** {@inheritDoc} */
236 237
         @Override
237
-        public Object get(final Object argument) { return ((ClientInfo) argument).getHostname(); }
238
+        public Object get(final ActionComponentArgument arg) { return ((ClientInfo) arg.getObject()).getHostname(); }
238 239
         /** {@inheritDoc} */
239 240
         @Override
240 241
         public Class<?> appliesTo() { return ClientInfo.class; }
@@ -250,7 +251,7 @@ public enum CoreActionComponent implements ActionComponent {
250 251
     USER_NAME {
251 252
         /** {@inheritDoc} */
252 253
         @Override
253
-        public Object get(final Object argument) { return ((ChannelClientInfo) argument).getClient().getNickname(); }
254
+        public Object get(final ActionComponentArgument arg) { return ((ChannelClientInfo) arg.getObject()).getClient().getNickname(); }
254 255
         /** {@inheritDoc} */
255 256
         @Override
256 257
         public Class<?> appliesTo() { return ChannelClientInfo.class; }
@@ -266,7 +267,7 @@ public enum CoreActionComponent implements ActionComponent {
266 267
     USER_MODES {
267 268
         /** {@inheritDoc} */
268 269
         @Override
269
-        public Object get(final Object argument) { return ((ChannelClientInfo) argument).getAllModes(); }
270
+        public Object get(final ActionComponentArgument arg) { return ((ChannelClientInfo) arg.getObject()).getAllModes(); }
270 271
         /** {@inheritDoc} */
271 272
         @Override
272 273
         public Class<?> appliesTo() { return ChannelClientInfo.class; }
@@ -282,7 +283,7 @@ public enum CoreActionComponent implements ActionComponent {
282 283
     USER_HOST {
283 284
         /** {@inheritDoc} */
284 285
         @Override
285
-        public Object get(final Object argument) { return ((ChannelClientInfo) argument).getClient().getHostname(); }
286
+        public Object get(final ActionComponentArgument arg) { return ((ChannelClientInfo) arg.getObject()).getClient().getHostname(); }
286 287
         /** {@inheritDoc} */
287 288
         @Override
288 289
         public Class<?> appliesTo() { return ChannelClientInfo.class; }
@@ -298,7 +299,7 @@ public enum CoreActionComponent implements ActionComponent {
298 299
     USER_COMCHANS {
299 300
         /** {@inheritDoc} */
300 301
         @Override
301
-        public Object get(final Object argument) { return Integer.valueOf(((ChannelClientInfo) argument).getClient().getChannelCount()); }
302
+        public Object get(final ActionComponentArgument arg) { return Integer.valueOf(((ChannelClientInfo) arg.getObject()).getClient().getChannelCount()); }
302 303
         /** {@inheritDoc} */
303 304
         @Override
304 305
         public Class<?> appliesTo() { return ChannelClientInfo.class; }
@@ -314,7 +315,7 @@ public enum CoreActionComponent implements ActionComponent {
314 315
     STRING_STRING {
315 316
         /** {@inheritDoc} */
316 317
         @Override
317
-        public Object get(final Object argument) { return argument; }
318
+        public Object get(final ActionComponentArgument arg) { return arg.getObject(); }
318 319
         /** {@inheritDoc} */
319 320
         @Override
320 321
         public Class<?> appliesTo() { return String.class; }
@@ -330,7 +331,7 @@ public enum CoreActionComponent implements ActionComponent {
330 331
     STRING_STRIPPED {
331 332
         /** {@inheritDoc} */
332 333
         @Override
333
-        public Object get(final Object argument) { return Styliser.stipControlCodes((String) argument); }
334
+        public Object get(final ActionComponentArgument arg) { return Styliser.stipControlCodes((String) arg.getObject()); }
334 335
         /** {@inheritDoc} */
335 336
         @Override
336 337
         public Class<?> appliesTo() { return String.class; }
@@ -346,7 +347,7 @@ public enum CoreActionComponent implements ActionComponent {
346 347
     STRING_LENGTH {
347 348
         /** {@inheritDoc} */
348 349
         @Override
349
-        public Object get(final Object argument) { return ((String) argument).length(); }
350
+        public Object get(final ActionComponentArgument arg) { return ((String) arg.getObject()).length(); }
350 351
         /** {@inheritDoc} */
351 352
         @Override
352 353
         public Class<?> appliesTo() { return String.class; }
@@ -362,7 +363,7 @@ public enum CoreActionComponent implements ActionComponent {
362 363
     STRINGARRAY_LENGTH {
363 364
         /** {@inheritDoc} */
364 365
         @Override
365
-        public Object get(final Object argument) { return Integer.valueOf(((String[]) argument).length); }
366
+        public Object get(final ActionComponentArgument arg) { return Integer.valueOf(((String[]) arg.getObject()).length); }
366 367
         /** {@inheritDoc} */
367 368
         @Override
368 369
         public Class<?> appliesTo() { return String[].class; }
@@ -378,7 +379,7 @@ public enum CoreActionComponent implements ActionComponent {
378 379
     CALENDAR_FULLSTRING {
379 380
         /** {@inheritDoc} */
380 381
         @Override
381
-        public Object get(final Object argument) { return ((GregorianCalendar) argument).getTime().toString(); }
382
+        public Object get(final ActionComponentArgument arg) { return ((GregorianCalendar) arg.getObject()).getTime().toString(); }
382 383
         /** {@inheritDoc} */
383 384
         @Override
384 385
         public Class<?> appliesTo() { return Calendar.class; }
@@ -394,7 +395,7 @@ public enum CoreActionComponent implements ActionComponent {
394 395
     KEYEVENT_KEYNAME {
395 396
         /** {@inheritDoc} */
396 397
         @Override
397
-        public Object get(final Object argument) { return KeyEvent.getKeyText(((KeyStroke) argument).getKeyCode()); }
398
+        public Object get(final ActionComponentArgument arg) { return KeyEvent.getKeyText(((KeyStroke) arg.getObject()).getKeyCode()); }
398 399
         /** {@inheritDoc} */
399 400
         @Override
400 401
         public Class<?> appliesTo() { return KeyStroke.class; }
@@ -410,8 +411,8 @@ public enum CoreActionComponent implements ActionComponent {
410 411
     KEYEVENT_CTRLSTATE {
411 412
         /** {@inheritDoc} */
412 413
         @Override
413
-        public Object get(final Object argument) {
414
-            return Boolean.valueOf((((KeyStroke) argument).getModifiers() & KeyEvent.CTRL_DOWN_MASK) != 0);
414
+        public Object get(final ActionComponentArgument arg) {
415
+            return Boolean.valueOf((((KeyStroke) arg.getObject()).getModifiers() & KeyEvent.CTRL_DOWN_MASK) != 0);
415 416
         }
416 417
         /** {@inheritDoc} */
417 418
         @Override
@@ -428,8 +429,8 @@ public enum CoreActionComponent implements ActionComponent {
428 429
     KEYEVENT_SHIFTSTATE {
429 430
         /** {@inheritDoc} */
430 431
         @Override
431
-        public Object get(final Object argument) {
432
-            return Boolean.valueOf((((KeyStroke) argument).getModifiers() & KeyEvent.SHIFT_DOWN_MASK) != 0);
432
+        public Object get(final ActionComponentArgument arg) {
433
+            return Boolean.valueOf((((KeyStroke) arg.getObject()).getModifiers() & KeyEvent.SHIFT_DOWN_MASK) != 0);
433 434
         }
434 435
         /** {@inheritDoc} */
435 436
         @Override
@@ -446,8 +447,8 @@ public enum CoreActionComponent implements ActionComponent {
446 447
     KEYEVENT_ALTSTATE {
447 448
         /** {@inheritDoc} */
448 449
         @Override
449
-        public Object get(final Object argument) {
450
-            return Boolean.valueOf((((KeyStroke) argument).getModifiers() & KeyEvent.ALT_DOWN_MASK) != 0);
450
+        public Object get(final ActionComponentArgument arg) {
451
+            return Boolean.valueOf((((KeyStroke) arg.getObject()).getModifiers() & KeyEvent.ALT_DOWN_MASK) != 0);
451 452
         }
452 453
         /** {@inheritDoc} */
453 454
         @Override
@@ -464,7 +465,7 @@ public enum CoreActionComponent implements ActionComponent {
464 465
     QUERY_HOST {
465 466
         /** {@inheritDoc} */
466 467
         @Override
467
-        public Object get(final Object argument) { return ((Query) argument).getHost(); }
468
+        public Object get(final ActionComponentArgument arg) { return ((Query) arg.getObject()).getHost(); }
468 469
         /** {@inheritDoc} */
469 470
         @Override
470 471
         public Class<?> appliesTo() { return Query.class; }
@@ -480,7 +481,7 @@ public enum CoreActionComponent implements ActionComponent {
480 481
     QUERY_NICK {
481 482
         /** {@inheritDoc} */
482 483
         @Override
483
-        public Object get(final Object argument) { return ((Query) argument).getName(); }
484
+        public Object get(final ActionComponentArgument arg) { return ((Query) arg.getObject()).getName(); }
484 485
         /** {@inheritDoc} */
485 486
         @Override
486 487
         public Class<?> appliesTo() { return Query.class; }
@@ -496,7 +497,7 @@ public enum CoreActionComponent implements ActionComponent {
496 497
     QUERY_COLOUR {
497 498
         /** {@inheritDoc} */
498 499
         @Override
499
-        public Object get(final Object argument) { return ((Query) argument).getNotification(); }
500
+        public Object get(final ActionComponentArgument arg) { return ((Query) arg.getObject()).getNotification(); }
500 501
         /** {@inheritDoc} */
501 502
         @Override
502 503
         public Class<?> appliesTo() { return Query.class; }
@@ -512,7 +513,7 @@ public enum CoreActionComponent implements ActionComponent {
512 513
     WINDOW_NAME {
513 514
         /** {@inheritDoc} */
514 515
         @Override
515
-        public Object get(final Object argument) { return ((FrameContainer) argument).getName(); }
516
+        public Object get(final ActionComponentArgument arg) { return ((FrameContainer) arg.getObject()).getName(); }
516 517
         /** {@inheritDoc} */
517 518
         @Override
518 519
         public Class<?> appliesTo() { return FrameContainer.class; }
@@ -528,7 +529,7 @@ public enum CoreActionComponent implements ActionComponent {
528 529
     WINDOW_COLOUR {
529 530
         /** {@inheritDoc} */
530 531
         @Override
531
-        public Object get(final Object argument) { return ((FrameContainer) argument).getNotification(); }
532
+        public Object get(final ActionComponentArgument arg) { return ((FrameContainer) arg.getObject()).getNotification(); }
532 533
         /** {@inheritDoc} */
533 534
         @Override
534 535
         public Class<?> appliesTo() { return FrameContainer.class; }
@@ -548,7 +549,7 @@ public enum CoreActionComponent implements ActionComponent {
548 549
     WINDOW_SERVER {
549 550
         /** {@inheritDoc} */
550 551
         @Override
551
-        public Object get(final Object argument) { return ((Window) argument)
552
+        public Object get(final ActionComponentArgument arg) { return ((Window) arg.getObject())
552 553
                 .getContainer().getServer(); }
553 554
         /** {@inheritDoc} */
554 555
         @Override
@@ -565,7 +566,7 @@ public enum CoreActionComponent implements ActionComponent {
565 566
     IDENTITY_NAME {
566 567
         /** {@inheritDoc} */
567 568
         @Override
568
-        public Object get(final Object argument) { return ((Identity) argument).getName(); }
569
+        public Object get(final ActionComponentArgument arg) { return ((Identity) arg.getObject()).getName(); }
569 570
         /** {@inheritDoc} */
570 571
         @Override
571 572
         public Class<?> appliesTo() { return Identity.class; }
@@ -581,7 +582,7 @@ public enum CoreActionComponent implements ActionComponent {
581 582
     INTEGER_VALUE {
582 583
         /** {@inheritDoc} */
583 584
         @Override
584
-        public Object get(final Object argument) { return (Integer) argument; }
585
+        public Object get(final ActionComponentArgument arg) { return (Integer) arg.getObject(); }
585 586
         /** {@inheritDoc} */
586 587
         @Override
587 588
         public Class<?> appliesTo() { return Integer.class; }

+ 9
- 4
src/com/dmdirc/actions/wrappers/AliasWrapper.java View File

@@ -28,6 +28,7 @@ import com.dmdirc.ServerManager;
28 28
 import com.dmdirc.actions.Action;
29 29
 import com.dmdirc.actions.ActionCondition;
30 30
 import com.dmdirc.actions.ActionGroup;
31
+import com.dmdirc.actions.ActionManager;
31 32
 import com.dmdirc.actions.CoreActionType;
32 33
 import com.dmdirc.commandparser.CommandManager;
33 34
 import com.dmdirc.interfaces.CommandController;
@@ -52,15 +53,19 @@ public final class AliasWrapper extends ActionGroup {
52 53
     /** Command controller to get command info from. */
53 54
     private final CommandController commandController;
54 55
 
56
+    /** Server Manager. */
57
+    private final ServerManager serverManager;
58
+
55 59
     /**
56 60
      * Creates a new instance of AliasWrapper.
57 61
      *
58 62
      * @param commandController Command controller to get command info from.
59 63
      */
60
-    public AliasWrapper(final CommandController commandController) {
64
+    public AliasWrapper(final CommandController commandController, final ServerManager serverManager) {
61 65
         super("aliases");
62 66
 
63 67
         this.commandController = commandController;
68
+        this.serverManager = serverManager;
64 69
     }
65 70
 
66 71
     /**
@@ -70,7 +75,7 @@ public final class AliasWrapper extends ActionGroup {
70 75
      */
71 76
     public static synchronized AliasWrapper getAliasWrapper() {
72 77
         if (me == null) {
73
-            me = new AliasWrapper(CommandManager.getCommandManager());
78
+            me = new AliasWrapper(CommandManager.getCommandManager(), ActionManager.getActionManager().getServerManager());
74 79
         }
75 80
 
76 81
         return me;
@@ -101,7 +106,7 @@ public final class AliasWrapper extends ActionGroup {
101 106
                             .addEntry(TabCompletionType.COMMAND, commandName);
102 107
                 }
103 108
 
104
-                for (Server server : ServerManager.getServerManager().getServers()) {
109
+                for (Server server : serverManager.getServers()) {
105 110
                     server.getTabCompleter().addEntry(TabCompletionType.COMMAND, commandName);
106 111
                 }
107 112
             } else {
@@ -124,7 +129,7 @@ public final class AliasWrapper extends ActionGroup {
124 129
 
125 130
             aliases.remove(commandName);
126 131
 
127
-            for (Server server : ServerManager.getServerManager().getServers()) {
132
+            for (Server server : serverManager.getServers()) {
128 133
                 server.getTabCompleter().removeEntry(TabCompletionType.COMMAND, commandName);
129 134
             }
130 135
         }

+ 2
- 3
src/com/dmdirc/commandline/CommandLineParser.java View File

@@ -23,7 +23,6 @@
23 23
 package com.dmdirc.commandline;
24 24
 
25 25
 import com.dmdirc.Main;
26
-import com.dmdirc.ServerManager;
27 26
 import com.dmdirc.commandparser.commands.global.NewServer;
28 27
 import com.dmdirc.config.IdentityManager;
29 28
 import com.dmdirc.logger.ErrorLevel;
@@ -116,7 +115,7 @@ public class CommandLineParser {
116 115
             }
117 116
         }
118 117
 
119
-        RemoteServer.bind();
118
+        new RemoteServer(main).bind();
120 119
     }
121 120
 
122 121
     /**
@@ -369,7 +368,7 @@ public class CommandLineParser {
369 368
      */
370 369
     public void processArguments() {
371 370
         for (URI address : addresses)  {
372
-            ServerManager.getServerManager().connectToAddress(address);
371
+            main.getServerManager().connectToAddress(address);
373 372
         }
374 373
     }
375 374
 

+ 14
- 5
src/com/dmdirc/commandline/RemoteServer.java View File

@@ -22,7 +22,7 @@
22 22
 
23 23
 package com.dmdirc.commandline;
24 24
 
25
-import com.dmdirc.ServerManager;
25
+import com.dmdirc.Main;
26 26
 import com.dmdirc.logger.ErrorLevel;
27 27
 import com.dmdirc.logger.Logger;
28 28
 
@@ -44,13 +44,22 @@ public class RemoteServer implements RemoteInterface {
44 44
     /** The maximum port to use for RMI binding. */
45 45
     private static final int MAXPORT = MINPORT + 5;
46 46
     /** The interface we're exposing. */
47
-    private static final RemoteServer SERVER = new RemoteServer();
47
+    private final Main main;
48
+
49
+    /**
50
+     * Crate a new RemoteServer.
51
+     *
52
+     * @param main Main instance to use to do things.
53
+     */
54
+    public RemoteServer(final Main main) {
55
+        this.main = main;
56
+    }
48 57
 
49 58
     /** {@inheritDoc} */
50 59
     @Override
51 60
     public void connect(final List<URI> addresses) throws RemoteException {
52 61
         for (URI address : addresses) {
53
-            ServerManager.getServerManager().connectToAddress(address);
62
+            main.getServerManager().connectToAddress(address);
54 63
         }
55 64
     }
56 65
 
@@ -58,11 +67,11 @@ public class RemoteServer implements RemoteInterface {
58 67
      * Binds to the RMI registry so that other clients may find this remote
59 68
      * server.
60 69
      */
61
-    public static void bind() {
70
+    public void bind() {
62 71
         RemoteInterface stub;
63 72
 
64 73
         try {
65
-            stub = (RemoteInterface) UnicastRemoteObject.exportObject(SERVER, 0);
74
+            stub = (RemoteInterface) UnicastRemoteObject.exportObject(this, 0);
66 75
         } catch (RemoteException ex) {
67 76
             Logger.appError(ErrorLevel.MEDIUM, "Unable to export remote interface", ex);
68 77
             return;

+ 1
- 2
src/com/dmdirc/commandparser/CommandLoader.java View File

@@ -22,7 +22,6 @@
22 22
 
23 23
 package com.dmdirc.commandparser;
24 24
 
25
-import com.dmdirc.BasicServerFactory;
26 25
 import com.dmdirc.commandparser.commands.channel.Ban;
27 26
 import com.dmdirc.commandparser.commands.channel.Cycle;
28 27
 import com.dmdirc.commandparser.commands.channel.Invite;
@@ -127,7 +126,7 @@ public class CommandLoader {
127 126
         manager.registerCommand(new Exit(), Exit.INFO);
128 127
         manager.registerCommand(new Help(), Help.INFO);
129 128
         manager.registerCommand(new Ifplugin(), Ifplugin.INFO);
130
-        manager.registerCommand(new NewServer(new BasicServerFactory()), NewServer.INFO);
129
+        manager.registerCommand(new NewServer(manager.getMain().getServerManager()), NewServer.INFO);
131 130
         manager.registerCommand(new Notify(), Notify.INFO);
132 131
         manager.registerCommand(new LoadPlugin(), LoadPlugin.INFO);
133 132
         manager.registerCommand(new UnloadPlugin(), UnloadPlugin.INFO);

+ 1
- 2
src/com/dmdirc/commandparser/CommandManager.java View File

@@ -25,7 +25,6 @@ package com.dmdirc.commandparser;
25 25
 import com.dmdirc.Main;
26 26
 import com.dmdirc.Query;
27 27
 import com.dmdirc.Server;
28
-import com.dmdirc.ServerManager;
29 28
 import com.dmdirc.commandparser.commands.Command;
30 29
 import com.dmdirc.commandparser.parsers.CommandParser;
31 30
 import com.dmdirc.config.ConfigBinding;
@@ -168,7 +167,7 @@ public class CommandManager implements CommandController {
168 167
         final String commandName = getCommandChar() + command.getName();
169 168
 
170 169
         // TODO: This logic is probably in two places. Abstract it.
171
-        for (Server server : ServerManager.getServerManager().getServers()) {
170
+        for (Server server : main.getServerManager().getServers()) {
172 171
             if (command.getType() == CommandType.TYPE_SERVER
173 172
                     || command.getType() == CommandType.TYPE_GLOBAL) {
174 173
                 registerCommandName(server.getTabCompleter(), commandName, register);

+ 1
- 2
src/com/dmdirc/commandparser/commands/global/AllServers.java View File

@@ -24,7 +24,6 @@ package com.dmdirc.commandparser.commands.global;
24 24
 
25 25
 import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.Server;
27
-import com.dmdirc.ServerManager;
28 27
 import com.dmdirc.commandparser.BaseCommandInfo;
29 28
 import com.dmdirc.commandparser.CommandArguments;
30 29
 import com.dmdirc.commandparser.CommandInfo;
@@ -51,7 +50,7 @@ public class AllServers extends Command implements IntelligentCommand {
51 50
             final CommandArguments args, final CommandContext context) {
52 51
         final String command = args.getArgumentsAsString();
53 52
 
54
-        for (Server target : ServerManager.getServerManager().getServers()) {
53
+        for (Server target : getController().getMain().getServerManager().getServers()) {
55 54
             target.getCommandParser().parseCommand(target, command);
56 55
         }
57 56
     }

+ 2
- 3
src/com/dmdirc/commandparser/commands/global/Ifplugin.java View File

@@ -34,7 +34,6 @@ import com.dmdirc.commandparser.commands.IntelligentCommand;
34 34
 import com.dmdirc.commandparser.commands.context.CommandContext;
35 35
 import com.dmdirc.commandparser.parsers.GlobalCommandParser;
36 36
 import com.dmdirc.plugins.PluginInfo;
37
-import com.dmdirc.plugins.PluginManager;
38 37
 import com.dmdirc.ui.input.AdditionalTabTargets;
39 38
 import com.dmdirc.ui.input.TabCompleter;
40 39
 
@@ -63,7 +62,7 @@ public class Ifplugin extends Command implements IntelligentCommand {
63 62
 
64 63
         final String pname = args.getArguments()[0].substring(negative ? 1 : 0);
65 64
 
66
-        final PluginInfo pluginInfo = PluginManager.getPluginManager().getPluginInfoByName(pname);
65
+        final PluginInfo pluginInfo = getController().getMain().getPluginManager().getPluginInfoByName(pname);
67 66
 
68 67
         boolean result = true;
69 68
 
@@ -93,7 +92,7 @@ public class Ifplugin extends Command implements IntelligentCommand {
93 92
             res = new AdditionalTabTargets().excludeAll();
94 93
 
95 94
             for (PluginInfo possPlugin
96
-                    : PluginManager.getPluginManager().getPluginInfos()) {
95
+                    : getController().getMain().getPluginManager().getPluginInfos()) {
97 96
                 res.add(possPlugin.getMetaData().getName());
98 97
                 res.add("!" + possPlugin.getMetaData().getName());
99 98
             }

+ 4
- 5
src/com/dmdirc/commandparser/commands/global/LoadPlugin.java View File

@@ -31,7 +31,6 @@ import com.dmdirc.commandparser.commands.Command;
31 31
 import com.dmdirc.commandparser.commands.IntelligentCommand;
32 32
 import com.dmdirc.commandparser.commands.context.CommandContext;
33 33
 import com.dmdirc.plugins.PluginInfo;
34
-import com.dmdirc.plugins.PluginManager;
35 34
 import com.dmdirc.plugins.PluginMetaData;
36 35
 import com.dmdirc.ui.input.AdditionalTabTargets;
37 36
 
@@ -55,9 +54,9 @@ public class LoadPlugin extends Command implements IntelligentCommand {
55 54
         }
56 55
 
57 56
         // Add previously unknown plugin to plugin manager
58
-        PluginManager.getPluginManager().addPlugin(
57
+        getController().getMain().getPluginManager().addPlugin(
59 58
                 args.getArgumentsAsString());
60
-        final PluginInfo plugin = PluginManager.getPluginManager()
59
+        final PluginInfo plugin = getController().getMain().getPluginManager()
61 60
                 .getPluginInfo(args.getArgumentsAsString());
62 61
 
63 62
         if (plugin == null) {
@@ -71,7 +70,7 @@ public class LoadPlugin extends Command implements IntelligentCommand {
71 70
             if (plugin.isLoaded()) {
72 71
                 sendLine(origin, args.isSilent(), FORMAT_OUTPUT,
73 72
                         "Plugin loaded.");
74
-                PluginManager.getPluginManager().updateAutoLoad(plugin);
73
+                getController().getMain().getPluginManager().updateAutoLoad(plugin);
75 74
             } else {
76 75
                 sendLine(origin, args.isSilent(), FORMAT_OUTPUT,
77 76
                         "Loading plugin failed. ("
@@ -90,7 +89,7 @@ public class LoadPlugin extends Command implements IntelligentCommand {
90 89
 
91 90
         if (arg == 0) {
92 91
             for (PluginMetaData possPlugin
93
-                    : PluginManager.getPluginManager().getAllPlugins()) {
92
+                    : getController().getMain().getPluginManager().getAllPlugins()) {
94 93
                 res.add(possPlugin.getRelativeFilename());
95 94
             }
96 95
         }

+ 1
- 2
src/com/dmdirc/commandparser/commands/global/NewServer.java View File

@@ -35,7 +35,6 @@ import com.dmdirc.config.IdentityManager;
35 35
 import com.dmdirc.interfaces.ServerFactory;
36 36
 import com.dmdirc.logger.ErrorLevel;
37 37
 import com.dmdirc.logger.Logger;
38
-import com.dmdirc.plugins.PluginManager;
39 38
 import com.dmdirc.plugins.Service;
40 39
 import com.dmdirc.ui.input.AdditionalTabTargets;
41 40
 
@@ -239,7 +238,7 @@ public class NewServer extends Command implements IntelligentCommand {
239 238
         final AdditionalTabTargets res = new AdditionalTabTargets();
240 239
 
241 240
         if (arg == 0) {
242
-            for (Service parserType : PluginManager.getPluginManager().getServicesByType("parser")) {
241
+            for (Service parserType : getController().getMain().getPluginManager().getServicesByType("parser")) {
243 242
                 res.add(parserType.getName()+"://");
244 243
             }
245 244
         }

+ 3
- 4
src/com/dmdirc/commandparser/commands/global/ReloadPlugin.java View File

@@ -31,7 +31,6 @@ import com.dmdirc.commandparser.commands.Command;
31 31
 import com.dmdirc.commandparser.commands.IntelligentCommand;
32 32
 import com.dmdirc.commandparser.commands.context.CommandContext;
33 33
 import com.dmdirc.plugins.PluginInfo;
34
-import com.dmdirc.plugins.PluginManager;
35 34
 import com.dmdirc.ui.input.AdditionalTabTargets;
36 35
 
37 36
 /**
@@ -53,12 +52,12 @@ public class ReloadPlugin extends Command implements IntelligentCommand {
53 52
             return;
54 53
         }
55 54
 
56
-        final PluginInfo plugin = PluginManager.getPluginManager()
55
+        final PluginInfo plugin = getController().getMain().getPluginManager()
57 56
                 .getPluginInfoByName(args.getArguments()[0]);
58 57
         if (plugin == null) {
59 58
             sendLine(origin, args.isSilent(), FORMAT_ERROR,
60 59
                     "Plugin Reloading failed - Plugin not loaded");
61
-        } else if (PluginManager.getPluginManager().reloadPlugin(plugin.getMetaData().getRelativeFilename())) {
60
+        } else if (getController().getMain().getPluginManager().reloadPlugin(plugin.getMetaData().getRelativeFilename())) {
62 61
             sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "Plugin Reloaded.");
63 62
         } else {
64 63
             sendLine(origin, args.isSilent(), FORMAT_ERROR, "Plugin Reloading failed");
@@ -72,7 +71,7 @@ public class ReloadPlugin extends Command implements IntelligentCommand {
72 71
         final AdditionalTabTargets res = new AdditionalTabTargets().excludeAll();
73 72
 
74 73
         if (arg == 0) {
75
-            for (PluginInfo possPlugin : PluginManager.getPluginManager().getPluginInfos()) {
74
+            for (PluginInfo possPlugin : getController().getMain().getPluginManager().getPluginInfos()) {
76 75
                 res.add(possPlugin.getMetaData().getName());
77 76
             }
78 77
         }

+ 4
- 5
src/com/dmdirc/commandparser/commands/global/UnloadPlugin.java View File

@@ -31,7 +31,6 @@ import com.dmdirc.commandparser.commands.Command;
31 31
 import com.dmdirc.commandparser.commands.IntelligentCommand;
32 32
 import com.dmdirc.commandparser.commands.context.CommandContext;
33 33
 import com.dmdirc.plugins.PluginInfo;
34
-import com.dmdirc.plugins.PluginManager;
35 34
 import com.dmdirc.ui.input.AdditionalTabTargets;
36 35
 
37 36
 /**
@@ -53,13 +52,13 @@ public class UnloadPlugin extends Command implements IntelligentCommand {
53 52
             return;
54 53
         }
55 54
 
56
-        final PluginInfo plugin = PluginManager.getPluginManager()
55
+        final PluginInfo plugin = getController().getMain().getPluginManager()
57 56
                 .getPluginInfoByName(args.getArguments()[0]);
58 57
         if (plugin == null) {
59 58
             sendLine(origin, args.isSilent(), FORMAT_ERROR, "Plugin unloading failed - Plugin not loaded");
60
-        } else if (PluginManager.getPluginManager().delPlugin(plugin.getMetaData().getRelativeFilename())) {
59
+        } else if (getController().getMain().getPluginManager().delPlugin(plugin.getMetaData().getRelativeFilename())) {
61 60
             sendLine(origin, args.isSilent(), FORMAT_OUTPUT, "Plugin Unloaded.");
62
-            PluginManager.getPluginManager().updateAutoLoad(plugin);
61
+            getController().getMain().getPluginManager().updateAutoLoad(plugin);
63 62
         } else {
64 63
             sendLine(origin, args.isSilent(), FORMAT_ERROR, "Plugin Unloading failed");
65 64
         }
@@ -72,7 +71,7 @@ public class UnloadPlugin extends Command implements IntelligentCommand {
72 71
         final AdditionalTabTargets res = new AdditionalTabTargets().excludeAll();
73 72
 
74 73
         if (arg == 0) {
75
-            for (PluginInfo possPlugin : PluginManager.getPluginManager().getPluginInfos()) {
74
+            for (PluginInfo possPlugin : getController().getMain().getPluginManager().getPluginInfos()) {
76 75
                 if (possPlugin.isLoaded()) {
77 76
                     res.add(possPlugin.getMetaData().getName());
78 77
                 }

+ 2
- 2
src/com/dmdirc/interfaces/actions/ActionComponent.java View File

@@ -54,10 +54,10 @@ public interface ActionComponent {
54 54
      * Retrieves the component of the specified argument that this component
55 55
      * represents.
56 56
      *
57
-     * @param argument The object to retrieve the component from
57
+     * @param arg The object to retrieve the component from
58 58
      * @return The relevant component of the object
59 59
      */
60
-    Object get(Object argument);
60
+    Object get(ActionComponentArgument arg);
61 61
 
62 62
     /**
63 63
      * Retrieves the type of class that this component applies to.

src/com/dmdirc/BasicServerFactory.java → src/com/dmdirc/interfaces/actions/ActionComponentArgument.java View File

@@ -19,23 +19,23 @@
19 19
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 20
  * SOFTWARE.
21 21
  */
22
+package com.dmdirc.interfaces.actions;
22 23
 
23
-package com.dmdirc;
24
-
25
-import com.dmdirc.config.Identity;
26
-import com.dmdirc.interfaces.ServerFactory;
27
-
28
-import java.net.URI;
24
+import com.dmdirc.Main;
25
+import lombok.Getter;
26
+import lombok.RequiredArgsConstructor;
29 27
 
30 28
 /**
31
- * A basic factory for servers.
29
+ * Represents an argument for an ActionComponent
32 30
  */
33
-public class BasicServerFactory implements ServerFactory {
34
-
35
-    /** {@inheritDoc} */
36
-    @Override
37
-    public Server createServer(final URI uri, final Identity profile) {
38
-        return new Server(uri, profile);
39
-    }
31
+@RequiredArgsConstructor
32
+@SuppressWarnings("PMD.UnusedPrivateField")
33
+public class ActionComponentArgument {
34
+    /** Instance of main that ActionComponents may wish to use. */
35
+    @Getter
36
+    private final Main main;
40 37
 
38
+    /** The object this argument wraps. */
39
+    @Getter
40
+    private final Object object;
41 41
 }

+ 10
- 0
src/com/dmdirc/interfaces/ui/UIController.java View File

@@ -24,6 +24,7 @@ package com.dmdirc.interfaces.ui;
24 24
 
25 25
 import com.dmdirc.Channel;
26 26
 import com.dmdirc.FrameContainer;
27
+import com.dmdirc.Main;
27 28
 import com.dmdirc.Server;
28 29
 
29 30
 import java.net.URI;
@@ -34,6 +35,15 @@ import java.net.URI;
34 35
  */
35 36
 public interface UIController {
36 37
 
38
+    /**
39
+     * Get the instance of Main that created this UIController.
40
+     *
41
+     * @return Instance of Main that created this UIController.
42
+     * @Deprecated Global state is bad.
43
+     */
44
+    @Deprecated
45
+    Main getMain();
46
+
37 47
     /**
38 48
      * Requests that the specified window be bought to focus in this UI.
39 49
      *

+ 1
- 2
src/com/dmdirc/plugins/BaseFileDependantPlugin.java View File

@@ -56,8 +56,7 @@ public class BaseFileDependantPlugin extends BasePlugin {
56 56
     private File initFilesDir() {
57 57
         if (filesDir == null) {
58 58
             final String fs = System.getProperty("file.separator");
59
-            final String dir = PluginManager.getPluginManager()
60
-                    .getFilesDirectory();
59
+            final String dir = metaData.getManager().getFilesDirectory();
61 60
             filesDir = new File(dir + metaData.getName() + fs);
62 61
             if (!filesDir.exists()) {
63 62
                 filesDir.mkdirs();

+ 8
- 18
src/com/dmdirc/plugins/GlobalClassLoader.java View File

@@ -34,17 +34,20 @@ import java.util.Map;
34 34
  */
35 35
 public final class GlobalClassLoader extends ClassLoader {
36 36
 
37
-    /** Singleton instance of the GlobalClassLoader. */
38
-    private static GlobalClassLoader me;
39
-
40 37
     /** HashMap containing sources of Global class files. */
41 38
     private final Map<String, String> resourcesList = new HashMap<String, String>();
42 39
 
40
+    /** Plugin Manager that owns this GlobalClassLoader. */
41
+    private final PluginManager manager;
42
+
43 43
     /**
44 44
      * Create a new GlobalClassLoader.
45
+     *
46
+     * @param manager Plugin Manager that this GCL is used by.
45 47
      */
46
-    private GlobalClassLoader() {
48
+    public GlobalClassLoader(final PluginManager manager) {
47 49
         super();
50
+        this.manager = manager;
48 51
     }
49 52
 
50 53
     /**
@@ -57,19 +60,6 @@ public final class GlobalClassLoader extends ClassLoader {
57 60
         return findLoadedClass(name) != null;
58 61
     }
59 62
 
60
-    /**
61
-     * Retrieves the singleton instance of the GlobalClassLoader.
62
-     *
63
-     * @return A singleton instance of GlobalClassLoader.
64
-     */
65
-    public static synchronized GlobalClassLoader getGlobalClassLoader() {
66
-        if (me == null) {
67
-            me = new GlobalClassLoader();
68
-        }
69
-
70
-        return me;
71
-    }
72
-
73 63
     /**
74 64
      * Load the plugin with the given className.
75 65
      *
@@ -100,7 +90,7 @@ public final class GlobalClassLoader extends ClassLoader {
100 90
         }
101 91
 
102 92
         // Check the other plugins.
103
-        for (PluginInfo pi : PluginManager.getPluginManager().getPluginInfos()) {
93
+        for (PluginInfo pi : manager.getPluginInfos()) {
104 94
             final List<String> classList = pi.getClassList();
105 95
             if (classList.contains(name) && pi.getPluginClassLoader() != null) {
106 96
                 return pi.getPluginClassLoader().loadClass(name, false);

+ 11
- 6
src/com/dmdirc/plugins/PluginClassLoader.java View File

@@ -36,6 +36,9 @@ public class PluginClassLoader extends ClassLoader {
36 36
     /** The plugin Info object for the plugin we are loading. */
37 37
     private final PluginInfo pluginInfo;
38 38
 
39
+    /** Global Class Loader */
40
+    private final GlobalClassLoader globalLoader;
41
+
39 42
     /** The parent class loaders. */
40 43
     private final PluginClassLoader[] parents;
41 44
 
@@ -43,11 +46,13 @@ public class PluginClassLoader extends ClassLoader {
43 46
      * Create a new PluginClassLoader.
44 47
      *
45 48
      * @param info PluginInfo this classloader will be for
49
+     * @param globalLoader Global class loader to use where needed.
46 50
      * @param parents Parent ClassLoaders
47 51
      */
48
-    public PluginClassLoader(final PluginInfo info, final PluginClassLoader ... parents) {
52
+    public PluginClassLoader(final PluginInfo info, final GlobalClassLoader globalLoader, final PluginClassLoader ... parents) {
49 53
         this.pluginInfo = info;
50 54
         this.parents = parents;
55
+        this.globalLoader = globalLoader;
51 56
     }
52 57
 
53 58
     /**
@@ -57,7 +62,7 @@ public class PluginClassLoader extends ClassLoader {
57 62
      * @return A classloader configured with this one as its parent
58 63
      */
59 64
     public PluginClassLoader getSubClassLoader(final PluginInfo info) {
60
-        return new PluginClassLoader(info, this);
65
+        return new PluginClassLoader(info, globalLoader, this);
61 66
     }
62 67
 
63 68
     /**
@@ -81,7 +86,7 @@ public class PluginClassLoader extends ClassLoader {
81 86
      */
82 87
     public boolean isClassLoaded(final String name, final boolean checkGlobal) {
83 88
         return findLoadedClass(name) != null || (checkGlobal
84
-                && GlobalClassLoader.getGlobalClassLoader().isClassLoaded(name));
89
+                && globalLoader.isClassLoaded(name));
85 90
     }
86 91
 
87 92
     /**
@@ -117,12 +122,12 @@ public class PluginClassLoader extends ClassLoader {
117 122
         try {
118 123
             if (pluginInfo.isPersistent(name) || !res.resourceExists(fileName)) {
119 124
                 if (!pluginInfo.isPersistent(name) && askGlobal) {
120
-                    return GlobalClassLoader.getGlobalClassLoader().loadClass(name);
125
+                    return globalLoader.loadClass(name);
121 126
                 } else {
122 127
                     // Try to load class from previous load.
123 128
                     try {
124 129
                         if (askGlobal) {
125
-                            return GlobalClassLoader.getGlobalClassLoader().loadClass(name, pluginInfo);
130
+                            return globalLoader.loadClass(name, pluginInfo);
126 131
                         }
127 132
                     } catch (ClassNotFoundException e) {
128 133
                         /* Class doesn't exist, we load it ourself below */
@@ -150,7 +155,7 @@ public class PluginClassLoader extends ClassLoader {
150 155
 
151 156
         try {
152 157
             if (pluginInfo.isPersistent(name)) {
153
-                GlobalClassLoader.getGlobalClassLoader().defineClass(name, data);
158
+                globalLoader.defineClass(name, data);
154 159
             } else {
155 160
                 loadedClass = defineClass(name, data, 0, data.length);
156 161
             }

+ 11
- 11
src/com/dmdirc/plugins/PluginInfo.java View File

@@ -147,7 +147,7 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
147 147
         final Plugin[] plugins = new Plugin[parents.length];
148 148
 
149 149
         for (int i = 0; i < metaData.getParents().length; i++) {
150
-            final PluginInfo parent = PluginManager.getPluginManager()
150
+            final PluginInfo parent = metaData.getManager()
151 151
                     .getPluginInfoByName(metaData.getParents()[i]);
152 152
             parents[i] = parent.getInjector();
153 153
             plugins[i] = parent.getPlugin();
@@ -159,13 +159,13 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
159 159
             injector.addParameter(parentPlugin);
160 160
         }
161 161
 
162
-        injector.addParameter(PluginManager.class, PluginManager.getPluginManager());
162
+        injector.addParameter(PluginManager.class, metaData.getManager());
163 163
         injector.addParameter(ActionManager.getActionManager());
164 164
         injector.addParameter(PluginInfo.class, this);
165
-        injector.addParameter(Main.class, PluginManager.getPluginManager().getMain());
165
+        injector.addParameter(Main.class, metaData.getManager().getMain());
166 166
         injector.addParameter(PluginMetaData.class, metaData);
167 167
         injector.addParameter(IdentityManager.class, IdentityManager.getIdentityManager());
168
-        injector.addParameter(ServerManager.class, ServerManager.getServerManager());
168
+        injector.addParameter(ServerManager.class, metaData.getManager().getMain().getServerManager());
169 169
 
170 170
         return injector;
171 171
     }
@@ -288,7 +288,7 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
288 288
                 final String type = bits.length > 1 ? bits[1] : "misc";
289 289
 
290 290
                 if (!name.equalsIgnoreCase("any") && !type.equalsIgnoreCase("export")) {
291
-                    final Service service = PluginManager.getPluginManager().getService(type, name, true);
291
+                    final Service service = metaData.getManager().getService(type, name, true);
292 292
                     synchronized (provides) {
293 293
                         service.addProvider(this);
294 294
                         provides.add(service);
@@ -442,7 +442,7 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
442 442
      * @return True iff all required services were found and satisfied
443 443
      */
444 444
     protected boolean loadRequiredServices() {
445
-        final ServiceManager manager = PluginManager.getPluginManager();
445
+        final ServiceManager manager = metaData.getManager();
446 446
 
447 447
         for (String serviceInfo : metaData.getRequiredServices()) {
448 448
             final String[] parts = serviceInfo.split(" ", 2);
@@ -513,7 +513,7 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
513 513
         log.info("Loading required plugin '{}' for plugin {}",
514 514
                 new Object[] { name, metaData.getName() });
515 515
 
516
-        final PluginInfo pi = PluginManager.getPluginManager().getPluginInfoByName(name);
516
+        final PluginInfo pi = metaData.getManager().getPluginInfoByName(name);
517 517
 
518 518
         if (pi == null) {
519 519
             return false;
@@ -628,7 +628,7 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
628 628
 
629 629
             for (int i = 0; i < metaData.getParents().length; i++) {
630 630
                 final String parentName = metaData.getParents()[i];
631
-                final PluginInfo parent = PluginManager.getPluginManager()
631
+                final PluginInfo parent = metaData.getManager()
632 632
                         .getPluginInfoByName(parentName);
633 633
                 parent.addChild(this);
634 634
                 loaders[i] = parent.getPluginClassLoader();
@@ -646,7 +646,7 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
646 646
                 }
647 647
             }
648 648
 
649
-            pluginClassLoader = new PluginClassLoader(this, loaders);
649
+            pluginClassLoader = new PluginClassLoader(this, metaData.getManager().getGlobalClassLoader(), loaders);
650 650
         }
651 651
     }
652 652
 
@@ -774,7 +774,7 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
774 774
                 // Delete ourself as a child of our parent.
775 775
                 if (!parentUnloading) {
776 776
                     for (String parent : metaData.getParents()) {
777
-                        final PluginInfo pi = PluginManager.getPluginManager().getPluginInfoByName(parent);
777
+                        final PluginInfo pi = metaData.getManager().getPluginInfoByName(parent);
778 778
                         if (pi != null) {
779 779
                             pi.delChild(this);
780 780
                         }
@@ -892,7 +892,7 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
892 892
                 final String serviceName = bits.length > 4 ? bits[4] : bits[0];
893 893
 
894 894
                 // Add a provides for this
895
-                final Service service = PluginManager.getPluginManager().getService("export", serviceName, true);
895
+                final Service service = metaData.getManager().getService("export", serviceName, true);
896 896
                 synchronized (provides) {
897 897
                     service.addProvider(this);
898 898
                     provides.add(service);

+ 20
- 27
src/com/dmdirc/plugins/PluginManager.java View File

@@ -53,9 +53,6 @@ import java.util.Map;
53 53
  */
54 54
 public class PluginManager implements ActionListener, ServiceManager {
55 55
 
56
-    /** Singleton instance of the plugin manager. */
57
-    private static PluginManager me;
58
-
59 56
     /** List of known plugins' file names to their corresponding {@link PluginInfo} objects. */
60 57
     private final Map<String, PluginInfo> knownPlugins = new HashMap<String, PluginInfo>();
61 58
 
@@ -71,23 +68,39 @@ public class PluginManager implements ActionListener, ServiceManager {
71 68
     /** Parent. */
72 69
     private final Main main;
73 70
 
71
+    /** Global ClassLoader used by plugins from this manager. */
72
+    private final GlobalClassLoader globalClassLoader;
73
+
74 74
     /**
75 75
      * Creates a new instance of PluginManager.
76 76
      */
77
-    private PluginManager(final IdentityManager identityManager, final Main main) {
77
+    public PluginManager(final IdentityManager identityManager, final Main main) {
78 78
         final String fs = System.getProperty("file.separator");
79 79
         myDir = identityManager.getConfigDir() + "plugins" + fs;
80 80
         this.main = main;
81
+        this.globalClassLoader = new GlobalClassLoader(this);
81 82
         ActionManager.getActionManager().registerListener(this,
82 83
                 CoreActionType.CLIENT_PREFS_OPENED,
83 84
                 CoreActionType.CLIENT_PREFS_CLOSED);
85
+        refreshPlugins();
86
+    }
87
+
88
+    /**
89
+     * Get the global class loader in use for this plugin manager.
90
+     *
91
+     * @return Global Class Loader
92
+     */
93
+    public GlobalClassLoader getGlobalClassLoader() {
94
+        return globalClassLoader;
84 95
     }
85 96
 
86 97
     /**
87 98
      * Get the instance of Main that owns this.
88 99
      *
89
-     * @return
100
+     * @return main that owns this.
101
+     * @Deprecated Global state is bad.
90 102
      */
103
+    @Deprecated
91 104
     public Main getMain() {
92 105
         return main;
93 106
     }
@@ -208,26 +221,6 @@ public class PluginManager implements ActionListener, ServiceManager {
208 221
         }
209 222
     }
210 223
 
211
-    /**
212
-     * Retrieves the singleton instance of the plugin manager.
213
-     *
214
-     * @return A singleton instance of PluginManager.
215
-     */
216
-    public static synchronized PluginManager initPluginManager(final IdentityManager identityManager, final Main main) {
217
-        me = new PluginManager(identityManager, main);
218
-        me.refreshPlugins();
219
-        return me;
220
-    }
221
-
222
-    /**
223
-     * Retrieves the singleton instance of the plugin manager.
224
-     *
225
-     * @return A singleton instance of PluginManager.
226
-     */
227
-    public static synchronized PluginManager getPluginManager() {
228
-        return me;
229
-    }
230
-
231 224
     /**
232 225
      * Tests and adds the specified plugin to the known plugins list. Plugins
233 226
      * will only be added if: <ul><li>The file exists,<li>No other plugin with
@@ -251,7 +244,7 @@ public class PluginManager implements ActionListener, ServiceManager {
251 244
         }
252 245
 
253 246
         try {
254
-            final PluginMetaData metadata = new PluginMetaData(
247
+            final PluginMetaData metadata = new PluginMetaData(this,
255 248
                     new URL("jar:file:" + getDirectory() + filename
256 249
                     + "!/META-INF/plugin.config"),
257 250
                     new URL("file:" + getDirectory() + filename));
@@ -485,7 +478,7 @@ public class PluginManager implements ActionListener, ServiceManager {
485 478
         // Initialise all of our metadata objects
486 479
         for (String target : pluginPaths) {
487 480
             try {
488
-                final PluginMetaData targetMetaData = new PluginMetaData(
481
+                final PluginMetaData targetMetaData = new PluginMetaData(this,
489 482
                         new URL("jar:file:" + getDirectory() + target
490 483
                         + "!/META-INF/plugin.config"),
491 484
                         new URL("file:" + getDirectory() + target));

+ 15
- 2
src/com/dmdirc/plugins/PluginMetaData.java View File

@@ -135,13 +135,17 @@ public class PluginMetaData {
135 135
     /** The URL to load the metadata from. */
136 136
     private final URL url;
137 137
 
138
+    /** The parent plugin manager. */
139
+    private PluginManager manager;
140
+
138 141
     /**
139 142
      * Creates a new meta data reader for a config file at the specified URL.
140 143
      *
141 144
      * @param url The URL to load the config file from
142 145
      * @param pluginUrl The URL to the plugin that this data corresponds to
143 146
      */
144
-    public PluginMetaData(final URL url, final URL pluginUrl) {
147
+    public PluginMetaData(final PluginManager manager, final URL url, final URL pluginUrl) {
148
+        this.manager = manager;
145 149
         this.pluginUrl = pluginUrl;
146 150
         this.url = url;
147 151
     }
@@ -399,7 +403,7 @@ public class PluginMetaData {
399 403
     public String getRelativeFilename() {
400 404
         // Yuck...
401 405
         final String filename = getPluginUrl().getPath();
402
-        final String dir = new File(PluginManager.getPluginManager().getDirectory())
406
+        final String dir = new File(manager.getDirectory())
403 407
                 .getAbsolutePath() + File.separator;
404 408
         final String file = new File(filename).getAbsolutePath();
405 409
 
@@ -408,6 +412,15 @@ public class PluginMetaData {
408 412
 
409 413
     // <editor-fold defaultstate="collapsed" desc="Getters">
410 414
 
415
+    /**
416
+     * What plugin manager owns this metadata?
417
+     *
418
+     * @return The pluginmanager that created this metadata.
419
+     */
420
+    public PluginManager getManager() {
421
+        return manager;
422
+    }
423
+
411 424
     /**
412 425
      * Retrieves the URL to the plugin that this metadata corresponds to.
413 426
      *

+ 6
- 3
src/com/dmdirc/ui/UIAttachDialog.java View File

@@ -22,7 +22,7 @@
22 22
 
23 23
 package com.dmdirc.ui;
24 24
 
25
-import com.dmdirc.plugins.PluginManager;
25
+import com.dmdirc.Main;
26 26
 import com.dmdirc.plugins.Service;
27 27
 
28 28
 import java.awt.BorderLayout;
@@ -56,10 +56,13 @@ public class UIAttachDialog extends JDialog implements ActionListener,
56 56
     private static final int GAP = 5;
57 57
     /** Services list. */
58 58
     private final JList list;
59
+    /** Main instance. */
60
+    private final Main main;
59 61
 
60 62
     /** Creates a new dialog allowing the user to select and load a UI. */
61
-    public UIAttachDialog() {
63
+    public UIAttachDialog(final Main main) {
62 64
         super();
65
+        this.main = main;
63 66
         list = initList();
64 67
         setLayout(new BorderLayout());
65 68
         add(list, BorderLayout.CENTER);
@@ -72,7 +75,7 @@ public class UIAttachDialog extends JDialog implements ActionListener,
72 75
         final JList newList = new JList(model);
73 76
         newList.setCellRenderer(new ServiceRenderer());
74 77
         newList.addListSelectionListener(this);
75
-        final List<Service> services = PluginManager.getPluginManager()
78
+        final List<Service> services = main.getPluginManager()
76 79
                 .getServicesByType("ui");
77 80
         for (Service service : services) {
78 81
             model.addElement(service);

+ 1
- 2
src/com/dmdirc/ui/core/util/URLHandler.java View File

@@ -22,7 +22,6 @@
22 22
 
23 23
 package com.dmdirc.ui.core.util;
24 24
 
25
-import com.dmdirc.ServerManager;
26 25
 import com.dmdirc.config.ConfigManager;
27 26
 import com.dmdirc.config.IdentityManager;
28 27
 import com.dmdirc.interfaces.ui.UIController;
@@ -156,7 +155,7 @@ public class URLHandler {
156 155
             StatusBarManager.getStatusBarManager().setMessage(
157 156
                     new StatusMessage("Connecting to: " + uri.toString(),
158 157
                     config));
159
-            ServerManager.getServerManager().connectToAddress(uri);
158
+            controller.getMain().getServerManager().connectToAddress(uri);
160 159
         } else if ("BROWSER".equals(command)) {
161 160
             StatusBarManager.getStatusBarManager().setMessage(
162 161
                     new StatusMessage("Opening: " + uri.toString(),

+ 6
- 3
src/com/dmdirc/ui/input/InputHandler.java View File

@@ -35,8 +35,8 @@ import com.dmdirc.commandparser.parsers.CommandParser;
35 35
 import com.dmdirc.interfaces.ConfigChangeListener;
36 36
 import com.dmdirc.interfaces.ui.InputField;
37 37
 import com.dmdirc.interfaces.ui.InputValidationListener;
38
+import com.dmdirc.interfaces.ui.UIController;
38 39
 import com.dmdirc.parser.common.CompositionState;
39
-import com.dmdirc.plugins.PluginManager;
40 40
 import com.dmdirc.ui.input.tabstyles.TabCompletionResult;
41 41
 import com.dmdirc.ui.input.tabstyles.TabCompletionStyle;
42 42
 import com.dmdirc.ui.messages.Styliser;
@@ -110,6 +110,8 @@ public abstract class InputHandler implements ConfigChangeListener {
110 110
     private CompositionState state = CompositionState.IDLE;
111 111
     /** Timer used to manage timeouts of composition state. */
112 112
     private Timer compositionTimer;
113
+    /** UIController that owns this InputHandler. */
114
+    private final UIController controller;
113 115
 
114 116
     /**
115 117
      * Creates a new instance of InputHandler. Adds listeners to the target
@@ -119,10 +121,11 @@ public abstract class InputHandler implements ConfigChangeListener {
119 121
      * @param thisCommandParser The command parser to use for this text field.
120 122
      * @param thisParentWindow The window that owns this input handler
121 123
      */
122
-    public InputHandler(final InputField thisTarget,
124
+    public InputHandler(final UIController controller, final InputField thisTarget,
123 125
             final CommandParser thisCommandParser,
124 126
             final WritableFrameContainer thisParentWindow) {
125 127
 
128
+        this.controller = controller;
126 129
         buffer = new RollingList<String>(thisParentWindow.getConfigManager()
127 130
                 .getOptionInt("ui", "inputbuffersize"), "");
128 131
 
@@ -188,7 +191,7 @@ public abstract class InputHandler implements ConfigChangeListener {
188 191
      * Sets this inputhandler's tab completion style.
189 192
      */
190 193
     private void setStyle() {
191
-        style = (TabCompletionStyle) PluginManager.getPluginManager()
194
+        style = (TabCompletionStyle) controller.getMain().getPluginManager()
192 195
                 .getServiceProvider("tabcompletion", parentWindow
193 196
                 .getConfigManager().getOption("tabcompletion", "style"))
194 197
                 .getExportedService("getCompletionStyle").execute(tabCompleter,

+ 11
- 3
src/com/dmdirc/util/URLBuilder.java View File

@@ -22,9 +22,9 @@
22 22
 
23 23
 package com.dmdirc.util;
24 24
 
25
+import com.dmdirc.actions.ActionManager;
25 26
 import com.dmdirc.logger.ErrorLevel;
26 27
 import com.dmdirc.logger.Logger;
27
-import com.dmdirc.plugins.PluginManager;
28 28
 import com.dmdirc.ui.themes.ThemeManager;
29 29
 
30 30
 import java.net.MalformedURLException;
@@ -109,9 +109,17 @@ public final class URLBuilder {
109 109
      * @return An URL corresponding to the specified resource, or null on failure
110 110
      */
111 111
     public static URL buildPluginURL(final String plugin, final String path) {
112
+        // TODO: Un hack this.
113
+        // Using the ActionManager to getMain() so that we can get the plugin
114
+        // manager is a horribe horrible hack.
115
+        // But making this method require an instance of Main means that
116
+        // BuildURL also need one, which breaks other things. Specifically
117
+        // IconManager, which currently is created new each time it is needed
118
+        // rather than being created once and passed around.
112 119
         return buildJarURL(
113
-                PluginManager.getPluginManager().getPluginInfoByName(plugin)
114
-                .getMetaData().getPluginUrl().getPath(), path);
120
+                ActionManager.getActionManager().getMain().getPluginManager()
121
+                .getPluginInfoByName(plugin).getMetaData().getPluginUrl()
122
+                .getPath(), path);
115 123
     }
116 124
 
117 125
     /**

+ 23
- 23
test/com/dmdirc/ServerManagerTest.java View File

@@ -41,15 +41,15 @@ public class ServerManagerTest {
41 41
 
42 42
     @After
43 43
     public void tearDown() {
44
-        for (Server server : ServerManager.getServerManager().getServers()) {
45
-            ServerManager.getServerManager().unregisterServer(server);
44
+        for (Server server : TestMain.getTestMain().getServerManager().getServers()) {
45
+            TestMain.getTestMain().getServerManager().unregisterServer(server);
46 46
         }
47 47
     }
48 48
 
49 49
     @Test
50 50
     public void testGetServerManager() {
51
-        final ServerManager resultA = ServerManager.getServerManager();
52
-        final ServerManager resultB = ServerManager.getServerManager();
51
+        final ServerManager resultA = TestMain.getTestMain().getServerManager();
52
+        final ServerManager resultB = TestMain.getTestMain().getServerManager();
53 53
 
54 54
         assertNotNull(resultA);
55 55
         assertTrue(resultA instanceof ServerManager);
@@ -60,7 +60,7 @@ public class ServerManagerTest {
60 60
     public void testRegisterServer() {
61 61
         final Server server = mock(Server.class);
62 62
 
63
-        final ServerManager instance = ServerManager.getServerManager();
63
+        final ServerManager instance = TestMain.getTestMain().getServerManager();
64 64
 
65 65
         instance.registerServer(server);
66 66
 
@@ -71,7 +71,7 @@ public class ServerManagerTest {
71 71
     public void testUnregisterServer() {
72 72
         final Server server = mock(Server.class);
73 73
 
74
-        final ServerManager instance = ServerManager.getServerManager();
74
+        final ServerManager instance = TestMain.getTestMain().getServerManager();
75 75
 
76 76
         instance.registerServer(server);
77 77
         instance.unregisterServer(server);
@@ -81,7 +81,7 @@ public class ServerManagerTest {
81 81
 
82 82
     @Test
83 83
     public void testNumServers() {
84
-        final ServerManager instance = ServerManager.getServerManager();
84
+        final ServerManager instance = TestMain.getTestMain().getServerManager();
85 85
 
86 86
         assertEquals(instance.getServers().size(), instance.numServers());
87 87
 
@@ -103,7 +103,7 @@ public class ServerManagerTest {
103 103
         when(serverA.getAddress()).thenReturn("255.255.255.255");
104 104
         when(serverB.getAddress()).thenReturn("255.255.255.254");
105 105
 
106
-        final ServerManager sm = ServerManager.getServerManager();
106
+        final ServerManager sm = TestMain.getTestMain().getServerManager();
107 107
 
108 108
         sm.registerServer(serverA);
109 109
         sm.registerServer(serverB);
@@ -123,7 +123,7 @@ public class ServerManagerTest {
123 123
         when(serverB.isNetwork("Net2")).thenReturn(true);
124 124
         when(serverC.isNetwork("Net2")).thenReturn(true);
125 125
 
126
-        final ServerManager sm = ServerManager.getServerManager();
126
+        final ServerManager sm = TestMain.getTestMain().getServerManager();
127 127
 
128 128
         sm.registerServer(serverA);
129 129
         sm.registerServer(serverB);
@@ -142,8 +142,8 @@ public class ServerManagerTest {
142 142
     @Test
143 143
     public void testCloseAll() {
144 144
         final Server serverA = mock(Server.class);
145
-        ServerManager.getServerManager().registerServer(serverA);
146
-        ServerManager.getServerManager().closeAll();
145
+        TestMain.getTestMain().getServerManager().registerServer(serverA);
146
+        TestMain.getTestMain().getServerManager().closeAll();
147 147
         verify(serverA).disconnect();
148 148
         verify(serverA).close();
149 149
     }
@@ -151,8 +151,8 @@ public class ServerManagerTest {
151 151
     @Test
152 152
     public void testCloseAllWithMessage() {
153 153
         final Server serverA = mock(Server.class);
154
-        ServerManager.getServerManager().registerServer(serverA);
155
-        ServerManager.getServerManager().closeAll("message here");
154
+        TestMain.getTestMain().getServerManager().registerServer(serverA);
155
+        TestMain.getTestMain().getServerManager().closeAll("message here");
156 156
         verify(serverA).disconnect("message here");
157 157
         verify(serverA).close();
158 158
     }
@@ -160,8 +160,8 @@ public class ServerManagerTest {
160 160
     @Test
161 161
     public void testDisconnectAll() {
162 162
         final Server serverA = mock(Server.class);
163
-        ServerManager.getServerManager().registerServer(serverA);
164
-        ServerManager.getServerManager().disconnectAll("message here");
163
+        TestMain.getTestMain().getServerManager().registerServer(serverA);
164
+        TestMain.getTestMain().getServerManager().disconnectAll("message here");
165 165
         verify(serverA).disconnect("message here");
166 166
     }
167 167
 
@@ -172,8 +172,8 @@ public class ServerManagerTest {
172 172
         when(serverA.hasChannel("#DMDirc")).thenReturn(true);
173 173
         when(serverA.getState()).thenReturn(ServerState.CONNECTED);
174 174
 
175
-        ServerManager.getServerManager().registerServer(serverA);
176
-        ServerManager.getServerManager().joinDevChat();
175
+        TestMain.getTestMain().getServerManager().registerServer(serverA);
176
+        TestMain.getTestMain().getServerManager().joinDevChat();
177 177
 
178 178
         verify(serverA).join(new ChannelJoinRequest("#DMDirc"));
179 179
     }
@@ -185,8 +185,8 @@ public class ServerManagerTest {
185 185
         when(serverA.hasChannel("#DMDirc")).thenReturn(false);
186 186
         when(serverA.getState()).thenReturn(ServerState.CONNECTED);
187 187
 
188
-        ServerManager.getServerManager().registerServer(serverA);
189
-        ServerManager.getServerManager().joinDevChat();
188
+        TestMain.getTestMain().getServerManager().registerServer(serverA);
189
+        TestMain.getTestMain().getServerManager().joinDevChat();
190 190
 
191 191
         verify(serverA).join(new ChannelJoinRequest("#DMDirc"));
192 192
     }
@@ -202,12 +202,12 @@ public class ServerManagerTest {
202 202
         when(serverB.getNetwork()).thenReturn("Foonet");
203 203
         when(serverB.getState()).thenReturn(ServerState.CONNECTED);
204 204
 
205
-        ServerManager.getServerManager().registerServer(serverA);
206
-        ServerManager.getServerManager().registerServer(serverB);
205
+        TestMain.getTestMain().getServerManager().registerServer(serverA);
206
+        TestMain.getTestMain().getServerManager().registerServer(serverB);
207 207
 
208
-        ServerManager.getServerManager().joinDevChat();
208
+        TestMain.getTestMain().getServerManager().joinDevChat();
209 209
 
210
-        assertEquals(3, ServerManager.getServerManager().numServers());
210
+        assertEquals(3, TestMain.getTestMain().getServerManager().numServers());
211 211
     }
212 212
 
213 213
 }

+ 1
- 1
test/com/dmdirc/ServerTest.java View File

@@ -40,7 +40,7 @@ public class ServerTest {
40 40
     @BeforeClass
41 41
     public static void setUp() throws Exception {
42 42
         TestMain.getTestMain();
43
-        server = new Server(new URI("irc-test://255.255.255.255"),
43
+        server = new Server(TestMain.getTestMain().getServerManager(), new URI("irc-test://255.255.255.255"),
44 44
                 IdentityManager.getIdentityManager()
45 45
                 .getIdentitiesByType("profile").get(0));
46 46
     }

+ 4
- 1
test/com/dmdirc/TestMain.java View File

@@ -28,7 +28,10 @@ public class TestMain extends Main {
28 28
             // DON'T do anything to the user's configuration... (so no calls
29 29
             // to handleInvalidConfigFile(); here)
30 30
         }
31
-        PluginManager.initPluginManager(IdentityManager.getIdentityManager(), this);
31
+        serverManager = new ServerManager(this);
32
+        ActionManager.initActionManager(this, serverManager, IdentityManager.getIdentityManager());
33
+        pluginManager = new PluginManager(IdentityManager.getIdentityManager(), this);
34
+        pluginManager.refreshPlugins();
32 35
         CommandManager.initCommandManager(IdentityManager.getIdentityManager(), this);
33 36
 
34 37
         ActionManager.getActionManager().initialise();

+ 3
- 2
test/com/dmdirc/actions/ActionComponentChainTest.java View File

@@ -25,6 +25,7 @@ package com.dmdirc.actions;
25 25
 import com.dmdirc.TestMain;
26 26
 import com.dmdirc.Server;
27 27
 
28
+import com.dmdirc.interfaces.actions.ActionComponentArgument;
28 29
 import org.junit.BeforeClass;
29 30
 import org.junit.Test;
30 31
 
@@ -40,7 +41,7 @@ public class ActionComponentChainTest {
40 41
     @Test
41 42
     public void testSingle() {
42 43
         final ActionComponentChain chain = new ActionComponentChain(String.class, "STRING_STRING");
43
-        assertEquals(chain.get("foo bar baz"), "foo bar baz");
44
+        assertEquals(chain.get(new ActionComponentArgument(TestMain.getTestMain(), "foo bar baz")), "foo bar baz");
44 45
         assertEquals("STRING_STRING", chain.toString());
45 46
     }
46 47
 
@@ -48,7 +49,7 @@ public class ActionComponentChainTest {
48 49
     public void testDouble() {
49 50
         final ActionComponentChain chain = new ActionComponentChain(String.class,
50 51
                 "STRING_STRING.STRING_STRING");
51
-        assertEquals(chain.get("foo bar baz"), "foo bar baz");
52
+        assertEquals(chain.get(new ActionComponentArgument(TestMain.getTestMain(), "foo bar baz")), "foo bar baz");
52 53
         assertEquals("STRING_STRING.STRING_STRING", chain.toString());
53 54
     }
54 55
 

+ 7
- 0
test/com/dmdirc/actions/ActionModelTest.java View File

@@ -22,6 +22,8 @@
22 22
 
23 23
 package com.dmdirc.actions;
24 24
 
25
+import org.junit.BeforeClass;
26
+import com.dmdirc.TestMain;
25 27
 import com.dmdirc.interfaces.actions.ActionType;
26 28
 
27 29
 import java.util.ArrayList;
@@ -34,6 +36,11 @@ import static org.junit.Assert.*;
34 36
 
35 37
 public class ActionModelTest {
36 38
 
39
+    @BeforeClass
40
+    public static void setUp() throws Exception {
41
+        TestMain.getTestMain();
42
+    }
43
+
37 44
     @Test
38 45
     public void testConditions() {
39 46
         final ActionModel model = new ActionModel("group", "name");

+ 2
- 2
test/com/dmdirc/actions/wrappers/AliasWrapperTest.java View File

@@ -22,13 +22,13 @@
22 22
 
23 23
 package com.dmdirc.actions.wrappers;
24 24
 
25
+import com.dmdirc.TestMain;
25 26
 import com.dmdirc.actions.Action;
26 27
 import com.dmdirc.actions.ActionCondition;
27 28
 import com.dmdirc.actions.CoreActionComparison;
28 29
 import com.dmdirc.actions.CoreActionComponent;
29 30
 import com.dmdirc.actions.CoreActionType;
30 31
 import com.dmdirc.interfaces.CommandController;
31
-import com.dmdirc.interfaces.actions.ActionComparison;
32 32
 import com.dmdirc.interfaces.actions.ActionType;
33 33
 
34 34
 import java.util.ArrayList;
@@ -56,7 +56,7 @@ public class AliasWrapperTest {
56 56
         action = mock(Action.class);
57 57
         condition = mock(ActionCondition.class);
58 58
         conditions = new ArrayList<ActionCondition>();
59
-        aliasWrapper = new AliasWrapper(controller);
59
+        aliasWrapper = new AliasWrapper(controller, TestMain.getTestMain().getServerManager());
60 60
 
61 61
         when(condition.getArg()).thenReturn(1);
62 62
         when(condition.getComparison()).thenReturn(CoreActionComparison.STRING_EQUALS);

+ 2
- 1
test/com/dmdirc/commandparser/parsers/CommandParserTest.java View File

@@ -21,6 +21,7 @@
21 21
  */
22 22
 package com.dmdirc.commandparser.parsers;
23 23
 
24
+import com.dmdirc.TestMain;
24 25
 import com.dmdirc.Main;
25 26
 import com.dmdirc.commandparser.CommandManager;
26 27
 import com.dmdirc.commandparser.commands.global.Echo;
@@ -48,7 +49,7 @@ public class CommandParserTest {
48 49
         when(cm.getOptionChar("general", "commandchar")).thenReturn('/');
49 50
         final ConfigBinder binder = new ConfigBinder(cm);
50 51
         when(cm.getBinder()).thenReturn(binder);
51
-        commands = new CommandManager(cm, (Main)mock(Main.class));
52
+        commands = new CommandManager(cm, TestMain.getTestMain());
52 53
         commands.registerCommand(new Echo(commands), Echo.INFO);
53 54
     }
54 55
 

+ 9
- 8
test/com/dmdirc/ui/WindowManagerTest.java View File

@@ -21,6 +21,7 @@
21 21
  */
22 22
 package com.dmdirc.ui;
23 23
 
24
+import com.dmdirc.addons.ui_dummy.DummyController;
24 25
 import com.dmdirc.TestMain;
25 26
 import com.dmdirc.CustomWindow;
26 27
 import com.dmdirc.FrameContainer;
@@ -59,7 +60,7 @@ public class WindowManagerTest {
59 60
     public void testAddRoot() {
60 61
         final WindowManager manager = new WindowManager();
61 62
         final FrameListener tfm = mock(FrameListener.class);
62
-        final Window parent = new DummyInputWindow(new TestWritableFrameContainer(512, cm, commands));
63
+        final Window parent = new DummyInputWindow(new DummyController(TestMain.getTestMain()), new TestWritableFrameContainer(512, cm, commands));
63 64
 
64 65
         manager.addListener(tfm);
65 66
 
@@ -76,8 +77,8 @@ public class WindowManagerTest {
76 77
     public void testAddChild() {
77 78
         final WindowManager manager = new WindowManager();
78 79
         final FrameListener tfm = mock(FrameListener.class);
79
-        final Window parent = new DummyInputWindow(new TestWritableFrameContainer(512, cm, commands));
80
-        final Window child = new DummyInputWindow(new TestWritableFrameContainer(512, cm, commands));
80
+        final Window parent = new DummyInputWindow(new DummyController(TestMain.getTestMain()), new TestWritableFrameContainer(512, cm, commands));
81
+        final Window child = new DummyInputWindow(new DummyController(TestMain.getTestMain()), new TestWritableFrameContainer(512, cm, commands));
81 82
         manager.addWindow(parent.getContainer());
82 83
         manager.addListener(tfm);
83 84
 
@@ -91,7 +92,7 @@ public class WindowManagerTest {
91 92
     public void testRemoveRoot() {
92 93
         final WindowManager manager = new WindowManager();
93 94
         final FrameListener tfm = mock(FrameListener.class);
94
-        final Window parent = new DummyInputWindow(new TestWritableFrameContainer(512, cm, commands));
95
+        final Window parent = new DummyInputWindow(new DummyController(TestMain.getTestMain()), new TestWritableFrameContainer(512, cm, commands));
95 96
         manager.addWindow(parent.getContainer());
96 97
         manager.addListener(tfm);
97 98
 
@@ -104,8 +105,8 @@ public class WindowManagerTest {
104 105
     public void testRemoveChild() {
105 106
         final WindowManager manager = new WindowManager();
106 107
         final FrameListener tfm = mock(FrameListener.class);
107
-        final Window parent = new DummyInputWindow(new TestWritableFrameContainer(512, cm, commands));
108
-        final Window child = new DummyInputWindow(new TestWritableFrameContainer(512, cm, commands));
108
+        final Window parent = new DummyInputWindow(new DummyController(TestMain.getTestMain()), new TestWritableFrameContainer(512, cm, commands));
109
+        final Window child = new DummyInputWindow(new DummyController(TestMain.getTestMain()), new TestWritableFrameContainer(512, cm, commands));
109 110
         manager.addWindow(parent.getContainer());
110 111
         manager.addWindow(parent.getContainer(), child.getContainer());
111 112
         manager.addListener(tfm);
@@ -122,8 +123,8 @@ public class WindowManagerTest {
122 123
     public void testRemoveFrameManager() {
123 124
         final WindowManager manager = new WindowManager();
124 125
         final FrameListener tfm = mock(FrameListener.class);
125
-        final Window parent = new DummyInputWindow(new TestWritableFrameContainer(512, cm, commands));
126
-        final Window child = new DummyInputWindow(new TestWritableFrameContainer(512, cm, commands));
126
+        final Window parent = new DummyInputWindow(new DummyController(TestMain.getTestMain()), new TestWritableFrameContainer(512, cm, commands));
127
+        final Window child = new DummyInputWindow(new DummyController(TestMain.getTestMain()), new TestWritableFrameContainer(512, cm, commands));
127 128
         manager.addWindow(parent.getContainer());
128 129
 
129 130
         manager.addListener(tfm);

Loading…
Cancel
Save