mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-10 02:26:18 +00:00
added an auto-discovery mechanism for extension points (and most notably Descriptors.)
- extensions are now stored in ExtensionList. - discovery is extensible, but by default we use Sezpoz for annotation-based injection. This requires JDK6 for build. - a care has been taken to preserve backward compatibility. DescriptorList and manually adding to it continues to work. - AdministrativeMonitor is converted to use the new approach entirely, as a guinea pig of this feature. - Descriptors for View is partially switched to this new approach, where some classes register automatically while others do manually. This tests the compatibility aspect of this feature. A pluggable discovery is an attempt to embrace Plexus integration work, although for that to really work we need more coding. Next stop, more tests. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@15601 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
836b436f15
commit
d4c6a4b06c
15 files changed
+660
-74
No files matched your search
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright (c) 2004-2009, Sun Microsystems, 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 hudson;
|
||||
|
||||
import net.java.sezpoz.Indexable;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import hudson.ExtensionFinder.Sezpoz;
|
||||
|
||||
/**
|
||||
* Marks a field, a method, or a class for automatic discovery, so that Hudson can locate
|
||||
* implementations of {@link ExtensionPoint}s automatically.
|
||||
*
|
||||
* <p>
|
||||
* (In contrast, in earlier Hudson, the registration was manual.)
|
||||
*
|
||||
* <p>
|
||||
* In a simplest case, put this on your class, and Hudson will create an instance of it
|
||||
* and register it to the appropriate {@link ExtensionList}.
|
||||
*
|
||||
* <p>
|
||||
* 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 {@link 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.
|
||||
*
|
||||
* <p>
|
||||
* 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 {@link ExtensionFinder} for more details.
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
* @since 1.286
|
||||
* @see Sezpoz
|
||||
* @see ExtensionFinder
|
||||
* @see ExtensionList
|
||||
*/
|
||||
@Indexable
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({TYPE, FIELD, METHOD})
|
||||
@Documented
|
||||
public @interface Extension {
|
||||
}
|
||||
Reference in new issue
Block a user