Package step.functions.packages
Class FunctionPackageManager
- java.lang.Object
-
- step.functions.packages.FunctionPackageManager
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class FunctionPackageManager extends Object implements Closeable
This class is responsible for the handling ofFunctionPackageIt is responsible for the import ofFunctionPackage. The import of aFunctionPackagemeans:- the persistence of the
FunctionPackageitself - the definition of the
Functioncontained in the package - the registration of change watcher of the package file of the
FunctionPackage
-
-
Constructor Summary
Constructors Constructor Description FunctionPackageManager(FunctionPackageAccessor functionPackageAccessor, step.functions.manager.FunctionManager functionRepository, step.resources.ResourceManager resourceManager, step.attachments.FileResolver fileResolver, ch.exense.commons.app.Configuration configuration)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FunctionPackageaddOrUpdateFunctionPackage(FunctionPackage newFunctionPackage, step.core.objectenricher.ObjectEnricher objectEnricher)Adds or updates aFunctionPackageThis triggers the import or re-import of theFunctions contained in the packageFunctionPackageaddOrUpdateResourceBasedFunctionPackage(FunctionPackage newFunctionPackage, step.core.objectenricher.ObjectEnricher objectEnricher)Adds or updates a resource-basedFunctionPackageThis variation allows for the implicit identification and overwrite of a keyword package based on the name of the associated resourcevoidclose()protected voiddeleteResource(String path)FunctionPackagegetFunctionPackage(String id)protected StringgetLibraryResourceId(FunctionPackage fpackage)FunctionPackagegetPackageByResourceName(String resourceName)Load Keyword package based on the first match on the resource nameList<step.functions.Function>getPackageFunctions(String functionPackageId)List<step.functions.Function>getPackagePreview(FunctionPackage functionPackage)Get the list ofFunctioncontained in the provided packageprotected StringgetResourceId(FunctionPackage fpackage)protected StringgetResourceSplitValue(String resourceLocation)voidregisterAttributeResolver(String key, Function<String,String> value)voidregisterFunctionPackageHandler(FunctionPackageHandler packageHandler)Registers aFunctionPackageHandlerFunctionPackagereloadFunctionPackage(String functionPackageId, step.core.objectenricher.ObjectEnricher objectEnricher)Reloads aFunctionPackage.voidremoveFunctionPackage(String id)voidstart()
-
-
-
Constructor Detail
-
FunctionPackageManager
public FunctionPackageManager(FunctionPackageAccessor functionPackageAccessor, step.functions.manager.FunctionManager functionRepository, step.resources.ResourceManager resourceManager, step.attachments.FileResolver fileResolver, ch.exense.commons.app.Configuration configuration)
-
-
Method Detail
-
start
public void start()
-
registerFunctionPackageHandler
public void registerFunctionPackageHandler(FunctionPackageHandler packageHandler)
Registers aFunctionPackageHandler- Parameters:
packageHandler- the instance of theFunctionPackageHandler
-
reloadFunctionPackage
public FunctionPackage reloadFunctionPackage(String functionPackageId, step.core.objectenricher.ObjectEnricher objectEnricher) throws Exception
Reloads aFunctionPackage. This triggers a re-import of theFunctions contained in the package- Parameters:
functionPackageId- the ID of theFunctionPackageto be reloaded- Returns:
- the updated
FunctionPackage - Throws:
Exception- if any error occurs during reloading
-
addOrUpdateFunctionPackage
public FunctionPackage addOrUpdateFunctionPackage(FunctionPackage newFunctionPackage, step.core.objectenricher.ObjectEnricher objectEnricher) throws Exception
Adds or updates aFunctionPackageThis triggers the import or re-import of theFunctions contained in the package- Parameters:
newFunctionPackage- theFunctionPackageto be loaded- Returns:
- the updated
FunctionPackage - Throws:
Exception- if any error occurs during loading
-
addOrUpdateResourceBasedFunctionPackage
public FunctionPackage addOrUpdateResourceBasedFunctionPackage(FunctionPackage newFunctionPackage, step.core.objectenricher.ObjectEnricher objectEnricher) throws Exception
Adds or updates a resource-basedFunctionPackageThis variation allows for the implicit identification and overwrite of a keyword package based on the name of the associated resource- Parameters:
newFunctionPackage- theFunctionPackageto be loaded- Returns:
- the updated
FunctionPackage - Throws:
Exception- if any error occurs during loading
-
registerAttributeResolver
public void registerAttributeResolver(String key, Function<String,String> value)
-
getLibraryResourceId
protected String getLibraryResourceId(FunctionPackage fpackage)
-
getResourceId
protected String getResourceId(FunctionPackage fpackage)
-
getPackagePreview
public List<step.functions.Function> getPackagePreview(FunctionPackage functionPackage) throws Exception
Get the list ofFunctioncontained in the provided package- Parameters:
functionPackage- theFunctionPackagecontaining functions- Returns:
- the list of
Functionfound in theFunctionPackage - Throws:
Exception- if any error occurs during loading
-
getPackageByResourceName
public FunctionPackage getPackageByResourceName(String resourceName) throws Exception
Load Keyword package based on the first match on the resource name- Parameters:
resourceName- the resource name to search with- Returns:
- the first matching Keyword package
- Throws:
Exception- if any error occurs during loading
-
getFunctionPackage
public FunctionPackage getFunctionPackage(String id)
-
removeFunctionPackage
public void removeFunctionPackage(String id)
-
deleteResource
protected void deleteResource(String path)
-
getPackageFunctions
public List<step.functions.Function> getPackageFunctions(String functionPackageId)
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
-