@ -28,15 +28,17 @@ import org.springframework.util.StringUtils;
/ * *
/ * *
* Abstract , generic extension of { @link AbstractContextLoader } which loads a
* Abstract , generic extension of { @link AbstractContextLoader } which loads a
* { @link GenericApplicationContext } from the < em > locations < / em > provided to
* { @link GenericApplicationContext } from the < em > locations < / em > provided to
* { @link # loadContext ( String . . . ) } .
* { @link # loadContext loadContext ( ) } .
*
*
* < p > Concrete subclasses must provide an appropriate
* < p > Concrete subclasses must provide an appropriate implementation of
* { @link # createBeanDefinitionReader ( GenericApplicationContext ) BeanDefinitionReader } .
* { @link # createBeanDefinitionReader createBeanDefinitionReader ( ) } ,
* potentially overriding { @link # loadBeanDefinitions loadBeanDefinitions ( ) }
* in addition .
*
*
* @author Sam Brannen
* @author Sam Brannen
* @author Juergen Hoeller
* @author Juergen Hoeller
* @since 2 . 5
* @since 2 . 5
* @see # loadContext ( String . . . )
* @see # loadContext
* /
* /
public abstract class AbstractGenericContextLoader extends AbstractContextLoader {
public abstract class AbstractGenericContextLoader extends AbstractContextLoader {
@ -47,8 +49,7 @@ public abstract class AbstractGenericContextLoader extends AbstractContextLoader
* Loads a Spring ApplicationContext from the supplied < code > locations < / code > .
* Loads a Spring ApplicationContext from the supplied < code > locations < / code > .
* < p > Implementation details :
* < p > Implementation details :
* < ul >
* < ul >
* < li > Delegates to { @link # createGenericApplicationContext ( ) } to
* < li > Creates a { @link GenericApplicationContext } instance . < / li >
* create a { @link GenericApplicationContext } instance . < / li >
* < li > Calls { @link # prepareContext ( GenericApplicationContext ) } to
* < li > Calls { @link # prepareContext ( GenericApplicationContext ) } to
* prepare the context . < / li >
* prepare the context . < / li >
* < li > Calls { @link # customizeBeanFactory ( DefaultListableBeanFactory ) } to
* < li > Calls { @link # customizeBeanFactory ( DefaultListableBeanFactory ) } to
@ -72,7 +73,7 @@ public abstract class AbstractGenericContextLoader extends AbstractContextLoader
logger . debug ( String . format ( "Loading ApplicationContext for locations [%s]." ,
logger . debug ( String . format ( "Loading ApplicationContext for locations [%s]." ,
StringUtils . arrayToCommaDelimitedString ( locations ) ) ) ;
StringUtils . arrayToCommaDelimitedString ( locations ) ) ) ;
}
}
GenericApplicationContext context = create GenericApplicationContext( ) ;
GenericApplicationContext context = new GenericApplicationContext ( ) ;
prepareContext ( context ) ;
prepareContext ( context ) ;
customizeBeanFactory ( context . getDefaultListableBeanFactory ( ) ) ;
customizeBeanFactory ( context . getDefaultListableBeanFactory ( ) ) ;
loadBeanDefinitions ( context , locations ) ;
loadBeanDefinitions ( context , locations ) ;
@ -83,20 +84,6 @@ public abstract class AbstractGenericContextLoader extends AbstractContextLoader
return context ;
return context ;
}
}
/ * *
* Factory method for creating a new { @link GenericApplicationContext }
* to be used by this < code > ContextLoader < / code > .
* < p > The default implementation returns an instance of
* { @link GenericApplicationContext } . Can be overridden in subclasses
* to return a specific subclass of < code > GenericApplicationContext < / code > .
* @return a new < code > GenericApplicationContext < / code >
* @since 3 . 1
* @see # loadContext
* /
protected GenericApplicationContext createGenericApplicationContext ( ) {
return new GenericApplicationContext ( ) ;
}
/ * *
/ * *
* Prepare the { @link GenericApplicationContext } created by this < code > ContextLoader < / code > .
* Prepare the { @link GenericApplicationContext } created by this < code > ContextLoader < / code > .
* Called < i > before < / > bean definitions are read .
* Called < i > before < / > bean definitions are read .
@ -132,10 +119,10 @@ public abstract class AbstractGenericContextLoader extends AbstractContextLoader
* { @link BeanDefinitionReader # loadBeanDefinitions ( String ) load } the
* { @link BeanDefinitionReader # loadBeanDefinitions ( String ) load } the
* bean definitions .
* bean definitions .
* < p > Subclasses must provide an appropriate implementation of
* < p > Subclasses must provide an appropriate implementation of
* { @link # createBeanDefinitionReader } .
* { @link # createBeanDefinitionReader } . Alternatively subclasses may
* Alternatively subclasses may provide a < em > no - op < / em > implementation
* provide a < em > no - op < / em > implementation of { @link # createBeanDefinitionReader }
* of { @link # createBeanDefinitionReader } and override this method to
* and override this method to provide a custom strategy for loading or
* provide a custom strategy for loading or registering bean definitions .
* registering bean definitions .
* @param context the context into which the bean definitions should be loaded
* @param context the context into which the bean definitions should be loaded
* @param locations the resource locations from which to load the bean definitions
* @param locations the resource locations from which to load the bean definitions
* @since 3 . 1
* @since 3 . 1
@ -147,8 +134,7 @@ public abstract class AbstractGenericContextLoader extends AbstractContextLoader
/ * *
/ * *
* Factory method for creating a new { @link BeanDefinitionReader } for
* Factory method for creating a new { @link BeanDefinitionReader } for
* loading bean definitions into the supplied
* loading bean definitions into the supplied { @link GenericApplicationContext context } .
* { @link GenericApplicationContext context } .
* @param context the context for which the BeanDefinitionReader should be created
* @param context the context for which the BeanDefinitionReader should be created
* @return a BeanDefinitionReader for the supplied context
* @return a BeanDefinitionReader for the supplied context
* @see # loadBeanDefinitions
* @see # loadBeanDefinitions