Skip to content

Commit 9d59502

Browse files
committed
Issue 6036; Media - Jackson3
Signed-off-by: Jens-Otto Larsen <jens-otto.larsen@nav.no> Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
1 parent bbdf3d7 commit 9d59502

93 files changed

Lines changed: 6231 additions & 40 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎NOTICE.md‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,16 @@ Javassist Version 3.30.2-GA
7070
* Project: http://www.javassist.org/
7171
* Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
7272

73-
Jackson JAX-RS Providers Version 2.19.1
73+
Jackson JAX-RS Providers Version 2.20.1
7474
* License: Apache License, 2.0
7575
* Project: https://github.com/FasterXML/jackson-jaxrs-providers
7676
* Copyright: (c) 2009-2024 FasterXML, LLC. All rights reserved unless otherwise indicated.
7777

78+
Jackson Jakarta RS Providers Version 3.1.1
79+
* License: Apache License, 2.0
80+
* Project: https://github.com/FasterXML/jackson-jakarta-rs-providers
81+
* Copyright: (c) 2009-2026 FasterXML, LLC. All rights reserved unless otherwise indicated.
82+
7883
jQuery v3.7.1
7984
* License: jquery.org/license
8085
* Project: jquery.org

‎bom/pom.xml‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
33
Copyright (c) 2026 Contributors to the Eclipse Foundation.
4-
Copyright (c) 2013, 2025 Oracle and/or its affiliates. All rights reserved.
4+
Copyright (c) 2013, 2026 Oracle and/or its affiliates. All rights reserved.
55
66
This program and the accompanying materials are made available under the
77
terms of the Eclipse Public License v. 2.0, which is available at
@@ -312,6 +312,11 @@
312312
<artifactId>jersey-media-json-jackson</artifactId>
313313
<version>${project.version}</version>
314314
</dependency>
315+
<dependency>
316+
<groupId>org.glassfish.jersey.media</groupId>
317+
<artifactId>jersey-media-json-jackson3</artifactId>
318+
<version>${project.version}</version>
319+
</dependency>
315320
<dependency>
316321
<groupId>org.glassfish.jersey.media</groupId>
317322
<artifactId>jersey-media-json-jettison</artifactId>

‎bundles/apidocs/pom.xml‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
33
Copyright (c) 2026 Contributors to the Eclipse Foundation.
4-
Copyright (c) 2012, 2025 Oracle and/or its affiliates. All rights reserved.
4+
Copyright (c) 2012, 2026 Oracle and/or its affiliates. All rights reserved.
55
66
This program and the accompanying materials are made available under the
77
terms of the Eclipse Public License v. 2.0, which is available at
@@ -66,8 +66,9 @@
6666
<distribution>repo</distribution>
6767
<comments>Google Guava @ org.glassfish.jersey.internal.guava,
6868
Dropwizard Monitoring inspired classes @ org.glassfish.jersey.server.internal.monitoring.core,
69-
Hibernate Validation classes @ org.glassfish.jersey.server.validation.internal.hibernate, and
70-
Jackson JAX-RS Providers @ org.glassfish.jersey.jackson.internal.jackson.jaxrs</comments>
69+
Hibernate Validation classes @ org.glassfish.jersey.server.validation.internal.hibernate,
70+
Jackson JAX-RS Providers @ org.glassfish.jersey.jackson.internal.jackson.jaxrs, and
71+
Jackson Jakarta RS Providers @ org.glassfish.jersey.jackson3.internal.jackson.jakarta.rs</comments>
7172
</license>
7273
<license>
7374
<name>Public Domain</name>
@@ -297,6 +298,11 @@
297298
<artifactId>jersey-media-json-jackson</artifactId>
298299
<version>${project.version}</version>
299300
</dependency>
301+
<dependency>
302+
<groupId>org.glassfish.jersey.media</groupId>
303+
<artifactId>jersey-media-json-jackson3</artifactId>
304+
<version>${project.version}</version>
305+
</dependency>
300306
<dependency>
301307
<groupId>com.fasterxml.jackson.module</groupId>
302308
<artifactId>jackson-module-jaxb-annotations</artifactId>

