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

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