本文整理汇总了Java中org.eclipse.jetty.server.handler.DefaultHandler类的典型用法代码示例。如果您正苦于以下问题:Java DefaultHandler类的具体用法?Java DefaultHandler怎么用?Java DefaultHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DefaultHandler类属于org.eclipse.jetty.server.handler包,在下文中一共展示了DefaultHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startWebSocket
import org.eclipse.jetty.server.handler.DefaultHandler; //导入依赖的package包/类
/**
* start server
*
* @param port
* @param path
* @param handlerClass
*/
public static void startWebSocket(int port, String path, String handlerClass) {
try {
Server server = new Server(port);
HandlerList handlerList = new HandlerList();
ServletContextHandler context = new ServletContextHandler(
ServletContextHandler.SESSIONS);
context.setContextPath("/");
context.addServlet(new ServletHolder(new Jwservlet(handlerClass)),
path);
handlerList.addHandler(context);
handlerList.addHandler(new DefaultHandler());
server.setHandler(handlerList);
server.start();
server.join();
} catch (Exception e) {
e.printStackTrace();
LogUtil.LOG("start websocket server error:" + e.getMessage(),
LogLev.ERROR, WebSocketServer.class);
System.exit(1);
}
}
示例2: main
import org.eclipse.jetty.server.handler.DefaultHandler; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
// Create a basic Jetty server object that will listen on port 8080
Server server = new Server(8080);
// Create the ResourceHandler. It is the object that will actually
// handle the request for a given file. It is a Jetty Handler object
// so it is suitable for chaining with other handlers as you will see
// in other examples
ResourceHandler resource_handler = new ResourceHandler();
// Configure the ResourceHandler. Setting the resource base indicates
// where the files should be served out of
resource_handler.setDirectoriesListed(true);
resource_handler.setWelcomeFiles(new String[]{ "index.html" });
resource_handler.setResourceBase("src/main/webapp/");
// Add the ResourceHandler to the server
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] { resource_handler, new DefaultHandler() });
server.setHandler(handlers);
// Start server
server.start();
server.join();
}
示例3: prepare
import org.eclipse.jetty.server.handler.DefaultHandler; //导入依赖的package包/类
public void prepare() {
try {
Tools.verifyLocalPort("DBServer ", port());
server = new Server();
DefaultHandler webHandler = new DefaultHandler();
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[]{getResourceHandler(),
getUIWSHandler(), webHandler});
ServerConnector connector = new ServerConnector(server);
connector.setPort(port());
server.setConnectors(new Connector[]{connector});
server.setHandler(handlers);
LOG.log(Level.INFO, "DB Server on : http://{0}:{1}",
new Object[]{Tools.IP(), port() + ""});
} catch (Exception ex) {
LOG.log(Level.SEVERE, ex.getMessage(), ex);
}
}
示例4: start
import org.eclipse.jetty.server.handler.DefaultHandler; //导入依赖的package包/类
public void start() throws Exception {
RequestLogHandler requestLogHandler = new RequestLogHandler();
Slf4jRequestLog requestLog = new Slf4jRequestLog();
requestLog.setExtended(true);
requestLog.setLogTimeZone(TimeZone.getDefault().getID());
requestLog.setLogLatency(true);
requestLogHandler.setRequestLog(requestLog);
handlers.add(0, new ContextHandlerCollection());
handlers.add(requestLogHandler);
ContextHandlerCollection contexts = new ContextHandlerCollection();
contexts.setHandlers(handlers.toArray(new Handler[handlers.size()]));
HandlerCollection handlerCollection = new HandlerCollection();
handlerCollection.setHandlers(new Handler[] { contexts, new DefaultHandler(), requestLogHandler });
server.setHandler(handlerCollection);
server.start();
log.info("Server started at end point {}", getServiceUri());
}
示例5: start
import org.eclipse.jetty.server.handler.DefaultHandler; //导入依赖的package包/类
public void start() throws PulsarServerException {
log.info("Starting web socket proxy at port {}", conf.getWebServicePort());
try {
RequestLogHandler requestLogHandler = new RequestLogHandler();
Slf4jRequestLog requestLog = new Slf4jRequestLog();
requestLog.setExtended(true);
requestLog.setLogTimeZone(TimeZone.getDefault().getID());
requestLog.setLogLatency(true);
requestLogHandler.setRequestLog(requestLog);
handlers.add(0, new ContextHandlerCollection());
handlers.add(requestLogHandler);
ContextHandlerCollection contexts = new ContextHandlerCollection();
contexts.setHandlers(handlers.toArray(new Handler[handlers.size()]));
HandlerCollection handlerCollection = new HandlerCollection();
handlerCollection.setHandlers(new Handler[] { contexts, new DefaultHandler(), requestLogHandler });
server.setHandler(handlerCollection);
server.start();
} catch (Exception e) {
throw new PulsarServerException(e);
}
}
示例6: start
import org.eclipse.jetty.server.handler.DefaultHandler; //导入依赖的package包/类
public void start() throws PulsarServerException {
try {
RequestLogHandler requestLogHandler = new RequestLogHandler();
Slf4jRequestLog requestLog = new Slf4jRequestLog();
requestLog.setExtended(true);
requestLog.setLogTimeZone(TimeZone.getDefault().getID());
requestLog.setLogLatency(true);
requestLogHandler.setRequestLog(requestLog);
handlers.add(0, new ContextHandlerCollection());
handlers.add(requestLogHandler);
ContextHandlerCollection contexts = new ContextHandlerCollection();
contexts.setHandlers(handlers.toArray(new Handler[handlers.size()]));
HandlerCollection handlerCollection = new HandlerCollection();
handlerCollection.setHandlers(new Handler[] { contexts, new DefaultHandler(), requestLogHandler });
server.setHandler(handlerCollection);
server.start();
log.info("Web Service started at {}", pulsar.getWebServiceAddress());
} catch (Exception e) {
throw new PulsarServerException(e);
}
}
示例7: start
import org.eclipse.jetty.server.handler.DefaultHandler; //导入依赖的package包/类
/**
* Start the file server (blocking).
*
* @throws Exception If server cannot start
*/
public final void start() throws Exception {
LOGGER.info("Starting web interface at http://localhost:8000");
Server server = new Server(8000);
ResourceHandler resource_handler = new ResourceHandler();
resource_handler.setDirectoriesListed(true);
resource_handler.setWelcomeFiles(new String[]{"index.html"});
resource_handler.setResourceBase("../website");
HandlerList handlers = new HandlerList();
handlers.setHandlers(
new Handler[]{
resource_handler,
new DefaultHandler()});
server.setHandler(handlers);
server.start();
}
示例8: run
import org.eclipse.jetty.server.handler.DefaultHandler; //导入依赖的package包/类
public void run(int port) throws Exception {
Server server = new Server();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(port);
server.addConnector(connector);
ResourceHandler resource_handler = new ResourceHandler();
resource_handler.setDirectoriesListed(true);
resource_handler.setWelcomeFiles(new String[] { "index.html" });
resource_handler.setResourceBase("./performance/site/");
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] { resource_handler,
new DefaultHandler() });
server.setHandler(handlers);
server.start();
System.out.println("Started performance file server at port: " + port);
server.join();
}
示例9: main
import org.eclipse.jetty.server.handler.DefaultHandler; //导入依赖的package包/类
public static void main( String[] args )
throws Exception
{
Server server = new Server( 8080 );
WebAppContext webappcontext = new WebAppContext( "src/main/webapp", "/jaxrs" );
ContextHandlerCollection servlet_contexts = new ContextHandlerCollection();
webappcontext.setClassLoader( Thread.currentThread().getContextClassLoader() );
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers( new Handler[] { servlet_contexts, webappcontext, new DefaultHandler() } );
server.setHandler( handlers );
server.start();
server.join();
}
示例10: Olingo2SampleServer
import org.eclipse.jetty.server.handler.DefaultHandler; //导入依赖的package包/类
/**
*
* @param port
* @param resourcePath
*/
public Olingo2SampleServer(int port, String resourcePath) {
this.port = port;
server = new org.eclipse.jetty.server.Server(port);
WebAppContext webappcontext = new WebAppContext();
String contextPath = null;
try {
contextPath = Olingo2SampleServer.class.getResource(resourcePath).toURI().getPath();
} catch (URISyntaxException e) {
LOG.error("Unable to read the resource at {}", resourcePath, e);
}
webappcontext.setContextPath("/");
webappcontext.setWar(contextPath);
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[] {webappcontext, new DefaultHandler()});
server.setHandler(handlers);
}
示例11: main
import org.eclipse.jetty.server.handler.DefaultHandler; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
URI baseUri = UriBuilder.fromUri("http://localhost").port(SERVER_PORT)
.build();
ResourceConfig config = new ResourceConfig(Calculator.class);
Server server = JettyHttpContainerFactory.createServer(baseUri, config,
false);
ContextHandler contextHandler = new ContextHandler("/rest");
contextHandler.setHandler(server.getHandler());
ProtectionDomain protectionDomain = EmbeddedServer.class
.getProtectionDomain();
URL location = protectionDomain.getCodeSource().getLocation();
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setWelcomeFiles(new String[] { "index.html" });
resourceHandler.setResourceBase(location.toExternalForm());
System.out.println(location.toExternalForm());
HandlerCollection handlerCollection = new HandlerCollection();
handlerCollection.setHandlers(new Handler[] { resourceHandler,
contextHandler, new DefaultHandler() });
server.setHandler(handlerCollection);
server.start();
server.join();
}
示例12: setup
import org.eclipse.jetty.server.handler.DefaultHandler; //导入依赖的package包/类
private void setup(int port) {
if (server == null) {
server = new Server(port);
ServletHandler servletHandler = new ServletHandler();
webSocketServlet = new WebsocketOutboundServlet();
ServletHolder holder = new ServletHolder(webSocketServlet);
servletHandler.addServletWithMapping(holder, uri + URI_SUFFIX);
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setBaseResource(Resource.newClassPathResource("com/example/docroot/"));
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[]{servletHandler, resourceHandler, new DefaultHandler()});
server.setHandler(handlers);
try {
server.start();
String url = "ws://localhost:" + port + uri;
System.out.println(ImplMessages.getMessage("WS_SERVER_START_MSG", url));
// add the shutdown hook
Runtime.getRuntime().addShutdownHook(new Thread(() -> shutdown()));
} catch (Exception error) {
System.out.println(ImplMessages.getMessage("INIT_FAILURE", getClass().getName(), error.getMessage()));
error.printStackTrace();
}
}
}
开发者ID:Esri,项目名称:performance-test-harness-for-geoevent,代码行数:27,代码来源:WebsocketServerEventProducer.java
示例13: setup
import org.eclipse.jetty.server.handler.DefaultHandler; //导入依赖的package包/类
private void setup(int port) {
if (server == null) {
server = new Server(port);
ServletHandler servletHandler = new ServletHandler();
webSocketServlet = new WebsocketOutboundServlet(message -> receive(message));
ServletHolder holder = new ServletHolder(webSocketServlet);
servletHandler.addServletWithMapping(holder, uri + URI_SUFFIX);
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setBaseResource(Resource.newClassPathResource("com/example/docroot/"));
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[]{servletHandler, resourceHandler, new DefaultHandler()});
server.setHandler(handlers);
try {
server.start();
String url = "ws://localhost:" + port + uri;
System.out.println(ImplMessages.getMessage("WS_SERVER_START_MSG", url));
// add the shutdown hook
Runtime.getRuntime().addShutdownHook(new Thread(() -> shutdown()));
} catch (Exception error) {
System.out.println(ImplMessages.getMessage("INIT_FAILURE", getClass().getName(), error.getMessage()));
error.printStackTrace();
}
}
}
开发者ID:Esri,项目名称:performance-test-harness-for-geoevent,代码行数:27,代码来源:WebsocketServerEventConsumer.java
示例14: configure
import org.eclipse.jetty.server.handler.DefaultHandler; //导入依赖的package包/类
@Override
protected void configure(ServerBuilder sb) throws Exception {
sb.port(0, SessionProtocol.HTTP);
sb.port(0, SessionProtocol.HTTPS);
sb.sslContext(SessionProtocol.HTTPS,
certificate.certificateFile(),
certificate.privateKeyFile());
sb.serviceUnder(
"/jsp/",
new JettyServiceBuilder()
.handler(newWebAppContext())
.configurator(s -> jettyBeans.addAll(s.getBeans()))
.build()
.decorate(LoggingService.newDecorator()));
sb.serviceUnder(
"/default/",
new JettyServiceBuilder().handler(new DefaultHandler()).build());
final ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setResourceBase(webAppRoot().getPath());
sb.serviceUnder(
"/resources/",
new JettyServiceBuilder().handler(resourceHandler).build());
}
示例15: UIWebServer
import org.eclipse.jetty.server.handler.DefaultHandler; //导入依赖的package包/类
/**
* Constructor that pairs urls with servlets and sets the webapp folder.
*
* @param serverName
* Name of the server
* @param address
* Address of the server
* @param masterInfo
* MasterInfo for the tachyon filesystem this UIWebServer supports
* @return A new UIWebServer
*/
public UIWebServer(String serverName, InetSocketAddress address, MasterInfo masterInfo) {
mAddress = address;
mServerName = serverName;
mServer = new Server(mAddress);
WebAppContext webappcontext = new WebAppContext();
webappcontext.setContextPath(Constants.PATH_SEPARATOR);
File warPath = new File(CommonConf.get().WEB_RESOURCES);
webappcontext.setWar(warPath.getAbsolutePath());
HandlerList handlers = new HandlerList();
webappcontext.addServlet(new ServletHolder(new WebInterfaceGeneralServlet(masterInfo)),
"/home");
webappcontext.addServlet(new ServletHolder(new WebInterfaceConfigurationServlet(masterInfo)),
"/configuration");
webappcontext.addServlet(new ServletHolder(new WebInterfaceBrowseServlet(masterInfo)),
"/browse");
webappcontext.addServlet(new ServletHolder(new WebInterfaceMemoryServlet(masterInfo)),
"/memory");
webappcontext.addServlet(new ServletHolder(new WebInterfaceDependencyServlet(masterInfo)),
"/dependency");
handlers.setHandlers(new Handler[] { webappcontext, new DefaultHandler() });
mServer.setHandler(handlers);
}