You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Gianugo Rabellino <gi...@gmail.com> on 2005/01/07 11:54:16 UTC

fb:insert-bean & class hierarchies

Pardon me if this has been discussed already... I did some quick
search and was unable to find anything relevant.

We are currently being severely bitten by a limitation in the Java
reflection API that hits on fb:insert-bean. If class B extends A, and
you have a method in your binding base such as

void addA(A a)

you cannot bind it using a B instance since Java will complain about
not finding a

void addA(B b)

method.

Now, apart from this being quite silly from the reflection POV, is
there anything we're missing of is that a confirmed limitation? And,
if, so, would anyone here be interested in a fix? I can see three
solutions for that:

1. brute force approach: try to call the method with every possible
superclass of the parameter giving an error;

2. lookup: get all the methods, grab the one that needs to be called,
find out which is the correct superclass to use;

3. insert a "cast" semantic to the binding instruction and then cast
(using a Proxy?) to the correct implementation the class is expecting.

Of course the 4th solution still applies:

4. I'm a moron and I'm overlooking how this has been discussed at
lenght and solved long ago.

Ciao,

-- 
Gianugo Rabellino
Pro-netics s.r.l. -  http://www.pro-netics.com
Orixo, the XML business alliance: http://www.orixo.com

Re: fb:insert-bean & class hierarchies

Posted by Torsten Curdt <tc...@apache.org>.
Gianugo Rabellino wrote:
> Pardon me if this has been discussed already... I did some quick
> search and was unable to find anything relevant.
> 
> We are currently being severely bitten by a limitation in the Java
> reflection API that hits on fb:insert-bean.

Huh? ...you mean not providing the methods of
the base classes?

> If class B extends A, and
> you have a method in your binding base such as
> 
> void addA(A a)
> 
> you cannot bind it using a B instance since Java will complain about
> not finding a
> 
> void addA(B b)
> 
> method.

I am not sure how the insert-bean works but is
due to the inheritance or the overloading?

Maybe have a look at the ReflectionUtils (cocoon repo).

cheers
--
Torsten