Class GroovyActionsServiceImpl
- java.lang.Object
-
- org.apache.unomi.groovy.actions.services.impl.GroovyActionsServiceImpl
-
- All Implemented Interfaces:
GroovyActionsService
public class GroovyActionsServiceImpl extends Object implements GroovyActionsService
High-performance GroovyActionsService implementation with pre-compilation, hash-based change detection, and thread-safe execution.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceGroovyActionsServiceImpl.GroovyActionsServiceConfig
-
Constructor Summary
Constructors Constructor Description GroovyActionsServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Class<? extends groovy.lang.Script>getCompiledScript(String id)Retrieves a pre-compiled script class from cache.ScriptMetadatagetScriptMetadata(String actionName)Retrieves script metadata for monitoring and change detection.voidonDestroy()voidremove(String actionName)Removes a Groovy action and all associated metadata.voidsave(String actionName, String groovyScript)Saves a Groovy action script with compilation and validation.voidsetDefinitionsService(DefinitionsService definitionsService)voidsetPersistenceService(PersistenceService persistenceService)voidsetSchedulerService(SchedulerService schedulerService)voidstart(GroovyActionsServiceImpl.GroovyActionsServiceConfig config, org.osgi.framework.BundleContext bundleContext)
-
-
-
Method Detail
-
setDefinitionsService
public void setDefinitionsService(DefinitionsService definitionsService)
-
setPersistenceService
public void setPersistenceService(PersistenceService persistenceService)
-
setSchedulerService
public void setSchedulerService(SchedulerService schedulerService)
-
start
public void start(GroovyActionsServiceImpl.GroovyActionsServiceConfig config, org.osgi.framework.BundleContext bundleContext)
-
onDestroy
public void onDestroy()
-
save
public void save(String actionName, String groovyScript)
Saves a Groovy action script with compilation and validation.This method compiles the script, validates it has the required annotations, persists it, and updates the internal cache. If the script content hasn't changed, recompilation is skipped.
Implementation performs hash-based change detection to skip unnecessary recompilation.- Specified by:
savein interfaceGroovyActionsService- Parameters:
actionName- the unique identifier for the actiongroovyScript- the Groovy script source code
-
remove
public void remove(String actionName)
Removes a Groovy action and all associated metadata.This method removes the action from both the cache and persistent storage, and cleans up any registered action types in the definitions service.
- Specified by:
removein interfaceGroovyActionsService- Parameters:
actionName- the unique identifier of the action to remove
-
getCompiledScript
public Class<? extends groovy.lang.Script> getCompiledScript(String id)
Retrieves a pre-compiled script class from cache.This is the preferred method for script execution as it returns pre-compiled classes without any compilation overhead. Returns
nullif the script is not found in the cache.- Specified by:
getCompiledScriptin interfaceGroovyActionsService- Parameters:
id- the unique identifier of the action- Returns:
- the compiled script class, or
nullif not found in cache
-
getScriptMetadata
public ScriptMetadata getScriptMetadata(String actionName)
Retrieves script metadata for monitoring and change detection.The returned metadata includes content hash, compilation timestamp, and the compiled class reference. This is useful for monitoring tools and debugging.
- Specified by:
getScriptMetadatain interfaceGroovyActionsService- Parameters:
actionName- the unique identifier of the action- Returns:
- the script metadata, or
nullif not found
-
-