org.spicefactory.cinnamon.config.spring
Class ApplicationContextUtil

java.lang.Object
  extended by org.spicefactory.cinnamon.config.spring.ApplicationContextUtil

public class ApplicationContextUtil
extends Object

Contains utility methods for obtaining and setting Springs root WebApplicationContext from/to the applicationMap.

Author:
Jens Halm

Constructor Summary
ApplicationContextUtil()
           
 
Method Summary
static Boolean containsApplicationContext(Map<String,Object> applicationMap)
          Indicates if the given applicationMap contains Springs root WebApplicationContext.
static ApplicationContext getApplicationContext(Map<String,Object> applicationMap)
          Returns Springs root WebApplicationContext contained in the given applicationMap.
static Boolean setApplicationContext(Map<String,Object> applicationMap, ApplicationContext context)
          Puts the specified ApplicationContext instance into the given Map with the key WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE if there is no ApplicationContext already mapped to that key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ApplicationContextUtil

public ApplicationContextUtil()
Method Detail

getApplicationContext

public static ApplicationContext getApplicationContext(Map<String,Object> applicationMap)
Returns Springs root WebApplicationContext contained in the given applicationMap. This implementation assumes a standard Spring web application setup where the root WebApplicationContext can be retrieved from the ServletContext with the attribute name WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE.

Parameters:
applicationMap - the applicationMap (in a web application the wrapped ServletContext)
Returns:
the root ApplicationContext
Throws:
ConfigurationException - if the given applicationMap does not contain the root ApplicationContext under the default key.

containsApplicationContext

public static Boolean containsApplicationContext(Map<String,Object> applicationMap)
Indicates if the given applicationMap contains Springs root WebApplicationContext. This implementation assumes a standard Spring web application setup where the root WebApplicationContext can be retrieved from the ServletContext with the attribute name WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE.

Parameters:
applicationMap - the applicationMap (in a web application the wrapped ServletContext) to examine
Returns:
true if the given applicationMap contains Springs root WebApplicationContext

setApplicationContext

public static Boolean setApplicationContext(Map<String,Object> applicationMap,
                                            ApplicationContext context)
Puts the specified ApplicationContext instance into the given Map with the key WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE if there is no ApplicationContext already mapped to that key.

Parameters:
applicationMap - the applicationMap (in a web application the wrapped ServletContext)
context - the ApplicationContext to put into the Map
Returns:
true if the specified ApplicationContext was put into the Map