Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 63597 invoked from network); 8 Nov 2002 14:34:23 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 8 Nov 2002 14:34:23 -0000 Received: (qmail 20848 invoked by uid 97); 8 Nov 2002 14:35:10 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@jakarta.apache.org Received: (qmail 20791 invoked by uid 97); 8 Nov 2002 14:35:09 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 20734 invoked by uid 98); 8 Nov 2002 14:35:09 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) Date: Fri, 08 Nov 2002 09:33:52 -0500 From: Dmitri Plotnikov Subject: [clazz] draft reflect implementation To: commons-dev@jakarta.apache.org Message-id: <014201c28733$dc653fa0$0200a8c0@GATEWAY> MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Mailer: Microsoft Outlook Express 6.00.2720.3000 Content-type: multipart/mixed; boundary="Boundary_(ID_AHE7XVENxfamhCJSUVnlCQ)" X-Priority: 3 X-MSMail-priority: Normal X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N --Boundary_(ID_AHE7XVENxfamhCJSUVnlCQ) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7BIT 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 --Boundary_(ID_AHE7XVENxfamhCJSUVnlCQ) Content-type: text/plain; name=ClazzLog.txt Content-transfer-encoding: 7BIT Content-disposition: attachment; filename=ClazzLog.txt [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() ] ] ] --Boundary_(ID_AHE7XVENxfamhCJSUVnlCQ) Content-Type: text/plain; charset=us-ascii -- To unsubscribe, e-mail: For additional commands, e-mail: --Boundary_(ID_AHE7XVENxfamhCJSUVnlCQ)--