Hi,
I have an @Aspect that runs if I use the -javaagent aspectjweaver.jar option to do the LTW.
If I try to use the spring-instrumentation.jar the classes are not woven.
This is my test context.
The aspect to access the fieldsCode:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd "> <context:load-time-weaver aspectj-weaving="on"/> method="aspectOf" /--> </beans>
Is the problem the field access??Code:@Aspect public class UserEntityListener { private final static Logger LOG = LoggerFactory.getLogger(UserEntityListener.class); public UserEntityListener() { } @Pointcut("set(@com.example.springaspectjtest.auditable.AuditableProperty * *.*)") public void setField() {}; @Before("setField()") public void setFieldImpl(JoinPoint jp) { final Object[] args = jp.getArgs(); String newValue = args.length == 1 ? String.valueOf(args[0]) : Arrays.toString(args); final FieldSignature signature = (FieldSignature)jp.getSignature(); try { final Field field = signature.getField(); final boolean accessable = field.isAccessible(); field.setAccessible(true); try { Object oldValue = signature.getField().get(jp.getTarget()); LOG.info(String.format("FIELD set : %s\n\t%s\n\tfrom %s\n\t\toldvalue %s\n\t\tnew value %s", jp.getTarget().toString(), jp.getSignature().toString(), jp.getThis().toString(), String.valueOf(oldValue), newValue)); } finally { field.setAccessible(accessable); } } catch (IllegalAccessException ex) { LOG.error("ERROR ", ex); } } public void reset() { //Dummy NoOp } }
any idea whats happening? I can priovide a smal maven project as zip file, if needed.
Arne


Reply With Quote
