|
From: Alef A. <al...@jt...> - 2004-06-08 12:16:51
|
> I wouldn't mind such a refactoring. However, I don't see the clear > distinction between the new base class and BeanWrapperImpl: If the base > class contains everything including bean introspection, what exactly is > BeanWrapperImpl supposed to add - respectively, what does your own > subclass do differently? To allow for partial results to be returned from (Hibernate) queries but still letting the clients believe it's a concrete object, my own BeanWrapper is backed by a PropertyValues object rather than the real object. A call to getWrappedInstance() returns a Proxy, proxying to BeanWrapper to retrieve the values. This allows me to without changing anything to the view (the view can still use the databinder and the actual wrapped instance as internally that uses the BeanWrapper backed by the PropertyValues) switch from full-objects to partial objects being returned to the view or fat client. Reason for all this: complex domain model with huge objects (healthcare and the like) with stringent security requirements (certain parts of objects just cannot be transferred over the wire for example). Both the security requirements are met as well as the performance troubles (heavily interlinked domain model, where clients hardly ever need to view more than 5% of all data available). The latter could probably be solved by using the open session in view stuff, but it's problematic with fat and remote clients. > I assume that your own subclass wouldn't implement the BeanWrapper > interface in the first place, because it has its own API way. I just > wonder what it looks like then :-) Yes it does implement BeanWrapper ;-). It has the exact same functionality (you cannot modify properties with it, just read them). > I doubt that there will ever be an alternative implementation of the > BeanWrapper interface itself. It still makes sense to decouple interface > and implementation here, if just for testability. BeanWrapperImpl already > is a quite complex piece that you shouldn't necessarily work with > directly. It's a rare use case, but actually makes sense (to me ;-). Same functionality, different wrapped object. > If the changes don't affect the public BeanWrapper API, I wouldn't mind > including them in 1.0.3 - provided that we're just talking about a > refactoring that does not modify existing functionality. In my use case the only thing that changes is the wrapped instance (more specifically, the data container actually holding the data of the (proxied) interface being wrapped). Basically I would stick with the current API of the BeanWrapper and implement the AbstractBeanWrapper as a somewhat strategy-like class, where the current BeanWrapperImpl just has to override get/setPropertyValue(propertyName, actualName, key) method, currently delegating to the read/writeMethods of the object being wrapped (there is where I need to make changes). alef |