All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ch.ri.js.server.HTTPServer Maven / Gradle / Ivy

package ch.ri.js.server;

import li.rudin.mavenjs.servlet.MavenJSServlet;

import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;

public class HTTPServer
{
	public HTTPServer(int port)
	{
		this.port = port;
	}
	
	private final int port;
	private Server server;
	
	public void start() throws Exception
	{
		ServletContextHandler handler = new ServletContextHandler();
		
		ServletHolder holder = new ServletHolder(MavenJSServlet.class);
		holder.setInitOrder(1);
		handler.addServlet(holder, "/*");

		server = new Server(port);
		server.setHandler(handler);
		server.start();
	}
	
	public void stop() throws Exception
	{
		server.stop();
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy