Hi All,
I've been pulling my hair out with this one for some time. I'm trying to intercept reads and writes to an array. Reading is working really well but I cannot for the life of me get the writes to work. Here's is mu jboss-aop.xml file:
<?xml version="1.0" encoding="UTF-8"?> <aop> <interceptor class="com.intuit.tax.engine.group.TSingleGroupInterceptor"/> <arrayreplacement class="com.intuit.tax.engine.group.TSingleGroup" /> <prepare expr="field(* com.intuit.tax.engine.group.TSingleGroup->R)"/> <prepare expr="field(* com.intuit.tax.engine.group.TSingleGroup->B)"/> <prepare expr="field(* com.intuit.tax.engine.group.TSingleGroup->S)"/> <arraybind type="READ_WRITE"> <interceptor-ref name="com.intuit.tax.engine.group.TSingleGroupInterceptor"/> </arraybind> </aop>
public Object invoke(Invocation invocation) throws Throwable {
List<ArrayReference> refs = ArrayRegistry.getInstance().getArrayOwners(invocation.getTargetObject());
logger.debug("Owner is " + refs.get(0).getRootObject().getClass().getName() );
// These objects should only have a single owner
TSingleGroup group = (TSingleGroup)refs.get(0).getRootObject();
if ( invocation instanceof ArrayElementReadInvocation) {
logger.debug("Read invocation");
return invoke((ArrayElementReadInvocation) invocation, group);
} else if (invocation instanceof ArrayElementWriteInvocation) {
logger.debug("Write invocation");
return invoke((ArrayElementWriteInvocation) invocation, group);
}
logger.debug("No match for read/write. Invocation is: " + invocation.getClass().getName() );
throw new RuntimeException("This interceptor is for arrays");
}