Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Raptor Engineering Public Development
Jitsi
jaxb-api
Commits
a0cc226b
Commit
a0cc226b
authored
4 years ago
by
Lukas Jungmann
Browse files
Options
Download
Email Patches
Plain Diff
#172: default factory class name
Signed-off-by:
Lukas Jungmann
<
lukas.jungmann@oracle.com
>
parent
e9ca8e7d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
30 deletions
+23
-30
jaxb-api/src/main/java/jakarta/xml/bind/ContextFinder.java
jaxb-api/src/main/java/jakarta/xml/bind/ContextFinder.java
+21
-5
jaxb-api/src/main/java/jakarta/xml/bind/ModuleUtil.java
jaxb-api/src/main/java/jakarta/xml/bind/ModuleUtil.java
+1
-17
jaxb-api/src/main/mr-jar/jakarta/xml/bind/ModuleUtil.java
jaxb-api/src/main/mr-jar/jakarta/xml/bind/ModuleUtil.java
+1
-8
No files found.
jaxb-api/src/main/java/jakarta/xml/bind/ContextFinder.java
View file @
a0cc226b
/*
* Copyright (c) 2003, 202
0
Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 202
1
Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
...
...
@@ -43,6 +43,22 @@ class ContextFinder {
private
static
final
Logger
logger
;
/**
* When JAXB is in J2SE, rt.jar has to have a JAXB implementation.
* However, rt.jar cannot have META-INF/services/jakarta.xml.bind.JAXBContext
* because if it has, it will take precedence over any file that applications have
* in their jar files.
*
* <p>
* When the user bundles his own Jakarta XML Binding implementation, we'd like to use it, and we
* want the platform default to be used only when there's no other Jakarta XML Binding provider.
*
* <p>
* For this reason, we have to hard-code the class name into the API.
*/
//XXX: should we define and rely on "default" in jakarta?
static
final
String
DEFAULT_FACTORY_CLASS
=
"org.glassfish.jaxb.runtime.v2.ContextFactory"
;
static
{
logger
=
Logger
.
getLogger
(
"jakarta.xml.bind"
);
try
{
...
...
@@ -125,7 +141,7 @@ class ContextFinder {
Map
properties
)
throws
JAXBException
{
try
{
Class
spFactory
=
ServiceLoaderUtil
.
safeLoadClass
(
className
,
ModuleUtil
.
DEFAULT_FACTORY_CLASS
,
classLoader
);
Class
spFactory
=
ServiceLoaderUtil
.
safeLoadClass
(
className
,
DEFAULT_FACTORY_CLASS
,
classLoader
);
return
newInstance
(
contextPath
,
contextPathClasses
,
spFactory
,
classLoader
,
properties
);
}
catch
(
ClassNotFoundException
x
)
{
throw
new
JAXBException
(
Messages
.
format
(
Messages
.
DEFAULT_PROVIDER_NOT_FOUND
),
x
);
...
...
@@ -227,7 +243,7 @@ class ContextFinder {
Class
spi
;
try
{
spi
=
ServiceLoaderUtil
.
safeLoadClass
(
className
,
ModuleUtil
.
DEFAULT_FACTORY_CLASS
,
getContextClassLoader
());
spi
=
ServiceLoaderUtil
.
safeLoadClass
(
className
,
DEFAULT_FACTORY_CLASS
,
getContextClassLoader
());
}
catch
(
ClassNotFoundException
e
)
{
throw
new
JAXBException
(
Messages
.
format
(
Messages
.
DEFAULT_PROVIDER_NOT_FOUND
),
e
);
}
...
...
@@ -315,7 +331,7 @@ class ContextFinder {
// else no provider found
logger
.
fine
(
"Trying to create the platform default provider"
);
return
newInstance
(
contextPath
,
contextPathClasses
,
ModuleUtil
.
DEFAULT_FACTORY_CLASS
,
classLoader
,
properties
);
return
newInstance
(
contextPath
,
contextPathClasses
,
DEFAULT_FACTORY_CLASS
,
classLoader
,
properties
);
}
static
JAXBContext
find
(
Class
<?>[]
classes
,
Map
<
String
,
?>
properties
)
throws
JAXBException
{
...
...
@@ -372,7 +388,7 @@ class ContextFinder {
// else no provider found
logger
.
fine
(
"Trying to create the platform default provider"
);
return
newInstance
(
classes
,
properties
,
ModuleUtil
.
DEFAULT_FACTORY_CLASS
);
return
newInstance
(
classes
,
properties
,
DEFAULT_FACTORY_CLASS
);
}
...
...
This diff is collapsed.
Click to expand it.
jaxb-api/src/main/java/jakarta/xml/bind/ModuleUtil.java
View file @
a0cc226b
/*
* Copyright (c) 2017, 202
0
Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 202
1
Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
...
...
@@ -20,22 +20,6 @@ import java.io.IOException;
*/
class
ModuleUtil
{
/**
* When JAXB is in J2SE, rt.jar has to have a JAXB implementation.
* However, rt.jar cannot have META-INF/services/jakarta.xml.bind.JAXBContext
* because if it has, it will take precedence over any file that applications have
* in their jar files.
*
* <p>
* When the user bundles his own Jakarta XML Binding implementation, we'd like to use it, and we
* want the platform default to be used only when there's no other Jakarta XML Binding provider.
*
* <p>
* For this reason, we have to hard-code the class name into the API.
*/
// NOTICE: .toString() is used to prevent constant inlining by Java Compiler
static
final
String
DEFAULT_FACTORY_CLASS
=
"com.sun.xml.internal.bind.v2.ContextFactory"
.
toString
();
/**
* Resolves classes from context path.
* Only one class per package is needed to access its {@link java.lang.Module}
...
...
This diff is collapsed.
Click to expand it.
jaxb-api/src/main/mr-jar/jakarta/xml/bind/ModuleUtil.java
View file @
a0cc226b
/*
* Copyright (c) 2017, 202
0
Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 202
1
Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
...
...
@@ -14,7 +14,6 @@ import java.io.BufferedReader;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.lang.Module
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.logging.Level
;
...
...
@@ -29,12 +28,6 @@ class ModuleUtil {
private
static
Logger
logger
=
Logger
.
getLogger
(
"jakarta.xml.bind"
);
/**
* Jakarta XML Binding-RI default context factory.
*/
// NOTICE: .toString() is used to prevent constant inlining by Java Compiler
static
final
String
DEFAULT_FACTORY_CLASS
=
"com.sun.xml.bind.v2.ContextFactory"
.
toString
();
/**
* Resolves classes from context path.
* Only one class per package is needed to access its {@link java.lang.Module}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment