Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

XML DOM server editing with stateful EJBs  RSS feed

 
Andrew Jones
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Has anyone had experience with editing XML DOM documents on the server from a thin client?
When using stateful EJBs, the XML DOM objects take up a very large amount of memory, which looks like it would not scale well at all. Other options seem to be either a fat client (not really an option), or having single XML elements rather than the whole XML document extracted and updated as required.
Any thoughts?
Thanks in advance.
Cheers,
Andrew.
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or alternatively, don't DO that! Seriously, I've always considered using DOMs as domain objects a REALLY, REALLY bad idea. They're NOT objects! They're a big, bloated representation of data. They should only exist for VERY short lifecycles when you really and truly have to create some XML to immediately be placed somewhere else (like a file or database).
Don't use a DOM as your domain. Build real, live, honest-to-god Java classes to represent your business objects. Then, only create the DOM exactly at the final point that XML is needed (probably in a temporary variable that will be immediately GC'd). The memory cost will be MUCH less (orders of magnitude, perhaps). (Or perhaps you might not use it even then -- we've found generating XML with Streams to be much faster and more memory-efficient...IMHO DOM's should be limited to parsing, and maybe not even then, given SAX...)
I've participated in a couple of rewrites of programs that did this and the space and time savings were significant. In fact, I'll probably describe the entire "DOM as domain" approach as an anti-pattern in the next revision of my WebSphere book...
Kyle
[ August 21, 2002: Message edited by: Kyle Brown ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!