Posted by mkarg
on March 1, 2014 at 5:23 PM PST
JAX-RS based WebDAV interfaces getting faster, less memory consuming, and more stable when switching over to latest release 1.2.1.
It actually happened a few weeks ago already, but I simply didn't find the time to spread the word earlier -- just too much other stuff to do (see end of posting), so I tell you now: WebDAV Support for JAX-RS 1.2 is out!
What has happened since 1.1?
First of all, 1.2 is a complete internal overhaul, which not only finally is covered with unit tests rather completely (which revealed several previously unknown bugs now being fixed thanks to that unit tests), moreover the overhaul provides improved performance and simplicity in use. This comes mostly from the fact that lots of WebDAV XML elements actually are intended to be though of as enumerations (like or ). Unfortunately the original WebDAV DTD does not clearly express this (to be understood as: DTDs cannot express that, only XSDs could, but WebDAV is defined in terms of DTD still, unfortunately), so it is impossible to implement it as a Java enum. So the solution used in 1.2 (and current maintenance release 1.2.1) is to use JAXB technology to replace equal instances on the fly by Java singletons. Said that, memory consumption of parsed WebDAV XML bodies is obviously less with 1.2 thank with 1.1 -- without changing the application itself, solely by replacing the WebDAV library! Ontop, when willing to modify the application, comparisons on such "pseudo enums" can be simplified. Using == instead of equals() will provide a correct and valid result since 1.2, and improves execution speed certainly. And as more singletons have been added to the library, there is no more need to create lots of empty instances like new Write() -- this can just be written as WRITE now, which is way better to read. Check the JavaDocs to find the places where singletons have been added!
Second, the new code provides a starting point for using header values in a more readable manner. Instead of declaring @HeaderParam as String and then manually dealing with String alchemy or conversion to Java objects, it is now possible to natively declare these headers as WebDAV types. This is implemented for TimeOut currently, but more will follow in future releases. No more String algorithmic, no more manual conversion, all done under the hood automatically! But one warning: There was a bug in Jersey preventing this feature from working well. So to use this on Jersey, an upgrade to Jersey 2.6 is essential, unfortunately (as this feature implies a recompilation anyways, that shouldn't be a real drawback).
So how to obtain 1.2? Using Maven all one has to do is to declare the following dependency, as WebDAV Support for JAX-RS 1.2.1 is found on the Maven Central Repository: