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
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/

Attachment: clazz.zip
Description: clazz.zip

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

Reply via email to