
Se un plugin desidera percepire il ciclo di vita, può implementare l'interfaccia 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;
}
Nella directory dei plugin, inserisci un file plugin.properties e il file jar dell'agent nativo.
Ad esempio:
type=traditional
name=demo-agent
version=1.0.0
agentJarPath=demo-agent.jar
Quindi one-java-agent avvierà questo demo-agent.
mvn clean install di bytekitmvn clean package -DskipTests && mvn testmvn clean package -P local -DskipTests viene creato il pacchetto e installata l'ultima versione nella directory locale ~/oneoneagent