[Figleaf-developer] No need for proxies - at least at the moment
Status: Alpha
Brought to you by:
steckman
|
From: <sam...@ma...> - 2004-07-02 08:35:03
|
I had a major brainwave last night and realised we don't need proxies at all. Here is my new proposed workflow for introducing developer-defined beans into the system. 1. The ProxyFactory (now needs to be renamed) gets given an object 2. It invokes an ObjectIntrospector to retrieve an Informative implementation 3. It creates an implementation of the new interface Bean (needs a rename?) which implements Informative and Observable. In addition it defines two new methods: Object getProperty(String propertyName); void setProperty(String propertyName, Object propertyValue); These methods fire change events accordingly without any need for proxied method interception. 4. This is returned to the UI layer (or whatever). 5. To interact with this developer defined object, the UI first gets a list of properties to expose them (which comes from the underlying Informative implementation). To invoke a method, it calls getProperty() or setProperty() with the relevent property name. This removes the need for all proxies, results in easier to test, less complicaed code, and I think gives the UI evervything it needs. We may still need proxies for remoting/securirty/validation or whatever, but for the moment it doesn't look like we need to. Changes to support this: * The ProxyFactory/CglibProxyFactory will become a BeanFactory/BeanFactoryImpl. The existing getProxy becomes makeBean * Property becomes your PropertyDescriptor * Mutable becomes Observable So now you can call: Bean bean = beanFactory.makeBean(developerDefinedObject); ... bean.getProperties(); bean.getName(); bean.getDescription(); ... bean.addChangeListener(); bean.removeChangeListener(); ... Object retVal = bean.getProperty(propertyName); bean.setProperty(propertyName, newValue); Further down the line getProperty and setProperty can throw validation exceptions, or we can add an isValidPropertyValue() method or something. What do you think? sam |