You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by Evan Koffler <ev...@codezodiac.com> on 2002/07/20 19:05:49 UTC

Intake, mapToObject, Interfaces - Patch provided

Attached is a patch in 'cvs diff -u' format for 
jakarta-turbine-fulcrum's 
src/java/org/apache/fulcrum/intake/model/Group.java.

Here's a copy of the original email that I posted to turbine-user

============= Original email describing the problem =============
Hello,

I've been using Intake quite successfully until a recent change I made 
in my code. The mapTo object is a configuration object that does the 
PropertyChange and VetoableChange JavaBean pattern and it got rather 
tedious. So I switched to using an dynamic Proxy 
(java.lang.reflect.Proxy). Testing with regular Java classes it works 
great.

Following the code, Intake.mapTo(Retrievable) uses the Retrievable's 
classname (and superclasses) as the key into a Map for fields (and 
ultimately their setter/getters. The dynamic Proxy is initialized by 
providing an interface. Sun's implementation in the JDK auto-creates 
a new class that implements the interface as well as extending Object 
while naming the class Proxy0 (as in zero, not oh). Therefore, the 
proxied object ends up with a name not known to Intake yet 
implementing an interface. So Group.init(Retrievable)'s logic of 
chasing the classes and superclasses won't find any fields for the 
class.

And actually this problem will exist for any class that implements the 
interface since it won't match the intake.xml definitions.

I hope this is clear enough. And since I haven't posed a question yet: 
Any ideas on how to make it work? 

I'm off to try hacking on Group to see if I can make it recognize the 
Proxy and chase the interfaces.

Thanks,
Evan

--