use of org.hotswap.agent.javassist.CtConstructor in project HotswapAgent by HotswapProjects.
the class MyFacesPlugin method facesApplicationAssociateInitialized.
@OnClassLoadEvent(classNameRegexp = "org.apache.myfaces.config.RuntimeConfig")
public static void facesApplicationAssociateInitialized(CtClass ctClass) throws NotFoundException, CannotCompileException {
String buildInitializePlugin = PluginManagerInvoker.buildInitializePlugin(MyFacesPlugin.class);
for (CtConstructor constructor : ctClass.getDeclaredConstructors()) {
constructor.insertAfter(buildInitializePlugin);
}
LOGGER.debug("org.apache.myfaces.config.RuntimeConfig with plugin initialization.");
}
use of org.hotswap.agent.javassist.CtConstructor in project HotswapAgent by HotswapProjects.
the class OsgiEquinoxPlugin method patchEquinox.
@OnClassLoadEvent(classNameRegexp = "org.eclipse.osgi.launch.Equinox")
public static void patchEquinox(CtClass ctClass) throws CannotCompileException {
String initializePlugin = PluginManagerInvoker.buildInitializePlugin(OsgiEquinoxPlugin.class);
String initializeThis = PluginManagerInvoker.buildCallPluginMethod(OsgiEquinoxPlugin.class, "initOsgiEquinox");
for (CtConstructor constructor : ctClass.getDeclaredConstructors()) {
constructor.insertAfter(initializePlugin);
constructor.insertAfter(initializeThis);
}
}
use of org.hotswap.agent.javassist.CtConstructor in project HotswapAgent by HotswapProjects.
the class GlassFishPlugin method transformFelix.
@OnClassLoadEvent(classNameRegexp = "org.apache.felix.framework.Felix")
public static void transformFelix(ClassPool classPool, CtClass ctClass) throws NotFoundException, CannotCompileException {
CtClass[] constructorParams = new CtClass[] { classPool.get("java.util.Map") };
CtConstructor declaredConstructor = ctClass.getDeclaredConstructor(constructorParams);
declaredConstructor.insertBefore("{" + "if ($1 == null) { " + "$1 = new java.util.HashMap();" + "}" + "String __bootDeleg = (String) $1.get(\"" + FRAMEWORK_BOOTDELEGATION + "\");" + "if (__bootDeleg == null) {" + "__bootDeleg = \"\";" + "}" + "if (__bootDeleg.indexOf(\"org.hotswap.agent\") == -1) {" + "__bootDeleg = __bootDeleg.trim();" + "if (!__bootDeleg.isEmpty()) {" + "__bootDeleg = __bootDeleg + \", \";" + "}" + "__bootDeleg = __bootDeleg + \"" + BOOTDELEGATION_PACKAGES + "\";" + "$1.put(\"" + FRAMEWORK_BOOTDELEGATION + "\", __bootDeleg);" + "}" + "}");
// declaredConstructor.insertAfter(PluginManagerInvoker.buildInitializePlugin(GlassFishPlugin.class));
LOGGER.debug("Class 'org.apache.felix.framework.Felix' patched in classLoader {}.");
}
use of org.hotswap.agent.javassist.CtConstructor in project HotswapAgent by HotswapProjects.
the class Hibernate3JPATransformers method annotationMetaDataProviderRegisterVariable.
/**
* Annotation meta data provider register variable.
*
* @param ctClass the ct class
* @throws CannotCompileException the cannot compile exception
*/
@OnClassLoadEvent(classNameRegexp = "org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider")
public static void annotationMetaDataProviderRegisterVariable(CtClass ctClass) throws CannotCompileException {
StringBuilder src = new StringBuilder("{");
src.append(PluginManagerInvoker.buildInitializePlugin(Hibernate3JPAPlugin.class));
src.append(PluginManagerInvoker.buildCallPluginMethod(Hibernate3JPAPlugin.class, "registerAnnotationMetaDataProvider", "this", "java.lang.Object"));
src.append("}");
for (CtConstructor constructor : ctClass.getDeclaredConstructors()) {
constructor.insertAfter(src.toString());
}
ctClass.addMethod(CtNewMethod.make("public void __resetCache() {" + " this.configuredBeans.clear(); " + "}", ctClass));
LOGGER.debug("org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider - added method __resetCache().");
}
use of org.hotswap.agent.javassist.CtConstructor in project HotswapAgent by HotswapProjects.
the class Javac method compileMethod.
private CtBehavior compileMethod(Parser p, MethodDecl md) throws CompileError {
int mod = MemberResolver.getModifiers(md.getModifiers());
CtClass[] plist = gen.makeParamList(md);
CtClass[] tlist = gen.makeThrowsList(md);
recordParams(plist, Modifier.isStatic(mod));
md = p.parseMethod2(stable, md);
try {
if (md.isConstructor()) {
CtConstructor cons = new CtConstructor(plist, gen.getThisClass());
cons.setModifiers(mod);
md.accept(gen);
cons.getMethodInfo().setCodeAttribute(bytecode.toCodeAttribute());
cons.setExceptionTypes(tlist);
return cons;
} else {
Declarator r = md.getReturn();
CtClass rtype = gen.resolver.lookupClass(r);
recordReturnType(rtype, false);
CtMethod method = new CtMethod(rtype, r.getVariable().get(), plist, gen.getThisClass());
method.setModifiers(mod);
gen.setThisMethod(method);
md.accept(gen);
if (md.getBody() != null)
method.getMethodInfo().setCodeAttribute(bytecode.toCodeAttribute());
else
method.setModifiers(mod | Modifier.ABSTRACT);
method.setExceptionTypes(tlist);
return method;
}
} catch (NotFoundException e) {
throw new CompileError(e.toString());
}
}
Aggregations