org.springframework.config.java.support
Class ConfigurationSupport

java.lang.Object
  extended by org.springframework.config.java.support.ConfigurationSupport
All Implemented Interfaces:
org.springframework.beans.factory.BeanFactoryAware, org.springframework.context.ApplicationContextAware

@Configuration
public abstract class ConfigurationSupport
extends java.lang.Object
implements org.springframework.beans.factory.BeanFactoryAware, org.springframework.context.ApplicationContextAware

Convenient base class for Configurations, allowing easy lookup of beans in the owning factory as well as other services.

Author:
Rod Johnson, Chris Beams

Constructor Summary
ConfigurationSupport()
           
 
Method Summary
protected  org.springframework.context.ApplicationContext getApplicationContext()
           
<T> T
getBean(java.lang.Class<T> type)
           
<T> T
getBean(java.lang.Class<T> type, java.lang.String beanName)
           
 java.lang.Object getBean(java.lang.String beanName)
           
protected  org.springframework.beans.factory.BeanFactory getBeanFactory()
           
protected
<T> T
getConfigured(T object)
          Invoke callbacks on the object, as though it were configured in the factory.
protected  java.lang.Object getObject(org.springframework.beans.factory.FactoryBean factoryBean)
          Return the object created by this FactoryBean instance, first invoking any container callbacks on the instance.
<T> T
getObject(org.springframework.beans.factory.FactoryBean factoryBean, java.lang.Class<T> requiredType)
          Same as getObject(FactoryBean), but checks FactoryBean.getObjectType() against user-supplied requiredType and then casts internally to return a strongly-typed result.
 void setApplicationContext(org.springframework.context.ApplicationContext ac)
           
 void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigurationSupport

public ConfigurationSupport()
Method Detail

setBeanFactory

public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
Specified by:
setBeanFactory in interface org.springframework.beans.factory.BeanFactoryAware

getBeanFactory

protected org.springframework.beans.factory.BeanFactory getBeanFactory()

setApplicationContext

public void setApplicationContext(org.springframework.context.ApplicationContext ac)
Specified by:
setApplicationContext in interface org.springframework.context.ApplicationContextAware

getApplicationContext

protected org.springframework.context.ApplicationContext getApplicationContext()

getBean

public java.lang.Object getBean(java.lang.String beanName)

getBean

public <T> T getBean(java.lang.Class<T> type)

getBean

public <T> T getBean(java.lang.Class<T> type,
                     java.lang.String beanName)

getObject

protected java.lang.Object getObject(org.springframework.beans.factory.FactoryBean factoryBean)
                              throws FactoryBeanObjectCreationException
Return the object created by this FactoryBean instance, first invoking any container callbacks on the instance.

Parameters:
factoryBean - FactoryBean instance
Returns:
The object created by the configured FactoryBean instance
Throws:
FactoryBeanObjectCreationException - wraps and rethrows any Exception thrown when invoking the underlying FactoryBean.getObject() method.
See Also:
FactoryBeanObjectCreationException

getObject

public <T> T getObject(org.springframework.beans.factory.FactoryBean factoryBean,
                       java.lang.Class<T> requiredType)
Same as getObject(FactoryBean), but checks FactoryBean.getObjectType() against user-supplied requiredType and then casts internally to return a strongly-typed result.

Note: Will likely be removed/deprecated in the Spring 3.0 timeframe, presuming that FactoryBean will be parameterized, at which point its generics metadata can be used directly.

Type Parameters:
T - Expected type
Parameters:
factoryBean - target FactoryBean instance
requiredType - Class of expected type
Returns:

getConfigured

protected <T> T getConfigured(T object)
Invoke callbacks on the object, as though it were configured in the factory. If appropriate, the object may be wrapped before being returned. For this reason, it is recommended to always respect the return value when using this method.

Parameters:
object - object to configure
Returns:
either the original object or a wrapped one after callbacks called on it.