Switched to jersey 2.3.5 due to jakarta being shit

master
Edward M. Kagan 4 years ago
parent 82d5d46fb3
commit 687cd0d4fb

@ -8,7 +8,7 @@ import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
public class Bench { public class Bench {
public static final String BASE_URI = "http://localhost:8080"; public static final String BASE_URI = "http://0.0.0.0:8080";
public static void main(String[] args) throws IOException, InterruptedException { public static void main(String[] args) throws IOException, InterruptedException {
JAXRSServerFactoryBean factoryBean = new JAXRSServerFactoryBean(); JAXRSServerFactoryBean factoryBean = new JAXRSServerFactoryBean();

@ -8,7 +8,7 @@ import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
public class Bench { public class Bench {
public static final String BASE_URI = "http://localhost:8080"; public static final String BASE_URI = "http://0.0.0.0:8080";
public static void main(String[] args) throws IOException, InterruptedException { public static void main(String[] args) throws IOException, InterruptedException {
JAXRSServerFactoryBean factoryBean = new JAXRSServerFactoryBean(); JAXRSServerFactoryBean factoryBean = new JAXRSServerFactoryBean();

@ -8,7 +8,7 @@ import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
public class Bench { public class Bench {
public static final String BASE_URI = "http://localhost:8080"; public static final String BASE_URI = "http://0.0.0.0:8080";
public static void main(String[] args) throws IOException, InterruptedException { public static void main(String[] args) throws IOException, InterruptedException {
JAXRSServerFactoryBean factoryBean = new JAXRSServerFactoryBean(); JAXRSServerFactoryBean factoryBean = new JAXRSServerFactoryBean();

@ -1,17 +1,16 @@
package twopm.tech.bench.jaxrs; package twopm.tech.bench.jaxrs;
import jakarta.ws.rs.GET; import javax.ws.rs.GET;
import jakarta.ws.rs.POST; import javax.ws.rs.POST;
import jakarta.ws.rs.Path; import javax.ws.rs.Path;
import jakarta.ws.rs.PathParam; import javax.ws.rs.PathParam;
import jakarta.ws.rs.Produces; import javax.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
@Path("/test") @Path("/test")
public class TestResource { public class TestResource {
@GET @GET
@Path("/")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public String index() { public String index() {
return "{ \"status\" : \"OK\", \"method\" : \"GET\" }"; return "{ \"status\" : \"OK\", \"method\" : \"GET\" }";

@ -1,33 +1,31 @@
package twopm.tech.bench.jaxrs; package twopm.tech.bench.jaxrs;
import jakarta.ws.rs.GET; import javax.ws.rs.GET;
import jakarta.ws.rs.POST; import javax.ws.rs.POST;
import jakarta.ws.rs.Path; import javax.ws.rs.Path;
import jakarta.ws.rs.PathParam; import javax.ws.rs.PathParam;
import jakarta.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@Path("/test")
@Path("test")
public class TestResource { public class TestResource {
@GET @GET
// @Path("/") @Produces(MediaType.APPLICATION_JSON)
@Produces("application/json")
public String index() { public String index() {
return "{ \"status\" : \"OK\", \"method\" : \"GET\" }"; return "{ \"status\" : \"OK\", \"method\" : \"GET\" }";
} }
@GET @GET
@Path("{id}") @Path("/{id}")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public String get(@PathParam("id") Long id) { public String get(@PathParam("id") Long id) {
return "{ \"status\" : \"OK\", \"method\" : \"GET\", \"test\" : " + String.valueOf(id) + " }"; return "{ \"status\" : \"OK\", \"method\" : \"GET\", \"test\" : " + String.valueOf(id) + " }";
} }
@POST @POST
@Path("{id}") @Path("/{id}")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public String post(@PathParam("id") Long id) { public String post(@PathParam("id") Long id) {
return "{ \"status\" : \"OK\", \"method\" : \"POST\", \"test\" : " + String.valueOf(id) + " }"; return "{ \"status\" : \"OK\", \"method\" : \"POST\", \"test\" : " + String.valueOf(id) + " }";
} }

@ -20,14 +20,18 @@
<artifactId>jersey-hk2</artifactId> <artifactId>jersey-hk2</artifactId>
<version>${jersey.version}</version> <version>${jersey.version}</version>
</dependency> </dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>${jakarta.servlet-api.version}</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId> <artifactId>maven-shade-plugin</artifactId>

@ -1,6 +1,5 @@
package twopm.tech.bench.jaxrs; package twopm.tech.bench.jaxrs;
import com.sun.net.httpserver.HttpServer;
import java.io.IOException; import java.io.IOException;
import java.net.URI; import java.net.URI;
import java.util.logging.Level; import java.util.logging.Level;

@ -1,17 +1,16 @@
package twopm.tech.bench.jaxrs; package twopm.tech.bench.jaxrs;
import jakarta.ws.rs.GET; import javax.ws.rs.GET;
import jakarta.ws.rs.POST; import javax.ws.rs.POST;
import jakarta.ws.rs.Path; import javax.ws.rs.Path;
import jakarta.ws.rs.PathParam; import javax.ws.rs.PathParam;
import jakarta.ws.rs.Produces; import javax.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
@Path("/test") @Path("/test")
public class TestResource { public class TestResource {
@GET @GET
@Path("/")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public String index() { public String index() {
return "{ \"status\" : \"OK\", \"method\" : \"GET\" }"; return "{ \"status\" : \"OK\", \"method\" : \"GET\" }";

@ -1,17 +1,16 @@
package twopm.tech.bench.jaxrs; package twopm.tech.bench.jaxrs;
import jakarta.ws.rs.GET; import javax.ws.rs.GET;
import jakarta.ws.rs.POST; import javax.ws.rs.POST;
import jakarta.ws.rs.Path; import javax.ws.rs.Path;
import jakarta.ws.rs.PathParam; import javax.ws.rs.PathParam;
import jakarta.ws.rs.Produces; import javax.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
@Path("/test") @Path("/test")
public class TestResource { public class TestResource {
@GET @GET
@Path("/")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public String index() { public String index() {
return "{ \"status\" : \"OK\", \"method\" : \"GET\" }"; return "{ \"status\" : \"OK\", \"method\" : \"GET\" }";

@ -1,17 +1,16 @@
package twopm.tech.bench.jaxrs; package twopm.tech.bench.jaxrs;
import jakarta.ws.rs.GET; import javax.ws.rs.GET;
import jakarta.ws.rs.POST; import javax.ws.rs.POST;
import jakarta.ws.rs.Path; import javax.ws.rs.Path;
import jakarta.ws.rs.PathParam; import javax.ws.rs.PathParam;
import jakarta.ws.rs.Produces; import javax.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
@Path("/test") @Path("/test")
public class TestResource { public class TestResource {
@GET @GET
@Path("/")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public String index() { public String index() {
return "{ \"status\" : \"OK\", \"method\" : \"GET\" }"; return "{ \"status\" : \"OK\", \"method\" : \"GET\" }";

@ -1,6 +1,5 @@
package twopm.tech.bench.jaxrs; package twopm.tech.bench.jaxrs;
import com.sun.net.httpserver.HttpContext;
import com.sun.net.httpserver.HttpServer; import com.sun.net.httpserver.HttpServer;
import java.io.IOException; import java.io.IOException;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
@ -12,7 +11,6 @@ public class Bench {
HttpServer server = HttpServer.create(new InetSocketAddress(8080), 10); HttpServer server = HttpServer.create(new InetSocketAddress(8080), 10);
HttpContextBuilder contextBuilder = new HttpContextBuilder(); HttpContextBuilder contextBuilder = new HttpContextBuilder();
contextBuilder.getDeployment().getActualResourceClasses().add(TestResource.class); contextBuilder.getDeployment().getActualResourceClasses().add(TestResource.class);
HttpContext context = contextBuilder.bind(server);
server.start(); server.start();
Runtime.getRuntime().addShutdownHook(new Thread(() -> { Runtime.getRuntime().addShutdownHook(new Thread(() -> {

Loading…
Cancel
Save