Class SpringContextService

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static <T> T 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)
      Deprecated.
      use getBean(String) instead
      static void init​(javax.servlet.ServletContext servletContext)
      Initialize a global Application Context containing all beans (core + plugins) Now uses GenericApplicationContext for better performances.
      static boolean isBeanEnabled​(java.lang.String strBeanName)
      Indicates if a bean, referenced by its name, is part of an enabled plugin.
      void processPluginEvent​(PluginEvent event)
      Process a plugin event
      static void shutdown()
      Closes the Spring context
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getBean

        public static <T> T 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.
        Type Parameters:
        T - the generic type
        Parameters:
        strName - The bean's name
        Returns:
        The instance of the bean
      • getPluginBean

        @Deprecated
        public static java.lang.Object getPluginBean​(java.lang.String strPluginName,
                                                     java.lang.String strName)
        Deprecated.
        use getBean(String) instead
        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
      • isBeanEnabled

        public static boolean isBeanEnabled​(java.lang.String strBeanName)
        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:
        true if the bean is part of an enabled plugin, false otherwise
      • init

        public static void init​(javax.servlet.ServletContext servletContext)
                         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"
        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

        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
      • shutdown

        public static void shutdown()
        Closes the Spring context
        Since:
        5.1.0