Преглед на файлове

Manually create the server factory.

Change-Id: I95836b7bb40bcfef25b2504fe50c5f63a723975b
Reviewed-on: http://gerrit.dmdirc.com/3699
Reviewed-by: Greg Holmes <greg@dmdirc.com>
Automatic-Compile: DMDirc Build Manager
pull/1/head
Chris Smith преди 10 години
родител
ревизия
03f85acf46
променени са 2 файла, в които са добавени 115 реда и са изтрити 10 реда
  1. 6
    10
      src/com/dmdirc/Server.java
  2. 109
    0
      src/com/dmdirc/ServerFactoryImpl.java

+ 6
- 10
src/com/dmdirc/Server.java Целия файл

@@ -22,7 +22,6 @@
22 22
 
23 23
 package com.dmdirc;
24 24
 
25
-import com.dmdirc.ClientModule.UserConfig;
26 25
 import com.dmdirc.commandparser.CommandType;
27 26
 import com.dmdirc.commandparser.parsers.CommandParser;
28 27
 import com.dmdirc.events.ChannelOpenedEvent;
@@ -67,8 +66,6 @@ import com.dmdirc.ui.input.TabCompleterFactory;
67 66
 import com.dmdirc.ui.input.TabCompletionType;
68 67
 import com.dmdirc.ui.messages.Formatter;
69 68
 import com.dmdirc.util.URLBuilder;
70
-import com.dmdirc.util.annotations.factory.Factory;
71
-import com.dmdirc.util.annotations.factory.Unbound;
72 69
 
73 70
 import com.google.common.eventbus.EventBus;
74 71
 
@@ -105,7 +102,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
105 102
  * The Server class represents the client's view of a server. It maintains a list of all channels,
106 103
  * queries, etc, and handles parser callbacks pertaining to the server.
107 104
  */
108
-@Factory(inject = true, singleton = true, providers = true, name = "ServerFactoryImpl")
109 105
 public class Server extends FrameContainer implements ConfigChangeListener,
110 106
         CertificateProblemListener, Connection {
111 107
 
@@ -215,8 +211,8 @@ public class Server extends FrameContainer implements ConfigChangeListener,
215 211
      */
216 212
     public Server(
217 213
             final ServerManager manager,
218
-            @Unbound final ConfigProviderMigrator configMigrator,
219
-            @Unbound final CommandParser commandParser,
214
+            final ConfigProviderMigrator configMigrator,
215
+            final CommandParser commandParser,
220 216
             final ParserFactory parserFactory,
221 217
             final TabCompleterFactory tabCompleterFactory,
222 218
             final IdentityFactory identityFactory,
@@ -229,10 +225,10 @@ public class Server extends FrameContainer implements ConfigChangeListener,
229 225
             final URLBuilder urlBuilder,
230 226
             final EventBus eventBus,
231 227
             final MessageEncoderFactory messageEncoderFactory,
232
-            @SuppressWarnings("qualifiers") @UserConfig final ConfigProvider userSettings,
233
-            @Unbound final ScheduledExecutorService executorService,
234
-            @Unbound final URI uri,
235
-            @Unbound final ConfigProvider profile) {
228
+            final ConfigProvider userSettings,
229
+            final ScheduledExecutorService executorService,
230
+            final URI uri,
231
+            final ConfigProvider profile) {
236 232
         super(null, "server-disconnected",
237 233
                 getHost(uri),
238 234
                 getHost(uri),

+ 109
- 0
src/com/dmdirc/ServerFactoryImpl.java Целия файл

@@ -0,0 +1,109 @@
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;
24
+
25
+import com.dmdirc.commandparser.parsers.CommandParser;
26
+import com.dmdirc.interfaces.config.ConfigProvider;
27
+import com.dmdirc.interfaces.config.ConfigProviderMigrator;
28
+import com.dmdirc.interfaces.config.IdentityFactory;
29
+import com.dmdirc.messages.MessageSinkManager;
30
+import com.dmdirc.ui.WindowManager;
31
+import com.dmdirc.ui.core.components.StatusBarManager;
32
+import com.dmdirc.ui.input.TabCompleterFactory;
33
+import com.dmdirc.util.URLBuilder;
34
+
35
+import com.google.common.eventbus.EventBus;
36
+
37
+import java.net.URI;
38
+import java.util.concurrent.ScheduledExecutorService;
39
+
40
+import javax.inject.Inject;
41
+import javax.inject.Provider;
42
+import javax.inject.Singleton;
43
+
44
+/**
45
+ * Factory for {@link Server}s
46
+ */
47
+@Singleton
48
+public class ServerFactoryImpl {
49
+
50
+    private final Provider<ServerManager> manager;
51
+    private final ParserFactory parserFactory;
52
+    private final TabCompleterFactory tabCompleterFactory;
53
+    private final IdentityFactory identityFactory;
54
+    private final MessageSinkManager messageSinkManager;
55
+    private final StatusBarManager statusBarManager;
56
+    private final WindowManager windowManager;
57
+    private final Provider<ChannelFactory> channelFactory;
58
+    private final Provider<QueryFactory> queryFactory;
59
+    private final Provider<RawFactory> rawFactory;
60
+    private final URLBuilder urlBuilder;
61
+    private final EventBus eventBus;
62
+    private final MessageEncoderFactory messageEncoderFactory;
63
+    private final ConfigProvider userSettings;
64
+
65
+    @Inject
66
+    public ServerFactoryImpl(
67
+            final Provider<ServerManager> manager,
68
+            final ParserFactory parserFactory,
69
+            final TabCompleterFactory tabCompleterFactory,
70
+            final IdentityFactory identityFactory,
71
+            final MessageSinkManager messageSinkManager,
72
+            final StatusBarManager statusBarManager,
73
+            final WindowManager windowManager,
74
+            final Provider<ChannelFactory> channelFactory,
75
+            final Provider<QueryFactory> queryFactory,
76
+            final Provider<RawFactory> rawFactory,
77
+            final URLBuilder urlBuilder,
78
+            final EventBus eventBus,
79
+            final MessageEncoderFactory messageEncoderFactory,
80
+            @ClientModule.UserConfig final ConfigProvider userSettings) {
81
+        this.manager = manager;
82
+        this.parserFactory = parserFactory;
83
+        this.tabCompleterFactory = tabCompleterFactory;
84
+        this.identityFactory = identityFactory;
85
+        this.messageSinkManager = messageSinkManager;
86
+        this.statusBarManager = statusBarManager;
87
+        this.windowManager = windowManager;
88
+        this.channelFactory = channelFactory;
89
+        this.queryFactory = queryFactory;
90
+        this.rawFactory = rawFactory;
91
+        this.urlBuilder = urlBuilder;
92
+        this.eventBus = eventBus;
93
+        this.messageEncoderFactory = messageEncoderFactory;
94
+        this.userSettings = userSettings;
95
+    }
96
+
97
+    public Server getServer(
98
+            final ConfigProviderMigrator configMigrator,
99
+            final CommandParser commandParser,
100
+            final ScheduledExecutorService executorService,
101
+            final URI uri,
102
+            final ConfigProvider profile) {
103
+        return new Server(manager.get(), configMigrator, commandParser, parserFactory,
104
+                tabCompleterFactory, identityFactory, messageSinkManager, statusBarManager,
105
+                windowManager, channelFactory.get(), queryFactory.get(), rawFactory.get(),
106
+                urlBuilder, eventBus, messageEncoderFactory, userSettings, executorService, uri,
107
+                profile);
108
+    }
109
+}

Loading…
Отказ
Запис