Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,10 @@
* This class encapsulates all metadata associated with a compiled Groovy script,
* including content hash for efficient change detection and the compiled class
* for direct execution without recompilation.
* </p>
Copy link
Copy Markdown
Contributor

@Fgerthoffert Fgerthoffert Sep 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you removing </p> while keeping <p> ?

Aren't they never closed ?

Copy link
Copy Markdown
Contributor Author

@jayblanc jayblanc Sep 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, according to Javadoc Doc : https://www.oracle.com/technical-resources/articles/java/javadoc-tool.html#format there is no closing tag for paragraphs:

If you have more than one paragraph in the doc comment, separate the paragraphs with a <p> paragraph tag, as shown.

*
* <p>
* Thread Safety: This class is immutable and thread-safe. All fields are final
* and the class provides no methods to modify its state after construction.
* </p>
*
*
* @since 2.7.0
*/
public final class ScriptMetadata {
Expand All @@ -43,10 +40,10 @@ public final class ScriptMetadata {
private final String contentHash;
private final long creationTime;
private final Class<? extends Script> compiledClass;

/**
* Constructs a new ScriptMetadata instance.
*
*
* @param actionName the unique name/identifier of the action
* @param scriptContent the raw Groovy script content
* @param compiledClass the compiled Groovy script class
Expand All @@ -62,17 +59,17 @@ public ScriptMetadata(String actionName, String scriptContent, Class<? extends S
if (compiledClass == null) {
throw new IllegalArgumentException("Compiled class cannot be null");
}

this.actionName = actionName;
this.scriptContent = scriptContent;
this.contentHash = calculateHash(scriptContent);
this.creationTime = System.currentTimeMillis();
this.compiledClass = compiledClass;
}

/**
* Calculates SHA-256 hash of the given content.
*
*
* @param content the content to hash
* @return Base64 encoded SHA-256 hash
* @throws RuntimeException if SHA-256 algorithm is not available
Expand All @@ -86,14 +83,13 @@ private String calculateHash(String content) {
throw new RuntimeException("SHA-256 algorithm not available", e);
}
}

/**
* Determines if the script content has changed compared to new content.
* <p>
* This method uses SHA-256 hash comparison for efficient change detection
* without storing or comparing the full script content.
* </p>
*
*
* @param newContent the new script content to compare against
* @return {@code true} if content has changed, {@code false} if unchanged
* @throws IllegalArgumentException if newContent is null
Expand All @@ -104,53 +100,53 @@ public boolean hasChanged(String newContent) {
}
return !contentHash.equals(calculateHash(newContent));
}

/**
* Returns the action name/identifier.
*
*
* @return the action name, never null
*/
public String getActionName() {
return actionName;
public String getActionName() {
return actionName;
}

/**
* Returns the original script content.
*
*
* @return the script content, never null
*/
public String getScriptContent() {
return scriptContent;
public String getScriptContent() {
return scriptContent;
}

/**
* Returns the SHA-256 hash of the script content.
*
*
* @return Base64 encoded content hash, never null
*/
public String getContentHash() {
return contentHash;
public String getContentHash() {
return contentHash;
}

/**
* Returns the timestamp when this metadata was created.
*
*
* @return creation timestamp in milliseconds since epoch
*/
public long getCreationTime() {
return creationTime;
public long getCreationTime() {
return creationTime;
}

/**
* Returns the compiled Groovy script class.
* <p>
* This class can be used to create new script instances for execution
* without requiring recompilation.
* </p>
*
*
*
* @return the compiled script class, never null
*/
public Class<? extends Script> getCompiledClass() {
return compiledClass;
public Class<? extends Script> getCompiledClass() {
return compiledClass;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
* This service provides functionality to load, compile, cache, and execute
* Groovy scripts as actions within the Apache Unomi framework. It implements
* optimized compilation and caching strategies to achieve high performance.
* </p>
*
* <p>
* Key features:
* <ul>
Expand All @@ -37,12 +35,9 @@
* <li>Thread-safe compilation and execution</li>
* <li>Unified caching architecture for compiled scripts</li>
* </ul>
* </p>
*
* <p>
* Thread Safety: Implementations must be thread-safe as this service
* is accessed concurrently during script execution.
* </p>
*
* @see GroovyAction
* @see ScriptMetadata
Expand All @@ -56,7 +51,6 @@ public interface GroovyActionsService {
* 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.
* </p>
*
* @param actionName the unique identifier for the action
* @param groovyScript the Groovy script source code
Expand All @@ -70,7 +64,6 @@ public interface GroovyActionsService {
* <p>
* This method removes the action from both the cache and persistent storage,
* and cleans up any registered action types in the definitions service.
* </p>
*
* @param actionName the unique identifier of the action to remove
* @throws IllegalArgumentException if id is null
Expand All @@ -83,7 +76,6 @@ public interface GroovyActionsService {
* This is the preferred method for script execution as it returns
* pre-compiled classes without any compilation overhead. Returns
* {@code null} if the script is not found in the cache.
* </p>
*
* @param actionName the unique identifier of the action
* @return the compiled script class, or {@code null} if not found in cache
Expand All @@ -97,7 +89,6 @@ public interface GroovyActionsService {
* The returned metadata includes content hash, compilation timestamp,
* and the compiled class reference. This is useful for monitoring
* tools and debugging.
* </p>
*
* @param actionName the unique identifier of the action
* @return the script metadata, or {@code null} if not found
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,9 @@ public static void waitForYellowStatus(CloseableHttpClient httpClient, String es

/**
* Updates documents in an index based on a specified query.
*
* <p>This method sends a request to update documents that match the provided query in the specified index. The update operation is
* performed asynchronously, and the method waits for the task to complete before returning.</p>
* <p>
* This method sends a request to update documents that match the provided query in the specified index. The update operation is
* performed asynchronously, and the method waits for the task to complete before returning.
*
* @param httpClient the CloseableHttpClient used to send the request to the Elasticsearch server
* @param esAddress the address of the Elasticsearch server
Expand All @@ -332,10 +332,10 @@ public static void updateByQuery(CloseableHttpClient httpClient, String esAddres

/**
* Deletes documents from an index based on a specified query.
*
* <p>This method sends a request to the Elasticsearch cluster to delete documents
* <p>
* This method sends a request to the Elasticsearch cluster to delete documents
* that match the provided query in the specified index. The deletion operation is
* performed asynchronously, and the method waits for the task to complete before returning.</p>
* performed asynchronously, and the method waits for the task to complete before returning.
*
* @param httpClient the CloseableHttpClient used to send the request to the Elasticsearch server
* @param esAddress the address of the Elasticsearch server
Expand Down
Loading