-
1. Re: [testing with AOP]
ifrit Apr 8, 2005 9:23 AM (in response to ifrit)Well i'll add more to my request.
What i'd like to do is replace call of new Date();
with my own call of new Date(), that is a Date that is speed up.
Is that realistic?? -
2. Re: [testing with AOP]
kabirkhan Apr 8, 2005 9:27 AM (in response to ifrit)A constructor caller pointcut could help, the question is if the overhead of this is worth the performance increase of your Date class.
Please take a look at the tutorial that comes with the AOP distribution :-) -
3. Re: [testing with AOP]
ifrit Apr 11, 2005 5:25 AM (in response to ifrit)well, i tried many things, but for the moment i can't intercept a constructor call.
public class HelloAOP { public void callMe () { System.out.println("AOP"); } /** * */ public static void main (String args[] ) { new HelloAOP().callMe(); } }
jboss-aop.xml file<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <aop> <!--aspect class="IOExceptionInjector" scope="PER_VM"/> <bind pointcut="call(* $instanceof{java.io.BufferedReader}->readLine()) AND within(HelloAOP)"> <advice name="throwIO" aspect="IOExceptionInjector"/> <interceptor class="HelloAOPInterceptor"/> </bind--> <bind pointcut="call(*->new(..))"> <interceptor class="HelloAOPInterceptor"/> </bind> </aop>
import org.jboss.aop.advice.Interceptor; import org.jboss.aop.joinpoint.Invocation; public class HelloAOPInterceptor implements Interceptor { public String getName() { return "HelloAOPInterceptor"; } public Object invoke(Invocation invocation) throws Throwable { System.out.println("Hello, "); return invocation.invokeNext(); } }
-
4. Re: [testing with AOP]
kabirkhan Apr 12, 2005 3:32 AM (in response to ifrit)Does the constructor tutorial work for you?
-
5. Re: [testing with AOP]
ifrit Apr 12, 2005 8:25 AM (in response to ifrit)well, it may be some malfunction with eclipse, now i can do the interception. it works fine, but i still got a question, is it possible to intercept
public static void main(String [] args)
, for the moment by me it appears as it doesn't work.
I'd like to do that to initialize some variables at the start of application.
Thanks all. -
6. Re: [testing with AOP]
ifrit Apr 12, 2005 9:04 AM (in response to ifrit)like the other one, it doens't work for the first tries, but now it works fine. So for the moment i don"t have other question about aop, but it may come when i may try the hot deployment.
See you later. -
7. Re: [testing with AOP]
ifrit Apr 12, 2005 10:30 AM (in response to ifrit)lol, a question sooner than expected.
how do i write pointcut expression for tables arguments??
for example for the function main(String [] args)
java.lang.String [] isn't accepted -
8. Re: [testing with AOP]
kabirkhan Apr 12, 2005 10:33 AM (in response to ifrit)It should work if you do
"execution(public static void blah.MyClass->main(java.lang.String[])"
-
9. Re: [testing with AOP]
ifrit Apr 13, 2005 3:24 AM (in response to ifrit)yes it works, for the story, it was just a space beetwen String and [ that was the cause of the error, but if there is no space it works perfectly. maybe something to say in the doc.
-
10. Re: [testing with AOP]
ifrit Apr 18, 2005 6:27 AM (in response to ifrit)Is it possible to apply a point cut to an entire branch of packages, like for example
pointcut="..." and within(java.*)
for all class in package java and the subpackages aso.