The following code works fine from a unit test where I build up the test fixture in code. It also works fine if I create a unit test where I define the necessary beans in a spring config xml file. It doesn't work however when I deploy the code and context file to a Java EE container.
public class QuicCsvUpdaterChains {
private Map<Process, QuicCsvUpdater> updateChains = new Hashtable<Process, QuicCsvUpdater>();
public QuicCsvUpdaterChains() {}
public QuicCsvUpdaterChains(Map<Process, List<QuicCsvUpdater>> updaters) {
Set<Entry<Process, List<QuicCsvUpdater>>> entrySet = updaters.entrySet();
for(Entry<Process, List<QuicCsvUpdater>> entry : entrySet) {
updateChains.put(entry.getKey(), join(new ArrayList<QuicCsvUpdater>(entry.getValue())));
}
}
private QuicCsvUpdater join(List<QuicCsvUpdater> updaters) {
if(updaters.size() == 1) {
return updaters.remove(0);
}
QuicCsvUpdater updater = updaters.remove(0);
QuicCsvUpdater next = join(updaters);
updater.setNextInChain(next);
return updater;
}
The call to updater.setNextInChain(next) never actually sets next on the updater. From what I can see in the debugger stepping in at the line updater.setNextInChain(next), in Cglib2AopProxy the call to set takes place on the target but the proxy is never updated.
Why would it be that in Cglib2AopProxy the target is updated but the proxy is never updated to reflect the change?
In Cglib2AopProxy I get to this line
else {
// We need to create a method invocation...
retVal = new CglibMethodInvocation(proxy, target, method, args, targetClass, chain, methodProxy).proceed();
}
What I see is that the 'setNextInChain' method is called on the target but not on the proxy, I'm presuming the proxy needs to be updated becuase in my code where I call updater.setNextInChain(next) it's the proxy that I hold a reference to.
Aucun commentaire:
Enregistrer un commentaire