Browse Source

DI the exec plugin

Change-Id: I3f9336773ea52d47e6f23dc52720a2046fad0ad3
Reviewed-on: http://gerrit.dmdirc.com/3183
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Chris Smith <chris@dmdirc.com>
tags/0.8
Greg Holmes 10 years ago
parent
commit
69a0ce510f

+ 3
- 0
src/com/dmdirc/addons/exec/ExecCommand.java View File

@@ -39,6 +39,8 @@ import java.io.IOException;
39 39
 import java.util.LinkedList;
40 40
 import java.util.List;
41 41
 
42
+import javax.inject.Inject;
43
+
42 44
 /**
43 45
  * A command which allows users execute scripts.
44 46
  */
@@ -54,6 +56,7 @@ public class ExecCommand extends Command {
54 56
      *
55 57
      * @param controller The controller to use for command information.
56 58
      */
59
+    @Inject
57 60
     public ExecCommand(final CommandController controller) {
58 61
         super(controller);
59 62
     }

+ 32
- 0
src/com/dmdirc/addons/exec/ExecModule.java View File

@@ -0,0 +1,32 @@
1
+/*
2
+ * Copyright (c) 2006-2014 DMDirc Developers
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.addons.exec;
24
+
25
+import com.dmdirc.ClientModule;
26
+
27
+import dagger.Module;
28
+
29
+@Module(injects = ExecCommand.class, addsTo = ClientModule.class)
30
+public class ExecModule {
31
+
32
+}

+ 10
- 9
src/com/dmdirc/addons/exec/ExecPlugin.java View File

@@ -22,22 +22,23 @@
22 22
 
23 23
 package com.dmdirc.addons.exec;
24 24
 
25
-import com.dmdirc.interfaces.CommandController;
25
+import com.dmdirc.plugins.PluginInfo;
26 26
 import com.dmdirc.plugins.implementations.BaseCommandPlugin;
27 27
 
28
+import dagger.ObjectGraph;
29
+
28 30
 /**
29 31
  * A plugin which provides an execute command.
30 32
  */
31 33
 public class ExecPlugin extends BaseCommandPlugin {
32 34
 
33
-    /**
34
-     * Creates a new instance of this plugin.
35
-     *
36
-     * @param commandController Command controller to register commands
37
-     */
38
-    public ExecPlugin(final CommandController commandController) {
39
-        super(commandController);
40
-        registerCommand(new ExecCommand(commandController), ExecCommand.INFO);
35
+    @Override
36
+    public void load(final PluginInfo pluginInfo, final ObjectGraph graph) {
37
+        super.load(pluginInfo, graph);
38
+
39
+        setObjectGraph(graph.plus(new ExecModule()));
40
+        registerCommand(ExecCommand.class, ExecCommand.INFO);
41 41
     }
42 42
 
43
+
43 44
 }

Loading…
Cancel
Save