History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: XSTR-157
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Assignee: Unassigned
Reporter: Henri Tremblay
Votes: 1
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
XStream

Hard to allow xstream to have a converter supporting generated classes

Created: 16/Nov/04 04:18 PM   Updated: 07/Aug/06 09:30 PM
Component/s: None
Affects Version/s: None
Fix Version/s: 1.2

Issue Links:
Supercedes
 


 Description  « Hide
I am trying to create a converter for cglib. The initial idea was to do just like XStream is already doing for JDK dynamic proxies.

The problem is that XStream is cheating a lot to have proxies working.

First you need an alias to replace the class name.

Then you need this alias to return a Dummy class that will allow the wanted converter to be called.

After that, you need to override DefaultClassMapper to replicate this hack in DefaultClassMapper:

if (result == null && Proxy.isProxyClass(type)) {
result = (String) typeToNameMap.get(DynamicProxy.class);
}

And finally, you need to register the converter in your new mapper because the converter needs the mapper.

All this is not really obvious. And it's not possible to provide a generic converter since you also need a ClassMapper.

So we really need something better. There are loads of solutions. All requiring more of less refactoring.

I think the question should be: If I want to remove all the Dynamic proxy's hacks, what should I do?

The solution I can think of:
1- To pass a class name instead of a Class to canConvert. It will remove the need to have a dummy class and putting an alias will be made easy.
2- Allow the converter to have a converter to have the mapper injected in some kind of way when we register it to XStream.
3- Have something more powerful than aliases. Maybe have a new method on Converters that perform the lookup. If this is not efficient, be at least able to have a lookup hook where we can put code like Proxy.isProxyClass(type)



 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Joe Walnes - 19/Dec/04 04:35 PM
Hi Henri

I see the problem and have taken your suggestions on board. Please come and discuss this on the XStream mailing list.

Thanks
-Joe


Joerg Schaible - 11/Apr/06 07:55 PM
A converter for CGLIB has been added to the code base as solution for XSTR-239. Please have a look and report if it addresses your requirements.