
Si un plugin desea conocer el ciclo de vida, puede implementar la interfaz PluginActivator:
public interface PluginActivator {
// 让插件本身判断是否要启动
boolean enabled(PluginContext context);
public void init(PluginContext context) throws Exception;
/**
* Before calling this method, the {@link PluginState} is
* {@link PluginState#STARTING}, after calling, the {@link PluginState} is
* {@link PluginState#ACTIVE}
*
* @param context
*/
public void start(PluginContext context) throws Exception;
/**
* Before calling this method, the {@link PluginState} is
* {@link PluginState#STOPPING}, after calling, the {@link PluginState} is
* {@link PluginState#RESOLVED}
*
* @param context
*/
public void stop(PluginContext context) throws Exception;
}
En el directorio de plugins, coloque un plugin.properties y el archivo jar del agente original.
Por ejemplo:
type=traditional
name=demo-agent
version=1.0.0
agentJarPath=demo-agent.jar
Entonces one java agent iniciará este demo-agent.
mvn clean install de bytekit primero.mvn clean package -DskipTests && mvn testmvn clean package -P local -DskipTests empaquetará e instalará la última versión localmente en el directorio ~/oneoneagent.