|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.picocontainer.defaults.DecoratingComponentAdapter
org.picocontainer.defaults.BeanPropertyComponentAdapter
public class BeanPropertyComponentAdapter
Decorating component adapter that can be used to set additional properties
on a component in a bean style. These properties must be managed manually
by the user of the API, and will not be managed by PicoContainer. This class
is therefore not the same as SetterInjectionComponentAdapter
,
which is a true Setter Injection adapter.
PropertyEditor
and using its setAsText
method.
Note that this class doesn't cache instances. If you want caching,
use a CachingComponentAdapter
around this one.
Field Summary | |
---|---|
private java.util.Map |
properties
|
private java.util.Map |
setters
|
Constructor Summary | |
---|---|
BeanPropertyComponentAdapter(ComponentAdapter delegate)
Construct a BeanPropertyComponentAdapter. |
Method Summary | |
---|---|
static java.lang.Object |
convert(java.lang.String typeName,
java.lang.String value,
java.lang.ClassLoader classLoader)
Converts a String value of a named type to an object. |
private java.lang.Object |
convertType(PicoContainer container,
java.lang.reflect.Method setter,
java.lang.String propertyValue)
|
java.lang.Object |
getComponentInstance(PicoContainer container)
Get a component instance and set given property values. |
private java.lang.reflect.Method[] |
getMethods(java.lang.Class clazz)
|
private java.lang.String |
getPropertyName(java.lang.reflect.Method method)
|
private java.lang.Object |
getSetterParameter(java.lang.String propertyName,
java.lang.Object propertyValue,
java.lang.Object componentInstance,
PicoContainer container)
Converts and validates the given property value to an appropriate object for calling the bean's setter. |
private java.util.Map |
getSetters(java.lang.Class clazz)
|
private boolean |
isSetter(java.lang.reflect.Method method)
|
void |
setProperties(java.util.Map properties)
Sets the bean property values that should be set upon creation. |
Methods inherited from class org.picocontainer.defaults.DecoratingComponentAdapter |
---|
accept, changeMonitor, currentMonitor, dispose, dispose, getComponentImplementation, getComponentKey, getDelegate, hasLifecycle, hasLifecycle, start, start, stop, stop, toString, verify |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private java.util.Map properties
private transient java.util.Map setters
Constructor Detail |
---|
public BeanPropertyComponentAdapter(ComponentAdapter delegate) throws PicoInitializationException
delegate
- the wrapped ComponentAdapter
PicoInitializationException
Method Detail |
---|
public java.lang.Object getComponentInstance(PicoContainer container) throws PicoInitializationException, PicoIntrospectionException, AssignabilityRegistrationException, NotConcreteRegistrationException
getComponentInstance
in interface ComponentAdapter
getComponentInstance
in class DecoratingComponentAdapter
container
- the PicoContainer
, that is used to resolve any possible dependencies of the instance.
PicoInitializationException
- if the component could not be instantiated.
PicoIntrospectionException
- if the component has dependencies which could not be resolved, or
instantiation of the component lead to an ambigous situation within the
container.
AssignabilityRegistrationException
NotConcreteRegistrationException
setProperties(Map)
private java.util.Map getSetters(java.lang.Class clazz)
private java.lang.reflect.Method[] getMethods(java.lang.Class clazz)
private java.lang.String getPropertyName(java.lang.reflect.Method method)
private boolean isSetter(java.lang.reflect.Method method)
private java.lang.Object convertType(PicoContainer container, java.lang.reflect.Method setter, java.lang.String propertyValue) throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException
public static java.lang.Object convert(java.lang.String typeName, java.lang.String value, java.lang.ClassLoader classLoader) throws java.lang.ClassNotFoundException
PropertyEditor
.
typeName
- name of the typevalue
- its valueclassLoader
- used to load a class if typeName is "class" or "java.lang.Class" (ignored otherwise)
java.lang.ClassNotFoundException
- if typeName is "class" or "java.lang.Class" and class couldn't be loaded.public void setProperties(java.util.Map properties)
properties
- bean propertiesprivate java.lang.Object getSetterParameter(java.lang.String propertyName, java.lang.Object propertyValue, java.lang.Object componentInstance, PicoContainer container) throws PicoInitializationException, java.lang.ClassCastException
propertyName
- String the property name on the component that
we will be setting the value to.propertyValue
- Object the property value that we've been given. It
may need conversion to be formed into the value we need for the
component instance setter.componentInstance
- the component that we're looking to provide
the setter to.
PicoInitializationException
java.lang.ClassCastException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |