Class SpringContextService
java.lang.Object
fr.paris.lutece.portal.service.spring.SpringContextService
- All Implemented Interfaces:
PluginEventListener
This class provides a way to use Spring Framework ligthweight containers offering IoC (Inversion of Control) features.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TReturn an instance, which may be shared or independent, of the given bean name.static <T> List<T>getBeansOfType(Class<T> classDef) Returns a list of bean among all that implements a given interface or extends a given classstatic org.springframework.context.ApplicationContextGets the application contextstatic ObjectgetPluginBean(String strPluginName, String strName) Deprecated.static voidinit(javax.servlet.ServletContext servletContext) Initialize a global Application Context containing all beans (core + plugins) Now uses GenericApplicationContext for better performances.static booleanisBeanEnabled(String strBeanName) Indicates if a bean, referenced by its name, is part of an enabled plugin.voidprocessPluginEvent(PluginEvent event) Process a plugin eventstatic voidshutdown()Closes the Spring context
-
Method Details
-
getBean
Return an instance, which may be shared or independent, of the given bean name. This method allows a Spring BeanFactory to be used as a replacement for the Singleton or Prototype design pattern.
The bean is retreived from the main context defined in the WEB-INF/conf/core_context.xml.- Type Parameters:
T- the generic type- Parameters:
strName- The bean's name- Returns:
- The instance of the bean
-
getPluginBean
Deprecated.usegetBean(String)insteadReturn an instance of the given bean name loaded by the a Spring BeanFactory. The bean is retreived from a plugin context defined in the WEB-INF/conf/plugins/[plugin_name]_context.xml.- Parameters:
strPluginName- The Plugin's namestrName- The bean's name- Returns:
- The instance of the bean
-
isBeanEnabled
Indicates if a bean, referenced by its name, is part of an enabled plugin. Per Lutece convention, the plugin is determined from the bean's name prefix. If no prefix is present, the bean is considered enabled.- Parameters:
strBeanName- The bean's name- Returns:
trueif the bean is part of an enabled plugin,falseotherwise
-
init
Initialize a global Application Context containing all beans (core + plugins) Now uses GenericApplicationContext for better performances. A wrong formatted file will not block block context to be built (without the file), but a wrong bean (i.e. cannot be instantiated) will cause a full context failure. Context is less "failure-friendly"- Parameters:
servletContext- The servlet context- Throws:
LuteceInitException- The lutece init exception- Since:
- 2.4
-
getContext
public static org.springframework.context.ApplicationContext getContext()Gets the application context- Returns:
- The application context
-
getBeansOfType
Returns a list of bean among all that implements a given interface or extends a given class- Type Parameters:
T- The class type- Parameters:
classDef- The class type- Returns:
- A list of beans
-
processPluginEvent
Process a plugin event- Specified by:
processPluginEventin interfacePluginEventListener- Parameters:
event- The event to process
-
shutdown
public static void shutdown()Closes the Spring context- Since:
- 5.1.0
-
getBean(String)instead