Skip to content

Commit

Permalink
Migrate to Jakarta.
Browse files Browse the repository at this point in the history
  • Loading branch information
noboomu committed Sep 27, 2023
1 parent 636dde5 commit ffb84ea
Show file tree
Hide file tree
Showing 19 changed files with 160 additions and 167 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Proteus Changelog.
## Unreleased
### No issue

**Switch to SourceBuddy from OpenHFT for dynamic complilation. Breaks < JDK 17 compatability however.**


[636dde50434f508](https://github.com/noboomu/proteus/commit/636dde50434f508) Joshua Bauer *2023-09-25 18:47:26*

**Added additional MediaType to support Wavefront and Pixar.**


Expand Down
8 changes: 5 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<guava.version>32.1.2-jre</guava.version>
<guice.version>5.1.0</guice.version>
<jackson.version>2.15.2</jackson.version>
<jakarta-ws-rs.version>2.1.6</jakarta-ws-rs.version>
<jakarta-ws-rs.version>3.1.0</jakarta-ws-rs.version>
<jansi.version>1.18</jansi.version>
<java.version>17</java.version>
<javapoet.version>1.13.0</javapoet.version>
Expand All @@ -65,18 +65,18 @@
<maven-enforcer-plugin.version>3.0.0-M3</maven-enforcer-plugin.version>
<maven-surefire-plugin.version>3.0.0-M4</maven-surefire-plugin.version>
<nexus-staging-maven-plugin.version>1.6.8</nexus-staging-maven-plugin.version>
<openapi.version>2.2.1</openapi.version>
<openapi.version>2.2.16</openapi.version>
<openhft-compiler.version>2.23ea0</openhft-compiler.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<proteus.version>${project.version}</proteus.version>
<reflections.version>0.10.2</reflections.version>
<slf4j.version>1.7.36</slf4j.version>
<snakeyaml.version>1.30</snakeyaml.version>
<swagger.version>1.5.21</swagger.version>
<typesafe-config.version>1.4.2</typesafe-config.version>
<undertow.version>2.2.18.Final</undertow.version>
<woodstox.version>6.3.0</woodstox.version>
<micrometer-core.version>1.9.1</micrometer-core.version>
<jakarta-validation-api.version>3.0.2</jakarta-validation-api.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -126,6 +126,8 @@
<version>4.0.1</version>
<type>pom</type>
</dependency>


</dependencies>

<dependencyManagement>
Expand Down
38 changes: 20 additions & 18 deletions proteus-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -192,21 +192,21 @@ Proteus Changelog.
<version>${jakarta-ws-rs.version}</version>
</dependency>

<!-- <dependency>-->
<!-- <groupId>net.openhft</groupId>-->
<!-- <artifactId>compiler</artifactId>-->
<!-- <version>${openhft-compiler.version}</version>-->
<!-- <exclusions>-->
<!-- <exclusion>-->
<!-- <groupId>org.slf4j</groupId>-->
<!-- <artifactId>slf4j-api</artifactId>-->
<!-- </exclusion>-->
<!-- <exclusion>-->
<!-- <groupId>com.sun.java</groupId>-->
<!-- <artifactId>tools</artifactId>-->
<!-- </exclusion>-->
<!-- </exclusions>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>net.openhft</groupId>-->
<!-- <artifactId>compiler</artifactId>-->
<!-- <version>${openhft-compiler.version}</version>-->
<!-- <exclusions>-->
<!-- <exclusion>-->
<!-- <groupId>org.slf4j</groupId>-->
<!-- <artifactId>slf4j-api</artifactId>-->
<!-- </exclusion>-->
<!-- <exclusion>-->
<!-- <groupId>com.sun.java</groupId>-->
<!-- <artifactId>tools</artifactId>-->
<!-- </exclusion>-->
<!-- </exclusions>-->
<!-- </dependency>-->

<dependency>
<groupId>com.javax0.sourcebuddy</groupId>
Expand Down Expand Up @@ -245,11 +245,12 @@ Proteus Changelog.
</dependency>

<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<version>${jakarta-validation-api.version}</version>
</dependency>


<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
Expand Down Expand Up @@ -331,6 +332,7 @@ Proteus Changelog.
<scope>compile</scope>
</dependency>


<!--<dependency>-->
<!--<groupId>org.eclipse.microprofile.health</groupId>-->
<!--<artifactId>microprofile-health-api</artifactId>-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@
import io.undertow.server.session.SessionAttachmentHandler;
import io.undertow.util.Headers;
import io.undertow.util.Methods;
import jakarta.ws.rs.core.MediaType;
import org.apache.commons.lang3.time.DurationFormatUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xnio.Xnio;
import org.xnio.XnioWorker;

import javax.ws.rs.core.MediaType;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.InputStream;
Expand Down Expand Up @@ -323,7 +322,7 @@ public void buildServer() {

try {

final var compiled = Compiler.java().from(source).compile();
final var compiled = Compiler.java().from(source).compile();

// compiled.saveTo(Paths.get("./target/generated_classes"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -839,31 +839,31 @@ public static <T> T namedModel(final HttpServerExchange exchange, final Class<T>
public static Function<Method, HttpString> httpMethodFromMethod = (m) ->
Arrays.stream(m.getDeclaredAnnotations()).map(a -> {

if (a instanceof javax.ws.rs.POST)
if (a instanceof jakarta.ws.rs.POST)
{
return Methods.POST;
}
else if (a instanceof javax.ws.rs.GET)
else if (a instanceof jakarta.ws.rs.GET)
{
return Methods.GET;
}
else if (a instanceof javax.ws.rs.PUT)
else if (a instanceof jakarta.ws.rs.PUT)
{
return Methods.PUT;
}
else if (a instanceof javax.ws.rs.DELETE)
else if (a instanceof jakarta.ws.rs.DELETE)
{
return Methods.DELETE;
}
else if (a instanceof javax.ws.rs.OPTIONS)
else if (a instanceof jakarta.ws.rs.OPTIONS)
{
return Methods.OPTIONS;
}
else if (a instanceof javax.ws.rs.HEAD)
else if (a instanceof jakarta.ws.rs.HEAD)
{
return Methods.HEAD;
}
else if (a instanceof javax.ws.rs.PATCH)
else if (a instanceof jakarta.ws.rs.PATCH)
{
return Methods.PATCH;
}
Expand All @@ -876,9 +876,9 @@ else if (a instanceof javax.ws.rs.PATCH)

public static Function<Method, String> pathTemplateFromMethod = (m) ->
{
javax.ws.rs.Path childPath = m.getDeclaredAnnotation(javax.ws.rs.Path.class);
jakarta.ws.rs.Path childPath = m.getDeclaredAnnotation(jakarta.ws.rs.Path.class);

javax.ws.rs.Path parentPath = m.getDeclaringClass().getDeclaredAnnotation(javax.ws.rs.Path.class);
jakarta.ws.rs.Path parentPath = m.getDeclaringClass().getDeclaredAnnotation(jakarta.ws.rs.Path.class);

if (!childPath.value().equals("/"))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,15 @@
import org.xnio.conduits.StreamSinkConduit;
import org.xnio.conduits.StreamSourceConduit;

import javax.ws.rs.core.MediaType;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.file.Path;
import java.util.Deque;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.Executor;
import java.util.stream.Collectors;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.google.inject.Inject;
import io.sinistral.proteus.protocol.HttpHeaders;
import com.google.inject.Inject;
import io.sinistral.proteus.protocol.MediaType;
import io.sinistral.proteus.server.predicates.ServerPredicates;
import io.sinistral.proteus.wrappers.JsonViewWrapper;
Expand All @@ -15,13 +14,12 @@
import io.undertow.server.handlers.Cookie;
import io.undertow.server.handlers.ExceptionHandler;
import io.undertow.util.*;
import jakarta.ws.rs.core.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.ws.rs.core.Response;

import java.net.URI;
import java.nio.ByteBuffer;
import java.text.SimpleDateFormat;
import java.nio.ByteBuffer;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
Expand All @@ -35,7 +33,7 @@
/**
* @author jbauer
* Base server response. Friendlier interface to underlying exchange.
* @TODO extend javax.ws.rs.core.Response
* @TODO extend jakarta.ws.rs.core.Response
*/

public class ServerResponse<T>
Expand All @@ -59,7 +57,7 @@ public class ServerResponse<T>
protected int status = StatusCodes.OK;
protected final HeaderMap headers = new HeaderMap();
protected final Map<String, Cookie> cookies = new HashMap<>();
protected String contentType = javax.ws.rs.core.MediaType.APPLICATION_JSON;
protected String contentType = jakarta.ws.rs.core.MediaType.APPLICATION_JSON;
protected T entity;
protected Throwable throwable;
// protected Class<? extends JsonContext> jsonContext;
Expand Down Expand Up @@ -303,11 +301,11 @@ protected void setContentType(String contentType)
{
this.contentType = contentType;

if (this.contentType.contains(javax.ws.rs.core.MediaType.APPLICATION_JSON)) {
if (this.contentType.contains(jakarta.ws.rs.core.MediaType.APPLICATION_JSON)) {
if (!this.preprocessed) {
this.processJson = true;
}
} else if (this.contentType.contains(javax.ws.rs.core.MediaType.APPLICATION_XML)) {
} else if (this.contentType.contains(jakarta.ws.rs.core.MediaType.APPLICATION_XML)) {
if (!this.preprocessed) {
this.processXml = true;
}
Expand All @@ -321,7 +319,7 @@ public ServerResponse<T> contentType(String contentType)
}


public ServerResponse<T> contentType(javax.ws.rs.core.MediaType mediaType)
public ServerResponse<T> contentType(jakarta.ws.rs.core.MediaType mediaType)
{
this.setContentType(mediaType.toString());
return this;
Expand All @@ -338,19 +336,19 @@ public ServerResponse<T> applicationJson()
if (!this.preprocessed) {
this.processJson = true;
}
this.contentType = javax.ws.rs.core.MediaType.APPLICATION_JSON;
this.contentType = jakarta.ws.rs.core.MediaType.APPLICATION_JSON;
return this;
}

public ServerResponse<T> textHtml()
{
this.contentType = javax.ws.rs.core.MediaType.TEXT_HTML;
this.contentType = jakarta.ws.rs.core.MediaType.TEXT_HTML;
return this;
}

public ServerResponse<T> applicationOctetStream()
{
this.contentType = javax.ws.rs.core.MediaType.APPLICATION_OCTET_STREAM;
this.contentType = jakarta.ws.rs.core.MediaType.APPLICATION_OCTET_STREAM;
return this;
}

Expand All @@ -359,13 +357,13 @@ public ServerResponse<T> applicationXml()
if (!this.preprocessed) {
this.processXml = true;
}
this.contentType = javax.ws.rs.core.MediaType.APPLICATION_XML;
this.contentType = jakarta.ws.rs.core.MediaType.APPLICATION_XML;
return this;
}

public ServerResponse<T> textPlain()
{
this.contentType = javax.ws.rs.core.MediaType.TEXT_PLAIN;
this.contentType = jakarta.ws.rs.core.MediaType.TEXT_PLAIN;
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
package io.sinistral.proteus.server.exceptions;

import javax.ws.rs.core.Response.Status;
import jakarta.ws.rs.core.Response.Status;

/**
* @author jbauer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@
import org.slf4j.LoggerFactory;

import javax.lang.model.element.Modifier;
import javax.ws.rs.BeanParam;
import javax.ws.rs.FormParam;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.Path;
import javax.ws.rs.core.MediaType;
import jakarta.ws.rs.BeanParam;
import jakarta.ws.rs.FormParam;
import jakarta.ws.rs.HeaderParam;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.core.MediaType;
import java.io.File;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
Expand Down Expand Up @@ -76,7 +76,7 @@
/**
* Generates code and compiles a <code>Supplier<RoutingHandler></code> class
* from the target class's methods that are annotated with a JAX-RS method
* annotation (i.e. <code>javax.ws.rs.GET</code>)
* annotation (i.e. <code>jakarta.ws.rs.GET</code>)
*
* @author jbauer
*/
Expand Down Expand Up @@ -430,7 +430,7 @@ else if (t.equals(HttpServerExchange.class) || t.equals(ServerRequest.class))
for (Method m : clazz.getDeclaredMethods())
{

if (!Optional.ofNullable(m.getAnnotation(javax.ws.rs.Path.class)).isPresent())
if (!Optional.ofNullable(m.getAnnotation(jakarta.ws.rs.Path.class)).isPresent())
{
continue;
}
Expand Down Expand Up @@ -459,11 +459,11 @@ else if (t.equals(HttpServerExchange.class) || t.equals(ServerRequest.class))
isDebug = debugAnnotation.get().value();
}

Optional<javax.ws.rs.Produces> producesAnnotation = Optional.ofNullable(m.getAnnotation(javax.ws.rs.Produces.class));
Optional<jakarta.ws.rs.Produces> producesAnnotation = Optional.ofNullable(m.getAnnotation(jakarta.ws.rs.Produces.class));

if (producesAnnotation.isEmpty())
{
producesAnnotation = Optional.ofNullable(clazz.getAnnotation(javax.ws.rs.Produces.class));
producesAnnotation = Optional.ofNullable(clazz.getAnnotation(jakarta.ws.rs.Produces.class));

if (producesAnnotation.isPresent())
{
Expand All @@ -484,11 +484,11 @@ else if (t.equals(HttpServerExchange.class) || t.equals(ServerRequest.class))

endpointInfo.setProduces(producesContentType);

Optional<javax.ws.rs.Consumes> consumesAnnotation = Optional.ofNullable(m.getAnnotation(javax.ws.rs.Consumes.class));
Optional<jakarta.ws.rs.Consumes> consumesAnnotation = Optional.ofNullable(m.getAnnotation(jakarta.ws.rs.Consumes.class));

if (consumesAnnotation.isEmpty())
{
consumesAnnotation = Optional.ofNullable(clazz.getAnnotation(javax.ws.rs.Consumes.class));
consumesAnnotation = Optional.ofNullable(clazz.getAnnotation(jakarta.ws.rs.Consumes.class));

if (consumesAnnotation.isPresent())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.ws.rs.core.MediaType;
import jakarta.ws.rs.core.MediaType;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Arrays;
Expand Down
Loading

0 comments on commit ffb84ea

Please sign in to comment.