Package ubic.gemma.core.context
Class SpringContextUtils
java.lang.Object
ubic.gemma.core.context.SpringContextUtils
Methods to create Spring contexts for Gemma manually. This is meant to be used by CLIs only.
- Author:
- pavlidis
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.springframework.context.ApplicationContextgetApplicationContext(boolean testing, boolean isWebApp, String[] additionalConfigurationLocations) Deprecated.static org.springframework.context.ApplicationContextgetApplicationContext(String[] activeProfiles, String... additionalConfigurationLocations) Obtain an application context for Gemma.static voidprepareContext(org.springframework.context.ApplicationContext context) Prepare a given context for prime time.
-
Constructor Details
-
SpringContextUtils
public SpringContextUtils()
-
-
Method Details
-
getApplicationContext
public static org.springframework.context.ApplicationContext getApplicationContext(String[] activeProfiles, String... additionalConfigurationLocations) throws org.springframework.beans.BeansException Obtain an application context for Gemma.- Parameters:
activeProfiles- list of active profiles, for testing useEnvironmentProfiles.TESTadditionalConfigurationLocations- a list of additional configuration location to load beans from- Returns:
- a fully initialized
ApplicationContext - Throws:
org.springframework.beans.BeansException- if the creation of the context fails
-
getApplicationContext
@Deprecated public static org.springframework.context.ApplicationContext getApplicationContext(boolean testing, boolean isWebApp, String[] additionalConfigurationLocations) throws org.springframework.beans.BeansException Deprecated.this method does not support producing Gemma Web contexts, please migrate existing code to usegetApplicationContext(String[], String...)instead.- Parameters:
isWebApp- If true, aUnsupportedOperationExceptionwill be raised since retrieving the Web application context is not supported from here. Use WebApplicationContextUtils.getWebApplicationContext() instead. This is only kept for backward-compatibility with external scripts.- Throws:
org.springframework.beans.BeansException- See Also:
-
prepareContext
public static void prepareContext(org.springframework.context.ApplicationContext context) Prepare a given context for prime time.Perform the following steps:
- ensure that the security context holder strategy is set to
SecurityContextHolder.MODE_INHERITABLETHREADLOCAL - activate the
devprofile as a fallback if no profile are active - activate the
schedulerprofile ifquartzOnis set - verify that exactly one environment profile is active (see
EnvironmentProfiles) - log an informative message with the context version and active profiles
- ensure that the security context holder strategy is set to
-
getApplicationContext(String[], String...)instead.