public class AppBeans
extends java.lang.Object
BeanLocator
Constructor and Description |
---|
AppBeans() |
Modifier and Type | Method and Description |
---|---|
static boolean |
containsBean(java.lang.String name)
Whether a bean with the given name is present.
|
static <T> T |
get(java.lang.Class<T> beanType)
Return the bean instance that matches the given object type.
|
static <T> T |
get(java.lang.String name)
Return an instance of the specified bean.
|
static <T> T |
get(java.lang.String name,
java.lang.Class<T> beanType)
Return an instance of the specified bean.
|
static <T> java.util.Map<java.lang.String,T> |
getAll(java.lang.Class<T> beanType)
Return the bean instances that match the given object type (including
subclasses).
|
static <T> T |
getPrototype(java.lang.Class<T> beanType,
java.lang.Object... args)
Return an instance of prototype bean, specifying explicit constructor arguments.
|
static <T> T |
getPrototype(java.lang.String name,
java.lang.Object... args)
Return an instance of prototype bean, specifying explicit constructor arguments.
|
public static <T> T get(java.lang.Class<T> beanType)
NAME
, this name is used to look up the
bean to improve performance.beanType
- type the bean must match; can be an interface or superclass. null
is disallowed.public static <T> T get(java.lang.String name)
name
- the name of the bean to retrieveBeanFactory.getBean(java.lang.String)
public static <T> T get(java.lang.String name, @Nullable java.lang.Class<T> beanType)
name
- the name of the bean to retrievebeanType
- type the bean must match. Can be an interface or superclass of the actual class, or null
for any match. For example, if the value is Object.class, this method will succeed whatever the class of the
returned instance.public static <T> T getPrototype(java.lang.String name, java.lang.Object... args)
name
- the name of the bean to retrieveargs
- constructor argumentspublic static <T> T getPrototype(java.lang.Class<T> beanType, java.lang.Object... args)
beanType
- type the bean must match; can be an interface or superclass. null
is disallowed.args
- constructor argumentspublic static <T> java.util.Map<java.lang.String,T> getAll(java.lang.Class<T> beanType)
The Map returned by this method should always return bean names and corresponding bean instances in the order of definition in the backend configuration, as far as possible.
beanType
- the class or interface to match, or null
for all concrete beanspublic static boolean containsBean(java.lang.String name)