diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-11-30 13:55:05 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-11-30 13:55:05 +1300 |
commit | cefc12afe98f610aa0f266bcac4361f9ec414ee5 (patch) | |
tree | 48d47a0eec0c2d8a3ee7f448f8d535d7d826d546 /src/org/traccar/web/WebServer.java | |
parent | c6692703c8099577cb86c3eace5d8d1bc11f212d (diff) | |
parent | 1a25796d62bdf88f2cba0387a09e2eb71599e588 (diff) | |
download | trackermap-server-cefc12afe98f610aa0f266bcac4361f9ec414ee5.tar.gz trackermap-server-cefc12afe98f610aa0f266bcac4361f9ec414ee5.tar.bz2 trackermap-server-cefc12afe98f610aa0f266bcac4361f9ec414ee5.zip |
Merge master of guterresrafael/traccar into rest
Diffstat (limited to 'src/org/traccar/web/WebServer.java')
-rw-r--r-- | src/org/traccar/web/WebServer.java | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/org/traccar/web/WebServer.java b/src/org/traccar/web/WebServer.java index f5a6acdd9..2318c4151 100644 --- a/src/org/traccar/web/WebServer.java +++ b/src/org/traccar/web/WebServer.java @@ -24,6 +24,8 @@ import org.eclipse.jetty.server.handler.ResourceHandler; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; import org.eclipse.jetty.webapp.WebAppContext; +import org.glassfish.jersey.server.ResourceConfig; +import org.glassfish.jersey.servlet.ServletContainer; import org.traccar.Config; import org.traccar.helper.Log; @@ -101,6 +103,12 @@ public class WebServer { } private void initApi() { + initOldApi(); + initRestApi(); + } + + @Deprecated + private void initOldApi() { ServletContextHandler servletHandler = new ServletContextHandler(ServletContextHandler.SESSIONS); servletHandler.setContextPath("/api"); servletHandler.addServlet(new ServletHolder(new AsyncServlet()), "/async/*"); @@ -120,6 +128,15 @@ public class WebServer { handlers.addHandler(servletHandler); } + private void initRestApi() { + ResourceConfig resourceConfig = new ResourceConfig(); + resourceConfig.packages("org.traccar.api"); + ServletContextHandler servletHandler = new ServletContextHandler(ServletContextHandler.NO_SESSIONS); + ServletHolder servletHolder = new ServletHolder(new ServletContainer(resourceConfig)); + servletHandler.addServlet(servletHolder, "/rest/*"); + handlers.addHandler(servletHandler); + } + public void start() { try { server.start(); |