Browse Source

DI the DNS Plugin (and fix DCOP)

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

+ 3
- 0
src/com/dmdirc/addons/dcop/DcopCommand.java View File

@@ -33,6 +33,8 @@ import com.dmdirc.interfaces.CommandController;
33 33
 
34 34
 import java.util.List;
35 35
 
36
+import javax.inject.Inject;
37
+
36 38
 /**
37 39
  * The dcop command retrieves information from a dcop application.
38 40
  */
@@ -48,6 +50,7 @@ public class DcopCommand extends Command {
48 50
      *
49 51
      * @param controller The controller to use for command information.
50 52
      */
53
+    @Inject
51 54
     public DcopCommand(final CommandController controller) {
52 55
         super(controller);
53 56
     }

+ 3
- 0
src/com/dmdirc/addons/dns/DNSCommand.java View File

@@ -34,6 +34,8 @@ import com.dmdirc.interfaces.CommandController;
34 34
 import java.util.Timer;
35 35
 import java.util.TimerTask;
36 36
 
37
+import javax.inject.Inject;
38
+
37 39
 /**
38 40
  * Performs DNS lookups for nicknames, hostnames or IPs.
39 41
  */
@@ -49,6 +51,7 @@ public class DNSCommand extends Command {
49 51
      *
50 52
      * @param controller The controller to use for command information.
51 53
      */
54
+    @Inject
52 55
     public DNSCommand(final CommandController controller) {
53 56
         super(controller);
54 57
     }

+ 32
- 0
src/com/dmdirc/addons/dns/DNSModule.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.dns;
24
+
25
+import com.dmdirc.ClientModule;
26
+
27
+import dagger.Module;
28
+
29
+@Module(injects = DNSCommand.class, addsTo = ClientModule.class)
30
+public class DNSModule {
31
+
32
+}

+ 10
- 10
src/com/dmdirc/addons/dns/DNSPlugin.java View File

@@ -22,28 +22,28 @@
22 22
 
23 23
 package com.dmdirc.addons.dns;
24 24
 
25
-import com.dmdirc.interfaces.CommandController;
25
+import com.dmdirc.addons.debug.DebugModule;
26
+import com.dmdirc.plugins.PluginInfo;
26 27
 import com.dmdirc.plugins.implementations.BaseCommandPlugin;
27 28
 
28 29
 import java.net.InetAddress;
29 30
 import java.net.UnknownHostException;
30
-
31 31
 import java.util.ArrayList;
32 32
 import java.util.List;
33 33
 
34
+import dagger.ObjectGraph;
35
+
34 36
 /**
35 37
  * DNS plugin.
36 38
  */
37 39
 public final class DNSPlugin extends BaseCommandPlugin {
38 40
 
39
-    /**
40
-     * Creates a new instance of this plugin.
41
-     *
42
-     * @param commandController Command controller to register commands
43
-     */
44
-    public DNSPlugin(final CommandController commandController) {
45
-        super(commandController);
46
-        registerCommand(new DNSCommand(commandController), DNSCommand.INFO);
41
+    @Override
42
+    public void load(final PluginInfo pluginInfo, final ObjectGraph graph) {
43
+        super.load(pluginInfo, graph);
44
+
45
+        setObjectGraph(graph.plus(new DebugModule()));
46
+        registerCommand(DNSCommand.class, DNSCommand.INFO);
47 47
     }
48 48
 
49 49
     /**

Loading…
Cancel
Save