commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Berin Loritsch <blorit...@apache.org>
Subject Re: [clazz] Clazz APIs Mock-up. Take II
Date Mon, 28 Oct 2002 19:28:11 GMT
Dmitri Plotnikov wrote:
> Here's another iteration of Clazz APIs.

Without looking at the API itself, I like what you are describing
here.  It seems intuitive.  Now, my question is this.  If I have
a ClazzLibrary or a ClazzLoader, can I perform something like this:

ClazzLibrary loader = Clazz.getClazz( something ).getClazzLibrary();
Clazz[] implementingClazzes = loader.findClazzForAttribute( "attribute-name" );


That would be excellent.  (Substitute Property for Attribute if that
is what you want to call it).

> 
> The basic changes:
> 
> 1. I did away with the modelURI and all that nonsense. You should be
> able to uniquely bind an object to its clazz. I don't think any more
> that the idea that the same object can belong to multiple clazzes is
> workable.
> 
> 2. There is now a notion of ClazzLibrary, which produces and caches
> Clazzes of a certain kind.  ClazzLoaders are plug-ins into the
> ClazzLibrary.
> 
> So, the basic algorithm is this:
> 
>   Object something = ...;
> 
>   Clazz clazz = Clazz.getClazz(something);
> 
> The implementation of getClazz does this:
> 
>   for each clazzLibrary {
>     if (clazzLibrary.isMember(instance)){
>        return clazzLibrary.getClazz(instance);
>     }
>   }
> 
> The library may cache clazzes, but does not really have to.  If it
> does, it may do it like this:
> 
>   String name = this.getClazzName(something);
>   Clazz clazz = (Clazz)cache.get(name);
>   if (clazz != null){
>      return clazz;
>   }
> 
>   for each clazzloader {
>     if (clazzloader.isMember(something)){
>       clazz = clazzloader.getClazz(name);
>       name = clazz.getName();
>       cache.put(name, clazz);
>       return clazz;
>     }
>   }
>   throw ...;
> 
> ClazzLibraries are statically registered with Clazz
> Clazzloaders are registered with ClazzLibraries
> 
> The whole point of separation between libraries and loaders is
> performance. The idea is that we quickly determine which library the
> object belongs to and let the corresponding library cache Clazzes if it
> can.
> 
> 3. I have added FieldAccessors we were discussing earlier
> 
> 4. Added getDeclaredFields() and getDeclaredMethods()
> 
> 5. Added "add" and "remove" methods to IndexedFieldAccessor.
> 
> I punted on the idea of handling Maps with the same mechanism as beans.
>  We may want to introduce another mechanism for those.  The issue is
> that there is very little type information on them.  That said, a bean
> can still be implemented as a map (see DynaBean).
> 
> - Dmitri
> 
> 
> 
> __________________________________________________
> Do you Yahoo!?
> Y! Web Hosting - Let the expert host your web site
> http://webhosting.yahoo.com/
> 
> 
> ------------------------------------------------------------------------
> 
> --
> To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


-- 

"They that give up essential liberty to obtain a little temporary safety
  deserve neither liberty nor safety."
                 - Benjamin Franklin


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


Mime
View raw message