public void start() {
if (neoServer!=null) throw new IllegalStateException("Server already running");
URL url = getClass().getResource("/" + propertiesFile);
if (url==null) throw new IllegalArgumentException("Could not resolve properties file "+propertiesFile);
Logging logging = graphDatabase.getDependencyResolver().resolveDependency(Logging.class);
final Jetty9WebServer jettyWebServer = new Jetty9WebServer(logging); /* {
@Override
protected void startJetty() {
final Server jettyServer = getJetty();
jettyServer.setStopAtShutdown(true);
final JettyStartupListener startupListener = new JettyStartupListener();
jettyServer.getServer().addLifeCycleListener(startupListener);
// System.err.println("jetty is started before notification " + jettyServer.isStarted());
super.startJetty();
startupListener.await();
jettyServer.removeLifeCycleListener(startupListener);
// System.err.println("jetty is started after notification " + jettyServer.isStarted());
}
@Override
public void stop() {
final Server jettyServer = getJetty();
final JettyStartupListener listener = new JettyStartupListener();
jettyServer.getServer().addLifeCycleListener(listener);
super.stop();
listener.await();
jettyServer.removeLifeCycleListener(listener);
}
}; */
jettyWebServer.addFilter(new Filter() {
public void init(FilterConfig filterConfig) throws ServletException { }
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException {
userAgent = ((HttpServletRequest)request).getHeader("User-Agent");
filterChain.doFilter(request, response);