From: <Vin...@ge...> - 2003-05-09 19:48:18
|
I talked with Jonas (aspectwerkz guy) again, and he is working on implementing dynamic configuration of pointcuts (places where you hook in the class). It's not stable yet and will require some time I guess. In the meantime, we can get around that pretty easily by being very generous when we define pointcuts for classes. The nice thing is that specification of aspects is based on regexp, so we can do something like: <aspect pattern="myclasses.."> <pointcut type="method" pattern"* *(..)"/> </aspect> That will weave all methods all methods in all classes under the myclasses package. In a first phase, we can deal with that and generate a minimal config file for aspectwerkz when the test is run, then load the aspectwerkz framework. Scenario -------- So suppose we want to mock class MyClass. When test code creates a new Mock like this: Mock mock = new Mock(MyClass.class) we generate an aspectwerkz configuration file for MyClass that will weave all methods and fields. We can add advices as necessary from there to do whatever we want. We need to be careful with classloading though. We need to reload the aspectwerkz framework after generating the configuration file, and then reload the MyClass class. I guess we will need to use our own classloader for that inside our Mock framework. Any thoughts on this? -- Vincent |