|
@@ -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
|
+}
|