Skip to content

Commit

Permalink
Jakarta Namespace - jackson compatible on the jakarta classifier
Browse files Browse the repository at this point in the history
  • Loading branch information
GedMarc committed Nov 12, 2020
1 parent d72f6f0 commit bbc03ae
Show file tree
Hide file tree
Showing 82 changed files with 6,116 additions and 87 deletions.
3 changes: 2 additions & 1 deletion apache-cxf/pom.xml
Expand Up @@ -68,8 +68,9 @@
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<groupId>com.guicedee.services</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<classifier>jakarta</classifier>
</dependency>

<dependency>
Expand Down
@@ -0,0 +1 @@
org.apache.cxf.jaxrs.impl.RuntimeDelegateImpl
@@ -0,0 +1 @@
org.apache.cxf.jaxrs.sse.client.SseEventSourceBuilderImpl
@@ -0,0 +1,2 @@
com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl
com.sun.xml.messaging.saaj.soap.ver1_2.SOAPMessageFactory1_2Impl
@@ -0,0 +1 @@
com.sun.xml.messaging.saaj.soap.SAAJMetaFactoryImpl
@@ -0,0 +1 @@
com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnectionFactory
@@ -0,0 +1,2 @@
com.sun.xml.messaging.saaj.soap.ver1_1.SOAPFactory1_1Impl
com.sun.xml.messaging.saaj.soap.ver1_2.SOAPFactory1_2Impl
@@ -0,0 +1 @@
org.apache.cxf.jaxws22.spi.ProviderImpl
103 changes: 103 additions & 0 deletions jackson-base/pom.xml
@@ -0,0 +1,103 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<!-- This module was also published with a richer model, Gradle metadata, -->
<!-- which should be used instead. Do not delete the following line which -->
<!-- is to indicate to Gradle or any Gradle module metadata file consumer -->
<!-- that they should prefer consuming it instead. -->
<!-- do_not_remove: published-with-gradle-metadata -->
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.guicedee.services</groupId>
<artifactId>services-parent</artifactId>
<version>0.0.0_0-SNAPSHOT</version>
</parent>

<artifactId>jackson-jaxrs-base</artifactId>
<name>Jackson-JAXRS-base</name>
<packaging>jar</packaging>

<description>Pile of code that is shared by all Jackson-based JAX-RS
providers.
</description>

<properties>
<osgi.export>
${project.groupId}.annotation.*;version=${project.version}
,${project.groupId}.base.*;version=${project.version}
,${project.groupId}.cfg.*;version=${project.version}
,${project.groupId}.util.*;version=${project.version}
</osgi.export>
<osgi.import>javax.ws.rs;version="${javax.ws.rs.version}"
,javax.ws.rs.core;version="${javax.ws.rs.version}"
,javax.ws.rs.ext;version="${javax.ws.rs.version}",
*
</osgi.import>
</properties>

<dependencies>
<!-- Extends Jackson core, mapper -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>

<dependency>
<groupId>com.guicedee.services</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
</dependency>
<!-- test deps should come from parent -->
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.moditect</groupId>
<artifactId>moditect-maven-plugin</artifactId>
<configuration>
<jvmVersion>11</jvmVersion>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<id>jakarta</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>jakarta</shadedClassifierName>
<createDependencyReducedPom>false</createDependencyReducedPom>
<artifactSet>
<includes>
<include>${project.groupId}:${project.artifactId}</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>javax.xml.bind</pattern>
<shadedPattern>jakarta.xml.bind</shadedPattern>
</relocation>
<relocation>
<pattern>javax.ws.rs</pattern>
<shadedPattern>jakarta.ws.rs</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>

</plugins>
</build>

</project>
@@ -0,0 +1,39 @@
package com.fasterxml.jackson.jaxrs.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.SerializationFeature;

/**
* Annotation that can be used enable and/or disable various
* features for <code>ObjectReader</code>s and <code>ObjectWriter</code>s.
*/
@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.PARAMETER })
@Retention(RetentionPolicy.RUNTIME)
@com.fasterxml.jackson.annotation.JacksonAnnotation
public @interface JacksonFeatures
{
/**
* Deserialization features to enable.
*/
public DeserializationFeature[] deserializationEnable() default { };

/**
* Deserialization features to disable.
*/
public DeserializationFeature[] deserializationDisable() default { };

/**
* Serialization features to enable.
*/
public SerializationFeature[] serializationEnable() default { };

/**
* Serialization features to disable.
*/
public SerializationFeature[] serializationDisable() default { };
}
@@ -0,0 +1,12 @@
/**
* Package that contains annotations applicable to all content types.
* Currently defined are:
*<ul>
* <li>{@link com.fasterxml.jackson.jaxrs.annotation.JacksonFeatures} allows
* enabling and/or disabling {@link com.fasterxml.jackson.databind.DeserializationFeature}s
* and {@link com.fasterxml.jackson.databind.SerializationFeature}s for individual
* endpoints.
* </li>
* </ul>
*/
package com.fasterxml.jackson.jaxrs.annotation;
@@ -0,0 +1,22 @@
package com.fasterxml.jackson.jaxrs.base;

import com.fasterxml.jackson.databind.JsonMappingException;

import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.ext.ExceptionMapper;

/**
* Implementation if {@link ExceptionMapper} to send down a "400 Bad Request"
* response in the event that unmappable JSON is received.
*<p>
* Note that {@link jakarta.ws.rs.ext.Provider} annotation was include up to
* Jackson 2.7, but removed from 2.8 (as per [jaxrs-providers#22]
*
* @since 2.2
*/
public class JsonMappingExceptionMapper implements ExceptionMapper<JsonMappingException> {
@Override
public Response toResponse(JsonMappingException exception) {
return Response.status(Response.Status.BAD_REQUEST).entity(exception.getMessage()).type("text/plain").build();
}
}
@@ -0,0 +1,22 @@
package com.fasterxml.jackson.jaxrs.base;

import com.fasterxml.jackson.core.JsonParseException;

import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.ext.ExceptionMapper;

/**
* Implementation of {@link ExceptionMapper} to send down a "400 Bad Request"
* in the event unparsable JSON is received.
*<p>
* Note that {@link jakarta.ws.rs.ext.Provider} annotation was include up to
* Jackson 2.7, but removed from 2.8 (as per [jaxrs-providers#22]
*
* @since 2.2
*/
public class JsonParseExceptionMapper implements ExceptionMapper<JsonParseException> {
@Override
public Response toResponse(JsonParseException exception) {
return Response.status(Response.Status.BAD_REQUEST).entity(exception.getMessage()).type("text/plain").build();
}
}
@@ -0,0 +1,13 @@
package com.fasterxml.jackson.jaxrs.base;

import java.io.IOException;

/**
* Implementors of this class contains strategies for NoContentException creation
*/
public interface NoContentExceptionSupplier
{
String NO_CONTENT_MESSAGE = "No content (empty input stream)";

IOException createNoContentException();
}

0 comments on commit bbc03ae

Please sign in to comment.