Class BibernateContextHolder
java.lang.Object
io.github.blyznytsiaorg.bibernate.session.BibernateContextHolder
Internal usage for repositories etc.
Utility class for managing thread-local instances of the Reflections library,
which is used for classpath scanning and metadata retrieval.
- Since:
- 1.0
- Author:
- Blyzhnytsia Team
-
Field Summary
Modifier and TypeFieldDescriptionprivate static final ThreadLocal
<Map<Class<?>, EntityMetadata>> private static final ThreadLocal
<org.reflections.Reflections> Thread-local instance of Reflections for classpath scanning and metadata retrieval.private static final ThreadLocal
<BibernateSession> private static final ThreadLocal
<BibernateSessionFactory> -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Map
<Class<?>, EntityMetadata> Retrieves the entity metadata stored in the current thread's context.static BibernateSession
static BibernateSessionFactory
static org.reflections.Reflections
Gets the thread-local instance of Reflections.static void
static void
static void
setBibernateEntityMetadata
(Map<Class<?>, EntityMetadata> entityMetadata) Sets the entity metadata in the current thread's context.static void
setBibernateSession
(BibernateSession bibernateSession) static void
setBibernateSessionFactory
(BibernateSessionFactory bibernateSessionFactory) static void
setReflection
(String internalPackage) Sets the thread-local instance of Reflections based on the provided internal package for classpath scanning.
-
Field Details
-
reflectionsThreadLocal
Thread-local instance of Reflections for classpath scanning and metadata retrieval. -
entityMetadataContextHolder
-
sessionContextHolder
-
sessionFactoryContextHolder
-
-
Constructor Details
-
BibernateContextHolder
public BibernateContextHolder()
-
-
Method Details
-
getReflections
public static org.reflections.Reflections getReflections()Gets the thread-local instance of Reflections.- Returns:
- The Reflections instance for the current thread.
-
setReflection
Sets the thread-local instance of Reflections based on the provided internal package for classpath scanning.- Parameters:
internalPackage
- The internal package to use for classpath scanning.
-
getBibernateEntityMetadata
Retrieves the entity metadata stored in the current thread's context.- Returns:
- the map containing entity metadata, where the keys are entity classes and the values are corresponding metadata
-
setBibernateEntityMetadata
Sets the entity metadata in the current thread's context.- Parameters:
entityMetadata
- the map containing entity metadata, where the keys are entity classes and the values are corresponding metadata
-
getBibernateSession
-
setBibernateSession
-
resetBibernateSession
public static void resetBibernateSession() -
getBibernateSessionFactory
-
setBibernateSessionFactory
-
resetBibernateSessionFactory
public static void resetBibernateSessionFactory()
-