ServletContextHandler servletContextHandler = new ServletContextHandler(server, "/", true, false);
//Servlet adress is defined with the bean name
//try to avoid xml config (dont sacrifice type safety)
GenericWebApplicationContext genericWebApplicationContext = new GenericWebApplicationContext();
genericWebApplicationContext.registerBeanDefinition("/loginService",
BeanDefinitionBuilder.genericBeanDefinition(HttpInvokerServiceExporter.class).
addPropertyValue("service", loginService).
addPropertyValue("serviceInterface", LoginService.class.getName()).
getBeanDefinition());
genericWebApplicationContext.registerBeanDefinition("/copperMonitoringService",
BeanDefinitionBuilder.genericBeanDefinition(HttpInvokerServiceExporter.class).
addPropertyValue("service", copperMonitoringService).
addPropertyValue("serviceInterface", CopperMonitoringService.class.getName()).
addPropertyValue("remoteInvocationExecutor", remoteInvocationExecutor).
getBeanDefinition());
genericWebApplicationContext.refresh();
DispatcherServlet dispatcherServlet = new DispatcherServlet(genericWebApplicationContext);
ServletHolder servletHolder = new ServletHolder(dispatcherServlet);
servletContextHandler.addServlet(servletHolder, "/*");