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.

Plugin.java 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * Copyright (C) 2012-present the original author or authors.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.pf4j;
  17. import org.slf4j.Logger;
  18. import org.slf4j.LoggerFactory;
  19. /**
  20. * This class will be extended by all plugins and
  21. * serve as the common class between a plugin and the application.
  22. *
  23. * @author Decebal Suiu
  24. */
  25. public class Plugin {
  26. /**
  27. * Makes logging service available for descending classes.
  28. */
  29. protected final Logger log = LoggerFactory.getLogger(getClass());
  30. /**
  31. * Wrapper of the plugin.
  32. * @deprecated Use application custom {@code PluginContext} instead of {@code PluginWrapper}.
  33. * See demo for more details.
  34. */
  35. @Deprecated
  36. protected PluginWrapper wrapper;
  37. /**
  38. * Constructor to be used by plugin manager for plugin instantiation.
  39. * Your plugins have to provide constructor with this exact signature to
  40. * be successfully loaded by manager.
  41. * @deprecated Use application custom {@code PluginContext} instead of {@code PluginWrapper}.
  42. * See demo for more details.
  43. */
  44. @Deprecated
  45. public Plugin(final PluginWrapper wrapper) {
  46. if (wrapper == null) {
  47. throw new IllegalArgumentException("Wrapper cannot be null");
  48. }
  49. this.wrapper = wrapper;
  50. }
  51. public Plugin() {
  52. }
  53. /**
  54. * Retrieves the wrapper of this plug-in.
  55. * @deprecated Use application custom {@code PluginContext} instead of {@code PluginWrapper}.
  56. * See demo for more details.
  57. */
  58. @Deprecated
  59. public final PluginWrapper getWrapper() {
  60. return wrapper;
  61. }
  62. /**
  63. * This method is called by the application when the plugin is started.
  64. * See {@link PluginManager#startPlugin(String)}.
  65. */
  66. public void start() {
  67. }
  68. /**
  69. * This method is called by the application when the plugin is stopped.
  70. * See {@link PluginManager#stopPlugin(String)}.
  71. */
  72. public void stop() {
  73. }
  74. /**
  75. * This method is called by the application when the plugin is deleted.
  76. * See {@link PluginManager#deletePlugin(String)}.
  77. */
  78. public void delete() {
  79. }
  80. }