package com.test;

import java.io.IOException;


import org.glassfish.grizzly.http.server.HttpServer;
import org.glassfish.grizzly.http.server.NetworkListener;
import org.glassfish.grizzly.http.server.ServerConfiguration;
import org.glassfish.grizzly.servlet.ServletHandler;







import com.sun.jersey.spi.spring.container.servlet.SpringServlet;





public class Start {

	public static void main(String[] args) throws IOException {
		HttpServer server = new HttpServer();
		NetworkListener listener = new NetworkListener("grizzly2", "localhost", 3388);
		server.addListener(listener);
		
		
		ServletHandler sa = new ServletHandler();		
		sa.setContextPath("/");		
		sa.setServletInstance(new SpringServlet());
		sa.addContextParameter("contextConfigLocation", "classpath:spring-context.xml");				
		sa.addServletListener("org.springframework.web.context.ContextLoaderListener");
		sa.addServletListener("org.springframework.web.context.request.RequestContextListener");    	    	
    	ServerConfiguration config = server.getServerConfiguration();
    	config.addHttpHandler(sa, new String[] {"/"});
        
			
    	server.start();
        
		System.in.read();
		
	}

}
