The knitting engine itself is pretty much fully functional and has a robust set of tests which validate its behavior. I'm now starting to build the PatternDraw functionality as well as some of the other things that need to be written while driving through a pattern. One such thing is a recording mechanism for the knitting engine. It essentially monitors external calls into the engine and records the sequence of those calls. In KnitML, an instruction can be tagged with an identifier so that you can refer to it later in the pattern if you want to issue a repeat, so this feature is very important to the health of a KnitML interpreter.
In order to implement this in the engine, I had to develop a way to record the actions I perform on the engine. The best way to do this is with some sort of AOP advice to the engine itself. I'm familiar with Spring AOP (i.e. the proxy-target style of AOP), but I wanted to dabble with AspectJ. Unfortunately, this has caused me more headaches than it's been worth. AspectJ is actually too good at what it does and I can't figure out how to tell it how to only record a top-level method call into the engine using only a pointcut. I've settled on incrementing / decrementing a depth counter with branching logic in the advice, which actually works pretty well. Ideally, though, sub-calls to methods shouldn't even be selected by the pointcut. Are there any AspectJ experts out there?
[ 1 comment ] ( 6 views ) | [ 0 trackbacks ] | permalink