package io.github.spharris.pvwatts;

import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.jboss.resteasy.plugins.guice.GuiceResteasyBootstrapServletContextListener;
import org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher;

import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
import com.fasterxml.jackson.jaxrs.xml.JacksonXMLProvider;
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;

import io.github.spharris.ssc.web.ModuleService;

public class PVWattsJava {

	public static void main(String[] args) throws Exception {
		Injector injector = Guice.createInjector(new SscWebModule());
		
		Server server = new Server(3000);
		
		ServletContextHandler handler = new ServletContextHandler(server, "/");
		handler.addEventListener(injector.getInstance(GuiceResteasyBootstrapServletContextListener.class));
		
		ServletHolder sh = new ServletHolder(HttpServletDispatcher.class);
		handler.addServlet(sh, "/*");
		server.setHandler(handler);
		
		server.start();
		server.join();
	}
	
	private static class SscWebModule extends AbstractModule {
		
		@Override
		protected void configure() {
			bind(ModuleService.class);
			bind(JacksonJsonProvider.class);
			bind(JacksonXMLProvider.class);
		}
		
	}
}

@@ -610,16 +610,72 @@
 Service;
+%0Aimport io.github.spharris.ssc.web.UnknownModuleHandler;
 %0A%0Apublic
@@ -1342,32 +1342,69 @@
 Service.class);%0A
+%09%09%09bind(UnknownModuleHandler.class);%0A
 %09%09%09bind(JacksonJ

Add handler for an unknown module