Skip to content
This repository was archived by the owner on May 28, 2018. It is now read-only.

Commit 2314a6c

Browse files
committed
Repackaging jackson.jaxrs to media.json-jackson module.
Change-Id: Id7d4df830d6b0dedaa929f8fe12575462c53f52f
1 parent bff5db2 commit 2314a6c

29 files changed

Lines changed: 2830 additions & 19 deletions

etc/config/checkstyle-suppressions.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
55
6-
Copyright (c) 2014-2015 Oracle and/or its affiliates. All rights reserved.
6+
Copyright (c) 2014-2017 Oracle and/or its affiliates. All rights reserved.
77
88
The contents of this file are subject to the terms of either the GNU
99
General Public License Version 2 only ("GPL") or the Common Development
@@ -47,6 +47,8 @@
4747
<suppress files="com[\\/]sun[\\/]research[\\/]ws[\\/]wadl" checks=".*"/>
4848
<!-- Suppress all checks on all JMH generated files. -->
4949
<suppress files="org[\\/]openjdk[\\/]jmh" checks=".*"/>
50+
<!-- Suppress all checks on repackaged Jackson JAX-RS providers. -->
51+
<suppress files="org[\\/]glassfish[\\/]jersey[\\/]jackson[\\/]internal[\\/]jackson" checks=".*"/>
5052
<suppress files="generated" checks=".*"/>
5153

5254
<!-- 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
@@ -71,3 +71,4 @@ build.readme
7171
/core-server/src/main/java/org/glassfish/jersey/server/internal/monitoring/UniformTimeSnapshot.java
7272
/core-server/src/main/java/org/glassfish/jersey/server/internal/monitoring/UniformTimeValuesSnapshot.java
7373
/core-server/src/main/java/jersey/repackaged
74+
/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson

media/json-jackson/pom.xml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,25 @@
9696
<version>${project.version}</version>
9797
</dependency>
9898

99+
<!--<dependency>-->
100+
<!--<groupId>com.fasterxml.jackson.jaxrs</groupId>-->
101+
<!--<artifactId>jackson-jaxrs-base</artifactId>-->
102+
<!--</dependency>-->
103+
<!--<dependency>-->
104+
<!--<groupId>com.fasterxml.jackson.jaxrs</groupId>-->
105+
<!--<artifactId>jackson-jaxrs-json-provider</artifactId>-->
106+
<!--</dependency>-->
99107
<dependency>
100-
<groupId>com.fasterxml.jackson.jaxrs</groupId>
101-
<artifactId>jackson-jaxrs-base</artifactId>
108+
<groupId>com.fasterxml.jackson.core</groupId>
109+
<artifactId>jackson-annotations</artifactId>
102110
</dependency>
103111
<dependency>
104-
<groupId>com.fasterxml.jackson.jaxrs</groupId>
105-
<artifactId>jackson-jaxrs-json-provider</artifactId>
112+
<groupId>com.fasterxml.jackson.core</groupId>
113+
<artifactId>jackson-databind</artifactId>
106114
</dependency>
107115
<dependency>
108-
<groupId>com.fasterxml.jackson.core</groupId>
109-
<artifactId>jackson-annotations</artifactId>
116+
<groupId>com.fasterxml.jackson.module</groupId>
117+
<artifactId>jackson-module-jaxb-annotations</artifactId>
110118
</dependency>
111119

112120
<dependency>

media/json-jackson/src/main/java/org/glassfish/jersey/jackson/JacksonFeature.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33
*
4-
* Copyright (c) 2012-2015 Oracle and/or its affiliates. All rights reserved.
4+
* Copyright (c) 2012-2017 Oracle and/or its affiliates. All rights reserved.
55
*
66
* The contents of this file are subject to the terms of either the GNU
77
* General Public License Version 2 only ("GPL") or the Common Development
@@ -50,12 +50,11 @@
5050
import org.glassfish.jersey.internal.util.PropertiesHelper;
5151
import org.glassfish.jersey.jackson.internal.FilteringJacksonJaxbJsonProvider;
5252
import org.glassfish.jersey.jackson.internal.JacksonFilteringFeature;
53+
import org.glassfish.jersey.jackson.internal.jackson.jaxrs.base.JsonMappingExceptionMapper;
54+
import org.glassfish.jersey.jackson.internal.jackson.jaxrs.base.JsonParseExceptionMapper;
55+
import org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJaxbJsonProvider;
5356
import org.glassfish.jersey.message.filtering.EntityFilteringFeature;
5457

