> I have also been looking into runtime interface implementation to
> create Mock objects and a basic AOP framework. I'm stuck at the
> exact same thing as you are and the others that are working on this.
> My guess is that we will need to have some kind of bytecode
> manipulation framework to achieve this.
I think we should turn that into a feature request for a future Flash
Player. Of course you can start a project for a bytecode manipulation
framework, but for some of the simpler cases it should be the Player
API itself that should provide a hook. Just look how Java projects
deal with this. In Spring for example they only create a CGLIB proxy
for AOP proxies when you proxy a class that does not implement any
interfaces. Otherwise they proxy the implemented interfaces with JDK
Dynamic Proxies. And that exact thing is something I would like to see
in AS4!
For those of you who don't know Java: The java.lang.reflect.Proxy
class has the following method:
newProxyInstance (ClassLoader loader, Class<?>[] interfaces,
InvocationHandler h)
This will return a proxy class that implements all interfaces
specified with the second parameter and delegates all method
invocations to the specified InvocationHandler instance.
It would really be great to have something similar in AS4!
Typesafe proxy objects are useful for:
- AOP frameworks
- Mock frameworks
- Remote Service Stubs
and very likely for a ton of other things!
Jens Halm
Spicefactory
www.spicefactory.org