org.apache.lucene.gdata.server.registry.configuration
Class PropertyInjector

java.lang.Object
  extended by org.apache.lucene.gdata.server.registry.configuration.PropertyInjector

public class PropertyInjector
extends Object

PropertyInjector is used to set member variables / properties of classes via setter methods using the ComponentConfiguration class.

To populate a object with properties from a ComponentConfiguration instance the class or a superclass of the object to populate has to provide at least one setter method with a single parameter. The object to populate is set via the setTargetObject(java.lang.Object) method. The class of the object will be analyzed for setter methods having a "set" prefix in their method name. If one of the found setter methods is annotated with Requiered this property is interpreted as a mandatory property. Mandatory properties must be available in the provided ComponentConfiguration, if not the injection will fail.
The ComponentConfiguration contains key / value pairs where the key must match the signature of the setter method without the 'set' prefix and must begin with a lower case character. KeybufferSize does match a method signature of setBufferSize The type of the parameter will be reflected via the Reflection API and instantiated with the given value if possible.

Setter methods without a Required annotation will be set if the property is present in the ComponentConfiguration

This class does not support overloaded setter methods.

Author:
Simon Willnauer
See Also:
Requiered, ComponentConfiguration

Constructor Summary
PropertyInjector()
           
 
Method Summary
 void clear()
          Sets all members to their default values and clears the internal used Map instances
protected  int getOptionalSize()
           
protected  int getRequiredSize()
           
 void injectProperties(ComponentConfiguration bean)
          Injects the properties stored in the ComponentConfiguration to the corresponding methods of the target object
 void setTargetObject(Object o)
          Sets the object to be populated with the properties provided in the ComponentConfiguration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertyInjector

public PropertyInjector()
Method Detail

setTargetObject

public void setTargetObject(Object o)
Sets the object to be populated with the properties provided in the ComponentConfiguration.

Parameters:
o - - the object to populate

getRequiredSize

protected int getRequiredSize()

getOptionalSize

protected int getOptionalSize()

injectProperties

public void injectProperties(ComponentConfiguration bean)
Injects the properties stored in the ComponentConfiguration to the corresponding methods of the target object

Parameters:
bean - - configuration bean containing all properties to set.

clear

public void clear()
Sets all members to their default values and clears the internal used Map instances

See Also:
Map.clear()


Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.