I have a pointcut expression which is working fine when written in java but when written in xml gives error. Since my aspect is written in one project and it's jar is available in other project I have to provide it's mapping in the XML in other projects using the same aspect in JAR.
In Java:
@Pointcut("get(java.lang.String com.air.ghl..*) and @annotation(value)")
public void isDynamicValue(DynamicValue dynamicValue) {}
@Around("isDynamicValue(dynamicValue)")
public Object getDynamicString(DynamicValue dynamicValue, ProceedingJoinPoint thisJoinPoint) throws Throwable {
System.out.println(thisJoinPoint);
System.out.println(" " + dynamicValue);
return thisJoinPoint.proceed();
}
In XML:
<bean id="dynamicValueAspect" class="com.air.ghl.util.DynamicValueAspect"/>
<aop:aspect id="dynamicValue" ref="dynamicValueAspect">
<aop:pointcut id="dynamicValueStringPointCut" expression="get(java.lang.String com.air.ghl..*) and @annotation(value)"/>
<aop:around method="getDynamicString" pointcut-ref="dynamicValueStringPointCut"/>
</aop:aspect
Error while server up:
Caused by: org.aspectj.weaver.tools.UnsupportedPointcutPrimitiveException: Pointcut expression 'get(java.lang.String com.air.ghl..*) && @annotation(value)' contains unsupported pointcut primitive 'get'
at org.aspectj.weaver.tools.PointcutParser.validateKindedPointcut(PointcutParser.java:522)
at org.aspectj.weaver.tools.PointcutParser.validateAgainstSupportedPrimitives(PointcutParser.java:437)
at org.aspectj.weaver.tools.PointcutParser.validateAgainstSupportedPrimitives(PointcutParser.java:412)
at org.aspectj.weaver.tools.PointcutParser.resolvePointcutExpression(PointcutParser.java:311)
at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:294)
at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:208)
at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:194)
at org.springframework.aop.aspectj.AspectJExpressionPointcut.checkReadyToMatch(AspectJExpressionPointcut.java:183)
at org.springframework.aop.aspectj.AspectJExpressionPointcut.getMethodMatcher(AspectJExpressionPointcut.java:169)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.buildSafePointcut(AbstractAspectJAdvice.java:187)
at org.springframework.aop.aspectj.AspectJPointcutAdvisor.<init>(AspectJPointcutAdvisor.java:51)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:148)
Thanks. :)