Skip to content
Open
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
@@ -0,0 +1,25 @@
package org.zstack.header.zql;

/**
* BeforeApiCallExtensionPoint is an extension point that allows plugins
* to perform custom operations before executing API calls.
*
* This provides a hook for business modules to execute pre-processing logic
* (such as health checks, validation, etc.) before API operations are performed.
*/
public interface BeforeApiCallExtensionPoint {
/**
* Check if this extension supports the given VO class
* @param voClass the VO class to check
* @return true if this extension supports the VO class, false otherwise
*/
boolean supports(Class<?> voClass);

/**
* Perform operations before executing API call.
* This allows business modules to trigger health checks or other pre-processing logic.
*
* @param voClass the VO class type
*/
void beforeApiCall(Class<?> voClass);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.zstack.header.zql;

import java.util.List;

/**
* BeforeCallZWatchReturnWithExtensionPoint is an extension point that allows plugins
* to perform custom operations before executing ZQL return with queries.
*
* This provides a hook for business modules to execute pre-processing logic
* (such as health checks, validation, etc.) before monitoring data is retrieved.
*/
public interface BeforeCallZWatchReturnWithExtensionPoint {
/**
* Check if this extension supports the given VO class
* @param voClass the VO class to check
* @return true if this extension supports the VO class, false otherwise
*/
boolean supports(Class<?> voClass);

/**
* Perform operations before executing ZQL return with query.
* This allows business modules to trigger health checks or other pre-processing logic.
*
* @param voClass the VO class type
* @param uuids the list of resource UUIDs to process
*/
void beforeCallZWatch(Class<?> voClass, List<String> uuids);
}
Comment on lines +5 to +28
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for implementations of BeforeCallZWatchReturnWithExtensionPoint
echo "=== 查找 BeforeCallZWatchReturnWithExtensionPoint 的实现类 ==="
rg -nP --type=java 'implements.*BeforeCallZWatchReturnWithExtensionPoint' -g '!**/test/**'

echo -e "\n=== 查找扩展点的调用和注册位置 ==="
rg -nP --type=java 'BeforeCallZWatchReturnWithExtensionPoint' -g '!**/test/**' -A 2 -B 2

echo -e "\n=== 查找 BeforeApiCallExtensionPoint 的定义和使用 ==="
fd -e java -type f | xargs grep -l 'BeforeApiCallExtensionPoint' | head -5

echo -e "\n=== 查找 ZWatch 相关代码 ==="
rg -nP --type=java 'ZWatch|returnWith' -g '!**/test/**' | grep -E '(class|interface|return|with)' | head -30

Repository: MatheMatrix/zstack

Length of output: 5736


🏁 Script executed:

#!/bin/bash
# Get more details on the extension point interface itself
echo "=== 查看扩展点接口定义所在文件 ==="
cat -n header/src/main/java/org/zstack/header/zql/BeforeCallZWatchReturnWithExtensionPoint.java

echo -e "\n=== 查找同目录下的其他扩展点接口 ==="
find header/src/main/java/org/zstack/header/zql -name '*ExtensionPoint.java' -type f

Repository: MatheMatrix/zstack

Length of output: 1880


🏁 Script executed:

#!/bin/bash
# Search for where extension points are registered/collected
echo "=== 查找可能的扩展点管理器或注册机制 ==="
rg -nP --type=java 'plugin.*extension|Extension.*manager|getPluginManager' -g '!**/test/**' | head -20

echo -e "\n=== 查找调用 beforeCallZWatch 的位置 ==="
rg -nP --type=java 'beforeCallZWatch' -g '!**/test/**'

Repository: MatheMatrix/zstack

Length of output: 845


🏁 Script executed:

#!/bin/bash
# Search for BeforeApiCallExtensionPoint
echo "=== 查找 BeforeApiCallExtensionPoint 的定义 ==="
cat -n header/src/main/java/org/zstack/header/zql/BeforeApiCallExtensionPoint.java 2>/dev/null || echo "File not found"

echo -e "\n=== 查找 BeforeApiCallExtensionPoint 的实现 ==="
rg -nP 'implements.*BeforeApiCallExtensionPoint'

echo -e "\n=== 查找 ZQL.java 中的 callReturnWithExtensions 方法 ==="
rg -nP 'callReturnWithExtensions' -A 20 search/src/main/java/org/zstack/zql/ZQL.java

Repository: MatheMatrix/zstack

Length of output: 3846


🏁 Script executed:

#!/bin/bash
# Check PR context and git history
echo "=== 查找 BeforeCallZWatchReturnWithExtensionPoint 相关的 git 信息 ==="
git log --oneline --all | grep -i 'zwatch\|returnwith\|extension' | head -10

echo -e "\n=== 查找 BeforeCallZWatchReturnWithExtensionPoint 在 git 中首次出现的 commit ==="
git log -p --all -- '**/BeforeCallZWatchReturnWithExtensionPoint.java' | head -100

Repository: MatheMatrix/zstack

Length of output: 197


🏁 Script executed:

#!/bin/bash
# Check if there's a callReturnWithExtensions implementation
echo "=== 查找涉及 BeforeCallZWatchReturnWithExtensionPoint 的完整代码段 ==="
rg -nP 'callReturnWithExtensions|BeforeCallZWatch' -B 5 -A 15

echo -e "\n=== 查找 ZQL.java 中处理 returnWith 的位置 ==="
rg -nP 'returnWith\s*=' search/src/main/java/org/zstack/zql/ZQL.java -B 3 -A 3

Repository: MatheMatrix/zstack

Length of output: 8420


🏁 Script executed:

#!/bin/bash
# Final verification - check if there are any TODOs or FIXMEs related to this
echo "=== 查找相关的 TODO 或 FIXME ==="
rg -nP 'TODO|FIXME' header/src/main/java/org/zstack/header/zql/BeforeCallZWatchReturnWithExtensionPoint.java header/src/main/java/org/zstack/header/zql/BeforeApiCallExtensionPoint.java

echo -e "\n=== 查找测试文件中的相关引用 ==="
find . -path '*/test/**' -name '*.java' -type f | xargs grep -l 'BeforeCallZWatchReturnWithExtensionPoint\|BeforeApiCallExtensionPoint' 2>/dev/null || echo "No test files found"

echo -e "\n=== 查找 PR 相关文件或描述 ==="
find . -name 'COMMIT_EDITMSG' -o -name '.git/COMMIT_EDITMSG' 2>/dev/null | xargs cat 2>/dev/null || echo "No commit message found"

Repository: MatheMatrix/zstack

Length of output: 153


扩展点接口未实现且未集成,需要完成实现或移除。

经验证,BeforeCallZWatchReturnWithExtensionPointBeforeApiCallExtensionPoint 两个扩展点存在重大问题:

