Interface Plugin
public interface Plugin
Plugin SPI - Defines the lifecycle callbacks for a plugin
插件 SPI - 定义插件的生命周期回调
Implement this interface to create a plugin that participates in the managed lifecycle (discover → load → start → stop → unload).
实现此接口以创建参与托管生命周期的插件 (发现 → 加载 → 启动 → 停止 → 卸载)。
Usage Examples | 使用示例:
public class AuthPlugin implements Plugin {
@Override
public void onStart(PluginContext context) {
System.out.println("Auth plugin started: " + context.pluginId());
}
@Override
public void onStop() {
System.out.println("Auth plugin stopped");
}
}
Security | 安全性:
- Thread-safe: Implementation dependent - 线程安全: 取决于实现
- Since:
- JDK 25, opencode-base-classloader V1.0.3
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidonStart(PluginContext context) Called when the plugin is started 插件启动时调用default voidonStop()Called when the plugin is stopped 插件停止时调用
-
Method Details
-
onStart
Called when the plugin is started 插件启动时调用- Parameters:
context- the plugin context providing identity and descriptor | 提供身份和描述符的插件上下文
-
onStop
default void onStop()Called when the plugin is stopped 插件停止时调用
-