diff options
author | Rafael Guterres <guterresrafael@gmail.com> | 2015-11-27 03:32:59 -0200 |
---|---|---|
committer | Rafael Guterres <guterresrafael@gmail.com> | 2015-11-27 03:32:59 -0200 |
commit | c57bd2d472467b1b3a45aee1b97c9a0aeef5958a (patch) | |
tree | 26fae20adf1970b5834f06393a3c703c972f39b1 /src/org/traccar/web/WebServer.java | |
parent | 77cd23da84ebebcf99a97a8aef88aa9a4884ca40 (diff) | |
download | trackermap-server-c57bd2d472467b1b3a45aee1b97c9a0aeef5958a.tar.gz trackermap-server-c57bd2d472467b1b3a45aee1b97c9a0aeef5958a.tar.bz2 trackermap-server-c57bd2d472467b1b3a45aee1b97c9a0aeef5958a.zip |
Initial implementation of new api with jax-rs.
Revert servlets to old api and remove plurals.
Fix findbugs for header origin.
Diffstat (limited to 'src/org/traccar/web/WebServer.java')
-rw-r--r-- | src/org/traccar/web/WebServer.java | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/org/traccar/web/WebServer.java b/src/org/traccar/web/WebServer.java index 2e7e1a31b..146dee613 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; @@ -98,23 +100,33 @@ 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/*"); servletHandler.addServlet(new ServletHolder(new ServerServlet()), "/server/*"); - servletHandler.addServlet(new ServletHolder(new ServerServlet()), "/servers/*"); servletHandler.addServlet(new ServletHolder(new UserServlet()), "/user/*"); - servletHandler.addServlet(new ServletHolder(new UserServlet()), "/users/*"); servletHandler.addServlet(new ServletHolder(new DeviceServlet()), "/device/*"); - servletHandler.addServlet(new ServletHolder(new DeviceServlet()), "/devices/*"); servletHandler.addServlet(new ServletHolder(new PositionServlet()), "/position/*"); - servletHandler.addServlet(new ServletHolder(new PositionServlet()), "/positions/*"); servletHandler.addServlet(new ServletHolder(new CommandServlet()), "/command/*"); - servletHandler.addServlet(new ServletHolder(new CommandServlet()), "/commands/*"); servletHandler.addServlet(new ServletHolder(new MainServlet()), "/*"); 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(); |