@ -0,0 +1,48 @@ | |||
<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/maven-v4_0_0.xsd"> | |||
<modelVersion>4.0.0</modelVersion> | |||
<parent> | |||
<groupId>com.jarylchng</groupId> | |||
<artifactId>reactive-mongo-examples</artifactId> | |||
<version>1.0</version> | |||
</parent> | |||
<artifactId>tomcat-jersey</artifactId> | |||
<dependencies> | |||
<dependency> | |||
<groupId>com.jarylchng</groupId> | |||
<artifactId>common-jersey</artifactId> | |||
<version>${project.version}</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.tomcat.embed</groupId> | |||
<artifactId>tomcat-embed-core</artifactId> | |||
<version>${tomcat.version}</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.glassfish.jersey.containers</groupId> | |||
<artifactId>jersey-container-servlet</artifactId> | |||
<version>${jersey.version}</version> | |||
</dependency> | |||
</dependencies> | |||
<build> | |||
<plugins> | |||
<plugin> | |||
<groupId>org.apache.maven.plugins</groupId> | |||
<artifactId>maven-jar-plugin</artifactId> | |||
<version>3.1.2</version> | |||
<configuration> | |||
<archive> | |||
<manifest> | |||
<mainClass>com.jarylchng.reactivemongoexample.tomcatjersey.TomcatJersey</mainClass> | |||
</manifest> | |||
</archive> | |||
</configuration> | |||
</plugin> | |||
</plugins> | |||
</build> | |||
</project> |
@ -0,0 +1,42 @@ | |||
package com.jarylchng.reactivemongoexample.tomcatjersey; | |||
import com.jarylchng.reactivemongoexample.common.EmbedMongo; | |||
import com.jarylchng.reactivemongoexample.common.ResourceReactive; | |||
import com.jarylchng.reactivemongoexample.common.ResourceSynced; | |||
import org.apache.catalina.Context; | |||
import org.apache.catalina.LifecycleException; | |||
import org.apache.catalina.startup.Tomcat; | |||
import org.glassfish.jersey.server.ResourceConfig; | |||
import org.glassfish.jersey.servlet.ServletContainer; | |||
import javax.servlet.annotation.WebFilter; | |||
import javax.ws.rs.core.Application; | |||
import java.io.File; | |||
@WebFilter(asyncSupported = true) | |||
public class TomcatJersey extends Application { | |||
private static void startServer() throws LifecycleException { | |||
Tomcat tomcat = new Tomcat(); | |||
File base = new File(System.getProperty("java.io.tmpdir")); | |||
tomcat.setBaseDir(base.getAbsolutePath()); | |||
tomcat.setPort(8080); | |||
Context context = tomcat.addWebapp("", base.getAbsolutePath()); | |||
Tomcat.addServlet(context, "tomcat-jersey", | |||
new ServletContainer(new ResourceConfig() | |||
.register(ResourceReactive.class) | |||
.register(ResourceSynced.class))) | |||
.setAsyncSupported(true); | |||
context.addServletMappingDecoded("/*", "tomcat-jersey"); | |||
tomcat.start(); | |||
tomcat.getConnector(); | |||
} | |||
public static void main(String[] args) throws LifecycleException { | |||
EmbedMongo.start(); | |||
startServer(); | |||
} | |||
} | |||
@ -0,0 +1,43 @@ | |||
<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/maven-v4_0_0.xsd"> | |||
<modelVersion>4.0.0</modelVersion> | |||
<parent> | |||
<groupId>com.jarylchng</groupId> | |||
<artifactId>reactive-mongo-examples</artifactId> | |||
<version>1.0</version> | |||
</parent> | |||
<artifactId>tomcat-resteasy</artifactId> | |||
<dependencies> | |||
<dependency> | |||
<groupId>com.jarylchng</groupId> | |||
<artifactId>common-resteasy</artifactId> | |||
<version>${project.version}</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.tomcat.embed</groupId> | |||
<artifactId>tomcat-embed-core</artifactId> | |||
<version>${tomcat.version}</version> | |||
</dependency> | |||
</dependencies> | |||
<build> | |||
<plugins> | |||
<plugin> | |||
<groupId>org.apache.maven.plugins</groupId> | |||
<artifactId>maven-jar-plugin</artifactId> | |||
<version>3.1.2</version> | |||
<configuration> | |||
<archive> | |||
<manifest> | |||
<mainClass>com.jarylchng.reactivemongoexample.tomcatresteasy.TomcatResteasy</mainClass> | |||
</manifest> | |||
</archive> | |||
</configuration> | |||
</plugin> | |||
</plugins> | |||
</build> | |||
</project> |
@ -0,0 +1,37 @@ | |||
package com.jarylchng.reactivemongoexample.tomcatresteasy; | |||
import com.jarylchng.reactivemongoexample.common.CommonApplication; | |||
import com.jarylchng.reactivemongoexample.common.EmbedMongo; | |||
import org.apache.catalina.Context; | |||
import org.apache.catalina.LifecycleException; | |||
import org.apache.catalina.startup.Tomcat; | |||
import org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher; | |||
import org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap; | |||
import javax.ws.rs.core.Application; | |||
import java.io.File; | |||
public class TomcatResteasy extends Application { | |||
private static void startServer() throws LifecycleException { | |||
Tomcat tomcat = new Tomcat(); | |||
File base = new File(System.getProperty("java.io.tmpdir")); | |||
tomcat.setBaseDir(base.getAbsolutePath()); | |||
tomcat.setPort(8080); | |||
Context context = tomcat.addContext("", base.getAbsolutePath()); | |||
context.addApplicationListener(ResteasyBootstrap.class.getName()); | |||
Tomcat.addServlet(context, "tomcat-resteasy", new HttpServletDispatcher()); | |||
context.addParameter("javax.ws.rs.Application", CommonApplication.class.getName()); | |||
context.addServletMappingDecoded("/*", "tomcat-resteasy"); | |||
tomcat.start(); | |||
tomcat.getConnector(); | |||
} | |||
public static void main(String[] args) throws LifecycleException { | |||
EmbedMongo.start(); | |||
startServer(); | |||
} | |||
} | |||