  1. 完全未实现:整个代码库中不存在任何实现类
  2. 完全未集成beforeCallZWatch() 方法在任何地方都未被调用过
  3. 未注册扩展机制:与 pluginRgty.getExtensionList() 无关联
  4. 接口具有误导性:接口声称提供"执行 ZQL return with 查询前的钩子"功能,但实际上该功能并不存在

实际的 return with 查询处理(ZQL.java 第 351 行和 537-557 行)使用的是不同的 ReturnWithExtensionPoint,而非这两个新扩展点。

需要采取以下任一行动:

  • 在 ZQL 查询处理流程中正式集成这两个扩展点,包括实现注册和调用机制
  • 或在确认不需要后完全移除这两个接口定义
🤖 Prompt for AI Agents
In
header/src/main/java/org/zstack/header/zql/BeforeCallZWatchReturnWithExtensionPoint.java
lines 5-28, the extension interface is unused and misleading; either integrate
it into the ZQL return-with flow or remove it. To fix: if keeping, implement at
least one concrete extension, register the extension with the plugin registry
(pluginRgty.getExtensionList/registration), and invoke beforeCallZWatch(...)
from the ZQL return-with handling code paths (around the existing return-with
logic at ZQL.java lines ~351 and 537-557) passing the VO class and UUID list;
ensure supports(Class<?>) is consulted before calling. If removing, delete this
interface and any related unused BeforeApiCallExtensionPoint stubs and update
documentation and imports accordingly.