mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Fix AR-1464: Locale is carried into and out of the Content stack.
ApplicationContextHelper now gives out a singleton ApplicationContext and includes a 'closeApplicationContext' method. Pulled all "org.alfresco.repo.content/**Test" classes into a single test suite. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5722 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -35,17 +35,40 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
*/
|
||||
public class ApplicationContextHelper
|
||||
{
|
||||
private static ClassPathXmlApplicationContext instance;
|
||||
|
||||
/** location of required configuration files */
|
||||
public static final String[] CONFIG_LOCATIONS = new String[] { "classpath:alfresco/application-context.xml" };
|
||||
|
||||
/**
|
||||
* Instantiates a new application context.
|
||||
* Provides a static, single instance of the application context. This method can be
|
||||
* called repeatedly.
|
||||
*
|
||||
* @return Returns a new application context
|
||||
*/
|
||||
public static ApplicationContext getApplicationContext()
|
||||
public synchronized static ApplicationContext getApplicationContext()
|
||||
{
|
||||
return new ClassPathXmlApplicationContext(CONFIG_LOCATIONS);
|
||||
if (instance != null)
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
instance = new ClassPathXmlApplicationContext(CONFIG_LOCATIONS);
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes and releases the application context. On the next call to
|
||||
* {@link #getApplicationContext()}, a new context will be given.
|
||||
*/
|
||||
public synchronized void closeApplicationContext()
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
// Nothing to do
|
||||
return;
|
||||
}
|
||||
instance.close();
|
||||
instance = null;
|
||||
}
|
||||
|
||||
public static void main(String ... args)
|
||||
|
Reference in New Issue
Block a user