Package com.logicaldoc.util
Class Context
- java.lang.Object
-
- com.logicaldoc.util.Context
-
- All Implemented Interfaces:
EventListener
,org.springframework.beans.factory.Aware
,org.springframework.context.ApplicationContextAware
,org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>
public class Context extends Object implements org.springframework.context.ApplicationContextAware, org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>
Utility class collecting static methods related to spring's context.- Since:
- 3.0
- Author:
- Marco Meschieri - LogicalDOC
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
addListener(SystemEventListener evt)
Adds an Listener to a particular Event given fromvoid
close()
Closes this contextstatic Context
get()
Object
getBean(Class clazz)
Retrieves a bean registered in the Spring context using a class name.Object
getBean(String id)
Retrieves a bean registered in the Spring context.List<String>
getBeanIds()
Retrieves the collection of all the bean idsList<Object>
getBeansOfType(Class clazz)
Retrieves the list of bean of the same typeContextProperties
getProperties()
Gets the registry with all the configuration properties for this contextorg.springframework.core.io.Resource
getResource(String resourceLocation)
Returns a Spring-Resourceorg.springframework.core.io.Resource[]
getResources(String resourcePattern)
void
onApplicationEvent(org.springframework.context.ApplicationEvent event)
Processes a newly incoming event on appropriated events that registered itself on itstatic void
refresh()
Reloads the Spring application context.static void
removeListener(SystemEventListener evt)
Removes a particular Listener from the listvoid
setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
-
-
-
Method Detail
-
get
public static Context get()
-
getProperties
public ContextProperties getProperties()
Gets the registry with all the configuration properties for this context- Returns:
- the instance of ContextProperties in the application context
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
- Specified by:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
- Throws:
org.springframework.beans.BeansException
-
getBean
public Object getBean(String id)
Retrieves a bean registered in the Spring context.- Parameters:
id
- The bean identifier- Returns:
- The bean instance
-
getBeanIds
public List<String> getBeanIds()
Retrieves the collection of all the bean ids- Returns:
- the collection of ids of all the beans available in the application context
-
getBeansOfType
public List<Object> getBeansOfType(Class clazz)
Retrieves the list of bean of the same type- Parameters:
clazz
- class to use as filter- Returns:
- the collection of bean instances
-
getBean
public Object getBean(Class clazz)
Retrieves a bean registered in the Spring context using a class name. At first the fully qualified class name is checked, then if nothing was found the simple class name is used as bean id.- Parameters:
clazz
- The bean identifier as class name- Returns:
- The bean instance
-
refresh
public static void refresh()
Reloads the Spring application context.NOTE: use carefully, invoke only during setup when the config.xml is changed
-
addListener
public static void addListener(SystemEventListener evt)
Adds an Listener to a particular Event given from- Parameters:
evt
- the listener- See Also:
SystemEventListener.getSystemStatus()
-
removeListener
public static void removeListener(SystemEventListener evt)
Removes a particular Listener from the list- Parameters:
evt
- the system event
-
getResources
public org.springframework.core.io.Resource[] getResources(String resourcePattern)
-
getResource
public org.springframework.core.io.Resource getResource(String resourceLocation)
Returns a Spring-Resource- Parameters:
resourceLocation
- name of the resource to retrieve- Returns:
- the resource instance
-
onApplicationEvent
public void onApplicationEvent(org.springframework.context.ApplicationEvent event)
Processes a newly incoming event on appropriated events that registered itself on it- Specified by:
onApplicationEvent
in interfaceorg.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>
- Parameters:
event
- the event to process
-
close
public void close()
Closes this context
-
-