Hi,
This is a first webrev in a series that addresses a change intended
for JDK 8:
7169894: JAXP Plugability Layer: using service loader
I've been building up on Joe's work and Paul & Alan comments
from an earlier discussion thread [1]
This here addresses changes in the javax.xml.parsers
package for the SAXParserFactory and DocumentBuilderFactory - and
more specifically their no-argument newInstance() method.
This change replaces the custom code that was reading the
META-INF/services/ resources by a simple call to ServiceLoader.
<http://cr.openjdk.java.net/~dfuchs/JDK-7169894/javax.xml.parsers/webrev.00/>
In addition - since it is foreseen that the default implementation
for the parsers might come as a separate Module in the future, we
cannot make the assumption that the first service provider encountered
by the ServiceLoader will be the third-party/custom provider to
use.
As a consequence, since we must allow for a third-party/custom provider
to override the default implementation - we will skip over any
provider whose class name has the default implementation class name,
and return it only if no other provider is found.
This is a small spec change intended for JDK8 which is reflected in
the API Documentation of the two factory classes. The impact is that
in the very rare configuration where you have on the classpath
two providers: A.jar:B.jar, where A.jar has a services/* config that
points at the default factory implementation, and B.jar points at a
custom implementation, then the new XxxxFactory will return the
custom implementation pointed at by B.jar, whereas it used to
return the default implementation pointed at by A.jar.
best regards,
-- daniel
references:
[1]
http://mail.openjdk.java.net/pipermail/core-libs-dev/2012-June/010595.html