package org.forkalsrud.album;

import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;

public class Runner {

	/**
	 * @param args
	 * @throws Exception 
	 */
	public static void main(String[] args) throws Exception {
		Server server = new Server(8080);

		WebAppContext context = new WebAppContext();
        context.setDescriptor("src/main/webapp/WEB-INF/web.xml");
        context.setResourceBase("src/main/webapp");
        context.setContextPath("/photo");
        context.setParentLoaderPriority(true);

		context.setAttribute("album.baseurl", "http://localhost:8080/photo");
        server.setHandler(context);

        server.start();

		System.out.println("Visit http://localhost:8080/photo/album/");

		Runtime.getRuntime().addShutdownHook(new Thread(() -> {
			try {
				server.stop();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}));

        server.join();
	}

}
