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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * Copyright (c) 2006-2015 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.config.profiles.Profile;
  25. import com.dmdirc.interfaces.config.ConfigProvider;
  26. import com.dmdirc.interfaces.config.ConfigProviderMigrator;
  27. import com.dmdirc.interfaces.config.IdentityFactory;
  28. import com.dmdirc.ui.WindowManager;
  29. import com.dmdirc.ui.messages.BackBufferFactory;
  30. import com.dmdirc.ui.input.TabCompleterFactory;
  31. import com.dmdirc.ui.messages.sink.MessageSinkManager;
  32. import com.dmdirc.util.URLBuilder;
  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 WindowManager windowManager;
  49. private final Provider<ChannelFactory> channelFactory;
  50. private final Provider<QueryFactory> queryFactory;
  51. private final URLBuilder urlBuilder;
  52. private final DMDircMBassador eventBus;
  53. private final MessageEncoderFactory messageEncoderFactory;
  54. private final ConfigProvider userSettings;
  55. private final BackBufferFactory backBufferFactory;
  56. private final UserManager userManager;
  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 WindowManager windowManager,
  65. final Provider<ChannelFactory> channelFactory,
  66. final Provider<QueryFactory> queryFactory,
  67. final URLBuilder urlBuilder,
  68. final DMDircMBassador eventBus,
  69. final MessageEncoderFactory messageEncoderFactory,
  70. @ClientModule.UserConfig final ConfigProvider userSettings,
  71. final BackBufferFactory backBufferFactory,
  72. final UserManager userManager) {
  73. this.manager = manager;
  74. this.parserFactory = parserFactory;
  75. this.tabCompleterFactory = tabCompleterFactory;
  76. this.identityFactory = identityFactory;
  77. this.messageSinkManager = messageSinkManager;
  78. this.windowManager = windowManager;
  79. this.channelFactory = channelFactory;
  80. this.queryFactory = queryFactory;
  81. this.urlBuilder = urlBuilder;
  82. this.eventBus = eventBus;
  83. this.messageEncoderFactory = messageEncoderFactory;
  84. this.userSettings = userSettings;
  85. this.backBufferFactory = backBufferFactory;
  86. this.userManager = userManager;
  87. }
  88. public Server getServer(
  89. final ConfigProviderMigrator configMigrator,
  90. final CommandParser commandParser,
  91. final ScheduledExecutorService executorService,
  92. final URI uri,
  93. final Profile profile) {
  94. return new Server(manager.get(), configMigrator, commandParser, parserFactory,
  95. tabCompleterFactory, identityFactory, messageSinkManager, windowManager,
  96. channelFactory.get(), queryFactory.get(), urlBuilder, eventBus,
  97. messageEncoderFactory, userSettings, executorService, uri, profile,
  98. backBufferFactory, userManager);
  99. }
  100. }