JAXP defines a Plugability Layer that specifies how it will locate an implementation or service provider. In the Java API documentation, the Plugability Layer is described in all of the factories including
javax.xml.datatype.DatatypeFactory, javax.xml.parsers.DocumentBuilderFactory, javax.xml.parsers.SAXParserFactory, javax.xml.stream.XMLEventFactory, javax.xml.stream.XMLInputFactory, javax.xml.stream.XMLOutputFactory, javax.xml.transform.TransformerFactory, javax.xml.validation.SchemaFactory, and javax.xml.xpath.XPathFactory.
The process is best described in javax.xml.datatype.DatatypeFactory as follows.
Quote from the Java API Documentation of javax.xml.datatype.DatatypeFactory:
newInstance() is used to create a new DatatypeFactory. The following implementation resolution mechanisms are used in the following order:
1. If the system property specified by DATATYPEFACTORY_PROPERTY, "javax.xml.datatype.DatatypeFactory", exists, a class with the name of the property's value is instantiated. Any Exception thrown during the instantiation process is wrapped as a DatatypeConfigurationException.
2. If the file ${JAVA_HOME}/lib/jaxp.properties exists, it is loaded in a Properties Object. The Properties Object is then queried for the property as documented in the prior step and processed as documented in the prior step.
3. The services resolution mechanism is used, e.g. META-INF/services/java.xml.datatype.DatatypeFactory. Any Exception thrown during the instantiation process is wrapped as a DatatypeConfigurationException.
4. The final mechanism is to attempt to instantiate the Class specified by DATATYPEFACTORY_IMPLEMENTATION_CLASS. Any Exception thrown during the instantiation process is wrapped as a DatatypeConfigurationException.
In a module system, the location of a service provider will be centered around finding modules that provide the service. The process defined in the JAXP Plugability Layer will need to be modified accordingly. This change request is targeted to changing the 3rd step, the basis of the process. Other changes will be requested in the future as the general solutions in the areas of module finding and loading become clearer (for example, if there may be a preferred service, or if there's a way to pick a specific provider).
Below is the change for the 3rd step.
In javax.xml.datatype.DatatypeFactory, the description of the process is in the beginning of the class, while for all other factories, it is in the newInstance method. The descriptions were slightly different among different factories. With this change, all of them will use the same text as follows.
3. Using the service-provider loading facility defined by the java.util.ServiceLoader class to attempt to locate and load an implementation of the service. Any Exception thrown during the instantiation process is wrapped as a ConfigurationException.
javax.xml.datatype.DatatypeFactory, javax.xml.parsers.DocumentBuilderFactory, javax.xml.parsers.SAXParserFactory, javax.xml.stream.XMLEventFactory, javax.xml.stream.XMLInputFactory, javax.xml.stream.XMLOutputFactory, javax.xml.transform.TransformerFactory, javax.xml.validation.SchemaFactory, and javax.xml.xpath.XPathFactory.
The process is best described in javax.xml.datatype.DatatypeFactory as follows.
Quote from the Java API Documentation of javax.xml.datatype.DatatypeFactory:
newInstance() is used to create a new DatatypeFactory. The following implementation resolution mechanisms are used in the following order:
1. If the system property specified by DATATYPEFACTORY_PROPERTY, "javax.xml.datatype.DatatypeFactory", exists, a class with the name of the property's value is instantiated. Any Exception thrown during the instantiation process is wrapped as a DatatypeConfigurationException.
2. If the file ${JAVA_HOME}/lib/jaxp.properties exists, it is loaded in a Properties Object. The Properties Object is then queried for the property as documented in the prior step and processed as documented in the prior step.
3. The services resolution mechanism is used, e.g. META-INF/services/java.xml.datatype.DatatypeFactory. Any Exception thrown during the instantiation process is wrapped as a DatatypeConfigurationException.
4. The final mechanism is to attempt to instantiate the Class specified by DATATYPEFACTORY_IMPLEMENTATION_CLASS. Any Exception thrown during the instantiation process is wrapped as a DatatypeConfigurationException.
In a module system, the location of a service provider will be centered around finding modules that provide the service. The process defined in the JAXP Plugability Layer will need to be modified accordingly. This change request is targeted to changing the 3rd step, the basis of the process. Other changes will be requested in the future as the general solutions in the areas of module finding and loading become clearer (for example, if there may be a preferred service, or if there's a way to pick a specific provider).
Below is the change for the 3rd step.
In javax.xml.datatype.DatatypeFactory, the description of the process is in the beginning of the class, while for all other factories, it is in the newInstance method. The descriptions were slightly different among different factories. With this change, all of them will use the same text as follows.
3. Using the service-provider loading facility defined by the java.util.ServiceLoader class to attempt to locate and load an implementation of the service. Any Exception thrown during the instantiation process is wrapped as a ConfigurationException.
- duplicates
-
JDK-8005954 JAXP Plugability Layer should use java.util.ServiceLoader
- Resolved
- is cloned by
-
JDK-8005954 JAXP Plugability Layer should use java.util.ServiceLoader
- Resolved
- relates to
-
JDK-6975142 JAXP FactoryFinder fails to locate provider
- Closed
-
JDK-8046152 JEP 162: Prepare for Modularization
- Closed