Re: [Figleaf-developer] Current code changes
Status: Alpha
Brought to you by:
steckman
|
From: Greg S. <ste...@on...> - 2004-07-01 22:58:38
|
The proxy should intercept all method calls. Then for those that are on
a method of interest, for example those for which there is a
PropertyDescriptor, the proxy will perform some special behavior. Such
as firing events. For all the rest, it just invokes the method on the
underlying object. I think it would be better to use the
PropertyDescriptor rather than the Property you wrote, because it allows
you to access the read and write methods for the property directly, so
you can check if they are being called in your interceptor.
The code would look something like:
public Object intercept(Object o, Method method, Object[] args,
MethodProxy methodProxy) throws Throwable {
PropertyDescriptor[] pd=
((Informative)o).getClassDescriptor().getPropertyDescriptors();
for(int i=0; i<pd.length; i++){
if(method==pd[i].getReadMethod(){
//invoke method here...
//...do what the proxy wants
//...or invoke method here
return;
}else if(method==pd[i].getWriteMethod(){
//invoke method here...
//...do what the proxy wants
//...or invoke method here
return;
}
}
//the method invoked was not for a property
method.invoke(o, args);
}
Greg
sam...@ma... wrote:
>OK, I have made a bit of a mistake with the current code. Firstly I've confused
>the notion of defining what properties there are with how they are invoked. This
>is a problem in that it gives the developer power over how get/set are
>implemented under the hood, thereby eliminating the possibility for me to make
>sure I intercept all property calls and fire the relevent change events. With
>that in mind I'm going to change Property to define one method, getName (read
>only etc can wait for a bit). I'll then create a seperate class capable of
>taking an object and executing the properties.
>
>sam
>
>
>
>
|