Package com.smeup.kokos.sdk.util
Class LibraryVersionDumpMgr
java.lang.Object
com.smeup.kokos.sdk.util.LibraryVersionDumpMgr
Manages the version information of source libraries.
The version information is retrieved from the source library's Git repository (in local environment)
or from a `.dslversion` file (in production environment).
This class is responsible for maintaining a synchronized map of source library versions,
logging their version details, and ensuring thread-safe access. It follows the Singleton
design pattern to ensure only one instance of the manager exists.
Key functionalities include:
- Creating and retrieving the singleton instance.
- Logging and updating version information for source libraries.
- Handling thread-safe operations on the source library version map.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordRepresents the version information of a source library. -
Method Summary
Modifier and TypeMethodDescriptionvoiddumpLibraryVersion(String name, SourceLibrary sourceLibrary) Logs the version information of a source library.voiddumpLibraryVersionIfNeeded(Path filePath, Consumer<LibraryVersionDumpMgr.SourceLibraryVersion> seenLibraryVersion) Dumps the library version information if the specified file path is associated with any source library passed to the createInstance method.static LibraryVersionDumpMgrRetrieves the singleton instance of `LibraryVersionDumpMgr`.static LibraryVersionDumpMgrnewInstance(Map<String, SourceLibrary> libraries) Creates a new instance of `LibraryVersionDumpMgr`.
-
Method Details
-
newInstance
Creates a new instance of `LibraryVersionDumpMgr`. This method initializes the singleton instance with the provided libraries. If an instance already exists, a warning is logged.- Parameters:
libraries- a map of source library names to their corresponding `SourceLibrary` objects- Returns:
- the newly created instance of `LibraryVersionDumpMgr`
-
getInstance
Retrieves the singleton instance of `LibraryVersionDumpMgr`. This method ensures that the `LibraryVersionDumpMgr` instance has been initialized before returning it. If the instance is not initialized, an `IllegalStateException` is thrown.- Returns:
- the singleton instance of `LibraryVersionDumpMgr`
- Throws:
IllegalStateException- if the `LibraryVersionDumpMgr` instance is not initialized
-
dumpLibraryVersion
Logs the version information of a source library.- Parameters:
name- the name of the source librarysourceLibrary- the source library object containing path and other details
-
dumpLibraryVersionIfNeeded
public void dumpLibraryVersionIfNeeded(Path filePath, Consumer<LibraryVersionDumpMgr.SourceLibraryVersion> seenLibraryVersion) Dumps the library version information if the specified file path is associated with any source library passed to the createInstance method. This method checks if the given file path belongs to any source library by iterating through the map of source library versions. If a match is found, it retrieves the last modified time of the file and logs the library version information if needed.- Parameters:
filePath- the path of the file to check and dump library version information forseenLibraryVersion- a consumer to handle the processed `SourceLibraryVersion` only if seen time is before the last modified time of the file
-