org.picocontainer.behaviors
Class PropertyApplicator<T>
java.lang.Object
org.picocontainer.behaviors.AbstractBehavior<T>
org.picocontainer.behaviors.PropertyApplicator<T>
- All Implemented Interfaces:
- Serializable, Behavior<T>, ComponentAdapter<T>, ComponentMonitorStrategy, LifecycleStrategy
public class PropertyApplicator<T>
- extends AbstractBehavior<T>
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 SetterInjector,
which is a true Setter Injection adapter.
This adapter is mostly handy for setting various primitive properties via setters;
it is also able to set javabean properties by discovering an appropriate
PropertyEditor and using its setAsText method.
Note that this class doesn't cache instances. If you want caching,
use a Cached around this one.
- Author:
- Aslak Hellesøy, Mauro Talevi
- See Also:
- Serialized Form
| Methods inherited from class org.picocontainer.behaviors.AbstractBehavior |
accept, changeMonitor, componentHasLifecycle, currentMonitor, dispose, dispose, findAdapterOfType, getComponentImplementation, getComponentKey, getDelegate, hasLifecycle, start, start, stop, stop, verify |
PropertyApplicator
public PropertyApplicator(ComponentAdapter<T> delegate)
throws PicoCompositionException
- Construct a PropertyApplicator.
- Parameters:
delegate - the wrapped ComponentAdapter
- Throws:
PicoCompositionException
getComponentInstance
public T getComponentInstance(PicoContainer container)
throws PicoCompositionException
- Get a component instance and set given property values.
- Specified by:
getComponentInstance in interface ComponentAdapter<T>- Overrides:
getComponentInstance in class AbstractBehavior<T>
- Parameters:
container - the PicoContainer, that is used to resolve any possible dependencies of the instance.
- Returns:
- the component instance with any properties of the properties map set.
- Throws:
PicoCompositionException - if the component has dependencies which could not be resolved, or
instantiation of the component lead to an ambigous situation within the
container.
PicoCompositionException - if the component has dependencies which could not be resolved, or
instantiation of the component lead to an ambigous situation within the
container.
PicoCompositionException - if the component has dependencies which could not be resolved, or
instantiation of the component lead to an ambigous situation within the
container.- See Also:
setProperties(Map)
convert
public static Object convert(String typeName,
String value,
ClassLoader classLoader)
- Converts a String value of a named type to an object.
Works with primitive wrappers, String, File, URL types, or any type that has
an appropriate
PropertyEditor.
- Parameters:
typeName - name of the typevalue - its valueclassLoader - used to load a class if typeName is "class" or "java.lang.Class" (ignored otherwise)
- Returns:
- instantiated object or null if the type was unknown/unsupported
setProperties
public void setProperties(Map<String,String> properties)
- Sets the bean property values that should be set upon creation.
- Parameters:
properties - bean properties
toString
public String toString()
- Overrides:
toString in class AbstractBehavior<T>
setProperty
public void setProperty(String name,
String value)
Copyright © 2003-2007 Codehaus. All Rights Reserved.