‎bundles/examples/pom.xml‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
33
Copyright (c) 2026 Contributors to the Eclipse Foundation.
4-
Copyright (c) 2013, 2025 Oracle and/or its affiliates. All rights reserved.
4+
Copyright (c) 2013, 2026 Oracle and/or its affiliates. All rights reserved.
55
66
This program and the accompanying materials are made available under the
77
terms of the Eclipse Public License v. 2.0, which is available at
@@ -68,8 +68,9 @@
6868
<distribution>repo</distribution>
6969
<comments>Google Guava @ org.glassfish.jersey.internal.guava,
7070
Dropwizard Monitoring inspired classes @ org.glassfish.jersey.server.internal.monitoring.core,
71-
Hibernate Validation classes @ org.glassfish.jersey.server.validation.internal.hibernate, and
72-
Jackson JAX-RS Providers @ org.glassfish.jersey.jackson.internal.jackson.jaxrs</comments>
71+
Hibernate Validation classes @ org.glassfish.jersey.server.validation.internal.hibernate,
72+
Jackson JAX-RS Providers @ org.glassfish.jersey.jackson.internal.jackson.jaxrs, and
73+
Jackson Jakarta RS Providers @ org.glassfish.jersey.jackson3.internal.jackson.jakarta.rs</comments>
7374
</license>
7475
<license>
7576
<name>Public Domain</name>

‎docs/pom.xml‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
33
Copyright (c) 2026 Contributors to the Eclipse Foundation.
4-
Copyright (c) 2010, 2025 Oracle and/or its affiliates. All rights reserved.
4+
Copyright (c) 2010, 2026 Oracle and/or its affiliates. All rights reserved.
55
66
This program and the accompanying materials are made available under the
77
terms of the Eclipse Public License v. 2.0, which is available at
@@ -64,8 +64,9 @@
6464
<distribution>repo</distribution>
6565
<comments>Google Guava @ org.glassfish.jersey.internal.guava,
6666
Dropwizard Monitoring inspired classes @ org.glassfish.jersey.server.internal.monitoring.core,
67-
Hibernate Validation classes @ org.glassfish.jersey.server.validation.internal.hibernate, and
68-
Jackson JAX-RS Providers @ org.glassfish.jersey.jackson.internal.jackson.jaxrs</comments>
67+
Hibernate Validation classes @ org.glassfish.jersey.server.validation.internal.hibernate,
68+
Jackson JAX-RS Providers @ org.glassfish.jersey.jackson.internal.jackson.jaxrs, and
69+
Jackson Jakarta RS Providers @ org.glassfish.jersey.jackson3.internal.jackson.jakarta.rs</comments>
6970
</license>
7071
<license>
7172
<name>Public Domain</name>

‎etc/config/checkstyle-suppressions.xml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
33
4-
Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved.
4+
Copyright (c) 2014, 2018, 2026 Oracle and/or its affiliates. All rights reserved.
55
66
This program and the accompanying materials are made available under the
77
terms of the Eclipse Public License v. 2.0, which is available at
@@ -26,6 +26,7 @@
2626
<suppress files="org[\\/]openjdk[\\/]jmh" checks=".*"/>
2727
<!-- Suppress all checks on repackaged Jackson JAX-RS providers. -->
2828
<suppress files="org[\\/]glassfish[\\/]jersey[\\/]jackson[\\/]internal[\\/]jackson" checks=".*"/>
29+
<suppress files="org[\\/]glassfish[\\/]jersey[\\/]jackson3[\\/]internal[\\/]jackson" checks=".*"/>
2930
<suppress files="generated" checks=".*"/>
3031

3132
<!-- Suppress all checks for all Jersey repackaged libraries. -->

‎etc/config/copyright-exclude‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ build.readme
8585
/core-server/src/main/java/org/glassfish/jersey/server/internal/monitoring/core/UniformTimeValuesSnapshot.java
8686
/core-server/src/main/java/jersey/repackaged
8787
/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson
88+
/media/json-jackson3/src/main/java/org/glassfish/jersey/jackson3/internal/jackson
8889
/META-INF/NOTICE.md
8990
NOTICE.md
9091
/ext/cdi/jersey-cdi1x/src/main/java/org/glassfish/jersey/ext/cdi1x/internal/ProcessAllAnnotatedTypes.java

‎examples/NOTICE.md‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,16 @@ Javassist Version 3.30.2-GA
7171
* Project: http://www.javassist.org/
7272
* Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
7373

