Class AutowiredList<T>

java.lang.Object
java.util.concurrent.CopyOnWriteArrayList<T>
com.tccc.kos.commons.util.AutowiredList<T>
All Implemented Interfaces:
Serializable, Cloneable, Iterable<T>, Collection<T>, List<T>, RandomAccess
Direct Known Subclasses:
ListenerList

public class AutowiredList<T> extends CopyOnWriteArrayList<T>
Specialized list class supports autowiring. When a bean with an Autowired AutowiredList property that has been added to a BeanContext will cause the context to automatically add any beans in the context of type <T> to the list. If new child contexts are added, any beans of type <T> will also be added. If a child context is destroyed, any beans from that context will automatically be removed from the list. This effectively makes AutowiredList a dynamically updated alternative to calling ctx.getBeans(T). In addition, since the list is updated during context lifecycle events, access the contents of the list is very efficient compared to querying the context.

While this is a List, it is mutated exclusively using add() and remove() within BeanContext. These methods are instrumented to allow notification callbacks when changes are made to the list. Use setOnAdd() and setOnRemove() to receive notifications of changes to the list. While this can be a very useful feature, be aware that the notifications will occur during BeanContext processing so it may be common that beans are not fully configured or ready for use. In addition, any processing in these callbacks will interrupt the BeanContext process.

Since:
1.0
Version:
2022-08-30
See Also: