mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-31 00:53:21 +00:00 
			
		
		
		
	Ticket #362: Super basic REST endpoint exposed with Guice and Jersey.
This commit is contained in:
		| @@ -0,0 +1,52 @@ | ||||
| package org.glyptodon.guacamole.net.basic.rest; | ||||
|  | ||||
| /* | ||||
|  *  Guacamole - Clientless Remote Desktop | ||||
|  *  Copyright (C) 2010  Michael Jumper | ||||
|  * | ||||
|  *  This program is free software: you can redistribute it and/or modify | ||||
|  *  it under the terms of the GNU Affero General Public License as published by | ||||
|  *  the Free Software Foundation, either version 3 of the License, or | ||||
|  *  (at your option) any later version. | ||||
|  * | ||||
|  *  This program is distributed in the hope that it will be useful, | ||||
|  *  but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|  *  GNU Affero General Public License for more details. | ||||
|  * | ||||
|  *  You should have received a copy of the GNU Affero General Public License | ||||
|  *  along with this program.  If not, see <http://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|  | ||||
| import com.google.inject.Guice; | ||||
| import com.google.inject.servlet.ServletModule; | ||||
| import com.sun.jersey.guice.spi.container.servlet.GuiceContainer; | ||||
| import javax.servlet.ServletContextEvent; | ||||
| import javax.servlet.ServletContextListener; | ||||
| import org.glyptodon.guacamole.net.basic.rest.connection.ConnectionService; | ||||
|  | ||||
| /** | ||||
|  * A ServletContextListenr to listen for initialization of the servlet context | ||||
|  * in order to set up the REST services. | ||||
|  *  | ||||
|  * @author James Muehlner | ||||
|  */ | ||||
| public class RESTServletContextListener implements ServletContextListener { | ||||
|  | ||||
|     @Override | ||||
|     public void contextInitialized(ServletContextEvent sce) { | ||||
|         Guice.createInjector(new ServletModule() { | ||||
|             @Override | ||||
|             protected void configureServlets() { | ||||
|                  | ||||
|                 bind(ConnectionService.class); | ||||
|                  | ||||
|                 serve("*").with(GuiceContainer.class); | ||||
|             } | ||||
|         }); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void contextDestroyed(ServletContextEvent sce) {} | ||||
|      | ||||
| } | ||||
| @@ -0,0 +1,24 @@ | ||||
| /* | ||||
|  * To change this template, choose Tools | Templates | ||||
|  * and open the template in the editor. | ||||
|  */ | ||||
| package org.glyptodon.guacamole.net.basic.rest.connection; | ||||
|  | ||||
| import javax.ws.rs.GET; | ||||
| import javax.ws.rs.Path; | ||||
|  | ||||
| /** | ||||
|  * A REST Service for handling connection CRUD operations. | ||||
|  *  | ||||
|  * @author James Muehlner | ||||
|  */ | ||||
| @Path("/api/connection") | ||||
| public class ConnectionService { | ||||
|      | ||||
|     @Path("/") | ||||
|     @GET | ||||
|     public String getConnections() { | ||||
|         return "goo"; | ||||
|     }    | ||||
|      | ||||
| } | ||||
		Reference in New Issue
	
	Block a user