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.

Extension.java 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 java.lang.annotation.Documented;
  18. import java.lang.annotation.Inherited;
  19. import java.lang.annotation.Retention;
  20. import java.lang.annotation.Target;
  21. import static java.lang.annotation.ElementType.TYPE;
  22. import static java.lang.annotation.RetentionPolicy.RUNTIME;
  23. /**
  24. * An extension is a class that extends an extension point.
  25. * Use this annotation to mark a class as an extension.
  26. * The extension class must implement the extension point interface or extend the extension point abstract class.
  27. *
  28. * @author Decebal Suiu
  29. */
  30. @Retention(RUNTIME)
  31. @Target(TYPE)
  32. @Inherited
  33. @Documented
  34. public @interface Extension {
  35. /**
  36. * The order of the extension.
  37. * The ordinal is used to sort the extensions.
  38. *
  39. * @return the order of the extension
  40. */
  41. int ordinal() default 0;
  42. /**
  43. * An array of extension points, that are implemented by this extension.
  44. * This explicit configuration overrides the automatic detection of extension points in the
  45. * {@link org.pf4j.processor.ExtensionAnnotationProcessor}.
  46. * <p>
  47. * In case your extension is directly derived from an extension point this attribute is NOT required.
  48. * But under certain <a href="https://github.com/pf4j/pf4j/issues/264">more complex scenarios</a> it
  49. * might be useful to explicitly set the extension points for an extension.
  50. *
  51. * @return classes of extension points, that are implemented by this extension
  52. */
  53. Class<? extends ExtensionPoint>[] points() default {};
  54. /**
  55. * An array of plugin IDs, that have to be available in order to load this extension.
  56. * The {@link AbstractExtensionFinder} won't load this extension, if these plugins are not
  57. * available / started at runtime.
  58. * <p>
  59. * Notice: This feature requires the optional <a href="https://asm.ow2.io/">ASM library</a>
  60. * to be available on the applications classpath and has to be explicitly enabled via
  61. * {@link AbstractExtensionFinder#setCheckForExtensionDependencies(boolean)}.
  62. *
  63. * @return plugin IDs, that have to be available in order to load this extension
  64. */
  65. String[] plugins() default {};
  66. }