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.

PluginInjectorInitialiser.java 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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.plugins;
  23. import com.dmdirc.CorePluginExtractor;
  24. import com.dmdirc.ServerManager;
  25. import com.dmdirc.actions.ActionFactory;
  26. import com.dmdirc.actions.ActionManager;
  27. import com.dmdirc.actions.ActionSubstitutorFactory;
  28. import com.dmdirc.actions.wrappers.AliasWrapper;
  29. import com.dmdirc.actions.wrappers.PerformWrapper;
  30. import com.dmdirc.commandparser.CommandManager;
  31. import com.dmdirc.config.prefs.PreferencesManager;
  32. import com.dmdirc.interfaces.LifecycleController;
  33. import com.dmdirc.interfaces.config.IdentityController;
  34. import com.dmdirc.messages.MessageSinkManager;
  35. import com.dmdirc.ui.WindowManager;
  36. import com.dmdirc.ui.core.components.StatusBarManager;
  37. import com.dmdirc.ui.messages.ColourManager;
  38. import com.dmdirc.ui.themes.ThemeManager;
  39. import com.dmdirc.util.SimpleInjector;
  40. import com.dmdirc.util.URLBuilder;
  41. import com.google.common.eventbus.EventBus;
  42. import javax.inject.Inject;
  43. import lombok.RequiredArgsConstructor;
  44. /**
  45. * Utility class that can initialise a {@link SimpleInjector} for use by plugins.
  46. *
  47. * Eventually this should be replaced by using the same DI framework for plugins
  48. * as for the client.
  49. */
  50. @RequiredArgsConstructor(onConstructor = @__(@Inject))
  51. public class PluginInjectorInitialiser {
  52. private final ActionManager actionManager;
  53. private final ActionFactory actionFactory;
  54. private final AliasWrapper aliasWrapper;
  55. private final PluginManager pluginManager;
  56. private final IdentityController identityController;
  57. private final ServerManager serverManager;
  58. private final ThemeManager themeManager;
  59. private final CommandManager commandManager;
  60. private final MessageSinkManager messageSinkManager;
  61. private final WindowManager windowManager;
  62. private final StatusBarManager statusBarManager;
  63. private final PreferencesManager preferencesManager;
  64. private final PerformWrapper performWrapper;
  65. private final LifecycleController lifecycleController;
  66. private final CorePluginExtractor corePluginExtractor;
  67. private final URLBuilder urlBuilder;
  68. private final ColourManager colourManager;
  69. private final ActionSubstitutorFactory actionSubstitutorFactory;
  70. private final EventBus eventBus;
  71. /**
  72. * Initialises the given injector with all of the known "global" managers.
  73. *
  74. * @param injector The injector to be initialised
  75. */
  76. public void initialise(final SimpleInjector injector) {
  77. injector.addParameter(actionManager);
  78. injector.addParameter(PluginManager.class, pluginManager);
  79. injector.addParameter(identityController);
  80. injector.addParameter(ServerManager.class, serverManager);
  81. injector.addParameter(commandManager);
  82. injector.addParameter(MessageSinkManager.class, messageSinkManager);
  83. injector.addParameter(WindowManager.class, windowManager);
  84. injector.addParameter(statusBarManager);
  85. injector.addParameter(PreferencesManager.class, preferencesManager);
  86. injector.addParameter(PerformWrapper.class, performWrapper);
  87. injector.addParameter(AliasWrapper.class, aliasWrapper);
  88. injector.addParameter(LifecycleController.class, lifecycleController);
  89. injector.addParameter(corePluginExtractor);
  90. injector.addParameter(actionFactory);
  91. injector.addParameter(themeManager);
  92. injector.addParameter(urlBuilder);
  93. injector.addParameter(colourManager);
  94. injector.addParameter(actionSubstitutorFactory);
  95. injector.addParameter(eventBus);
  96. }
  97. }