org.shept.util
Class SpringApplicationContextHolder
java.lang.Object
org.shept.util.SpringApplicationContextHolder
- All Implemented Interfaces:
- org.springframework.context.ApplicationContextAware
public class SpringApplicationContextHolder
- extends Object
- implements org.springframework.context.ApplicationContextAware
- Version:
- $Rev$
- Author:
- Andreas Hahn
This is a helper for getting a reference to the Spring ApplicationContext from
outside the container.
- See Also:
In applicationContext.xml we just need a reference to self to make it work seamlessly
**** NOTE ***************************************************************************
Use this with caution as this approach is limited to one ApplicationContext per JVM !
As a workaround we might use a ThreadLocale for holding the context or
we might want to copy and rename this class for each individual use case,
e.g. MyAppContextHolder
**** NOTE ***************************************************************************
|
Field Summary |
private static org.springframework.context.ApplicationContext |
CONTEXT
|
|
Method Summary |
static org.springframework.context.ApplicationContext |
getContext()
|
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CONTEXT
private static org.springframework.context.ApplicationContext CONTEXT
SpringApplicationContextHolder
public SpringApplicationContextHolder()
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
throws org.springframework.beans.BeansException
- Specified by:
setApplicationContext in interface org.springframework.context.ApplicationContextAware
- Throws:
org.springframework.beans.BeansException
getContext
public static org.springframework.context.ApplicationContext getContext()
- Returns:
- the context
Copyright © 2011. All Rights Reserved.