Spring Web Services Framework

org.springframework.ws.support
Class DefaultStrategiesHelper

java.lang.Object
  extended by org.springframework.ws.support.DefaultStrategiesHelper

public class DefaultStrategiesHelper
extends Object

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
DefaultStrategiesHelper(Class<?> type)
          Initializes a new instance of the DefaultStrategiesHelper based on the given type.
DefaultStrategiesHelper(Properties defaultStrategies)
          Initializes a new instance of the DefaultStrategiesHelper based on the given set of properties.
DefaultStrategiesHelper(Resource resource)
          Initializes a new instance of the DefaultStrategiesHelper based on the given resource.
 
Method Summary
<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, 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, ApplicationContext applicationContext)
          Return the default strategy object for the given strategy interface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultStrategiesHelper

public DefaultStrategiesHelper(Properties defaultStrategies)
Initializes a new instance of the DefaultStrategiesHelper based on the given set of properties.


DefaultStrategiesHelper

public DefaultStrategiesHelper(Resource resource)
                        throws IllegalStateException
Initializes a new instance of the DefaultStrategiesHelper based on the given resource.

Throws:
IllegalStateException

DefaultStrategiesHelper

public DefaultStrategiesHelper(Class<?> type)
Initializes a new instance of the DefaultStrategiesHelper based on the given type.

This constructor will attempt to load a 'typeName'.properties file in the same package as the given type.

Method Detail

getDefaultStrategies

public <T> List<T> getDefaultStrategies(Class<T> strategyInterface)
                             throws BeanInitializationException
Create a list of strategy objects for the given strategy interface. Strategies are retrieved from the Properties object given at construction-time.

Parameters:
strategyInterface - the strategy interface
Returns:
a list of corresponding strategy objects
Throws:
BeansException - if initialization failed
BeanInitializationException

getDefaultStrategies

public <T> List<T> getDefaultStrategies(Class<T> strategyInterface,
                                        ApplicationContext applicationContext)
                             throws BeanInitializationException
Create a list of strategy objects for the given strategy interface. Strategies are retrieved from the Properties object given at construction-time. It instantiates the strategy objects and satisfies ApplicationContextAware with the supplied context if necessary.

Parameters:
strategyInterface - the strategy interface
applicationContext - used to satisfy strategies that are application context aware, may be null
Returns:
a list of corresponding strategy objects
Throws:
BeansException - if initialization failed
BeanInitializationException

getDefaultStrategy

public <T> T getDefaultStrategy(Class<T> strategyInterface)
                     throws BeanInitializationException
Return the default strategy object for the given strategy interface.

Parameters:
strategyInterface - the strategy interface
Returns:
the corresponding strategy object
Throws:
BeansException - if initialization failed
BeanInitializationException
See Also:
getDefaultStrategies(java.lang.Class)

getDefaultStrategy

public <T> T getDefaultStrategy(Class<T> strategyInterface,
                                ApplicationContext applicationContext)
                     throws 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 interface
applicationContext - used to satisfy strategies that are application context aware, may be null
Returns:
the corresponding strategy object
Throws:
BeansException - if initialization failed
BeanInitializationException

Spring Web Services Framework

Copyright © 2005-2013 The Spring Web Services Framework. All Rights Reserved.