Browse Source

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 years ago
parent
commit
03f85acf46
2 changed files with 115 additions and 10 deletions
  1. 6
    10
      src/com/dmdirc/Server.java
  2. 109
    0
      src/com/dmdirc/ServerFactoryImpl.java

+ 6
- 10
src/com/dmdirc/Server.java View File

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

+ 109
- 0
src/com/dmdirc/ServerFactoryImpl.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;
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…
Cancel
Save