Class BaseApplicationContextHelper

  • Direct Known Subclasses:
    DataModelTestApplicationContextHelper

    public abstract class BaseApplicationContextHelper
    extends java.lang.Object
    Helper class to provide static and common access to the Spring application context.
    Author:
    Derek Hulley
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.ClassLoader buildClassLoader​(java.lang.String[] classLocations)
      Build a classloader for the given classLocations, using the thread's context class loader as its parent.
      static void closeApplicationContext()
      Closes and releases the application context.
      static org.springframework.context.ApplicationContext getApplicationContext​(java.lang.String[] configLocations)  
      static org.springframework.context.ApplicationContext getApplicationContext​(java.lang.String[] configLocations, java.lang.String[] classLocations)
      Provides a static, single instance of the application context.
      static boolean isContextLoaded()
      Is there currently a context loaded and cached?
      static boolean isNoAutoStart()
      Will Subsystems with the autoStart=true property set on them be allowed to auto start? The default is to honour the spring configuration and allow them to, but they can be prevented if required.
      static boolean isUsingLazyLoading()
      Will the Spring beans be initilised in a lazy manner, or all in one go? The default it to load everything in one go, as spring normally does.
      static void setNoAutoStart​(boolean noAutoStart)
      Should the autoStart=true property on subsystems be honoured, or should this property be ignored and the auto start prevented? Normally we will use the spring configuration to decide what to start, but when running tests, you can use this to prevent the auto start.
      static void setUseLazyLoading​(boolean lazyLoading)
      Should the Spring beans be initilised in a lazy manner, or all in one go? Normally lazy loading/intialising shouldn't be used when running with the full context, but it may be appropriate to reduce startup times when using a small, cut down context.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BaseApplicationContextHelper

        public BaseApplicationContextHelper()
    • Method Detail

      • getApplicationContext

        public static org.springframework.context.ApplicationContext getApplicationContext​(java.lang.String[] configLocations)
      • buildClassLoader

        public static java.lang.ClassLoader buildClassLoader​(java.lang.String[] classLocations)
                                                      throws java.io.IOException
        Build a classloader for the given classLocations, using the thread's context class loader as its parent.
        Parameters:
        classLocations - String[]
        Returns:
        ClassLoader
        Throws:
        java.io.IOException
      • getApplicationContext

        public static org.springframework.context.ApplicationContext getApplicationContext​(java.lang.String[] configLocations,
                                                                                           java.lang.String[] classLocations)
                                                                                    throws java.io.IOException
        Provides a static, single instance of the application context. This method can be called repeatedly.

        If the configuration requested differs from one used previously, then the previously-created context is shut down.

        Returns:
        Returns an application context for the given configuration
        Throws:
        java.io.IOException
      • closeApplicationContext

        public static void closeApplicationContext()
        Closes and releases the application context. On the next call to getApplicationContext(String[]) , a new context will be given.
      • setUseLazyLoading

        public static void setUseLazyLoading​(boolean lazyLoading)
        Should the Spring beans be initilised in a lazy manner, or all in one go? Normally lazy loading/intialising shouldn't be used when running with the full context, but it may be appropriate to reduce startup times when using a small, cut down context.
      • isUsingLazyLoading

        public static boolean isUsingLazyLoading()
        Will the Spring beans be initilised in a lazy manner, or all in one go? The default it to load everything in one go, as spring normally does.
      • setNoAutoStart

        public static void setNoAutoStart​(boolean noAutoStart)
        Should the autoStart=true property on subsystems be honoured, or should this property be ignored and the auto start prevented? Normally we will use the spring configuration to decide what to start, but when running tests, you can use this to prevent the auto start.
      • isNoAutoStart

        public static boolean isNoAutoStart()
        Will Subsystems with the autoStart=true property set on them be allowed to auto start? The default is to honour the spring configuration and allow them to, but they can be prevented if required.
      • isContextLoaded

        public static boolean isContextLoaded()
        Is there currently a context loaded and cached?