XStream versus XMLEncoder
- From: apm35@xxxxxxxxxxxxxxxxxx
- Date: Tue, 4 Dec 2007 13:58:15 -0800 (PST)
Hello,
I have to send and receive messages using a JMS queue and have decided
to use XML to represent the messages. I have a class for each message
type (a couple of requests and a couple of replies). These classes
employ ctors that initialize the private members and there are getters
for each private data member. There are no setters and no default
ctor. I am currently using XStream. This allows me to convert an
object to an XML String and an XML String back to the object. It is
working just fine.
However, a colleague pointed out that there is a mechanism that comes
as std with java now that can be used to do the same job, XMLEncoder.
The code to serialize and deserialize is just as simple as it is with
XStream except that certain requirements are placed on the class being
serialized. It must be a bean, which means it only handles those
private data members for which there are getters and SETTERS and there
must be a default ctor. This has put me off XMLEncoder since my
classes have no need of these things. Also I regard a default ctor as
more dangerous than one that inits all the members, since it is
possible to use the default ctor then forget to call ALL the setters
that are required to fully init the object. Also it seems to me that I
would have to make my objects beans to use XMLEncoder and they would
otherwise not be beans since there is no other need for them to be.
They are not taking part in web pages or JSP or anything like that,
they just get written to and read from JMS queues.
Which do people think should be used? I want to use std components
where possible and the trouble with XStream is it means adding a
couple of jars to the project which already has loads. XMLEncoder is
at least standard so no new jars should be needed. But I do not like
the requirements it places on the classes to be serialized. Did
XStream come along before there was XMLEncoder? Does XMLEncoder mean
than XStream is no longer needed?
Comments please. I am still quite new to java and have no experience
of beans. I need some guidance.
Regards,
Andrew Marlow
.
- Follow-Ups:
- Re: XStream versus XMLEncoder
- From: GArlington
- Re: XStream versus XMLEncoder
- Prev by Date: Re: Math/Programming Algorithm Help
- Next by Date: Re: Exception when reading empty zip file
- Previous by thread: Struts-How to dynamically load a dropdown list?
- Next by thread: Re: XStream versus XMLEncoder
- Index(es):
Relevant Pages
|