Jens: Indeed, we need Proxy#newProxyInstance in AS. This is how EasyMock creates its mocks. There is an equivalent mechanism in c# that is used by Rhino Mocks, which is similar to EasyMock insofar as it uses the record/replay metaphor.
Cristophe: I would love to talk about this offline. Do you use Google Talk? I am aduston. I think that doing this in run time is a losing proposition. I think we have to resort to compile-time code generation. We can create an Eclipse build task and have it generate our mocks. Here's to the eventual end of hand-coding mocks in AS3, Adam --- In [email protected], Jens Halm <[EMAIL PROTECTED]> wrote: > > > > 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 >

