You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Gray, Andrew (ITDA)" <an...@DEFRA.GSI.GOV.UK> on 2004/08/05 17:26:21 UTC

betwixt files doesn't work with inherited Interfaces

Hi,

After some digging I've hit a "limitation" - ultimately due (IMHO) to
java.beans.Introspector - if you introspect an interface you don't get
deatils on anything defined in super interfaces  (I'm using jdk 1.4.2.02)


All of my javaBean structures are defined by interfaces with the
implementation classes being context specific.


public interface Person {
    String getName();
    void setName(String name);
}

public interface Developer extends Person {
    int getHackCount();
    void setHackCount(int hacks);
    Pet getPet();
    void setPet(Pet pet);}

public interface Pet {
   ...
}
public interface DevTeam {
    Collection getDevelopers();
    void addDeveloper(Developer dev);
}

add some .betwixt files telling the parser what mplementations to use
DevTeam.betwixt: -
...
<element name='developer' property='developers' class='MyDeveloper'/>
...

and Developer.betwixt: -
...
<element name='pet' property='pet' class='teh super-interfaceMyPet'/>
<addDefaults>
...
etc.

Now I come to unmarshall the following snippet in a xml doc.
...
<devTeam>
   <developer>
      <name>Joe Blo</name>
      <hackCount>32</hackCount>
      <pet> ... </pet>
  </developer>
</devTeam>
...

Trying to get betwixt to parse a Developer is failing as the Introspection
API is not telling it about the name property defined in Person.

Defining specific elements is no better. There is no WriteMethod returned
from the introspector so no Digester rule is created to parse "name" and it
ends up null.


Thoughts appreciated.
Will DynaBeans get round this?
Does anyone know if Sun will "fix" the introspector?
Is there a preferred workaround / approach if they won't (soon)?

(I don't want to redifine things in subclasses already in superclasses)

regards

Andy Gray



Department for Environment, Food and Rural Affairs (Defra)

This email and any attachments is intended for the named recipient only. Its
unauthorised use, disclosure, storage or copying is not permitted. If you have
received it in error, please destroy all copies and inform the sender. Whilst this
email and associated attachments will have been checked for known viruses
whilst within Defra systems we can accept no responsibility once it has left our
systems. Communications on Defra's computer systems may be monitored
and/or recorded to secure the effective operation of the system and for other
lawful purposes.


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


Re: betwixt files doesn't work with inherited Interfaces

Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
hi andrew

i'm a little intrigued by this problem and i'll take a look at adding a 
solution but i'm not likely to be able to have anything ready tonight. 
just to check i've parsed you correctly, you're using a normalizer and 
the introspection needs to pick up the methods on the super-interfaces 
for the given interface, right?

(unfortunately, you'll have to roll your own jar since it'll be too 
late to go into the upcoming 0.6 release.)

- robert

On 5 Aug 2004, at 16:26, Gray, Andrew (ITDA) wrote:

> Hi,
>
> After some digging I've hit a "limitation" - ultimately due (IMHO) to
> java.beans.Introspector - if you introspect an interface you don't get
> deatils on anything defined in super interfaces  (I'm using jdk 
> 1.4.2.02)
>
>
> All of my javaBean structures are defined by interfaces with the
> implementation classes being context specific.
>
>
> public interface Person {
>     String getName();
>     void setName(String name);
> }
>
> public interface Developer extends Person {
>     int getHackCount();
>     void setHackCount(int hacks);
>     Pet getPet();
>     void setPet(Pet pet);}
>
> public interface Pet {
>    ...
> }
> public interface DevTeam {
>     Collection getDevelopers();
>     void addDeveloper(Developer dev);
> }
>
> add some .betwixt files telling the parser what mplementations to use
> DevTeam.betwixt: -
> ...
> <element name='developer' property='developers' class='MyDeveloper'/>
> ...
>
> and Developer.betwixt: -
> ...
> <element name='pet' property='pet' class='teh super-interfaceMyPet'/>
> <addDefaults>
> ...
> etc.
>
> Now I come to unmarshall the following snippet in a xml doc.
> ...
> <devTeam>
>    <developer>
>       <name>Joe Blo</name>
>       <hackCount>32</hackCount>
>       <pet> ... </pet>
>   </developer>
> </devTeam>
> ...
>
> Trying to get betwixt to parse a Developer is failing as the 
> Introspection
> API is not telling it about the name property defined in Person.
>
> Defining specific elements is no better. There is no WriteMethod 
> returned
> from the introspector so no Digester rule is created to parse "name" 
> and it
> ends up null.
>
>
> Thoughts appreciated.
> Will DynaBeans get round this?
> Does anyone know if Sun will "fix" the introspector?
> Is there a preferred workaround / approach if they won't (soon)?
>
> (I don't want to redifine things in subclasses already in superclasses)
>
> regards
>
> Andy Gray
>
>
>
> Department for Environment, Food and Rural Affairs (Defra)
>
> This email and any attachments is intended for the named recipient 
> only. Its
> unauthorised use, disclosure, storage or copying is not permitted. If 
> you have
> received it in error, please destroy all copies and inform the sender. 
> Whilst this
> email and associated attachments will have been checked for known 
> viruses
> whilst within Defra systems we can accept no responsibility once it 
> has left our
> systems. Communications on Defra's computer systems may be monitored
> and/or recorded to secure the effective operation of the system and 
> for other
> lawful purposes.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>


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