开发者

Need to make third party objects serializable without writing wrapper

开发者 https://www.devze.com 2023-03-06 11:19 出处:网络
I have third party platform jars of which APIs need to be tested using webservices. These APIs take custom objects which are non serializable.

I have third party platform jars of which APIs need to be tested using webservices. These APIs take custom objects which are non serializable. Say for example some of the APIs are like this.

doSomething(CustomId someId, DBLoaderType type, DBFilter filter, boolean exclude) returns java.util.List<SomeNavigationSystem>

But these 开发者_开发百科CustomId, DBLoaderType, DBFilter, SomeNavigationSystem are not serializable objects.

Is there a way that I need not write any extra classes for all these classes (there is a lot of such classes) to serialize? If I write one wrapper or equivalent DTO for each business class then this will be very unscalable.


please have a look at the Google gson lib under http://code.google.com/p/google-gson/.

I am not sure if I fully understood your problem, but if you want to serialize objects that do not implement java.io.Serializable you should consider json or one of its implementations. Assuming that your objects are serializable from their 'nature', gson can serializable them into a string. Your web service schema may look ugly later, but it could work. You will end up in sending strings.


I am using XSteram it fixed my issues.

0

精彩评论

暂无评论...
验证码 换一张
取 消