T
- The type of the bean instance.public interface BeanHolder<T> extends AutoCloseable
Modifier and Type | Method and Description |
---|---|
void |
close()
Release any resource currently held by the
BeanHolder . |
T |
get() |
static <T> BeanHolder<List<T>> |
of(List<? extends BeanHolder<? extends T>> beanHolders) |
static <T> BeanHolder<T> |
of(T instance) |
T get()
beanHolder.get() == beanHolder.get()
is always true.void close()
BeanHolder
.
After this method has been called, the result of calling get()
on the same instance is undefined.
Warning: this method only releases resources that were allocated
by the creator of the bean instance, and of which the bean instance itself may not be aware.
If the bean instance itself (the one returned by get()
) exposes any close()
or other release method, they should be called before the BeanHolder
is released.
close
in interface AutoCloseable
RuntimeException
- If an error occurs while releasing resources.static <T> BeanHolder<T> of(T instance)
T
- The type of the bean instance.instance
- The bean instance.BeanHolder
whose get()
method returns the given instance,
and whose close()
method does not do anything.static <T> BeanHolder<List<T>> of(List<? extends BeanHolder<? extends T>> beanHolders)
T
- The type of the bean instances.beanHolders
- The bean holders.BeanHolder
whose get()
method returns a list containing
the instance of each given bean holder, in order,
and whose close()
method closes every given bean holder.Copyright © 2006-2019 Red Hat, Inc. and others. Licensed under the GNU Lesser General Public License (LGPL), version 2.1 or later.