fr.paris.lutece.portal.service.spring
Class SpringContextService

java.lang.Object
  extended by fr.paris.lutece.portal.service.spring.SpringContextService
All Implemented Interfaces:
PluginEventListener

public final class SpringContextService
extends java.lang.Object
implements PluginEventListener

This class provides a way to use Spring Framework ligthweight containers offering IoC (Inversion of Control) features.

See Also:
http://www.springframework.org

Method Summary
static java.lang.Object getBean(java.lang.String strName)
          Return an instance, which may be shared or independent, of the given bean name.
static
<T> java.util.List<T>
getBeansOfType(java.lang.Class<T> classDef)
          Returns a list of bean among all that implements a given interface or extends a given class
static org.springframework.context.ApplicationContext getContext()
          Gets the application context
static java.lang.Object getPluginBean(java.lang.String strPluginName, java.lang.String strName)
          Return an instance of the given bean name loaded by the a Spring BeanFactory.
static void init()
          Initialize a global Application Context containing all beans (core + plugins) Now uses GenericApplicationContext for better performances.
 void processPluginEvent(PluginEvent event)
          Process a plugin event
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getBean

public static java.lang.Object getBean(java.lang.String strName)
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.

Parameters:
strName - The bean's name
Returns:
The instance of the bean

getPluginBean

public static java.lang.Object getPluginBean(java.lang.String strPluginName,
                                             java.lang.String strName)
Return 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 name
strName - The bean's name
Returns:
The instance of the bean

init

public static void init()
                 throws LuteceInitException
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"

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

public static <T> java.util.List<T> getBeansOfType(java.lang.Class<T> classDef)
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

public void processPluginEvent(PluginEvent event)
Process a plugin event

Specified by:
processPluginEvent in interface PluginEventListener
Parameters:
event - The event to process


Copyright © 2011 Mairie de Paris. All Rights Reserved.