db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Clute, Andrew" <Andrew.Cl...@osn.state.oh.us>
Subject RE: ProxyHelper -- should it remain static?
Date Mon, 28 Mar 2005 19:29:15 GMT
> >  
> > 
> myOjb.getProxyFactory().getReferenceProxyFactory().getRealObject(obj);
> Why do you need the two indirections (proxy factory and 
> reference proxy factory) ?

I don't really like it either, especially when in some cases it starts
to look like this:


To be honest, I made them separate because 1) It was simpler (touched
less points) and 2) To keep Reference proxies and collection proxies
separate -- since configuration for them is separate as well.

Right now I have a base interface named ReferenceProxyFactory that the
implementations extend. I didn't like adding pass through methods on
ProxyFactory to the ReferenceProxyFactory, seemed easier to just get the
reference to the ReferenceProxyFactory. Maybe I can combine ProxyFactory
with the ReferenceProxyFactory into one single ProxyFactory that will
handle all proxy functions (both reference and collection).

> > This works well in most cases, except the ones where the use of 
> > ProxyHelper is completely disconnected from the rest of the 
> system -- 
> > there are no references to a PersistenceBroker, or OJB, or any 
> > configuration information to be able to walk to the 
> > ReferenceProxyFactory. If the goal is to get rid of all static 
> > instances, this is the right way of doing it, and a pattern 
> will need 
> > to be formulated to allow these 'rogue' cases access to 
> that information.
> Do you have an example of such a rogue case ? Are there 
> places in the current OJB (1.1) ?

I am in the process of going through right now and listing all these
'rogue' places. But for an immediate example, StatementsForClassImpl has
no apperant connection to configuation information and it uses

> > Thoughts on this?
> The problem with static is that you cannot get rid of the 
> loaded classes once they've been loaded. This can be quite 
> troublesome, e.g.
> unit-testing the XDoclet module is really a pain because 
> XDoclet itself uses static stuff extensively so I have to use 
> a clean class loader for each and every one of the 850+ unit 
> tests which leads to a total running time of ~30 min for a 
> run of all tests. Also using OJB within an IoC context (e.g. 
> Spring) is much more difficult for the same reasons.
> The general goal in OJB 1.1 is to get rid of static 
> completely (except for the LockMap AFAIK). If need be, then 
> the OJB or PC object can always be stored away in ThreadLocal 
> or the session or application context (for web apps).
> Also, generally I think applications rarely need to determine 
> whether an object is a proxy or the real thing (I at least 
> never had to know yet), so if within OJB all static usages 
> can be replaced by accesses to the OJB object, then IMO we 
> should use this way. I don't think that maintaining the API 
> of ProxyHelper is really necessary, especially because it 
> never was an endorsed API. And the app should be able to have 
> an OJB object available anyway.

Agreed. You have convinced me. I hadn't thought about the classloader
issues, which makes complete sense.

It might be best for me then to refactor all the static references to
ProxyHelper as well to use the OJB, and then deal with the rogue cases
on indiviual basis, once I have a firm grasp on which ones will not

Does this mean that BrokerHelper will be refactored as well? It is one
of the major culprits that uses ProxyHelper statically without any
application references.

Thanks for all the pointers as I get up to speed. My hope is become more
useful to OJB.


To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org

View raw message