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.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. */
  33. @Deprecated
  34. protected PluginWrapper wrapper;
  35. /**
  36. * Constructor to be used by plugin manager for plugin instantiation.
  37. * Your plugins have to provide constructor with this exact signature to
  38. * be successfully loaded by manager.
  39. * @deprecated Use application custom {@code PluginContext} instead of {@code PluginWrapper}.
  40. * See demo for more details.
  41. */
  42. @Deprecated
  43. public Plugin(final PluginWrapper wrapper) {
  44. if (wrapper == null) {
  45. throw new IllegalArgumentException("Wrapper cannot be null");
  46. }
  47. this.wrapper = wrapper;
  48. }
  49. public Plugin() {
  50. }
  51. /**
  52. * Retrieves the wrapper of this plug-in.
  53. */
  54. @Deprecated
  55. public final PluginWrapper getWrapper() {
  56. return wrapper;
  57. }
  58. /**
  59. * This method is called by the application when the plugin is started.
  60. * See {@link PluginManager#startPlugin(String)}.
  61. */
  62. public void start() {
  63. }
  64. /**
  65. * This method is called by the application when the plugin is stopped.
  66. * See {@link PluginManager#stopPlugin(String)}.
  67. */
  68. public void stop() {
  69. }
  70. /**
  71. * This method is called by the application when the plugin is deleted.
  72. * See {@link PluginManager#deletePlugin(String)}.
  73. */
  74. public void delete() {
  75. }
  76. }