Skip to main content

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

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


Back to the top