Package com.hybris.backoffice
Class BackofficeModulesManager
- java.lang.Object
-
- com.hybris.backoffice.BackofficeModulesManager
-
public class BackofficeModulesManager extends java.lang.ObjectA tooling class capable of finding and reading module's libraries and holding information about them.
-
-
Constructor Summary
Constructors Constructor Description BackofficeModulesManager(com.hybris.cockpitng.core.modules.LibraryFetcher libraryFetcher, com.hybris.cockpitng.modules.ModulesEnumeration modules)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidassureCorrectExistingModulesStructure()Deprecated, for removal: This API element is subject to removal in a future version.since 1808, introduce only to ease upgrade process - remove all occurrences when removedprotected voidfetchModules(java.io.File libdir, java.util.Properties libsURLs)java.io.FilegetDataRootDir()Gets a root directory for data filesprotected java.util.function.Function<java.lang.String,java.lang.String>[]getDirProcessors()protected com.hybris.cockpitng.core.modules.LibraryFetchergetLibraryFetcher()protected java.net.URIgetManuallyRegisteredModuleUrl(java.lang.String moduleName)java.util.Optional<com.hybris.cockpitng.core.modules.ModuleInfo>getModuleInfo(java.io.File moduleLibFile)Gets information about a specified module that is stored in specified libraryjava.util.Optional<com.hybris.cockpitng.core.modules.ModuleInfo>getModuleInfo(java.lang.String moduleName)Gets information about a specified module.java.io.FilegetModuleJarsRootDir()Gets a root directory, where module's libraries are kept.java.util.Optional<java.io.File>getModuleLib(java.lang.String moduleName)Gets specified module's library.protected java.lang.StringgetModuleLibFileName(java.lang.String moduleName)java.util.Optional<java.lang.String>getModuleName(java.io.File moduleLibFile)Gets name of module that is stored in specified libraryjava.util.Optional<java.lang.String>getModuleName(java.net.URI moduleURI)Provides a name of module that origines from provided URIprotected <R> java.util.Optional<R>getModulePath(java.io.File moduleLib, java.util.Properties moduleLibsURLS, java.util.function.Function<java.lang.String,R> pathConverter)protected <R> java.util.Optional<R>getModulePath(java.lang.String moduleName, java.util.Properties moduleLibsURLS, java.util.function.Function<java.lang.String,R> pathConverter)java.util.List<java.lang.String>getModules()Provides a list of attached backoffice modules.protected com.hybris.cockpitng.modules.ModulesEnumerationgetModulesEnumeration()java.util.Optional<java.net.URI>getModuleSource(java.io.File moduleLib)Gets the origin URI of module that is stored in specified libraryjava.util.Optional<java.net.URI>getModuleSource(java.lang.String moduleName)Gets the origin URI of specified moduleprotected java.io.FilegetRootDir(java.lang.String configuredRootDir, java.util.function.Function<java.lang.String,java.lang.String>... processors)protected booleanisModuleFetched(java.io.File moduleLibFile)booleanisModuleRegistered(java.lang.String moduleName)Checks if specified module is registered.protected java.util.PropertiesloadModuleLibsURLS(java.io.File libRoot)Loads information about libraries mapping: library -> module URLprotected java.lang.StringprocessDir(java.lang.String dir, java.util.function.Function<java.lang.String,java.lang.String>... processors)protected booleanqualifiesForRemoval(java.io.File moduleLibFile, java.util.Properties moduleLibsURLs)protected booleanqualifiesForUnregistering(java.io.File moduleLibFile, java.util.Properties moduleLibsURLs)voidrefreshAndFetch()Reloads all informations about registered backoffice modules.protected voidregisterExistingModules(java.util.Properties libsURLs)protected voidregisterNewModuleImmediately(com.hybris.cockpitng.core.modules.ModuleInfo moduleInfo, java.net.URI source)java.io.FileregisterNewModuleJar(java.lang.String moduleName)Creates and attaches new module libraryprotected voidregisterNewModuleJarImmediately(java.lang.String moduleName, java.io.File moduleLibFile, java.net.URI source, java.util.Properties moduleLibsURLs)protected voidremoveModuleJarImmediately(java.lang.String moduleName, java.io.File moduleLibFile, java.util.Properties moduleLibsURLs)protected voidstoreModuleLibsURLS(java.util.Properties props, java.io.File libRoot)voidunregisterModuleJar(java.lang.String moduleName)Detaches previously attached moduleprotected voidunregisterModuleJar(java.lang.String moduleName, java.io.File moduleLibFile)
-
-
-
Method Detail
-
refreshAndFetch
public void refreshAndFetch() throws com.hybris.cockpitng.core.CockpitApplicationExceptionReloads all informations about registered backoffice modules.All currently loaded modules are detached, newly initialized, modules libraries are being recreated and modules reattached.
- Throws:
com.hybris.cockpitng.core.CockpitApplicationException- throws if modules could not be reattached or libraries could not be recreated
-
isModuleRegistered
public boolean isModuleRegistered(java.lang.String moduleName)
Checks if specified module is registered.- Parameters:
moduleName- name of module- Returns:
trueif module with specified name is already registered
-
getModules
public java.util.List<java.lang.String> getModules()
Provides a list of attached backoffice modules. Returned list contains both fetched modules and manually registered.- Returns:
- list of modules names
- See Also:
registerNewModuleJar(String)
-
getModuleName
public java.util.Optional<java.lang.String> getModuleName(java.net.URI moduleURI)
Provides a name of module that origines from provided URI- Parameters:
moduleURI- module origin- Returns:
- name of module originated from specified URI
-
getModuleLib
public java.util.Optional<java.io.File> getModuleLib(java.lang.String moduleName)
Gets specified module's library.- Parameters:
moduleName- name of module- Returns:
- library of a module
-
getModuleSource
public java.util.Optional<java.net.URI> getModuleSource(java.lang.String moduleName)
Gets the origin URI of specified module- Parameters:
moduleName- name of module- Returns:
- origin URI of module
-
getModuleSource
public java.util.Optional<java.net.URI> getModuleSource(java.io.File moduleLib)
Gets the origin URI of module that is stored in specified library- Parameters:
moduleLib- module's library- Returns:
- origin URI of module
-
getModuleInfo
public java.util.Optional<com.hybris.cockpitng.core.modules.ModuleInfo> getModuleInfo(java.lang.String moduleName)
Gets information about a specified module.Please bear in mind that manager cannot provide module information about manually registerd modules. In this case
Optional.empty()is returned.- Parameters:
moduleName- name of module- Returns:
- information about module
- See Also:
registerNewModuleJar(String)
-
getModuleInfo
public java.util.Optional<com.hybris.cockpitng.core.modules.ModuleInfo> getModuleInfo(java.io.File moduleLibFile)
Gets information about a specified module that is stored in specified library- Parameters:
moduleLibFile- module's library- Returns:
- information about module
-
getModuleName
public java.util.Optional<java.lang.String> getModuleName(java.io.File moduleLibFile)
Gets name of module that is stored in specified library- Parameters:
moduleLibFile- module's library- Returns:
- module name
-
getDataRootDir
public java.io.File getDataRootDir()
Gets a root directory for data files- Returns:
- data root directory
-
getModuleJarsRootDir
public java.io.File getModuleJarsRootDir()
Gets a root directory, where module's libraries are kept.- Returns:
- module's libraries directory
-
registerNewModuleJar
public java.io.File registerNewModuleJar(java.lang.String moduleName) throws java.io.IOException, com.hybris.cockpitng.core.CockpitApplicationExceptionCreates and attaches new module library- Parameters:
moduleName- name of module- Returns:
- module's library
- Throws:
java.io.IOException- thrown is a library could not be created (i.e. file already exists)com.hybris.cockpitng.core.CockpitApplicationException- thrown if a library for this module is already attached
-
registerNewModuleJarImmediately
protected void registerNewModuleJarImmediately(java.lang.String moduleName, java.io.File moduleLibFile, java.net.URI source, java.util.Properties moduleLibsURLs) throws com.hybris.cockpitng.core.CockpitApplicationException- Throws:
com.hybris.cockpitng.core.CockpitApplicationException
-
unregisterModuleJar
public void unregisterModuleJar(java.lang.String moduleName) throws java.io.IOException, com.hybris.cockpitng.core.CockpitApplicationExceptionDetaches previously attached module- Parameters:
moduleName- module name- Throws:
java.io.IOException- thrown if library could not be deletedcom.hybris.cockpitng.core.CockpitApplicationException- thrown if module cannot be detached (i.e. is a built in module)
-
unregisterModuleJar
protected void unregisterModuleJar(java.lang.String moduleName, java.io.File moduleLibFile) throws java.io.IOException, com.hybris.cockpitng.core.CockpitApplicationException- Throws:
java.io.IOExceptioncom.hybris.cockpitng.core.CockpitApplicationException
-
removeModuleJarImmediately
protected void removeModuleJarImmediately(java.lang.String moduleName, java.io.File moduleLibFile, java.util.Properties moduleLibsURLs) throws java.io.IOException- Throws:
java.io.IOException
-
qualifiesForUnregistering
protected boolean qualifiesForUnregistering(java.io.File moduleLibFile, java.util.Properties moduleLibsURLs)
-
qualifiesForRemoval
protected boolean qualifiesForRemoval(java.io.File moduleLibFile, java.util.Properties moduleLibsURLs)
-
getModulePath
protected <R> java.util.Optional<R> getModulePath(java.lang.String moduleName, java.util.Properties moduleLibsURLS, java.util.function.Function<java.lang.String,R> pathConverter)
-
getModulePath
protected <R> java.util.Optional<R> getModulePath(java.io.File moduleLib, java.util.Properties moduleLibsURLS, java.util.function.Function<java.lang.String,R> pathConverter)
-
getLibraryFetcher
protected com.hybris.cockpitng.core.modules.LibraryFetcher getLibraryFetcher()
-
getModulesEnumeration
protected com.hybris.cockpitng.modules.ModulesEnumeration getModulesEnumeration()
-
getDirProcessors
protected java.util.function.Function<java.lang.String,java.lang.String>[] getDirProcessors()
-
getRootDir
protected java.io.File getRootDir(java.lang.String configuredRootDir, java.util.function.Function<java.lang.String,java.lang.String>... processors)
-
processDir
protected java.lang.String processDir(java.lang.String dir, java.util.function.Function<java.lang.String,java.lang.String>... processors)
-
loadModuleLibsURLS
protected java.util.Properties loadModuleLibsURLS(java.io.File libRoot)
Loads information about libraries mapping: library -> module URL- Parameters:
libRoot- root directory for local modules libraries- Returns:
- map <
library path;module URL>
-
registerExistingModules
protected void registerExistingModules(java.util.Properties libsURLs)
-
isModuleFetched
protected boolean isModuleFetched(java.io.File moduleLibFile)
-
assureCorrectExistingModulesStructure
@Deprecated(since="1808", forRemoval=true) protected void assureCorrectExistingModulesStructure()Deprecated, for removal: This API element is subject to removal in a future version.since 1808, introduce only to ease upgrade process - remove all occurrences when removed
-
fetchModules
protected void fetchModules(java.io.File libdir, java.util.Properties libsURLs)
-
getModuleLibFileName
protected java.lang.String getModuleLibFileName(java.lang.String moduleName)
-
storeModuleLibsURLS
protected void storeModuleLibsURLS(java.util.Properties props, java.io.File libRoot)
-
registerNewModuleImmediately
protected void registerNewModuleImmediately(com.hybris.cockpitng.core.modules.ModuleInfo moduleInfo, java.net.URI source)
-
getManuallyRegisteredModuleUrl
protected java.net.URI getManuallyRegisteredModuleUrl(java.lang.String moduleName)
-
-