diff --git a/core/src/main/java/hudson/Extension.java b/core/src/main/java/hudson/Extension.java index 66342a2b6161eb5ac7adfe30a6edd384337e4602..eb5a8d23f136979f80706ace6a1b5c89dfcf9a52 100644 --- a/core/src/main/java/hudson/Extension.java +++ b/core/src/main/java/hudson/Extension.java @@ -23,6 +23,7 @@ */ package hudson; +import jenkins.YesNoMaybe; import net.java.sezpoz.Indexable; import java.lang.annotation.Documented; @@ -31,6 +32,7 @@ import java.lang.annotation.Target; import static java.lang.annotation.ElementType.*; import static java.lang.annotation.RetentionPolicy.RUNTIME; +import static jenkins.YesNoMaybe.MAYBE; /** * Marks a field, a method, or a class for automatic discovery, so that Hudson can locate @@ -84,4 +86,20 @@ public @interface Extension { * @since 1.358 */ boolean optional() default false; + + /** + * 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. + * + * @since 1.DynamicExtensionFinder + */ + YesNoMaybe dynamicLoadable() default MAYBE; } diff --git a/core/src/main/java/jenkins/YesNoMaybe.java b/core/src/main/java/jenkins/YesNoMaybe.java new file mode 100644 index 0000000000000000000000000000000000000000..929c538c05169acd1750b7f09a7c49b752192dc9 --- /dev/null +++ b/core/src/main/java/jenkins/YesNoMaybe.java @@ -0,0 +1,54 @@ +/* + * The MIT License + * + * Copyright (c) 2011, CloudBees, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package jenkins; + +/** + * Enum that represents {@link Boolean} state (including null for the absence.) + * + *

+ * This is for situations where we can't use {@link Boolean}, such as annotation elements. + * + * @author Kohsuke Kawaguchi + */ +public enum YesNoMaybe { + YES, + NO, + MAYBE; + + public static Boolean toBoolean(YesNoMaybe v) { + if (v==null) return null; + return v.toBool(); + } + + public Boolean toBool() { + switch (this) { + case YES: + return true; + case NO: + return false; + default: + return null; + } + } +}