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
public class Context extends Object implements org.springframework.context.ApplicationContextAware, org.springframework.context.ApplicationListener
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 voidaddListener(SystemEvent evt)Adds an Listener to a particular Event given fromvoidclose()Closes this contextstatic Contextget()ObjectgetBean(Class clazz)Retrieves a bean registered in the Spring context using a class name.ObjectgetBean(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 typeContextPropertiesgetProperties()Gets the registry with all the configuration properties for this contextorg.springframework.core.io.ResourcegetResource(String resourceLocation)Returns a Spring-Resourceorg.springframework.core.io.Resource[]getResources(String resourcePattern)voidonApplicationEvent(org.springframework.context.ApplicationEvent event)Processes a newly incoming event on appropriated events that registered itself on itstatic voidrefresh()Reloads the Spring application context.static voidremoveListener(SystemEvent evt)Removes a particular Listener from the listvoidsetApplicationContext(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:
 setApplicationContextin 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(SystemEvent evt)
Adds an Listener to a particular Event given from- Parameters:
 evt- the listener- See Also:
 SystemEvent.getSystemStatus()
 
- 
removeListener
public static void removeListener(SystemEvent 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:
 onApplicationEventin interfaceorg.springframework.context.ApplicationListener- Parameters:
 event- the event to process
 
- 
close
public void close()
Closes this context 
 - 
 
 -