本文整理汇总了Java中org.eclipse.jetty.server.handler.ResourceHandler.setDirectoriesListed方法的典型用法代码示例。如果您正苦于以下问题:Java ResourceHandler.setDirectoriesListed方法的具体用法?Java ResourceHandler.setDirectoriesListed怎么用?Java ResourceHandler.setDirectoriesListed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jetty.server.handler.ResourceHandler
的用法示例。
在下文中一共展示了ResourceHandler.setDirectoriesListed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initServer
import org.eclipse.jetty.server.handler.ResourceHandler; //导入方法依赖的package包/类
private static void initServer(Properties properties) throws Exception {
Integer port = Integer.valueOf(properties.getProperty("server.port"));
String host = properties.getProperty("server.host");
Integer clientId = Integer.valueOf(properties.getProperty("client.id"));
String clientSecret = properties.getProperty("client.secret");
HandlerCollection handlers = new HandlerCollection();
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setDirectoriesListed(true);
resourceHandler.setWelcomeFiles(new String[]{"index.html"});
resourceHandler.setResourceBase(Application.class.getResource("/static").getPath());
VkApiClient vk = new VkApiClient(new HttpTransportClient());
handlers.setHandlers(new Handler[]{resourceHandler, new RequestHandler(vk, clientId, clientSecret, host)});
Server server = new Server(port);
server.setHandler(handlers);
server.start();
server.join();
}
示例2: main
import org.eclipse.jetty.server.handler.ResourceHandler; //导入方法依赖的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: start
import org.eclipse.jetty.server.handler.ResourceHandler; //导入方法依赖的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();
}
示例4: run
import org.eclipse.jetty.server.handler.ResourceHandler; //导入方法依赖的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();
}
示例5: main
import org.eclipse.jetty.server.handler.ResourceHandler; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
Server server = new Server(8080);
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.addServlet(new ServletHolder(new WebSocketChatServlet()), "/chat");
ResourceHandler resource_handler = new ResourceHandler();
resource_handler.setDirectoriesListed(true);
resource_handler.setResourceBase("public_html");
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[]{resource_handler, context});
server.setHandler(handlers);
server.start();
System.out.println("Server started!");
server.join();
}
示例6: WebSocketServer
import org.eclipse.jetty.server.handler.ResourceHandler; //导入方法依赖的package包/类
public WebSocketServer(int port, String rootDirPath, final MainWindow m, final Statement smt, final java.sql.Connection sqlcon) {
idCounter = 0;
connector = new SelectChannelConnector();
connector.setPort(port);
addConnector(connector);
wsHandler = new WebSocketHandler() {
@Override
public WebSocket doWebSocketConnect(HttpServletRequest request,
String protocol) {
idCounter++;
System.out.printf("Protocol:%s\n", protocol);
return new MyWebSocket(idCounter, m, smt, sqlcon);
}
};
resHandler = new ResourceHandler();
resHandler.setDirectoriesListed(true);
resHandler.setResourceBase(rootDirPath);
wsHandler.setHandler(resHandler);
setHandler(wsHandler);
}
开发者ID:ryohashioka,项目名称:Visual-Programming-Environment-for-Coordinating-Appliances-and-Services-in-a-Smart-House,代码行数:25,代码来源:WebSocketServer.java
示例7: attachHandlers
import org.eclipse.jetty.server.handler.ResourceHandler; //导入方法依赖的package包/类
private ContextHandlerCollection attachHandlers(final File staticsFolder, final Module... overrides) {
final MoodcatHandler moodcatHandler = new MoodcatHandler(this, staticsFolder, overrides);
final ResourceHandler resources = new ResourceHandler();
resources.setBaseResource(Resource.newResource(staticsFolder));
resources.setDirectoriesListed(false);
resources.setCacheControl("max-age=3600");
final HashSessionManager hashSessionManager = new HashSessionManager();
hashSessionManager.setMaxInactiveInterval(SESSION_KEEP_ALIVE);
final ContextHandlerCollection handlers = new ContextHandlerCollection();
// CHECKSTYLE:OFF
handlers.addContext("/", "/").setHandler(resources);
handlers.addContext("/", "/").setHandler(moodcatHandler);
// CHECKSTYLE:ON
return handlers;
}
示例8: main
import org.eclipse.jetty.server.handler.ResourceHandler; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
Server server = new Server(8080);
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.addServlet(new ServletHolder(new WebSocketChatServlet()), "/chat");
ResourceHandler resource_handler = new ResourceHandler();
resource_handler.setDirectoriesListed(true);
resource_handler.setResourceBase("public_html");
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[]{resource_handler, context});
server.setHandler(handlers);
server.start();
server.join();
}
示例9: main
import org.eclipse.jetty.server.handler.ResourceHandler; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
Server server = new Server(15000);
HandlerCollection hc = new HandlerCollection();
ResourceHandler rh = new ResourceHandler();
rh.setBaseResource(Resource.newClassPathResource("/com/frinika/web/content/"));
rh.setDirectoriesListed(true);
hc.addHandler(rh);
server.setHandler(hc);
server.start();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
initAndShowGUI();
}
});
}
示例10: main
import org.eclipse.jetty.server.handler.ResourceHandler; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
if (args.length != 1) {
System.out.append("Use port as the first argument");
System.exit(1);
}
String portString = args[0];
int port = Integer.valueOf(portString);
System.out.append("Starting at port: ").append(portString).append('\n');
Server server = new Server(port);
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.addServlet(new ServletHolder(new AdminPageServlet()), AdminPageServlet.adminPageURL);
ResourceHandler resource_handler = new ResourceHandler();
resource_handler.setDirectoriesListed(true);
resource_handler.setResourceBase("static");
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[]{resource_handler, context});
server.setHandler(handlers);
server.start();
server.join();
}
示例11: JettyCrosServer
import org.eclipse.jetty.server.handler.ResourceHandler; //导入方法依赖的package包/类
public JettyCrosServer() throws Exception {
server = new Server(80);
HandlerList handlers = new HandlerList();
ResourceHandler resource_handler = new ResourceHandler();
resource_handler.setDirectoriesListed(true);
resource_handler.setWelcomeFiles(new String[] { "index.html" });
resource_handler.setBaseResource(Resource.newClassPathResource("web"));
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");
context.setInitParameter("maxInterval", "1000");
context.setInitParameter("logLevel", "2");
handlers.setHandlers(new Handler[] { resource_handler, context});
server.setHandler(handlers);
FilterHolder filterHolder = new FilterHolder(new CrossOriginFilter());
filterHolder.getInitParameters().put(CrossOriginFilter.ALLOWED_HEADERS_PARAM, "X-Requested-With,Content-Type,Accept,Origin,Authorization");
context.addFilter(filterHolder, "/*", EnumSet.allOf(DispatcherType.class));
context.addServlet(new ServletHolder(new JsonServlet()), "/t.json");
context.addServlet(new ServletHolder(new DefaultServlet()), "/*");
}
示例12: run
import org.eclipse.jetty.server.handler.ResourceHandler; //导入方法依赖的package包/类
@Override
public void run() {
try {
Server server = new Server(8080);
ResourceHandler resource_handler = new ResourceHandler();
resource_handler.setDirectoriesListed(true);
resource_handler.setWelcomeFiles(new String[] { "index.html" });
resource_handler.setResourceBase("./www");
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] { resource_handler,
new StateHandler(this.geo) });
server.setHandler(handlers);
server.start();
server.join();
} catch (Exception e) {
e.printStackTrace();
}
}
示例13: main
import org.eclipse.jetty.server.handler.ResourceHandler; //导入方法依赖的package包/类
public static void main (String args[]) throws Exception{
logger.info("Starting JETTY server");
Server server = new Server(8080);
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setDirectoriesListed(true);
resourceHandler.setWelcomeFiles(new String[]{ "resources/html/configure.html" });
resourceHandler.setResourceBase(".");
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
resourceHandler.setWelcomeFiles(new String[]{ "resources/html/configure.html" });
resourceHandler.setResourceBase(".");
context.addServlet(new ServletHolder(new ConfigurationServlet()),"/cfg");
context.addServlet(new ServletHolder(new SaveConfigurationServlet()),"/cfg/save");
context.addServlet(new ServletHolder(new LoadConfigurationServlet()),"/cfg/load");
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] { resourceHandler, context });
server.setHandler(handlers);
server.start();
logger.info("Configuration server started at: http://localhost:8080/cfg");
server.join();
}
示例14: startWebServer
import org.eclipse.jetty.server.handler.ResourceHandler; //导入方法依赖的package包/类
public static void startWebServer(int port) throws Exception {
webServer = new Server();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(port);
webServer.addConnector(connector);
ResourceHandler resource_handler = new ResourceHandler();
resource_handler.setDirectoriesListed(true);
//resource_handler.setWelcomeFiles(new String[] { "index.html" });
String serverRoot = ServerStarter.class.getResource("/").getFile();
resource_handler.setResourceBase(serverRoot);
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] { resource_handler,
new DefaultHandler() });
webServer.setHandler(handlers);
webServer.start();
}
示例15: before_suite
import org.eclipse.jetty.server.handler.ResourceHandler; //导入方法依赖的package包/类
@BeforeSuite
public void before_suite() throws Exception {
// Launch Protractor's own test app on http://localhost:8080
((StdErrLog) Log.getRootLogger()).setLevel(StdErrLog.LEVEL_OFF);
webServer = new Server(new QueuedThreadPool(6));
ServerConnector connector = new ServerConnector(webServer, new HttpConnectionFactory());
connector.setPort(8080);
webServer.addConnector(connector);
ResourceHandler resource_handler = new ResourceHandler();
resource_handler.setDirectoriesListed(true);
resource_handler.setWelcomeFiles(new String[]{"index.html"});
resource_handler.setResourceBase("src/test/webapp");
HandlerList handlers = new HandlerList();
MovedContextHandler effective_symlink = new MovedContextHandler(webServer, "/lib/angular", "/lib/angular_v1.2.9");
handlers.setHandlers(new Handler[] { effective_symlink, resource_handler, new DefaultHandler() });
webServer.setHandler(handlers);
webServer.start();
driver = new ChromeDriver();
driver.manage().timeouts().setScriptTimeout(30, TimeUnit.SECONDS);
ngWebDriver = new NgWebDriver(driver);
}