mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Allow lazy loading of beans from the ApplicationContext if requested
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@18453 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -39,6 +39,7 @@ public class ApplicationContextHelper
|
||||
{
|
||||
private static ClassPathXmlApplicationContext instance;
|
||||
private static String[] usedConfiguration;
|
||||
private static boolean useLazyLoading = false;
|
||||
|
||||
/** location of required configuration files */
|
||||
public static final String[] CONFIG_LOCATIONS = new String[] { "classpath:alfresco/application-context.xml" };
|
||||
@@ -79,8 +80,13 @@ public class ApplicationContextHelper
|
||||
}
|
||||
// The config has changed so close the current context (if any)
|
||||
closeApplicationContext();
|
||||
|
||||
instance = new ClassPathXmlApplicationContext(configLocations);
|
||||
|
||||
if(useLazyLoading) {
|
||||
instance = new LazyClassPathXmlApplicationContext(configLocations);
|
||||
} else {
|
||||
instance = new ClassPathXmlApplicationContext(configLocations);
|
||||
}
|
||||
|
||||
usedConfiguration = configLocations;
|
||||
|
||||
return instance;
|
||||
@@ -102,6 +108,25 @@ public class ApplicationContextHelper
|
||||
usedConfiguration = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should the Spring beans be initilised in a lazy manner, or
|
||||
* all in one go?
|
||||
* Normally lazy loading/intialising shouldn't be used when
|
||||
* running with the full context, but it may be appropriate
|
||||
* to reduce startup times when using a small, cut down context.
|
||||
*/
|
||||
public static void setUseLazyLoading(boolean lazyLoading) {
|
||||
useLazyLoading = lazyLoading;
|
||||
}
|
||||
/**
|
||||
* Will the Spring beans be initilised in a lazy manner, or
|
||||
* all in one go? The default it to load everything in one
|
||||
* go, as spring normally does.
|
||||
*/
|
||||
public static boolean isUsingLazyLoading() {
|
||||
return useLazyLoading;
|
||||
}
|
||||
|
||||
public static void main(String ... args)
|
||||
{
|
||||
ClassPathXmlApplicationContext ctx = (ClassPathXmlApplicationContext) getApplicationContext();
|
||||
|
Reference in New Issue
Block a user