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
 
33
 
34
 import java.util.List;
34
 import java.util.List;
35
 
35
 
36
+import javax.inject.Inject;
37
+
36
 /**
38
 /**
37
  * The dcop command retrieves information from a dcop application.
39
  * The dcop command retrieves information from a dcop application.
38
  */
40
  */
48
      *
50
      *
49
      * @param controller The controller to use for command information.
51
      * @param controller The controller to use for command information.
50
      */
52
      */
53
+    @Inject
51
     public DcopCommand(final CommandController controller) {
54
     public DcopCommand(final CommandController controller) {
52
         super(controller);
55
         super(controller);
53
     }
56
     }

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

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

+ 32
- 0
src/com/dmdirc/addons/dns/DNSModule.java View File

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
 
22
 
23
 package com.dmdirc.addons.dns;
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
 import com.dmdirc.plugins.implementations.BaseCommandPlugin;
27
 import com.dmdirc.plugins.implementations.BaseCommandPlugin;
27
 
28
 
28
 import java.net.InetAddress;
29
 import java.net.InetAddress;
29
 import java.net.UnknownHostException;
30
 import java.net.UnknownHostException;
30
-
31
 import java.util.ArrayList;
31
 import java.util.ArrayList;
32
 import java.util.List;
32
 import java.util.List;
33
 
33
 
34
+import dagger.ObjectGraph;
35
+
34
 /**
36
 /**
35
  * DNS plugin.
37
  * DNS plugin.
36
  */
38
  */
37
 public final class DNSPlugin extends BaseCommandPlugin {
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