John Crossman wrote:
> Hello! I am working with Castor for the first time. Two questions:
>
> 1. My needs are specifically focused on improving performance in the
> unmarshalling of XML. How can I tweak Castor to perform as well as
> possible? Is there a parser that is known to perform best?
1. Cache the descriptors!
import org.exolab.castor.xml.ClassDescriptorResolver;
import org.exolab.castor.xml.Unmarshaller;
import org.exolab.castor.xml.util.ClassDescriptorResolverImpl;
ClassDescriptorResolver cdr = new ClassDescriptorResovlerImpl();
...
Unmarshaller unm = new Unmarshaller(...);
unm.setResolver(cdr);
By reusing the same ClassDescriptorResolver any time you create an
Unmarshaller instance, you will be reusing the existing class
descriptors previously loaded.
2. Disable validation
unm.setValidation(false);
3. Reuse objects
To cut down on object creation, you can reuse an existing object
model, but be careful this is an experimental feature.
Create an Unmarshaller with your existing root object and set object
reuse to true...
Unmarshaller unm = new Unmarshaller(myObjectRoot);
unm.setReuseObjects(true);
4. Try changing parsers
There are probably other approaches you can use as well, but those seem
to be the most popular ones.
>
>
> 2. Also, any un/official numbers on how well Castor performs next to
> JAXB, JiBX, Skaringa, etc.?
>
JiBX is supposed to be pretty speedy, though I've never tried it myself.
Perhaps Dennis Sosnoski could give you a better run down on comparisons.
--Keith
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev