Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Do cflow targets need to be woven?

Yes, the cflow target is woven to indicate 'this cflow is being entered' then at the real target place to weave it is a very simple/quick check to see 'are we in the cflow?'. There would be a less optimal implementation that looks at the stack trace at the actual join point target but we've never investigated implementing that. I suppose as a sub-optimal workaround you could inspect that stack yourself in your advice if you really can't weave the actual cflow target.

cheers,
Andy

On 24 April 2017 at 21:21, Eric B <ebenzacar@xxxxxxxxx> wrote:
I'm trying to use cflow to limit the scope of my pointcut, but it when I add the cflow argument, the pointcut is not intercepting the call at all.  In my build process, the cflow target is not part of the weaving at all.  Does the cflow target need to be part of the build/weave process?  Or is my pointcut wrong?

@Aspect
class MultiChoiceNullAspect{
@Pointcut("cflowbelow(execution( void javax.faces.webapp.FacesServlet.service(..) ) && !within(MultiChoiceNullAspect))")
public void facesServletCFlow(){}
@Pointcut("facesServletCFlow() && execution( public org.model.questionnaire.MultiChoiceItem* get*(..))")
public void multiChoiceObjects() {}
@Around("multiChoiceObjects()")
public Object emptyMultiChoice( final ProceedingJoinPoint pjp) throws Throwable{
Object o = pjp.proceed();
// if the return object is null, create an empty MultiChoice object instead 
if( o == null ){
return new MultiChoiceItem();
}

return o;
}
}



And my build instructions:
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>aspectj-maven-plugin</artifactId>
                <version>1.10</version>
                <configuration>
                    <showWeaveInfo>true</showWeaveInfo>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <complianceLevel>${java.version}</complianceLevel>
                    <encoding>UTF-8</encoding>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>test-compile</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjtools</artifactId>
                        <version>${aspectj.version}</version>
                    </dependency>
                </dependencies>
            </plugin>



Essentially, I'm trying to advise the execution of all getters that return MultiChoiceItem* when they are as part of the javax.faces.webapp.FacesServlet.service() method/flow.

Does the FacesServlet class need to be passed to the ajc compiler as well?  Or are the cflow() arguments just evaluated at runtime and don't need to be present in the compiler?  If the later, what am I doing wrong - why is my pointcut not triggering?

Thanks,

Eric


_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top