Permalink
Browse files

Woops. Add main method

  • Loading branch information...
1 parent 2804512 commit 72ffc8a1438627ef85504369c0016e769e2cc8d0 @klette klette committed Sep 19, 2013
Showing with 43 additions and 0 deletions.
  1. +43 −0 src/main/java/no/iterate/restify/rs/Restify.java
@@ -0,0 +1,43 @@
+package no.iterate.restify.rs;
+
+
+import com.sun.jersey.spi.container.servlet.ServletContainer;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.servlet.ServletContextHandler;
+import org.eclipse.jetty.servlet.ServletHolder;
+
+public class Restify {
+
+ public static void main(String[] args) throws Exception {
+ int port = 5000;
+ String envPort = System.getenv("PORT");
+ if (envPort != null) {
+ port = Integer.valueOf(envPort);
+ }
+ final Server server = new Server(port);
+
+ final ServletHolder servletHolder = new ServletHolder(ServletContainer.class);
+
+ servletHolder.setInitParameter(
+ "com.sun.jersey.config.property.resourceConfigClass",
+ "com.sun.jersey.api.core.PackagesResourceConfig");
+
+ servletHolder.setInitParameter(
+ "com.sun.jersey.config.property.packages",
+ "no.iterate.restify.rs" +
+ ";org.codehaus.jackson.jaxrs");
+
+ servletHolder.setInitParameter("com.sun.jersey.api.json.POJOMappingFeature", "true");
+
+
+ ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
+ context.setContextPath("/");
+ context.addServlet(servletHolder, "/*");
+
+ server.setHandler(context);
+
+ server.start();
+ server.join();
+ }
+
+}

0 comments on commit 72ffc8a

Please sign in to comment.