Esempio n. 1
0
        private void LoadStaticContent(string mountPoint)
        {
            string contentLocation = _staticContent[mountPoint];

            try
            {
                SessionHandler sessionHandler = new SessionHandler();
                sessionHandler.Server = Jetty;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.eclipse.jetty.webapp.WebAppContext staticContext = new org.eclipse.jetty.webapp.WebAppContext();
                WebAppContext staticContext = new WebAppContext();
                staticContext.Server         = Jetty;
                staticContext.ContextPath    = mountPoint;
                staticContext.SessionHandler = sessionHandler;
                staticContext.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
                URL resourceLoc = this.GetType().ClassLoader.getResource(contentLocation);
                if (resourceLoc != null)
                {
                    URL url = resourceLoc.toURI().toURL();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.eclipse.jetty.util.resource.Resource resource = org.eclipse.jetty.util.resource.Resource.newResource(url);
                    Resource resource = Resource.newResource(url);
                    staticContext.BaseResource = resource;

                    AddFiltersTo(staticContext);
                    staticContext.addFilter(new FilterHolder(new StaticContentFilter()), "/*", EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD));

                    _handlers.addHandler(staticContext);
                }
                else
                {
                    _log.warn("No static content available for Neo4j Server at %s. management console may not be available.", AddressConfigurationDescription());
                }
            }
            catch (Exception e)
            {
                _log.error("Unknown error loading static content", e);
                Console.WriteLine(e.ToString());
                Console.Write(e.StackTrace);
                throw new Exception(e);
            }
        }