org.springframework.batch.core.scope.util
Class PlaceholderTargetSource

java.lang.Object
  extended by org.springframework.aop.target.AbstractBeanFactoryBasedTargetSource
      extended by org.springframework.aop.target.SimpleBeanTargetSource
          extended by org.springframework.batch.core.scope.util.PlaceholderTargetSource
All Implemented Interfaces:
Serializable, TargetClassAware, TargetSource, BeanFactoryAware, InitializingBean

public class PlaceholderTargetSource
extends SimpleBeanTargetSource
implements InitializingBean

A TargetSource that lazily initializes its target, replacing bean definition properties dynamically if they are marked as placeholders. String values with embedded %{key} patterns will be replaced with the corresponding value from the injected context (which must also be a String). This includes dynamically locating a bean reference (e.g. ref="%{foo}"), and partial replacement of patterns (e.g. value="%{foo}-bar-%{spam}"). These replacements work for context values that are primitive (String, Long, Integer). You can also replace non-primitive values directly by making the whole bean property value into a placeholder (e.g. value="%{foo}" where foo is a property in the context).

Author:
Dave Syer
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.springframework.aop.target.AbstractBeanFactoryBasedTargetSource
logger
 
Constructor Summary
PlaceholderTargetSource()
           
 
Method Summary
 void afterPropertiesSet()
           
protected  String convertToString(Object value, TypeConverter typeConverter)
           
 Object getTarget()
           
 void setContextFactory(ContextFactory contextFactory)
          Public setter for the context factory.
 
Methods inherited from class org.springframework.aop.target.AbstractBeanFactoryBasedTargetSource
copyFrom, equals, getBeanFactory, getTargetBeanName, getTargetClass, hashCode, isStatic, releaseTarget, setBeanFactory, setTargetBeanName, setTargetClass, toString, writeReplace
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PlaceholderTargetSource

public PlaceholderTargetSource()
Method Detail

setContextFactory

public void setContextFactory(ContextFactory contextFactory)
Public setter for the context factory. Used to construct the context root whenever placeholders are replaced in a bean definition.

Parameters:
contextFactory - the ContextFactory

afterPropertiesSet

public void afterPropertiesSet()
Specified by:
afterPropertiesSet in interface InitializingBean

getTarget

public Object getTarget()
                 throws BeansException
Specified by:
getTarget in interface TargetSource
Overrides:
getTarget in class SimpleBeanTargetSource
Throws:
BeansException

convertToString

protected String convertToString(Object value,
                                 TypeConverter typeConverter)
Parameters:
value -
typeConverter -
Returns:
a String representation of the input if possible


Copyright © 2013 SpringSource. All Rights Reserved.