Hi,
I'm testing with javassist. Therefor I have created a little sample
application.
I'm running a JSF application on a JBoss server.
---------------------------HelloWorld Class ----------------------------
package com.easypaygroup.easyweb.control.employee;
public class HelloWorld {
public void say(){
System.out.println("say body");
}
}
--------------------------- WebApplication JSF -------------------------
/**
Change the method say of my HelloWorld class
**/
public void jtest(){
try {
ClassPool cp = ClassPool.getDefault();
cp.insertClassPath(new ClassClassPath(this.getClass()));
CtClass cc =
cp.get("com.easypaygroup.easyweb.control.employee.HelloWorld");
CtMethod m = cc.getDeclaredMethod("say");
m.insertBefore("System.out.println(\"*******************Begin***************************\");");
m.insertAfter("System.out.println(\"*******************End***************************\");");
cc.writeFile();
} catch (IOException ex) {
ex.printStackTrace();
} catch (NotFoundException ex) {
ex.printStackTrace();
} catch (CannotCompileException ex) {
ex.printStackTrace();
}
}
/**
Test my HelloWorld Class
**/
public void say(){
HelloWorld emp = new HelloWorld();
emp.say();
}
--------------------- END OF CODE ---------------------------
After changing my HelloWorld class. I call the method say, the output I get is
say body
But I expect
*******************Begin***************************
say body
"*******************End***************************
Does somebody knows where I'm wrong?
Thx in adv,
Pieter
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3935770#3935770
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3935770
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user