当前位置: 首页>>代码示例>>Java>>正文


Java ErrorHandler类代码示例

本文整理汇总了Java中org.eclipse.jetty.server.handler.ErrorHandler的典型用法代码示例。如果您正苦于以下问题:Java ErrorHandler类的具体用法?Java ErrorHandler怎么用?Java ErrorHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ErrorHandler类属于org.eclipse.jetty.server.handler包,在下文中一共展示了ErrorHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addJettyErrorPages

import org.eclipse.jetty.server.handler.ErrorHandler; //导入依赖的package包/类
private void addJettyErrorPages(ErrorHandler errorHandler,
		Collection<ErrorPage> errorPages) {
	if (errorHandler instanceof ErrorPageErrorHandler) {
		ErrorPageErrorHandler handler = (ErrorPageErrorHandler) errorHandler;
		for (ErrorPage errorPage : errorPages) {
			if (errorPage.isGlobal()) {
				handler.addErrorPage(ErrorPageErrorHandler.GLOBAL_ERROR_PAGE,
						errorPage.getPath());
			}
			else {
				if (errorPage.getExceptionName() != null) {
					handler.addErrorPage(errorPage.getExceptionName(),
							errorPage.getPath());
				}
				else {
					handler.addErrorPage(errorPage.getStatusCode(),
							errorPage.getPath());
				}
			}
		}
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:23,代码来源:JettyEmbeddedServletContainerFactory.java

示例2: buildServletContext

import org.eclipse.jetty.server.handler.ErrorHandler; //导入依赖的package包/类
/** Build a ServletContextHandler. */
private static ServletContextHandler buildServletContext(String contextPath) {
    if ( contextPath == null || contextPath.isEmpty() )
        contextPath = "/" ;
    else if ( !contextPath.startsWith("/") )
        contextPath = "/" + contextPath ;
    ServletContextHandler context = new ServletContextHandler() ;
    context.setDisplayName("PatchLogServer") ;
    MimeTypes mt = new MimeTypes();
    addMimeType(mt, Lang.TTL);
    addMimeType(mt, Lang.NT);
    addMimeType(mt, Lang.TRIG);
    addMimeType(mt, Lang.NQ);
    addMimeType(mt, Lang.RDFXML);
    context.setMimeTypes(mt);
    ErrorHandler eh = new HttpErrorHandler();
    context.setErrorHandler(eh) ;
    return context ;
}
 
开发者ID:afs,项目名称:rdf-delta,代码行数:20,代码来源:PatchLogServer.java

示例3: WebServer

import org.eclipse.jetty.server.handler.ErrorHandler; //导入依赖的package包/类
public WebServer(Config config, DataSource dataSource) {
    this.config = config;
    this.dataSource = dataSource;

    sessionManager = new HashSessionManager();
    int sessionTimeout = config.getInteger("web.sessionTimeout");
    if (sessionTimeout != 0) {
        sessionManager.setMaxInactiveInterval(sessionTimeout);
    }

    initServer();
    initApi();
    if (config.getBoolean("web.console")) {
        initConsole();
    }
    switch (config.getString("web.type", "new")) {
        case "old":
            initOldWebApp();
            break;
        default:
            initWebApp();
            break;
    }
    initClientProxy();
    server.setHandler(handlers);

    server.addBean(new ErrorHandler() {
        @Override
        protected void handleErrorPage(
                HttpServletRequest request, Writer writer, int code, String message) throws IOException {
            writer.write("<!DOCTYPE<html><head><title>Error</title></head><html><body>"
                    + code + " - " + HttpStatus.getMessage(code) + "</body></html>");
        }
    }, false);
}
 
开发者ID:bamartinezd,项目名称:traccar-service,代码行数:36,代码来源:WebServer.java

示例4: ServletContextHandler

import org.eclipse.jetty.server.handler.ErrorHandler; //导入依赖的package包/类
public ServletContextHandler(HandlerContainer parent, String contextPath, SessionHandler sessionHandler, SecurityHandler securityHandler, ServletHandler servletHandler, ErrorHandler errorHandler,int options)
{
    super((ContextHandler.Context)null);
    _options=options;
    _scontext = new Context();
    _sessionHandler = sessionHandler;
    _securityHandler = securityHandler;
    _servletHandler = servletHandler;

    if (contextPath!=null)
        setContextPath(contextPath);
    
    if (parent instanceof HandlerWrapper)
        ((HandlerWrapper)parent).setHandler(this);
    else if (parent instanceof HandlerCollection)
        ((HandlerCollection)parent).addHandler(this);
    
    
    // Link the handlers
    relinkHandlers();
    
    if (errorHandler!=null)
        setErrorHandler(errorHandler);
    
    
    this.addFilter(new FilterHolder(new HTTPAuthFilter()), "/v2/*", EnumSet.allOf(DispatcherType.class));

}
 
开发者ID:xiaomin0322,项目名称:marathon-auth-plugin,代码行数:29,代码来源:ServletContextHandler.java

示例5: startTheControllerServer

import org.eclipse.jetty.server.handler.ErrorHandler; //导入依赖的package包/类
/**
 * Start the controller as a RESTful server.
 * Use the setters of this class to change the default
 * port and host.
 * <br>
 * This method is blocking until the server is initialized.
 */
public final boolean startTheControllerServer() {

    //Jersey
    ResourceConfig config = new ResourceConfig();
    config.register(JacksonFeature.class);
    config.register(new EMController(this));
    config.register(LoggingFeature.class);

    //Jetty
    controllerServer = new Server(InetSocketAddress.createUnresolved(
            getControllerHost(), getControllerPort()));

    ErrorHandler errorHandler = new ErrorHandler();
    errorHandler.setShowStacks(true);
    controllerServer.setErrorHandler(errorHandler);

    ServletHolder servlet = new ServletHolder(new ServletContainer(config));

    ServletContextHandler context = new ServletContextHandler(controllerServer,
            ControllerConstants.BASE_PATH + "/*");
    context.addServlet(servlet, "/*");


    try {
        controllerServer.start();
    } catch (Exception e) {
        SimpleLogger.error("Failed to start Jetty: " + e.getMessage());
        controllerServer.destroy();
    }

    //just make sure we start from a clean state
    newSearch();

    SimpleLogger.info("Started controller server on: " + controllerServer.getURI());

    return true;
}
 
开发者ID:EMResearch,项目名称:EvoMaster,代码行数:45,代码来源:SutController.java

示例6: getErrorPageConfiguration

import org.eclipse.jetty.server.handler.ErrorHandler; //导入依赖的package包/类
/**
 * Create a configuration object that adds error handlers.
 * @return a configuration object for adding error pages
 */
private Configuration getErrorPageConfiguration() {
	return new AbstractConfiguration() {

		@Override
		public void configure(WebAppContext context) throws Exception {
			ErrorHandler errorHandler = context.getErrorHandler();
			context.setErrorHandler(new JettyEmbeddedErrorHandler(errorHandler));
			addJettyErrorPages(errorHandler, getErrorPages());
		}

	};
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:JettyEmbeddedServletContainerFactory.java

示例7: JettyServer

import org.eclipse.jetty.server.handler.ErrorHandler; //导入依赖的package包/类
public JettyServer(List<HttpServerConnectorCreator> connectors, List<Object> resources) {
        server=new org.eclipse.jetty.server.Server();
        currentConnectors.addAll(connectors);
        for (HttpServerConnectorCreator creator : currentConnectors) {
            creator.addToServer(server);
        }

        rootServlet = new UpdateableServlet(new ServletContainer(jerseySetup(resources)));
        ServletHolder holder = new ServletHolder(rootServlet);
        ServletContextHandler contextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
        contextHandler.addServlet( holder, "/*");
        ErrorHandler errorHandler = new ErrorHandler();
        errorHandler.setShowStacks(true);
        contextHandler.setErrorHandler(errorHandler);

        GzipHandler gzipHandler = new GzipHandler();
//            HashSet<String> mimeTypes = new HashSet<>();
//            mimeTypes.add("text/html");
//            mimeTypes.add("text/plain");
//            mimeTypes.add("text/css");
//            mimeTypes.add("application/x-javascript");
//            mimeTypes.add("application/json");
        gzipHandler.setMinGzipSize(0);

        gzipHandler.setHandler(contextHandler);

        HandlerCollection handlers = new HandlerList();
        additionalHandlers().forEach(handler -> handlers.addHandler(handler));
        handlers.addHandler(gzipHandler);
        server.setHandler(handlers);
    }
 
开发者ID:factoryfx,项目名称:factoryfx,代码行数:32,代码来源:JettyServer.java

示例8: getErrorPageConfiguration

import org.eclipse.jetty.server.handler.ErrorHandler; //导入依赖的package包/类
/**
 * Create a configuration object that adds error handlers.
 * @return a configuration object for adding error pages
 */
private Configuration getErrorPageConfiguration() {
	return new AbstractConfiguration() {
		@Override
		public void configure(WebAppContext context) throws Exception {
			ErrorHandler errorHandler = context.getErrorHandler();
			addJettyErrorPages(errorHandler, getErrorPages());
		}
	};
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:14,代码来源:JettyEmbeddedServletContainerFactory.java

示例9: main

import org.eclipse.jetty.server.handler.ErrorHandler; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
	
	org.eclipse.jetty.server.Server server = new org.eclipse.jetty.server.Server(8080);
	
	final ErrorHandler errorHandler = new ErrorHandler();
       errorHandler.setServer(server);
       errorHandler.setShowStacks(false);
       server.addBean(errorHandler);
              
       server.setStopAtShutdown(true);
       server.setStopTimeout(30*1000l);
	        
       ServletContextHandler handler = new ServletContextHandler(ServletContextHandler.SESSIONS);

       handler.setClassLoader(Thread.currentThread().getContextClassLoader());
       handler.setContextPath("/");
       handler.setInitParameter("tapestry.app-package", "com.ckfce.tapfatjar");
       
       FilterHolder filterHolder = new FilterHolder();
       filterHolder.setHeldClass(TapestryFilter.class);
       filterHolder.setName("app");
       
       handler.addFilter(filterHolder, "/*", EnumSet.of(DispatcherType.REQUEST));
       								
	server.setHandler(handler);
					 
       server.start();        
       server.join();
}
 
开发者ID:cakeface,项目名称:tapestry-fat-jar,代码行数:30,代码来源:Server.java

示例10: getServletContextHandler

import org.eclipse.jetty.server.handler.ErrorHandler; //导入依赖的package包/类
private ServletContextHandler getServletContextHandler(final WebApplicationContext context) throws IOException {
    ServletContextHandler contextHandler = new ServletContextHandler();
    contextHandler.setErrorHandler(null);
    contextHandler.setContextPath("/");
    contextHandler.addServlet(new ServletHolder(new DispatcherServlet(context)), "/*");
    contextHandler.addEventListener(new ContextLoaderListener(context));
    //        contextHandler.setResourceBase(new ClassPathResource("web").getURI().toString());
    //        contextHandler.setResourceBase("src/main/resources/web");
    contextHandler.setResourceBase("src/main/webapp");
    contextHandler.setErrorHandler(new ErrorHandler());
    contextHandler.getErrorHandler().setShowStacks(true);
    return contextHandler;
}
 
开发者ID:RoyalDev,项目名称:TheHumanity,代码行数:14,代码来源:GameServer.java

示例11: start

import org.eclipse.jetty.server.handler.ErrorHandler; //导入依赖的package包/类
/**
 * Start the web server including setup.
 * @throws Exception
 */
public void start() throws Exception {
  if (embeddedJetty == null) {
    return;
  }

  final ServerConnector serverConnector;
  if (config.getBoolean(ExecConstants.HTTP_ENABLE_SSL)) {
    serverConnector = createHttpsConnector();
  } else {
    serverConnector = createHttpConnector();
  }
  embeddedJetty.addConnector(serverConnector);

  // Add resources
  final ErrorHandler errorHandler = new ErrorHandler();
  errorHandler.setShowStacks(true);
  errorHandler.setShowMessageInTitle(true);

  final ServletContextHandler servletContextHandler =
      new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
  servletContextHandler.setErrorHandler(errorHandler);
  servletContextHandler.setContextPath("/");
  embeddedJetty.setHandler(servletContextHandler);

  final ServletHolder servletHolder = new ServletHolder(new ServletContainer(new DrillRestServer(workManager)));
  servletHolder.setInitOrder(1);
  servletContextHandler.addServlet(servletHolder, "/*");

  servletContextHandler.addServlet(
      new ServletHolder(new MetricsServlet(metrics)), "/status/metrics");
  servletContextHandler.addServlet(new ServletHolder(new ThreadDumpServlet()), "/status/threads");

  final ServletHolder staticHolder = new ServletHolder("static", DefaultServlet.class);
  staticHolder.setInitParameter("resourceBase", Resource.newClassPathResource("/rest/static").toString());
  staticHolder.setInitParameter("dirAllowed","false");
  staticHolder.setInitParameter("pathInfoOnly","true");
  servletContextHandler.addServlet(staticHolder,"/static/*");

  embeddedJetty.start();
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:45,代码来源:WebServer.java

示例12: getErrorHandler

import org.eclipse.jetty.server.handler.ErrorHandler; //导入依赖的package包/类
public ErrorHandler getErrorHandler() {
    return errorHandler;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:4,代码来源:JettyHttpComponent.java

示例13: setErrorHandler

import org.eclipse.jetty.server.handler.ErrorHandler; //导入依赖的package包/类
public void setErrorHandler(ErrorHandler errorHandler) {
    this.errorHandler = errorHandler;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:4,代码来源:JettyHttpComponent.java

示例14: generateErrorHandler

import org.eclipse.jetty.server.handler.ErrorHandler; //导入依赖的package包/类
private static ErrorHandler generateErrorHandler() {
    ErrorPageErrorHandler errorHandler = new ErrorPageErrorHandler();
    errorHandler.addErrorPage(Throwable.class, "/error");
    return errorHandler;
}
 
开发者ID:Nike-Inc,项目名称:backstopper,代码行数:6,代码来源:Main.java

示例15: JettyEmbeddedErrorHandler

import org.eclipse.jetty.server.handler.ErrorHandler; //导入依赖的package包/类
JettyEmbeddedErrorHandler(ErrorHandler delegate) {
	this.delegate = delegate;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:4,代码来源:JettyEmbeddedErrorHandler.java


注:本文中的org.eclipse.jetty.server.handler.ErrorHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。