Class ExtensionFinder.Sezpoz
- java.lang.Object
-
- hudson.ExtensionFinder
-
- hudson.ExtensionFinder.Sezpoz
-
- All Implemented Interfaces:
ExtensionPoint
- Enclosing class:
- ExtensionFinder
public static final class ExtensionFinder.Sezpoz extends ExtensionFinder
The bootstrap implementation that looks for theExtension
marker.Uses Sezpoz as the underlying mechanism.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class hudson.ExtensionFinder
ExtensionFinder.DefaultGuiceExtensionAnnotation, ExtensionFinder.GuiceExtensionAnnotation<T extends Annotation>, ExtensionFinder.GuiceFinder, ExtensionFinder.Sezpoz
-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Constructor Summary
Constructors Constructor Description Sezpoz()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Collection<ExtensionComponent<T>>
find(Class<T> type, Hudson jenkins)
Discover extensions of the given type.ExtensionComponentSet
refresh()
Rebuilds the internal index, if any, so that futureExtensionFinder.find(Class, Hudson)
calls will discover components newly added toPluginManager.uberClassLoader
.void
scout(Class extensionType, Hudson hudson)
Performs class initializations without creating instances.-
Methods inherited from class hudson.ExtensionFinder
_find, findExtensions, isRefreshable
-
-
-
-
Method Detail
-
refresh
public ExtensionComponentSet refresh()
Rebuilds the internal index, if any, so that futureExtensionFinder.find(Class, Hudson)
calls will discover components newly added toPluginManager.uberClassLoader
.The point of the refresh operation is not to disrupt instances of already loaded
ExtensionComponent
s, and only instantiate those that are new. Otherwise this will break the singleton semantics of various objects, such asDescriptor
s.The behaviour is undefined if
ExtensionFinder.isRefreshable()
is returning false.SezPoz implements value-equality of
IndexItem
, so- Specified by:
refresh
in classExtensionFinder
- Returns:
- never null
- See Also:
ExtensionFinder.isRefreshable()
-
find
public <T> Collection<ExtensionComponent<T>> find(Class<T> type, Hudson jenkins)
Description copied from class:ExtensionFinder
Discover extensions of the given type.This method is called only once per the given type after all the plugins are loaded, so implementations need not worry about caching.
This method should return all the known components at the time of the call, including those that are discovered later via
ExtensionFinder.refresh()
, even though those components are separately returned inExtensionComponentSet
.- Specified by:
find
in classExtensionFinder
- Type Parameters:
T
- The type of the extension points. This is not bound toExtensionPoint
because ofDescriptor
, which by itself doesn't implementExtensionPoint
for a historical reason.jenkins
- Jenkins whose behalf this extension finder is performing lookup.- Returns:
- Can be empty but never null.
-
scout
public void scout(Class extensionType, Hudson hudson)
Description copied from class:ExtensionFinder
Performs class initializations without creating instances. If two threads try to initialize classes in the opposite order, a dead lock will ensue, and we can get into a similar situation withExtensionFinder
s.That is, one thread can try to list extensions, which results in
ExtensionFinder
loading and initializing classes. This happens inside a context of a lock, so that another thread that tries to list the same extensions don't end up creating different extension instances. So this activity locks extension list first, then class initialization next.In the mean time, another thread can load and initialize a class, and that initialization can eventually results in listing up extensions, for example through static initializer. Such activity locks class initialization first, then locks extension list.
This inconsistent locking order results in a dead lock, you see.
So to reduce the likelihood, this method is called in prior to
ExtensionFinder.find(Class,Hudson)
invocation, but from outside the lock. The implementation is expected to perform all the class initialization activities from here.See JDK-4993813 for how to force a class initialization. Also see this blog post for how class initialization can results in a dead lock.
- Overrides:
scout
in classExtensionFinder
-
-