Re: [aspectwerkz-user] Pointcut problem in dynamic weaving
Alexandre Vasseur <[email protected]> Mon, 11 Jul 2005 17:32:54 +0200
| Newsgroups | gmane.comp.java.aspectwerkz.user |
|---|---|
| Message-ID | <[email protected]> |
Hi Could you send me (privately) a test case or little application that shows both problems - for the verify error with the static initalization - for the issue when hotdeploying an aspect that is using some cflow() pointcut Usually you need to send: - the main class - the aspect - the xml file (and avoid having third parties dependancies so that I can replay it as soon as I receive the code sample) Thanks Alex On 7/8/05, Sebastien Vallon <[email protected]> wrote: > > Hi everybody, > I have two problems with pointcut and dynamic weaving. I think both are > related but I'll try to explain anyway. > > In my application I defined a pointcut on a certain method: Pointcut > workingMethod. Inside the around advice related to this pointcut I want to > deploy an aspect I want to be executed immediately. Meaning my aspect was > defined as @After("WorkingMethod"). But when I try to load this aspect > dynamically I have this error message: > > Exception in thread "main" java.lang.VerifyError: (class: > core/C_1__1709278340_1090156494___AW_JoinPoint, method: > aw$staticinitialization signature: ()V) Illegal constant pool index > at core.C.work(Unknown Source) > at Main.main(Unknown Source) > Result: 1 > > I suppose this error is due to the fact that at the time I try to load the > dynamic aspect, the execution point is already in the method itself, > preventing to add another aspect related to this method. > > Am I right ? is there a solution to this problem ? > > To overcome this problem I created an empty object with an empty method. > This method is called in the around aspect. Here is the code I wrote: > > @Around("workingMethod") > public Object framework(JoinPoint joinPoint) throws Throwable { > > if( !deployed ){ > hdlAfter = Deployer.deploy(aspects.TempAspect.class); > }else{ > Deployer.undeploy(hdlAfter); > } > deployed = !deployed; > > > final Object result = joinPoint.proceed(); > > > CallToAspect callTheAspect = new CallToAspect(); > callTheAspect.callToAspect(); > > > return result; > } > > My dynamic aspects are now set to execute after the callToAspect() method. > This works. However as I may have numerous dynamic aspects I need to > identify the ones I want to execute. I was therefore thinking at adding a > cflow() to my dynamic aspect pointcut. > It used to be @Expression("execution(void callToAspect())") but I would like > it to be @Expression("execution(void callToAspect()) && > cflow(execution(core.C.work()))") for instance. I tested it in static mode > and it works. The around aspect is considered as part of the cflow() of the > method. But in dynamic mode it fails. Here is the exception: > > Exception in thread "main" java.lang.NoClassDefFoundError: > org/codehaus/aspectwerkz/cflow/Cflow_9800697 > at > framework.CallToAspect_1_541186724_2069866918___AW_JoinPoint.invoke(Unknown > Source) > at framework.CallToAspect.callToAspect(Unknown Source) > at framework.Framework.framework(Unknown Source) > at > core.Work_1_1525100228_3656070___AW_JoinPoint.proceed(Unknown > Source) > at > core.Work_1_1525100228_3656070___AW_JoinPoint.invoke(Unknown > Source) > at core.Work.work(Unknown Source) > at core.A.foo(Unknown Source) > at Main.main(Unknown Source) > > Does anyone have an idea to solve either one or both of this problems ? > > Thanks, > > Sebastien