tags:

views:

387

answers:

1

I am using Castor 1.2 for marshalling.

Do you have any experience with using Castor for this purpose?
Do you have suggestions for improving performance?

+1  A: 

Castor 1.2 was the last version to provide support for Java 1.4, so it's still widely used by shops that haven't made the transition to 1.5 or 1.6 (in my case, we're stuck with deploying to an older Weblogic version).

The best way to gain performance improvements is to use a mapping file, rather than having Castor use reflection to marshall/unmarshall your XML. The mapping file can contain explicit XML element to Java class mappings, and omit any translations you are not interested in. So, for example, if an XML record contains a customer's billing information along with a history of the last 100 orders, but all you care about is the billing information, you can explicitly map the appropriate XML elements to your billing information classes. Castor will ignore the remainder of the XML elements, speeding up the marshalling process.

A final tip is to download the source code for Castor 1.2, even if you don't plan on building the code yourself. The documentation for 1.2 hasn't been kept up to date, so some new features that appear to have been introduced in 1.3 and higher have actually been added to Castor 1.2 as well. A quick comparison of the 1.3 documentation and 1.2 code will let you see what improvements have been recently made to Castor 1.2.

KeithL