Package org.springframework.ws.support
Class DefaultStrategiesHelper
java.lang.Object
org.springframework.ws.support.DefaultStrategiesHelper
Helper class for for loading default implementations of an interface. Encapsulates a properties object, which
contains strategy interface names as keys, and comma-separated class names as values.
Simulates the normal lifecycle
for beans, by calling
BeanFactoryAware.setBeanFactory(BeanFactory)
,
ApplicationContextAware.setApplicationContext(ApplicationContext)
, etc.
- Since:
- 1.0.0
- Author:
- Arjen Poutsma
-
Constructor Summary
ConstructorDescriptionDefaultStrategiesHelper
(Class<?> type) Initializes a new instance of theDefaultStrategiesHelper
based on the given type.DefaultStrategiesHelper
(Properties defaultStrategies) Initializes a new instance of theDefaultStrategiesHelper
based on the given set of properties.DefaultStrategiesHelper
(org.springframework.core.io.Resource resource) Initializes a new instance of theDefaultStrategiesHelper
based on the given resource. -
Method Summary
Modifier and TypeMethodDescription<T> List<T>
getDefaultStrategies
(Class<T> strategyInterface) Create a list of strategy objects for the given strategy interface.<T> List<T>
getDefaultStrategies
(Class<T> strategyInterface, org.springframework.context.ApplicationContext applicationContext) Create a list of strategy objects for the given strategy interface.<T> T
getDefaultStrategy
(Class<T> strategyInterface) Return the default strategy object for the given strategy interface.<T> T
getDefaultStrategy
(Class<T> strategyInterface, org.springframework.context.ApplicationContext applicationContext) Return the default strategy object for the given strategy interface.
-
Constructor Details
-
DefaultStrategiesHelper
Initializes a new instance of theDefaultStrategiesHelper
based on the given set of properties. -
DefaultStrategiesHelper
public DefaultStrategiesHelper(org.springframework.core.io.Resource resource) throws IllegalStateException Initializes a new instance of theDefaultStrategiesHelper
based on the given resource.- Throws:
IllegalStateException
-
DefaultStrategiesHelper
Initializes a new instance of theDefaultStrategiesHelper
based on the given type.This constructor will attempt to load a 'typeName'.properties file in the same package as the given type.
-
-
Method Details
-
getDefaultStrategies
public <T> List<T> getDefaultStrategies(Class<T> strategyInterface) throws org.springframework.beans.factory.BeanInitializationException Create a list of strategy objects for the given strategy interface. Strategies are retrieved from theProperties
object given at construction-time.- Parameters:
strategyInterface
- the strategy interface- Returns:
- a list of corresponding strategy objects
- Throws:
org.springframework.beans.BeansException
- if initialization failedorg.springframework.beans.factory.BeanInitializationException
-
getDefaultStrategies
public <T> List<T> getDefaultStrategies(Class<T> strategyInterface, org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.factory.BeanInitializationException Create a list of strategy objects for the given strategy interface. Strategies are retrieved from theProperties
object given at construction-time. It instantiates the strategy objects and satisfiesApplicationContextAware
with the supplied context if necessary.- Parameters:
strategyInterface
- the strategy interfaceapplicationContext
- used to satisfy strategies that are application context aware, may benull
- Returns:
- a list of corresponding strategy objects
- Throws:
org.springframework.beans.BeansException
- if initialization failedorg.springframework.beans.factory.BeanInitializationException
-
getDefaultStrategy
public <T> T getDefaultStrategy(Class<T> strategyInterface) throws org.springframework.beans.factory.BeanInitializationException Return the default strategy object for the given strategy interface.- Parameters:
strategyInterface
- the strategy interface- Returns:
- the corresponding strategy object
- Throws:
org.springframework.beans.BeansException
- if initialization failedorg.springframework.beans.factory.BeanInitializationException
- See Also:
-
getDefaultStrategy
public <T> T getDefaultStrategy(Class<T> strategyInterface, org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.factory.BeanInitializationException Return the default strategy object for the given strategy interface.Delegates to
getDefaultStrategies(Class,ApplicationContext)
, expecting a single object in the list.- Parameters:
strategyInterface
- the strategy interfaceapplicationContext
- used to satisfy strategies that are application context aware, may benull
- Returns:
- the corresponding strategy object
- Throws:
org.springframework.beans.BeansException
- if initialization failedorg.springframework.beans.factory.BeanInitializationException
-