Package org.nuiton.topia.persistence
Class TopiaApplicationContextCache
java.lang.Object
org.nuiton.topia.persistence.TopiaApplicationContextCache
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 Summary
FieldsModifier and TypeFieldDescriptionprotected static Map<Properties,TopiaApplicationContext> Cache that contains all some already registered caches -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <C extends TopiaApplicationContext>
CgetContext(Properties config, com.google.common.base.Function<Properties, C> createContextFunction) Static method that can provide an ApplicationContext.Method to get the list of contexts in memory (each context is identified by its URL).static voidremoveContext(TopiaApplicationContext context) Remove the given TopiaApplicationContext from the registered ones
-
Field Details
-
contextCache
Cache that contains all some already registered caches
-
-
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 givenFunction<Properties, C>.- Type Parameters:
C- the type of TopiaApplicationContext you expect- Parameters:
config- the configuration of the contextcreateContextFunction- 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
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
Remove the given TopiaApplicationContext from the registered ones- Parameters:
context- the context instance to remove
-