Save This Page
Home » spring-framework-2.5.5-with-dependencies » org.springframework » beans » factory » config » [javadoc | source]
org.springframework.beans.factory.config
public class: FieldRetrievingFactoryBean [javadoc | source]
java.lang.Object
   org.springframework.beans.factory.config.FieldRetrievingFactoryBean

All Implemented Interfaces:
    BeanClassLoaderAware, BeanNameAware, InitializingBean, FactoryBean

FactoryBean which retrieves a static or non-static field value.

Typically used for retrieving public static final constants. Usage example:

// standard definition for exposing a static field, specifying the "staticField" property
<bean id="myField" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean">
<property name="staticField" value="java.sql.Connection.TRANSACTION_SERIALIZABLE"/>
</bean>

// convenience version that specifies a static field pattern as bean name
<bean id="java.sql.Connection.TRANSACTION_SERIALIZABLE"
class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean"/>

If you are using Spring 2.0, you can also use the following style of configuration for public static fields.

<util:constant static-field="java.sql.Connection.TRANSACTION_SERIALIZABLE"/>
Method from org.springframework.beans.factory.config.FieldRetrievingFactoryBean Summary:
afterPropertiesSet,   getObject,   getObjectType,   getTargetClass,   getTargetField,   getTargetObject,   isSingleton,   setBeanClassLoader,   setBeanName,   setStaticField,   setTargetClass,   setTargetField,   setTargetObject
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.springframework.beans.factory.config.FieldRetrievingFactoryBean Detail:
 public  void afterPropertiesSet() throws ClassNotFoundException, NoSuchFieldException 
 public Object getObject() throws IllegalAccessException 
 public Class getObjectType() 
 public Class getTargetClass() 
    Return the target class on which the field is defined.
 public String getTargetField() 
    Return the name of the field to be retrieved.
 public Object getTargetObject() 
    Return the target object on which the field is defined.
 public boolean isSingleton() 
 public  void setBeanClassLoader(ClassLoader classLoader) 
 public  void setBeanName(String beanName) 
    The bean name of this FieldRetrievingFactoryBean will be interpreted as "staticField" pattern, if neither "targetClass" nor "targetObject" nor "targetField" have been specified. This allows for concise bean definitions with just an id/name.
 public  void setStaticField(String staticField) 
    Set a fully qualified static field name to retrieve, e.g. "example.MyExampleClass.MY_EXAMPLE_FIELD". Convenient alternative to specifying targetClass and targetField.
 public  void setTargetClass(Class targetClass) 
    Set the target class on which the field is defined. Only necessary when the target field is static; else, a target object needs to be specified anyway.
 public  void setTargetField(String targetField) 
    Set the name of the field to be retrieved. Refers to either a static field or a non-static field, depending on a target object being set.
 public  void setTargetObject(Object targetObject) 
    Set the target object on which the field is defined. Only necessary when the target field is not static; else, a target class is sufficient.