commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dmitri Plotnikov <dplot...@yahoo.com>
Subject Re: [Clazz] subclassing vs. configuration (Was: Extending Clazz)
Date Fri, 20 Jun 2003 19:41:25 GMT
Victor,

--- victor.volle@gmxpro.net wrote:
> Dmitry:
> > > > 2. The reason all those things are implemented as subclasses
> rather
> > > > than configuration-based instances is precisely to avoid the
> need
> > > > for configuration.  In any complex environment you are working
> with
> > > > lots of ClassLoaders, which are allocated by some container. 
> > > > A ClazzLoader is  automatically allocated by Clazz for each 
> > > > ClassLoader as needed. 
> > > > Where would we put the hook for configuration?
> 
> Victor:
> > > But the fifth step, adding the new ClazzLoader,  _is_ a
> configuration
> > > anyway. 
> 
> Dmitry:
> > It's done at the factory level: you register your custom
> ClazzLoader
> > class (not instance) with a ClazzLoaderFactory.  The factory will
> > instantiate it as needed.
> 
> Sorry, I do not understand it. You do not want configuration because 
> you are not sure where to put the "configuration hook". But where
> (in my client code) do I register the ClazzLoader class. Here
> I have the "configuration hook". 
Right, but there is a big difference between registering a class with a
factory and actually instantiating a ClazzLoader and configuring it. 
When you register the class with the factory, it just sits there
dormant, with no overhead at all, until it is actually needed, which is
when it is instantiated.

> Or is the problem based on registering a ClazzLoader class 
> and not an instance?
I don't see it as a problem - I see it as a solution.

> I have further looked into the code and the problem seems to be 
> based on creating a ClazzLoader (zz) instance for each 
> ClassLoader (ss). Is this necessary? Why not have another
> getClazzForName(String) method that takes a ClassLoader?
> 
>    getClazzForName(String, ClassLoader)
> 
> Wouldn't that be much simpler?

The reason you allocate a ClazzLoader(zz) for each ClassLoader (ss) is
that you want to cache clazzes, rather than re-doing introspection
every time somebody needs a clazz.

> 
> Victor

- Dmitri

__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

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


Mime
View raw message