commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From victor.vo...@gmxpro.net
Subject Extending Clazz
Date Wed, 18 Jun 2003 12:43:29 GMT
>From the (perhaps not quite current?) overview I concluded that
to extend Clazz for "Customizing a Family of Reflected Clazzes"
I have to create

1) a subclass of Reflected*PropertyInspector
2) some (two) AccessMethodParsers
3) a subclass of (Standard)ReflectedClazz
4) a subclass of ReflectedClazzLoader
5) add the ClazzLoader created in step 4 to an
    existing ClazzLoader

I find this quite a lot to do. 

1) Wouldn't it be possible to create a new _instance_ 
    of ReflectedPropertyInspector and configure the 
   (two) AcessMethodParsers.
2) Wouldn't it be possible to simply create a new
    instance of a BaseAccessMethodParser that has 
    some methods like
   
      - getRequiredPrefix AND setRequiredPrefix (etc.)

    so that again, I would not need to subclass
3) The only reason to create a new subclass of
    ReflectedClazz seems to be that it has to implement
    getPropertyInspectors().
    Why is this method in ReflectedClazz and not in 
    ClazzLoader? 
    And again why do I have to subclass wouldn't
    a BaseReflectedClazz with getter AND setter for
    PropertyInspectors be sufficient?
4) ...

So it mostly boils down to subclassing vs. "configuring".

(Besides the remark on the placement of the 
getPropertyInspectors() method in step 3) which I simply
do not understand.)

I do not know, if it's just my preference, but I really dislike
having so many classes around.

The simplest solution I could imagine looks something like:

  AccessorMethodParser readMethod = new BaseAccessMethodParser();
  readMethod.setRequiredPrefix("add");
  readMethod.setRequiredParameterCount(1);
  readMethod.set...
  // for some methods like getValueType() a subclass might still be needed!
 
  AccessorMethodParser writeMethod = new BaseAccessMethodParser();
  ...

  reflectedPropertyInspector inspector = 
     new ReflectedPropertyInspector(readMethod, writeMethod);

  ClazzLoader clazzLoader = ...;
  clazzLoader.appendPropertyInspector(inspector);

Could this work with Clazz? 

Regards
Victor


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


Mime
View raw message