I am not really done with the first draft yet, but since I will have to
take about a week off from clazz, I wanted to commit what
I have done so far and give you a chance to look it over.
My initial focus was on implementing functionality equivalent to
that of java.beans.Introspector. There are several pretty cool
improvements over the Introspector:
1. Highly customizable design.
- You can add new ClazzLibraries for new kinds of Clazzes. So far
there is only one such library, ReflectClazzLibrary, but more are
coming.
- You can add new ClazzLoaders to customize Clazz generation for
individual clazzes or groups of clazzes.
- In the case of Reflected clazzes, you can change the way accessor
methods are bound to properties. For example, if you want to make
read methods look like "readFoo()" instead of "getFoo()", it is a matter
of overriding one method on ReflectScalarPropertyIntrospector.
- In the case of Reflected clazzes, you can add new categories of
properties. The default list of categories consists of List (which
works for Lists as well as arrays), Mapped and Scalar properties.
2. In the case of ReflectedClazzes, richer mapping of accessors to
properties: methods like getFoo(int), setBar(key,value), getFooKeySet()
etc are recognized.
3. If a property is Mapped, the corresponding clazzProperty.get()
returns a Map, even if all the bean defines is a bunch of accessor
methods like getFoo(key). The Map implementation returned by
clazzProperty will invoke those accessors if they exist (see the
ReflectedMap).
4. Similarly, if a property is a List or an array, the corresponding
value is a List (see ReflectedList).
5. Powerful diagnostic facility that optionally prints details of
introspection. You won't have to wonder any more: "how come it does
not see my property 'foo'". I have attached a sample diagnostic log.
Check it out, it's pretty cool.
The implemented functionality comes with tests, but as you will see not
all functionality is implemented yet.
Don't look for ATTRIBUTES, DELEGATORS or BEAN stuff yet - I'll get to
that in a week or so.
- Dmitri
[Clazz: org.apache.commons.clazz.reflect.ReflectableInstance
[baseProperty
[type] java.lang.String
[accessor methods:
[get~()] public java.lang.String
org.apache.commons.clazz.reflect.ReflectedSuperclazzInstance.getBaseProperty()
[set~(v)] public void
org.apache.commons.clazz.reflect.ReflectedSuperclazzInstance.setBaseProperty(java.lang.String)
]
]
[booleanProperty
[type] boolean
[accessor methods:
[get~()] public boolean
org.apache.commons.clazz.reflect.ReflectableInstance.isBooleanProperty()
[set~(v)] public void
org.apache.commons.clazz.reflect.ReflectableInstance.setBooleanProperty(boolean)
]
]
[halfProperty
[type] java.lang.String
[accessor methods:
[get~()] public java.lang.String
org.apache.commons.clazz.reflect.ReflectableInstance.getHalfProperty()
[set~(v)] public void
org.apache.commons.clazz.reflect.ReflectedSuperclazzInstance.setHalfProperty(java.lang.String)
]
]
[intArray (list)
[type] [I
[accessor methods:
[get~()] public int[]
org.apache.commons.clazz.reflect.ReflectableInstance.getIntArray()
[set~(v)] public void
org.apache.commons.clazz.reflect.ReflectableInstance.setIntArray(int[])
]
]
[integerProperty
[type] int
[accessor methods:
[get~()] public int
org.apache.commons.clazz.reflect.ReflectableInstance.getIntegerProperty()
[set~(v)] public void
org.apache.commons.clazz.reflect.ReflectableInstance.setIntegerProperty(int)
]
]
[mappedBooleans (mapped)
[type] java.util.Map
[accessor methods:
[get~()] public java.util.Map
org.apache.commons.clazz.reflect.ReflectableInstance.getMappedBooleans()
[set~(v)] public void
org.apache.commons.clazz.reflect.ReflectableInstance.setMappedBooleans(java.util.Map)
]
]
[*mappedInteger - NOT a list property
- Does not have either get() or get(int) method
[content type] java.lang.Integer
[accessor methods:
[remove~(v)] public void
org.apache.commons.clazz.reflect.ReflectableInstance.removeMappedInteger(java.lang.Integer)
]
]
[mappedInteger (mapped)
[key type] java.lang.Integer
[content type] java.lang.Integer
[accessor methods:
[get~(key)] public java.lang.Integer
org.apache.commons.clazz.reflect.ReflectableInstance.getMappedInteger(java.lang.Integer)
[set~(key,v)] public void
org.apache.commons.clazz.reflect.ReflectableInstance.setMappedInteger(java.lang.Integer,java.lang.Integer)
[remove~(key)] public void
org.apache.commons.clazz.reflect.ReflectableInstance.removeMappedInteger(java.lang.Integer)
[get~KeySet()] public java.lang.Integer[]
org.apache.commons.clazz.reflect.ReflectableInstance.getMappedIntegerKeys()
]
]
[mappedIntegerKeys (list)
[type] [Ljava.lang.Integer;
[accessor methods:
[get~()] public java.lang.Integer[]
org.apache.commons.clazz.reflect.ReflectableInstance.getMappedIntegerKeys()
]
]
[*mappedString - NOT a list property
- Does not have either get() or get(int) method
[content type] java.lang.String
[accessor methods:
[remove~(v)] public void
org.apache.commons.clazz.reflect.ReflectableInstance.removeMappedString(java.lang.String)
]
]
[mappedStringKeys
[type] java.util.Set
[accessor methods:
[get~()] public java.util.Set
org.apache.commons.clazz.reflect.ReflectableInstance.getMappedStringKeys()
]
]
[mappedStrings (mapped)
[aliases: mappedString]
[type] java.util.Map
[key type] java.lang.String
[content type] java.lang.String
[accessor methods:
[get~()] public java.util.Map
org.apache.commons.clazz.reflect.ReflectableInstance.getMappedStrings()
[set~(v)] public void
org.apache.commons.clazz.reflect.ReflectableInstance.setMappedStrings(java.util.Map)
[get~(key)] public java.lang.String
org.apache.commons.clazz.reflect.ReflectableInstance.getMappedString(java.lang.String)
[set~(key,v)] public void
org.apache.commons.clazz.reflect.ReflectableInstance.setMappedString(java.lang.String,java.lang.String)
[remove~(key)] public void
org.apache.commons.clazz.reflect.ReflectableInstance.removeMappedString(java.lang.String)
[get~KeySet()] public java.util.Set
org.apache.commons.clazz.reflect.ReflectableInstance.getMappedStringKeys()
]
]
[*notAMappedProperty - NOT a mapped property
- Does not have either get() or get(key) method
[key type] java.lang.String
[content type] java.lang.String
[accessor methods:
[set~(key,v)] public void
org.apache.commons.clazz.reflect.ReflectableInstance.setNotAMappedProperty(java.lang.String,java.lang.String)
]
]
[*notAProperty - NOT a property
- Has extraneous accessors:
public java.lang.Object
org.apache.commons.clazz.reflect.ReflectableInstance.getNotAProperty()
- Get() and set(v) types do not match
[type] boolean
[accessor methods:
[get~()] public boolean
org.apache.commons.clazz.reflect.ReflectableInstance.isNotAProperty()
[set~(v)] public void
org.apache.commons.clazz.reflect.ReflectableInstance.setNotAProperty(java.lang.String)
]
]
[string (list)
[content type] java.lang.String
[accessor methods:
[get~(int)] public java.lang.String
org.apache.commons.clazz.reflect.ReflectableInstance.getString(int)
[set~(int,v)] public void
org.apache.commons.clazz.reflect.ReflectableInstance.setString(int,java.lang.String)
[add~(v)] public void
org.apache.commons.clazz.reflect.ReflectableInstance.addString(java.lang.String)
[add~(int,v)] public void
org.apache.commons.clazz.reflect.ReflectableInstance.addString(int,java.lang.String)
[remove~(v)] public void
org.apache.commons.clazz.reflect.ReflectableInstance.removeString(java.lang.String)
[get~Count()] public int
org.apache.commons.clazz.reflect.ReflectableInstance.getStringCount()
]
]
[stringCount
[type] int
[accessor methods:
[get~()] public int
org.apache.commons.clazz.reflect.ReflectableInstance.getStringCount()
]
]
]
--
To unsubscribe, e-mail: <mailto:commons-dev-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@;jakarta.apache.org>