74-
Jackson JAX-RS Providers Version 2.19.1
74+
Jackson JAX-RS Providers Version 2.20.1
7575
* License: Apache License, 2.0
7676
* Project: https://github.com/FasterXML/jackson-jaxrs-providers
7777
* Copyright: (c) 2009-2023 FasterXML, LLC. All rights reserved unless otherwise indicated.
7878

79+
Jackson Jakarta RS Providers Version 3.1.1
80+
* License: Apache License, 2.0
81+
* Project: https://github.com/FasterXML/jackson-jakarta-rs-providers
82+
* Copyright: (c) 2009-2026 FasterXML, LLC. All rights reserved unless otherwise indicated.
83+
7984
jQuery v3.7.1
8085
* License: jquery.org/license
8186
* Project: jquery.org

‎examples/json-jackson3/README.MD‎

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
[//]: # " Copyright (c) 2015, 2020, 2026 Oracle and/or its affiliates. All rights reserved. "
2+
[//]: # " "
3+
[//]: # " This program and the accompanying materials are made available under the "
4+
[//]: # " terms of the Eclipse Distribution License v. 1.0, which is available at "
5+
[//]: # " http://www.eclipse.org/org/documents/edl-v10.php. "
6+
[//]: # " "
7+
[//]: # " SPDX-License-Identifier: BSD-3-Clause "
8+
9+
Jackson JAX-RS JSON Provider Example
10+
====================================
11+
12+
This example demonstrates how to produce/consume JSON representations
13+
from Java objects. This applies not only to JAXB beans, as shown in the
14+
`json-from-jaxb` example but also to ordinary, un-annotated, POJOs.
15+
16+
This example hosts three simple read-only resources: One provides an
17+
example of using a Jackson JSON provider (registered by the feature
18+
`JacksonFeature` in the `MyApplication` class) instead of using JAXB
19+
(Object-&gt;JAXB-&gt;JSON) which has some limitations (e.g. empty arrays
20+
in JAXB beans). For this resource the JSON representation is produced by
21+
the Jackson JAX-RS provider, while the XML representation is generated
22+
by JAXB as usual. The second web resource is based on a simple
23+
un-annotated POJO and provides only JSON-based representations: JSON and
24+
JSON with padding (JSONP). The third resource depicts how Jackson and
25+
JAXB annotations could be mixed together within a single POJO.
26+
27+
Contents
28+
--------
29+
30+
The "empty array" web resource is implemented by the `org.glassfish.jersey.examples.jackson3.EmptyArrayResource` class.
31+
32+
The "non JAXB" web resource is implemented by the `org.glassfish.jersey.examples.jackson3.NonJaxbBeanResource` class.
33+
34+
Both resources use the default Jackson mapper configuration to serialize JSON
35+
data out and depicts the corner cases, where the Jersey internal, StAX
36+
based, JSON processing can not be utilized.
37+
38+
The `org.glassfish.jersey.examples.jackson3.CombinedAnnotationResource`
39+
class is used to show how JAXB and Jackson annotations could be combined
40+
together in one Java bean for JSON serialization. See the
41+
42+
`org.glassfish.jersey.examples.jackson3.MyJsonMapperProvider` class
43+
where Jackson specific options are used to set up the desired JSON
44+
serialization configuration.
45+
46+
The mapping of the URI path space is presented in the following table:
47+
48+
URI path | Resource class | HTTP method
49+
---------------------------- | ---------------------------- | -------------
50+
**_/emptyArrayResource_** | EmptyArrayResource | GET
51+
**_/nonJaxbResource_** | NonJaxbBeanResource | GET
52+
**_/combinedAnnotations_** | CombinedAnnotationResource | GET
53+
54+
To use Jackson specific configuration options, one can implement a
55+
`ContextResolver<JsonMapper>` provider. For an example of such an
56+
implementation, see the `MyJsonMapperProvider` class.
57+
58+
Running the Example
59+
-------------------
60+
61+
Run the example as follows:
62+
63+
> mvn clean compile exec:java
64+
65+
This deploys the example using[Grizzly](https://projects.eclipse.org/projects/ee4j.grizzly)
66+
67+
A [WADL description](http://wadl.java.net/#spec) may be accessed at the URL:
68+
69+
- <http://localhost:8080/jackson/application.wadl>
70+
71+
The three resources are available at
72+
73+
- <http://localhost:8080/jackson/emptyArrayResource>
74+
- <http://localhost:8080/jackson/nonJaxbResource>
75+
- <http://localhost:8080/jackson/combinedAnnotations>
76+
77+
To easily obtain the different output types available,
78+
[cURL](http://curl.haxx.se/) can be used as follows:
79+
80+
Obtain the JSON output of EmptyArrayResource (use
81+
`-HAccept:application/xml` for XML output):
82+
83+
> curl -HAccept:application/json http://localhost:8080/jackson/emptyArrayResource
84+
85+
Obtain the JSON output of NonJaxbBeanResource (use `-HAccept:application/javascript` for JSONP output):
86+
87+
> curl -HAccept:application/json http://localhost:8080/jackson/nonJaxbResource
88+
89+
Obtain the JSON output of CombinedAnnotationResource:
90+
91+
> curl -HAccept:application/json http://localhost:8080/jackson/combinedAnnotations

‎examples/json-jackson3/pom.xml‎

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
4+
Copyright (c) 2010, 2026 Oracle and/or its affiliates. All rights reserved.
5+
6+
This program and the accompanying materials are made available under the
7+
terms of the Eclipse Distribution License v. 1.0, which is available at
8+
http://www.eclipse.org/org/documents/edl-v10.php.
9+
10+
SPDX-License-Identifier: BSD-3-Clause
11+
12+
-->
13+
14+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
15+
<modelVersion>4.0.0</modelVersion>
16+
17+
<parent>
18+
<groupId>org.glassfish.jersey.examples</groupId>
19+
<artifactId>project</artifactId>
20+
<version>${revision}</version>
21+
</parent>
22+
23+
<artifactId>json-jackson3</artifactId>
24+
<packaging>jar</packaging>
25+
<name>jersey-examples-json-jackson</name>
26+
27+
<description>Jersey JSON with Jackson example.</description>
28+
29+
<dependencies>
30+
<dependency>
31+
<groupId>org.glassfish.jersey.containers</groupId>
32+
<artifactId>jersey-container-grizzly2-http</artifactId>
33+
</dependency>
34+
<dependency>
35+
<groupId>org.glassfish.jersey.inject</groupId>
36+
<artifactId>jersey-hk2</artifactId>
37+
</dependency>
38+
<dependency>
39+
<groupId>org.glassfish.jersey.media</groupId>
40+
<artifactId>jersey-media-json-jackson3</artifactId>
41+
</dependency>
42+
43+
<dependency>
44+
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
45+
<artifactId>jersey-test-framework-provider-bundle</artifactId>
46+
<type>pom</type>
47+
<scope>test</scope>
48+
</dependency>
49+
<dependency>
50+
<groupId>org.glassfish.jersey.test-framework</groupId>
51+
<artifactId>jersey-test-framework-util</artifactId>
52+
<scope>test</scope>
53+
</dependency>
54+
55+
<dependency>
56+
<groupId>jakarta.xml.bind</groupId>
57+
<artifactId>jakarta.xml.bind-api</artifactId>
58+
</dependency>
59+
<dependency>
60+
<groupId>com.sun.xml.bind</groupId>
61+
<artifactId>jaxb-osgi</artifactId>
62+
</dependency>
63+
</dependencies>
64+
65+
<build>
66+
<plugins>
67+
<plugin>
68+
<groupId>org.codehaus.mojo</groupId>
69+
<artifactId>exec-maven-plugin</artifactId>
70+
<configuration>
71+
<mainClass>org.glassfish.jersey.examples.jackson3.App</mainClass>
72+
</configuration>
73+
</plugin>
74+
</plugins>
75+
</build>
76+
77+
<profiles>
78+
<profile>
79+
<id>pre-release</id>
80+
<build>
81+
<plugins>
82+
<plugin>
83+
<groupId>org.apache.maven.plugins</groupId>
84+
<artifactId>maven-assembly-plugin</artifactId>
85+
</plugin>
86+
</plugins>
87+
</build>
88+
</profile>
89+
</profiles>
90+
91+
</project>

0 commit comments

Comments
 (0)