本文整理汇总了Java中org.eclipse.jetty.server.handler.ErrorHandler.setShowStacks方法的典型用法代码示例。如果您正苦于以下问题:Java ErrorHandler.setShowStacks方法的具体用法?Java ErrorHandler.setShowStacks怎么用?Java ErrorHandler.setShowStacks使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jetty.server.handler.ErrorHandler
的用法示例。
在下文中一共展示了ErrorHandler.setShowStacks方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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);
}
示例3: 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();
}
示例4: 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();
}
示例5: start
import org.eclipse.jetty.server.handler.ErrorHandler; //导入方法依赖的package包/类
public void start() {
System.setProperty("java.net.preferIPv4Stack", "true");//TODO optional?
server = new org.eclipse.jetty.server.Server();
// HashSessionIdManager sessionIdManager = new HashSessionIdManager();
// server.setSessionIdManager(sessionIdManager);
connector = new NetworkTrafficServerConnector(server);
connector.setPort(httpPort);
connector.setHost(host);
server.addConnector(connector);
ServletContextHandler contextHandler = new ServletContextHandler();
SessionHandler sessionHandler = new SessionHandler();
// HashSessionManager sessionManager = new HashSessionManager();
// sessionManager.setMaxInactiveInterval(sessionTimeoutS);
// sessionManager.setSessionCookie(sessionManager.getSessionCookie()+httpPort); //avoid session mix up for 2 server running as localhost
// sessionHandler.setSessionManager(sessionManager);
contextHandler.setSessionHandler(sessionHandler);
contextHandler.addServlet(new ServletHolder(new ServletContainer(jerseySetup(restResource))), "/applicationServer/*");
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.setMimeTypes(mimeTypes);
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[]{resourceHandler, contextHandler});
gzipHandler.setHandler(handlers);
server.setHandler(gzipHandler);
try {
server.start();
} catch (Exception e) {
throw new RuntimeException(e);
}
}