55-
import com.fasterxml.jackson.jaxrs.base.JsonMappingExceptionMapper;
56-
import com.fasterxml.jackson.jaxrs.base.JsonParseExceptionMapper;
57-
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
58-
5958
/**
6059
* Feature used to register Jackson JSON providers.
6160
*

media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/FilteringJacksonJaxbJsonProvider.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33
*
4-
* Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
4+
* Copyright (c) 2015-2017 Oracle and/or its affiliates. All rights reserved.
55
*
66
* The contents of this file are subject to the terms of either the GNU
77
* General Public License Version 2 only ("GPL") or the Common Development
@@ -54,6 +54,11 @@
5454
import javax.inject.Singleton;
5555

5656
import org.glassfish.jersey.internal.util.ReflectionHelper;
57+
import org.glassfish.jersey.jackson.internal.jackson.jaxrs.cfg.EndpointConfigBase;
58+
import org.glassfish.jersey.jackson.internal.jackson.jaxrs.cfg.ObjectWriterInjector;
59+
import org.glassfish.jersey.jackson.internal.jackson.jaxrs.cfg.ObjectWriterModifier;
60+
import org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJaxbJsonProvider;
61+
import org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JsonEndpointConfig;
5762
import org.glassfish.jersey.message.filtering.spi.ObjectProvider;
5863

5964
import com.fasterxml.jackson.core.JsonGenerator;
@@ -68,11 +73,6 @@
6873
import com.fasterxml.jackson.databind.ser.BeanPropertyFilter;
6974
import com.fasterxml.jackson.databind.ser.FilterProvider;
7075
import com.fasterxml.jackson.databind.ser.PropertyFilter;
71-
import com.fasterxml.jackson.jaxrs.cfg.EndpointConfigBase;
72-
import com.fasterxml.jackson.jaxrs.cfg.ObjectWriterInjector;
73-
import com.fasterxml.jackson.jaxrs.cfg.ObjectWriterModifier;
74-
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
75-
import com.fasterxml.jackson.jaxrs.json.JsonEndpointConfig;
7676

7777
/**
7878
* Entity Data Filtering provider based on Jackson JSON provider.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package org.glassfish.jersey.jackson.internal.jackson.jaxrs.annotation;
2+
3+
import java.lang.annotation.ElementType;
4+
import java.lang.annotation.Retention;
5+
import java.lang.annotation.RetentionPolicy;
6+
import java.lang.annotation.Target;
7+
8+
import com.fasterxml.jackson.databind.DeserializationFeature;
9+
import com.fasterxml.jackson.databind.SerializationFeature;
10+
11+
/**
12+
* Annotation that can be used enable and/or disable various
13+
* features for <code>ObjectReader</code>s and <code>ObjectWriter</code>s.
14+
*/
15+
@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD })
16+
@Retention(RetentionPolicy.RUNTIME)
17+
@com.fasterxml.jackson.annotation.JacksonAnnotation
18+
public @interface JacksonFeatures
19+
{
20+
/**
21+
* Deserialization features to enable.
22+
*/
23+
public DeserializationFeature[] deserializationEnable() default { };
24+
25+
/**
26+
* Deserialization features to disable.
27+
*/
28+
public DeserializationFeature[] deserializationDisable() default { };
29+
30+
/**
31+
* Serialization features to enable.
32+
*/
33+
public SerializationFeature[] serializationEnable() default { };
34+
35+
/**
36+
* Serialization features to disable.
37+
*/
38+
public SerializationFeature[] serializationDisable() default { };
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package org.glassfish.jersey.jackson.internal.jackson.jaxrs.base;
2+
3+
import javax.ws.rs.core.Response;
4+
import javax.ws.rs.ext.ExceptionMapper;
5+
6+
import com.fasterxml.jackson.databind.JsonMappingException;
7+
8+
/**
9+
* Implementation if {@link ExceptionMapper} to send down a "400 Bad Request"
10+
* response in the event that unmappable JSON is received.
11+
*<p>
12+
* Note that {@link javax.ws.rs.ext.Provider} annotation was include up to
13+
* Jackson 2.7, but removed from 2.8 (as per [jaxrs-providers#22]
14+
*
15+
* @since 2.2
16+
*/
17+
public class JsonMappingExceptionMapper implements ExceptionMapper<JsonMappingException> {
18+
@Override
19+
public Response toResponse(JsonMappingException exception) {
20+
return Response.status(Response.Status.BAD_REQUEST).entity(exception.getMessage()).type("text/plain").build();
21+
}
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package org.glassfish.jersey.jackson.internal.jackson.jaxrs.base;
2+
3+
import javax.ws.rs.core.Response;
4+
import javax.ws.rs.ext.ExceptionMapper;
5+
6+
import com.fasterxml.jackson.core.JsonParseException;
7+
8+
/**
9+
* Implementation of {@link ExceptionMapper} to send down a "400 Bad Request"
10+
* in the event unparsable JSON is received.
11+
*<p>
12+
* Note that {@link javax.ws.rs.ext.Provider} annotation was include up to
13+
* Jackson 2.7, but removed from 2.8 (as per [jaxrs-providers#22]
14+
*
15+
* @since 2.2
16+
*/
17+
public class JsonParseExceptionMapper implements ExceptionMapper<JsonParseException> {
18+
@Override
19+
public Response toResponse(JsonParseException exception) {
20+
return Response.status(Response.Status.BAD_REQUEST).entity(exception.getMessage()).type("text/plain").build();
21+
}
22+
}

0 commit comments

Comments
 (0)