hudson
Class ExtensionList<T>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<T>
          extended by hudson.ExtensionList<T>
Type Parameters:
T - Type of the extension point. This class holds instances of the subtypes of 'T'.
All Implemented Interfaces:
Iterable<T>, Collection<T>, List<T>
Direct Known Subclasses:
DescriptorExtensionList

public class ExtensionList<T>
extends AbstractList<T>

Retains the known extension instances for the given type '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.

Since:
1.286
Author:
Kohsuke Kawaguchi
See Also:
Jenkins.getExtensionList(Class), Jenkins.getDescriptorList(Class)

Field Summary
 Class<T> extensionType
           
 Hudson hudson
          Deprecated. as of 1.417 Use jenkins
 Jenkins jenkins
           
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
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)
           
 
Method Summary
 void add(int index, T element)
           
 boolean add(T t)
          Deprecated. since 2009-02-23. Prefer automatic registration.
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>
U
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 ExtensionComponents.
 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.
 void refresh(ExtensionComponentSet delta)
          Used during Jenkins.refreshExtensions() to add new components into existing ExtensionLists.
 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.
 
Methods inherited from class java.util.AbstractList
addAll, clear, equals, hashCode, indexOf, lastIndexOf, listIterator, listIterator, removeRange, set, subList
 
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, removeAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, removeAll, retainAll, toArray, toArray
 

Field Detail

hudson

public final Hudson hudson
Deprecated. as of 1.417 Use jenkins

jenkins

public final Jenkins jenkins

extensionType

public final Class<T> extensionType
Constructor Detail

ExtensionList

protected ExtensionList(Hudson hudson,
                        Class<T> extensionType)
Deprecated. as of 1.416 Use ExtensionList(Jenkins, Class)


ExtensionList

protected ExtensionList(Jenkins jenkins,
                        Class<T> extensionType)

ExtensionList

protected ExtensionList(Hudson hudson,
                        Class<T> extensionType,
                        CopyOnWriteArrayList<ExtensionComponent<T>> legacyStore)
Deprecated. as of 1.416 Use ExtensionList(Jenkins, Class, CopyOnWriteArrayList)


ExtensionList

protected ExtensionList(Jenkins jenkins,
                        Class<T> extensionType,
                        CopyOnWriteArrayList<ExtensionComponent<T>> legacyStore)
Parameters:
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.
Method Detail

get

public <U extends T> U get(Class<U> type)
Looks for the extension instance of the given type (subclasses excluded), or return null.


iterator

public Iterator<T> iterator()
Specified by:
iterator in interface Iterable<T>
Specified by:
iterator in interface Collection<T>
Specified by:
iterator in interface List<T>
Overrides:
iterator in class AbstractList<T>

getComponents

public List<ExtensionComponent<T>> getComponents()
Gets the same thing as the 'this' list represents, except as ExtensionComponents.


get

public T get(int index)
Specified by:
get in interface List<T>
Specified by:
get in class AbstractList<T>

size

public int size()
Specified by:
size in interface Collection<T>
Specified by:
size in interface List<T>
Specified by:
size in class AbstractCollection<T>

reverseView

public List<T> reverseView()
Gets the read-only view of this ExtensionList where components are reversed.


remove

public boolean remove(Object o)
Specified by:
remove in interface Collection<T>
Specified by:
remove in interface List<T>
Overrides:
remove in class AbstractCollection<T>

remove

public final T remove(int index)
Specified by:
remove in interface List<T>
Overrides:
remove in class AbstractList<T>

add

public boolean add(T t)
Deprecated. since 2009-02-23. Prefer automatic registration.

Write access will put the instance into a legacy store.

Specified by:
add in interface Collection<T>
Specified by:
add in interface List<T>
Overrides:
add in class AbstractList<T>

add

public void add(int index,
                T element)
Specified by:
add in interface List<T>
Overrides:
add in class AbstractList<T>

getDynamic

public T getDynamic(String className)
Used to bind extension to URLs by their class names.

Since:
1.349

getLoadLock

protected Object getLoadLock()
Chooses the object that locks the loading of the extension instances.


refresh

public void refresh(ExtensionComponentSet delta)
Used during Jenkins.refreshExtensions() to add new components into existing ExtensionLists. Do not call from anywhere else.


load

protected List<ExtensionComponent<T>> load()
Loads all the extensions.


load

protected Collection<ExtensionComponent<T>> load(ExtensionComponentSet delta)
Picks up extensions that we care from the given list.


sort

protected List<ExtensionComponent<T>> sort(List<ExtensionComponent<T>> r)
If the 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.


create

public static <T> ExtensionList<T> create(Hudson hudson,
                                          Class<T> type)
Deprecated. as of 1.416 Use create(Jenkins, Class)


create

public static <T> ExtensionList<T> create(Jenkins jenkins,
                                          Class<T> type)

clearLegacyInstances

public static void clearLegacyInstances()
Exposed for the test harness to clear all legacy extension instances.



Copyright © 2004-2013. All Rights Reserved.