I am trying to extend flash.utils.Proxy so that I can intercept calls
made on an innerObject and provide cross cutting services/advices like
writing to a log or caching... (AOP...)
The big problem is that the user of the innerObject needs to be aware
of the ProxyClass otherwise - calls will not be intercepted.
for example:
a proxy factory class looks like this-
public class ProxyFactory
{
private var _target:*;
public function ProxyFactory(target:*){
_target = target;
}
public function GetProxy():*{
var proxy:AOPProxy = new AOPProxy(_target);
return (proxy);
}
}
and the usage:
var person:Person = factory.GetProxy();
this will produce a runtime casting exception!!
the fix is to do something like this:
var person:AOPProxy = factory.GetProxy();
or even -
var person:* = factory.GetProxy();
BUT - this is bad because the user of the factory is aware of the
proxy AND he loose code assist... he cannot see the properties of the
Person Class.
Does any body know of a better way (maybe creating runtime code
generated proxies??- code emission...)
Thanks,
Chen Bekor
Software Architect.