[
https://issues.apache.org/jira/browse/KARAF-7084?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17309280#comment-17309280
]
Grzegorz Grzybek commented on KARAF-7084:
-----------------------------------------
Here are some interesting (archaeology) findings about "Java + XML"...
As mentioned in [JSR 5 - JAXP 1.0|https://jcp.org/en/jsr/detail?id=5]:
bq. In many ways, XML and the Java Platform are a partnership made in heaven.
There were handy overview pages like:
* https://docs.oracle.com/javase/6/docs/index.html
* https://docs.oracle.com/javase/7/docs/index.html
* https://docs.oracle.com/javase/8/docs/index.html
But the pages changed after JDK8.
There were also pages explicitly for JAXP:
* https://docs.oracle.com/javase/6/docs/technotes/guides/xml/jaxp/index.html
* https://docs.oracle.com/javase/7/docs/technotes/guides/xml/jaxp/index.html
* https://docs.oracle.com/javase/8/docs/technotes/guides/xml/jaxp/index.html
That mentioned these packages (for all the 3 JDKs: 6, 7 and 8):
* javax.xml.datatype
* javax.xml.namespace
* javax.xml.parsers
* javax.xml.stream
* javax.xml.stream.events
* javax.xml.stream.util
* javax.xml.transform
* javax.xml.transform.dom
* javax.xml.transform.sax
* javax.xml.transform.stax
* javax.xml.transform.stream
* javax.xml.validation
* javax.xml.xpath
* org.w3c.dom
* org.w3c.dom.ranges
* org.w3c.dom.traversal
* org.w3c.dom.bootstrap
* org.w3c.dom.events
* org.w3c.dom.ls
* org.xml.sax
* org.xml.sax.ext
* org.xml.sax.helpers
The differences are explicitly highlighted:
*JDK 6*:
bq. The Java Platform, Standard Edition version 6.0 includes JAXP 1.4. JAXP 1.4
is a maintenance release of JAXP 1.3 with support for the Streaming API for XML
(StAX).
*JDK 7*:
bq. The Java Platform, Standard Edition version 7.0 includes JAXP 1.4. JAXP 1.4
is a maintenance release of JAXP 1.3 with support for the Streaming API for XML
(StAX).
*JDK 8*:
bq. The Java SE 7 Update 40 release includes JAXP 1.5.0. The Java SE 8 release
includes JAXP 1.6.
So actually JAXP 1.5 was introduced after JDK7u40.
What is most important in my opinion is this:
{quote}
The Java SE 8 release contains Java API for XML Processing (JAXP) 1.6, which
requires the use of the service provider loader facility defined by
java.util.ServiceLoader to load services from service configuration files. The
rationale for this is to allow for future modularization of the Java SE
platform where service providers may be deployed by means other than JAR files
and perhaps without the service configuration files. Note that the JAXP has
always specified the use of the 'Services API' without reference to a specific
API or service provider loading facility.
{quote}
[JEP 162|http://openjdk.java.net/jeps/162] mentiones the usage of
{{java.util.ServiceLoader}} wherever possible.
I wasn't able to find *why* JAXP (JSR 206) was simply withdrawn after releasing
JAXP 1.6...
What is interesting however is that XML stuff is Java is still carefully
handled. In [JDK 11 API documentation for java.xml
module|https://docs.oracle.com/en/java/javase/11/docs/api/java.xml/module-summary.html]
we can see:
{noformat}
*Module java.xml*
Defines the Java API for XML Processing (JAXP), the Streaming API for XML
(StAX), the Simple API for XML (SAX), and the W3C Document Object Model (DOM)
API.
{noformat}
And the most interesting thing is that because JPMS modules now export real
_services_ we know exactly what should we handle in special way in _Karaf
specs_:
* DatatypeFactory - Factory that creates new javax.xml.datatype Objects that
map XML to/from Java Objects.
* DocumentBuilderFactory - Defines a factory API that enables applications to
obtain a parser that produces DOM object trees from XML documents.
* SAXParserFactory - Defines a factory API that enables applications to
configure and obtain a SAX based parser to parse XML documents.
* SchemaFactory - Factory that creates Schema objects.
* TransformerFactory - A TransformerFactory instance can be used to create
Transformer and Templates objects.
* XMLEventFactory - This interface defines a utility class for creating
instances of XMLEvents
* XMLInputFactory - Defines an abstract implementation of a factory for getting
streams.
* XMLOutputFactory - Defines an abstract implementation of a factory for
getting XMLEventWriters and XMLStreamWriters.
* XMLReader - Interface for reading an XML document using callbacks. -
deprecated in favor of SAXParserFactory
* XPathFactory - An XPathFactory instance can be used to create XPath objects.
There are *two* new packages in {{java.xml}} module of JDK9+ comparing to JAXP
1.6 implemented in JDK8:
* javax.xml.catalog
* org.w3c.dom.views - this package is also available in JDK8, not mentioned in
[JAXP 1.6 page of JDK 8
guide|https://docs.oracle.com/javase/8/docs/technotes/guides/xml/jaxp/index.html]
but it is mentioned in JAXP 1.6 (JSR 206) itself.
Next comment will switch from JAXP/Specification research to source code
research.
> Not every factory access from JAXP (specs/java.xml) goes through OsgiLocator
> ----------------------------------------------------------------------------
>
> Key: KARAF-7084
> URL: https://issues.apache.org/jira/browse/KARAF-7084
> Project: Karaf
> Issue Type: Bug
> Reporter: Grzegorz Grzybek
> Assignee: Grzegorz Grzybek
> Priority: Major
> Fix For: 4.3.2
>
>
> I was checking this code:
> {code:java}
> System.out.println("== JAXP");
> info(DatatypeFactory.class, DatatypeFactory.newInstance());
> info(DocumentBuilderFactory.class, DocumentBuilderFactory.newInstance());
> info(SAXParserFactory.class, SAXParserFactory.newInstance());
> info(XMLEventFactory.class, XMLEventFactory.newInstance());
> info(XMLInputFactory.class, XMLInputFactory.newInstance());
> info(XMLOutputFactory.class, XMLOutputFactory.newInstance());
> info(TransformerFactory.class, TransformerFactory.newInstance());
> info(SchemaFactory.class,
> SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI));
> info(XPathFactory.class, XPathFactory.newInstance());
> System.out.println("== SAAJ");
> try {
> info(MessageFactory.class, MessageFactory.newInstance());
> info(SOAPConnectionFactory.class, SOAPConnectionFactory.newInstance());
> info(SOAPFactory.class, SOAPFactory.newInstance());
> } catch (Throwable ignored) {
> }
> System.out.println("== JAX-WS");
> try {
> info(Provider.class, Provider.provider());
> } catch (Throwable ignored) {
> }
> System.out.println("== JAXB");
> try {
> info(JAXBContext.class, JAXBContext.newInstance("grgr.test.jaxb.model",
> getClass().getClassLoader()));
> Class<?> cfClass =
> FrameworkUtil.getBundle(this.getClass()).adapt(BundleWiring.class).getClassLoader().loadClass("com.sun.xml.bind.v2.ContextFactory");
> System.out.println("ContextFactory class = " + cfClass);
> } catch (Throwable ignored) {
> }
> ...
> private void info(Class<?> clazz, Object service) {
> System.out.printf(" - %s: %s%n", clazz, service.getClass().getName());
> System.out.printf(" - %s%n", FrameworkUtil.getBundle(service.getClass()));
> }
> {code}
> TO see if I really can get implementations of JAXP interfaces, if given
> interface is implemented in a bundle with proper
> {{/META-INF/services/<service-name>}}. It works well with _some_ JAXP
> interfaces and with SAAJ. However it doesn't work with:
> * javax.xml.validation.SchemaFactory
> * javax.xml.xpath.XPathFactory
> * org.xml.sax.helpers.XMLReaderFactory (here there's not even a shaded
> factory in {{java.xml}} Karaf spec)
--
This message was sent by Atlassian Jira
(v8.3.4#803005)