Details
-
Type:
Improvement
-
Status:
Open
-
Priority:
Minor
-
Resolution: Unresolved
-
Labels:None
-
Number of attachments :
Description
The logics for figuring out implementation-specific factories checks for existence of an entry in jaxp.properties potentially EACH TIME newInstance() is called. This is wasteful in many ways, and could/should be optimized (either by fully caching the value found, or the fact none was found; or by timestamping to avoid the read at least – any mechanism would be better than re-reading the file each and every time). For naive usage (factory.newInstance() called for each use) and small input/output documents, this can actually have measurable performance impact, with little benefits.
Turns out that caching of the instance is, unfortunately, not trivial to do. The reason for this is that one of 3 mechanism is done on per-classloader basis, and thus caching couldn't use just a single global reference to the class(es) found. It would still be possible to cache results of reading jaxp.properties file, but chances are that the service/jar inspection is the slowest part, and that depends on class loader being passed in.
So it is possible that there is no good easy solution to this particular problem.