Package hudson

Annotation Type Extension


  • @Retention(RUNTIME)
    @Target({TYPE,FIELD,METHOD})
    @Documented
    public @interface Extension
    Marks a field, a method, or a class for automatic discovery, so that Hudson can locate implementations of ExtensionPoints automatically.

    (In contrast, in earlier Hudson, the registration was manual.)

    In a simplest case, put this on your class, and Hudson will create an instance of it and register it to the appropriate ExtensionList.

    If you'd like Hudson to call a factory method instead of a constructor, put this annotation on your static factory method. Hudson will invoke it and if the method returns a non-null instance, it'll be registered. The return type of the method is used to determine which ExtensionList will get the instance. Finally, you can put this annotation on a static field if the field contains a reference to an instance that you'd like to register.

    This is the default way of having your implementations auto-registered to Hudson, but Hudson also supports arbitrary DI containers for hosting your implementations. See ExtensionFinder for more details.

    Since:
    1.286
    Author:
    Kohsuke Kawaguchi
    See Also:
    SezPoz, ExtensionFinder, ExtensionList
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      YesNoMaybe dynamicLoadable
      Marks whether this extension works with dynamic loading of a plugin.
      boolean optional
      If an extension is optional, don't log any class loading errors when reading it.
      double ordinal
      Used for sorting extensions.
    • Element Detail

      • ordinal

        double ordinal
        Used for sorting extensions. Extensions will be sorted in the descending order of the ordinal. In other words, the extensions with the highest numbers will be chosen first. This is a rather poor approach to the problem, so its use is generally discouraged.
        Since:
        1.306
        Default:
        0.0
      • optional

        boolean optional
        If an extension is optional, don't log any class loading errors when reading it.
        Since:
        1.358
        Default:
        false
      • dynamicLoadable

        YesNoMaybe dynamicLoadable
        Marks whether this extension works with dynamic loading of a plugin.

        "Yes" indicates an explicit sign-off from the developer indicating this component supports that. Similarly, "No" indicates that this extension is known not to support it, which forces Jenkins not to offer dynamic loading as an option.

        The "MayBe" value indicates that there's no such explicit sign-off. So the dynamic loading may or may not work.

        If your plugin contains any extension that has dynamic loadability set to NO, then Jenkins will prompt the user to restart Jenkins to have the plugin take effect. If every component is marked as YES, then Jenkins will simply dynamic load the plugin without asking the user. Otherwise, Jenkins will ask the user if he wants to restart, or go ahead and dynamically deploy.

        Since:
        1.442
        Default:
        jenkins.YesNoMaybe.MAYBE