mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-08-07 23:23:52 +08:00
- 新增 JVM provider 工厂与 JMX、Endpoint 骨架实现 - 暴露 TestJVMConnection 和 JVMProbeCapabilities 并统一 QueryResult 返回 - 刷新 Wails 绑定与 JVM 连接模型,补齐前后端方法签名 - 补充 App 编排测试与 provider 契约测试,避免假成功和静默成功 - 更新需求追踪,记录 Task 2 审查结论与验证证据
61 lines
1.7 KiB
Go
61 lines
1.7 KiB
Go
package app
|
|
|
|
import (
|
|
"GoNavi-Wails/internal/connection"
|
|
"GoNavi-Wails/internal/jvm"
|
|
)
|
|
|
|
var newJVMProvider = jvm.NewProvider
|
|
|
|
func (a *App) TestJVMConnection(cfg connection.ConnectionConfig) connection.QueryResult {
|
|
normalized, err := jvm.NormalizeConnectionConfig(cfg)
|
|
if err != nil {
|
|
return connection.QueryResult{Success: false, Message: err.Error()}
|
|
}
|
|
|
|
provider, err := newJVMProvider(normalized.JVM.PreferredMode)
|
|
if err != nil {
|
|
return connection.QueryResult{Success: false, Message: err.Error()}
|
|
}
|
|
|
|
if err := provider.TestConnection(a.ctx, normalized); err != nil {
|
|
return connection.QueryResult{Success: false, Message: err.Error()}
|
|
}
|
|
|
|
return connection.QueryResult{Success: true, Message: "JVM 连接成功"}
|
|
}
|
|
|
|
func (a *App) JVMProbeCapabilities(cfg connection.ConnectionConfig) connection.QueryResult {
|
|
normalized, err := jvm.NormalizeConnectionConfig(cfg)
|
|
if err != nil {
|
|
return connection.QueryResult{Success: false, Message: err.Error()}
|
|
}
|
|
|
|
items := make([]jvm.Capability, 0, len(normalized.JVM.AllowedModes))
|
|
for _, mode := range normalized.JVM.AllowedModes {
|
|
provider, providerErr := newJVMProvider(mode)
|
|
if providerErr != nil {
|
|
items = append(items, jvm.Capability{
|
|
Mode: mode,
|
|
DisplayLabel: jvm.ModeDisplayLabel(mode),
|
|
Reason: providerErr.Error(),
|
|
})
|
|
continue
|
|
}
|
|
|
|
caps, probeErr := provider.ProbeCapabilities(a.ctx, normalized)
|
|
if probeErr != nil {
|
|
items = append(items, jvm.Capability{
|
|
Mode: mode,
|
|
DisplayLabel: jvm.ModeDisplayLabel(mode),
|
|
Reason: probeErr.Error(),
|
|
})
|
|
continue
|
|
}
|
|
|
|
items = append(items, caps...)
|
|
}
|
|
|
|
return connection.QueryResult{Success: true, Data: items}
|
|
}
|