[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] around advice on constructors
|
chicanery it would be! The result of an IFaceImpl constructor
call is IFaceImpl. It would be bad to permit that to be a
supertype of IFaceImpl. A subclass would work.
See also the FAQ entry
"How do I work with an object right when it is created?"
http://dev.eclipse.org/viewcvs/indextech.cgi/~checkout~/aspectj-home/doc/faq.html#q:adviseconstructors
For the ambitious contributor, Gregor noted that proxying
was on the table at one point in the declare space.
See the email titled
RE: interecepting all calls -- was Re: [aspectj-users]...
This is a commonly-sought pattern. If you find a new solution,
please do post it.
Thanks -
Wes
Daniel McAllansmith wrote:
>
> Hi,
>
> I'm trying to replace all newly created instances of an interface (Iface) with
> dynamic proxies which delegate to the actual new instance.
> This is pretty straight forward if I mandate that all instances must be
> created through factories with a well-known method which returns Iface
> (rather than IfaceImpl).
>
> Ideally I would like to be able to use code like the following:
>
> Iface if = new IfaceImpl();
>
> and an around() which creates a Proxy implementing the classes implemented by
> the result of proceed()
>
> unfortunately this results in a ClassCastException, the dynamic proxy is not
> an instance of IfaceImpl, only Iface.
>
> Does anybody know of any chicanery which might allow me to do this?
>
> Thanks
> Daniel
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users