commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dmitri Plotnikov <>
Subject [clazz] Clazz APIs Mock-up. Take II
Date Mon, 28 Oct 2002 16:12:21 GMT
Here's another iteration of Clazz APIs.

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

2. There is now a notion of ClazzLibrary, which produces and caches
Clazzes of a certain kind.  ClazzLoaders are plug-ins into the

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

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
View raw message