You can write plugin directly as a part of your application. Set pluginPackages=your.plugin.package
inside
your hotswap-agent.properties
configuration to discover @Plugin
annotated classes. You will also need
agent JAR dependency to compile, but be careful NOT to add the JAR to your application, it must be loaded only
as a javaagent. Maven dependency:
<dependency>
<groupId>org.hotswapagent</groupId>
<artifactId>hotswap-agent-core</artifactId>
<version>1.4.0</version>
<scope>provided</scope>
</dependency>
Example:
@Plugin(name = "MyPlugin")
public class MyPlugin {
@OnClassLoadEvent(classNameRegexp = ".*", events = LoadEvent.REDEFINE)
public static void onAnyReload() {
MyCache.clear();
}
@OnResourceFileEvent(path = "/", filter = ".*.resource")
public void onResourceChanged() {
MyResourceCache.clear();
}
}
See ExamplePlugin (part of TestApplication) to go through a commented simple plugin. Read agent readme to understand agent concepts. Check existing plugins source code for more examples.