T
- Type of the extension point. This class holds instances of the subtypes of 'T'.public class ExtensionList<T> extends AbstractList<T>
Extensions are loaded lazily on demand and automatically by using ExtensionFinder
, but this
class also provides a mechanism to provide compatibility with the older DescriptorList
-based
manual registration,
All ExtensionList
instances should be owned by Jenkins
, even though
extension points can be defined by anyone on any type. Use Jenkins.getExtensionList(Class)
and Jenkins.getDescriptorList(Class)
to obtain the instances.
Jenkins.getExtensionList(Class)
,
Jenkins.getDescriptorList(Class)
Modifier and Type | Field and Description |
---|---|
Class<T> |
extensionType |
Hudson |
hudson
Deprecated.
as of 1.417
Use
jenkins |
Jenkins |
jenkins |
modCount
Modifier | Constructor and Description |
---|---|
protected |
ExtensionList(Hudson hudson,
Class<T> extensionType)
Deprecated.
as of 1.416
Use
ExtensionList(Jenkins, Class) |
protected |
ExtensionList(Hudson hudson,
Class<T> extensionType,
CopyOnWriteArrayList<ExtensionComponent<T>> legacyStore)
Deprecated.
as of 1.416
Use
ExtensionList(Jenkins, Class, CopyOnWriteArrayList) |
protected |
ExtensionList(Jenkins jenkins,
Class<T> extensionType) |
protected |
ExtensionList(Jenkins jenkins,
Class<T> extensionType,
CopyOnWriteArrayList<ExtensionComponent<T>> legacyStore) |
Modifier and Type | Method and Description |
---|---|
void |
add(int index,
T element) |
boolean |
add(T t)
Deprecated.
since 2009-02-23.
Prefer automatic registration.
|
void |
addListener(ExtensionListListener listener)
Add a listener to the extension list.
|
static void |
clearLegacyInstances()
Exposed for the test harness to clear all legacy extension instances.
|
static <T> ExtensionList<T> |
create(Hudson hudson,
Class<T> type)
Deprecated.
as of 1.416
Use
create(Jenkins, Class) |
static <T> ExtensionList<T> |
create(Jenkins jenkins,
Class<T> type) |
<U extends T> |
get(Class<U> type)
Looks for the extension instance of the given type (subclasses excluded),
or return null.
|
T |
get(int index) |
List<ExtensionComponent<T>> |
getComponents()
Gets the same thing as the 'this' list represents, except as
ExtensionComponent s. |
T |
getDynamic(String className)
Used to bind extension to URLs by their class names.
|
protected Object |
getLoadLock()
Chooses the object that locks the loading of the extension instances.
|
Iterator<T> |
iterator() |
protected List<ExtensionComponent<T>> |
load()
Loads all the extensions.
|
protected Collection<ExtensionComponent<T>> |
load(ExtensionComponentSet delta)
Picks up extensions that we care from the given list.
|
static <T> ExtensionList<T> |
lookup(Class<T> type)
Gets the extension list for a given type.
|
void |
refresh(ExtensionComponentSet delta)
Used during
Jenkins.refreshExtensions() to add new components into existing ExtensionList s. |
T |
remove(int index) |
boolean |
remove(Object o) |
List<T> |
reverseView()
Gets the read-only view of this
ExtensionList where components are reversed. |
int |
size() |
protected List<ExtensionComponent<T>> |
sort(List<ExtensionComponent<T>> r)
If the
ExtensionList implementation requires sorting extensions,
override this method to do so. |
addAll, clear, equals, hashCode, indexOf, lastIndexOf, listIterator, listIterator, removeRange, set, subList
addAll, contains, containsAll, isEmpty, removeAll, retainAll, toArray, toArray, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
addAll, contains, containsAll, isEmpty, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
parallelStream, removeIf, stream
@Deprecated public final Hudson hudson
jenkins
@CheckForNull public final Jenkins jenkins
@Deprecated protected ExtensionList(Hudson hudson, Class<T> extensionType)
ExtensionList(Jenkins, Class)
@Deprecated protected ExtensionList(Hudson hudson, Class<T> extensionType, CopyOnWriteArrayList<ExtensionComponent<T>> legacyStore)
ExtensionList(Jenkins, Class, CopyOnWriteArrayList)
protected ExtensionList(Jenkins jenkins, Class<T> extensionType, CopyOnWriteArrayList<ExtensionComponent<T>> legacyStore)
legacyStore
- Place to store manually registered instances. The version of the constructor that
omits this uses a new Vector
, making the storage lifespan tied to the life of ExtensionList
.
If the manually registered instances are scoped to VM level, the caller should pass in a static list.public void addListener(@Nonnull ExtensionListListener listener)
listener
- The listener.@CheckForNull public <U extends T> U get(Class<U> type)
public List<ExtensionComponent<T>> getComponents()
ExtensionComponent
s.public T get(int index)
public int size()
size
in interface Collection<T>
size
in interface List<T>
size
in class AbstractCollection<T>
public List<T> reverseView()
ExtensionList
where components are reversed.public boolean remove(Object o)
remove
in interface Collection<T>
remove
in interface List<T>
remove
in class AbstractCollection<T>
public final T remove(int index)
@Deprecated public boolean add(T t)
add
in interface Collection<T>
add
in interface List<T>
add
in class AbstractList<T>
public void add(int index, T element)
public T getDynamic(String className)
protected Object getLoadLock()
public void refresh(ExtensionComponentSet delta)
Jenkins.refreshExtensions()
to add new components into existing ExtensionList
s.
Do not call from anywhere else.protected List<ExtensionComponent<T>> load()
protected Collection<ExtensionComponent<T>> load(ExtensionComponentSet delta)
protected List<ExtensionComponent<T>> sort(List<ExtensionComponent<T>> r)
ExtensionList
implementation requires sorting extensions,
override this method to do so.
The implementation should copy a list, do a sort, and return the new instance.
@Deprecated public static <T> ExtensionList<T> create(Hudson hudson, Class<T> type)
create(Jenkins, Class)
public static <T> ExtensionList<T> create(Jenkins jenkins, Class<T> type)
@Nonnull public static <T> ExtensionList<T> lookup(Class<T> type)
Jenkins.getExtensionList(Class)
but falls back to an empty list
in case Jenkins.getInstance()
is null.
Thus it is useful to call from all()
methods which need to behave gracefully during startup or shutdown.type
- the extension point typepublic static void clearLegacyInstances()
Copyright © 2017. All rights reserved.