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
Modifier and TypeMethodDescriptionstatic void
Adds an Listener to a particular Event given fromvoid
close()
Closes this contextboolean
containsBean
(String id) Says if a bean is or not availablestatic Context
get()
<R> R
Retrieves a bean registered in the Spring context using a class name.Retrieves a bean registered in the Spring context.Retrieves the collection of all the bean ids<R> List
<R> getBeansOfType
(Class<R> requiredType) Retrieves the list of bean of the same typeGets 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 itvoid
refresh()
Reloads the Spring application context.static void
Removes a particular Listener from the listvoid
setApplicationContext
(org.springframework.context.ApplicationContext applicationContext)
-
Method Details
-
get
-
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
Retrieves a bean registered in the Spring context.- Parameters:
id
- The bean identifier- Returns:
- The bean instance
-
containsBean
Says if a bean is or not available- Parameters:
id
- identifier of the bean- Returns:
- true if the bean is available
-
getBeanIds
Retrieves the collection of all the bean ids- Returns:
- the collection of ids of all the beans available in the application context
-
getBeansOfType
Retrieves the list of bean of the same type- Parameters:
requiredType
- class to use as filter- Returns:
- the collection of bean instances
-
getBean
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:
requiredType
- The bean identifier as class name- Returns:
- The bean instance
-
refresh
public void refresh()Reloads the Spring application context.NOTE: use carefully, invoke only during setup when the config.xml is changed
-
addListener
Adds an Listener to a particular Event given from- Parameters:
evt
- the listener- See Also:
-
removeListener
Removes a particular Listener from the list- Parameters:
evt
- the system event
-
getResources
-
getResource
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
-