You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ServerFactoryImpl.java 4.6KB

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