Class TopiaApplicationContextCache

java.lang.Object
org.nuiton.topia.persistence.TopiaApplicationContextCache

public class TopiaApplicationContextCache extends Object

This class will provide a TopiaApplicationContext cache. Its usage is not necessary, contexts can be directly created outside of this cache, then the cache will not contain any reference to the created ApplicationContexts.

This class is 'inspired' from the TopiaContextFactory of ToPIA 2.x

Since:
3.0
Author:
Arnaud Thimel (Code Lutin)
  • Field Details

  • Constructor Details

    • TopiaApplicationContextCache

      public TopiaApplicationContextCache()
  • Method Details

    • getContext

      public static <C extends TopiaApplicationContext> C getContext(Properties config, com.google.common.base.Function<Properties,C> createContextFunction)
      Static method that can provide an ApplicationContext. If the found context is closed, or if it does not exist, a new one is created using the given Function<Properties, C>.
      Type Parameters:
      C - the type of TopiaApplicationContext you expect
      Parameters:
      config - the configuration of the context
      createContextFunction - the function that will be in charge of the context creation. It might not be used inside the method if the context is found and still opened
      Returns:
      an opened instance of XyzTopiaApplicationContext
    • getRegisteredContextUrls

      public static List<String> getRegisteredContextUrls()
      Method to get the list of contexts in memory (each context is identified by its URL). To be used for debugging purpose only.
      Returns:
      a list of contexts URLs
    • removeContext

      public static void removeContext(TopiaApplicationContext context)
      Remove the given TopiaApplicationContext from the registered ones
      Parameters:
      context - the context instance to remove