use of org.hotswap.agent.plugin.deltaspike.DeltaSpikePlugin in project HotswapAgent by HotswapProjects.
the class RepositoryTransformer method patchRepositoryComponent.
/**
* Register DeltaspikePlugin and add reinitialization method to RepositoryComponent
*
* @param ctClass
* @throws CannotCompileException the cannot compile exception
*/
@OnClassLoadEvent(classNameRegexp = "org.apache.deltaspike.data.impl.meta.RepositoryComponent")
public static void patchRepositoryComponent(CtClass ctClass) throws CannotCompileException {
StringBuilder src = new StringBuilder("{");
src.append(PluginManagerInvoker.buildInitializePlugin(DeltaSpikePlugin.class));
src.append(PluginManagerInvoker.buildCallPluginMethod(DeltaSpikePlugin.class, "registerRepoComponent", "this", "java.lang.Object", "this.repoClass", "java.lang.Class"));
src.append("}");
for (CtConstructor constructor : ctClass.getDeclaredConstructors()) {
constructor.insertAfter(src.toString());
}
ctClass.addMethod(CtNewMethod.make("public void " + REINITIALIZE_METHOD + "() {" + " this.methods.clear(); " + " initialize();" + "}", ctClass));
LOGGER.debug("org.apache.deltaspike.data.impl.meta.RepositoryComponent - registration hook and reinitialization method added.");
}
Aggregations