The problem we had with our aspect was getting the instance of the cache into the aspect. Normally we would include this in the constructor as a collaborator. Obviously we can't do that because the aspect needs an empty constructor. So what are the options?
- Pass the instance into the method where the aspect is being used, then pull it out in the aspect by getting the method args.
- Use a service locator/factory or some other mechanism to get hold of the instance.
Since we went live with I found out that Castle Windsor has some limited options for AOP, it's called an IoC Interceptor this gives you the ability to intercept every method call on an interface. This is fine for what we have as all the interface calls require caching.