public class BeanWrapperFactory extends Object
A BeanWrapper uses the same BeanWrapperFactory to create the BeanWrapperContexts for its nested BeanWrappers. BeanWrapperFactory can also be used as an umbrella to create BeanWrappers in a more performant way as it caches the introspection information and re-uses it whenever possible.
| Constructor and Description |
|---|
BeanWrapperFactory() |
| Modifier and Type | Method and Description |
|---|---|
protected BeanInstanceBuilder |
getBeanInstanceBuilder() |
BeanWrapper |
getBeanWrapper(Class clazz)
Construct a bean wrapper around a class.
|
BeanWrapper |
getBeanWrapper(Object instance)
Construct a bean wrapper around an existing bean instance.
|
BeanWrapperContext |
getBeanWrapperContext(Class clazz)
Retrieves a BeanWrapperContext for java bean class.
|
BeanWrapperContext |
getBeanWrapperContext(Class clazz,
Type... types)
Retrieves a BeanWrapperContext for a parameterized (generic) java bean class.
|
void |
setBeanContextBuilder(BeanContextBuilder beanContextBuilder)
Control the creation of BeanWrapperContexts.
|
void |
setBeanInstanceBuilder(BeanInstanceBuilder beanInstanceBuilder)
Control the instantiation of beans and wrapped beans.
|
public BeanWrapperContext getBeanWrapperContext(Class clazz)
If the BeanWrapperContext is not in cache then creates a new one.
clazz - the bean class to inspect#getBeanWrapperContext(Class, Type...)}public BeanWrapperContext getBeanWrapperContext(Class clazz, Type... types)
If the BeanWrapperContext is not in cache then creates a new one.
clazz - the generic bean class to inspect.types - the parameters that defined the generic bean class.public BeanWrapper getBeanWrapper(Class clazz)
Bean instances will be instances of that class and will be created only when necessary.
Try to use a cached BeanWrapperContext to save introspection time.
clazz - class to instantiate the wrapped beanpublic BeanWrapper getBeanWrapper(Object instance)
Will try to use a cached BeanWrapperContext to save introspection time.
instance - the bean object to be wrappedprotected BeanInstanceBuilder getBeanInstanceBuilder()
public void setBeanInstanceBuilder(BeanInstanceBuilder beanInstanceBuilder)
The bean wrapper creates new instances using Class.newIntance() by default. You can use this this if you want to create class instances yourself.
beanInstanceBuilder - public void setBeanContextBuilder(BeanContextBuilder beanContextBuilder)
Provide a custom BeanContextBuilder that will instantiate your custom BeanWrapperContext. This way you can extend the BeanWrapperContext class and attach more information to a bean.
beanContextBuilder - Copyright © 2011-2013. All Rights Reserved.