Is there support/plans for advising (with AOP) a service with an executer that executes the call, so you get more control. An implementation of an Executor is the ThreadPoolExecutor (part of the new concurrency library in jdk5.0)
I sometimes have the need to do more than just make a service active (maybe his own thread) or synchronized (no own thread.. only one thread active in the service). I want to control the number of threads that are calling the service. I want to control what to do if the maximum number of threads are active (maybe a timeout.. or just wait). Maybe even control if a call has expired.
Mostly I use a ThreadPoolExecutor (jdk5.0 has good support) in a wrapper around the service, so the new service interface is the same as the original version. Calls where the caller depens on the result of the callee could be implemented by a Future, but mostly it are 'asynchronous' service interfaces (post and forget).
But this is a lot of (boring) work and I think AOP could be a better solution. A new class could be generated, based on the orginal, with the concurrency control structures in it. And even metadata could be used to add the needed information in a declarative manner.
Something like this for example. Only 2 threads can be active..Code:interface FooService{ @Active(number=2) void doSomething(); }
So.. are there any plans to implement this? Are there problems I have overlooked? Is something like this already implemented?


Reply With Quote