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 ofFunctionPackage
It is responsible for the import ofFunctionPackage
. The import of aFunctionPackage
means:- the persistence of the
FunctionPackage
itself - the definition of the
Function
contained 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 FunctionPackage
addOrUpdateFunctionPackage(FunctionPackage newFunctionPackage, step.core.objectenricher.ObjectEnricher objectEnricher)
Adds or updates aFunctionPackage
This triggers the import or re-import of theFunction
s contained in the packageFunctionPackage
addOrUpdateResourceBasedFunctionPackage(FunctionPackage newFunctionPackage, step.core.objectenricher.ObjectEnricher objectEnricher)
Adds or updates a resource-basedFunctionPackage
This variation allows for the implicit identification and overwrite of a keyword package based on the name of the associated resourcevoid
close()
protected void
deleteResource(String path)
FunctionPackage
getFunctionPackage(String id)
protected String
getLibraryResourceId(FunctionPackage fpackage)
FunctionPackage
getPackageByResourceName(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 ofFunction
contained in the provided packageprotected String
getResourceId(FunctionPackage fpackage)
protected String
getResourceSplitValue(String resourceLocation)
void
registerAttributeResolver(String key, Function<String,String> value)
void
registerFunctionPackageHandler(FunctionPackageHandler packageHandler)
Registers aFunctionPackageHandler
FunctionPackage
reloadFunctionPackage(String functionPackageId, step.core.objectenricher.ObjectEnricher objectEnricher)
Reloads aFunctionPackage
.void
removeFunctionPackage(String id)
void
start()
-
-
-
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 theFunction
s contained in the package- Parameters:
functionPackageId
- the ID of theFunctionPackage
to 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 aFunctionPackage
This triggers the import or re-import of theFunction
s contained in the package- Parameters:
newFunctionPackage
- theFunctionPackage
to 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-basedFunctionPackage
This variation allows for the implicit identification and overwrite of a keyword package based on the name of the associated resource- Parameters:
newFunctionPackage
- theFunctionPackage
to 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 ofFunction
contained in the provided package- Parameters:
functionPackage
- theFunctionPackage
containing functions- Returns:
- the list of
Function
found 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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
-