java - How to execute selected methods of a given class -
for example,
class { @test public int add() { .... } @test public int sub() { .... } @test public int div() { .... } @testnew public void mul() { .... } }
consider class named a..in class have annotated methods , want display methods has annotation @test. can done using java reflection's getannotation() methods. i'm getting proper output this. i've list of @test annotated methods displayed in jsp page precede checkbox each , every entry of output.
for example:
int add() [*] int sub() [*] int div() [] [execute]
consider square brackets checkboxes.
[*] -->selected checkbox.. [ ] -->not selected checkbox...
now,i want execute selected check box methods , display result. need generate xml files selected methods know much. don't know how can generate xml files selected methods result of selected methods.
once select checkbox , click on [execute] button ,result of selected methods should displayed.
how can ?
using reflection
class<?> c = class.forname("a"); method method = c.getdeclaredmethod("add", parametertypes) method.invoke (objecttoinvokeon, params)
more info -->
http://java.sun.com/docs/books/tutorial/reflect/member/methodinvocation.html
Comments
Post a Comment