sergehuber commented on code in PR #720: URL: https://github.com/apache/unomi/pull/720#discussion_r2217294474
########## extensions/groovy-actions/services/src/main/java/org/apache/unomi/groovy/actions/services/impl/GroovyActionsServiceImpl.java: ########## @@ -209,48 +328,182 @@ private void saveActionType(Action action) { definitionsService.setActionType(actionType); } + /** + * {@inheritDoc} + */ @Override public void remove(String id) { - if (groovyCodeSourceMap.containsKey(id)) { - try { - definitionsService.removeActionType( - groovyShell.parse(groovyCodeSourceMap.get(id)).getClass().getMethod("execute").getAnnotation(Action.class).id()); - } catch (NoSuchMethodException e) { - LOGGER.error("Failed to delete the action type for the id {}", id, e); + validateNotEmpty(id, "Script ID"); + + LOGGER.info("Removing script: {}", id); + + ScriptMetadata removedMetadata = scriptMetadataCache.remove(id); + persistenceService.remove(id, GroovyAction.class); + + if (removedMetadata != null) { + Action actionAnnotation = getActionAnnotation(removedMetadata.getCompiledClass()); + if (actionAnnotation != null) { + definitionsService.removeActionType(actionAnnotation.id()); } - persistenceService.remove(id, GroovyAction.class); } + + LOGGER.info("Script {} removed successfully", id); } + + /** + * {@inheritDoc} + * Performance Warning: Compiles on-demand if not cached. + */ @Override - public GroovyCodeSource getGroovyCodeSource(String id) { - return groovyCodeSourceMap.get(id); + public Class<? extends Script> getOrCompileScript(String id) { Review Comment: I've removed this method. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@unomi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org