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


Java ResourceHandler.setWelcomeFiles方法代码示例

本文整理汇总了Java中org.eclipse.jetty.server.handler.ResourceHandler.setWelcomeFiles方法的典型用法代码示例。如果您正苦于以下问题:Java ResourceHandler.setWelcomeFiles方法的具体用法?Java ResourceHandler.setWelcomeFiles怎么用?Java ResourceHandler.setWelcomeFiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jetty.server.handler.ResourceHandler的用法示例。


在下文中一共展示了ResourceHandler.setWelcomeFiles方法的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();
}
 
开发者ID:VKCOM,项目名称:vk-java-sdk,代码行数:24,代码来源:Application.java

示例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();
    }
 
开发者ID:biblelamp,项目名称:JavaEE,代码行数:27,代码来源:Main.java

示例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();
}
 
开发者ID:RUCD,项目名称:apt-graph,代码行数:25,代码来源:FileServer.java

示例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();
}
 
开发者ID:wxyzZ,项目名称:little_mitm,代码行数:22,代码来源:PerformanceServer.java

示例5: main

import org.eclipse.jetty.server.handler.ResourceHandler; //导入方法依赖的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();
}
 
开发者ID:AlanHohn,项目名称:jaxrs,代码行数:26,代码来源:EmbeddedServer.java

示例6: setUpGuiHandler

import org.eclipse.jetty.server.handler.ResourceHandler; //导入方法依赖的package包/类
/**
     * do setup for the static resource handler
     * @return ContextHandler for the static resource handler
     */
    private static ContextHandler setUpGuiHandler() throws MalformedURLException
    {
    	ContextHandler context1 = new ContextHandler();
		context1.setContextPath("/");        
		ResourceHandler res = new ResourceHandler();
		res.setWelcomeFiles(new String[]{"index.html"});
		res.setBaseResource(Resource.newResource("./resources/"));
		context1.setHandler(res);
		logger.info("<---gui handler initialised--->");
		
//    WebAppContext webApp = new WebAppContext();
//    webApp.setContextPath("/");
//    webApp.setResourceBase("/home/orpheus/projects/BeSeen/BeSeenium/resources/");
//    webApp.setWar("/home/orpheus/projects/BeSeen/BeSeenium/resources/quercus-4.0.18.war");
//    webApp.setServer(server);
   // context1.setHandler(webApp);
		
		return context1;
    }
 
开发者ID:jpchanson,项目名称:BeSeenium,代码行数:24,代码来源:HttpServer.java

示例7: 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()), "/*");
       
}
 
开发者ID:y12studio,项目名称:bkbc-tools,代码行数:27,代码来源:JettyCrosServer.java

示例8: 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();
	}
}
 
开发者ID:invider,项目名称:trux,代码行数:23,代码来源:TruxServer.java

示例9: 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();
}
 
开发者ID:sugarcrm,项目名称:candybean,代码行数:25,代码来源:ConfigurationServerDriver.java

示例10: 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);
}
 
开发者ID:paul-hammant,项目名称:ngWebDriver,代码行数:24,代码来源:AngularAndWebDriverTest.java

示例11: run

import org.eclipse.jetty.server.handler.ResourceHandler; //导入方法依赖的package包/类
/**
 * Run Jetty web server serving out supplied path on supplied port
 * 
 * @param path
 * @param port
 */
public void run(String path, String port) {
	Server server = new Server();
	SelectChannelConnector connector = new SelectChannelConnector();
       connector.setPort(Integer.parseInt(port));
       server.addConnector(connector);

       ResourceHandler resource_handler = new ResourceHandler();
       resource_handler.setDirectoriesListed(true);
       resource_handler.setWelcomeFiles(new String[]{ "index.html" });

       resource_handler.setResourceBase(path);

       HandlerList handlers = new HandlerList();
       handlers.setHandlers(new Handler[] { resource_handler, new DefaultHandler() });
       server.setHandler(handlers);

       LOGGER.info("Serving out contents of: [{}] on http://localhost:{}/", path, port);
       LOGGER.info("(To stop server hit CTRL-C)");
       
       try {
		server.start();
		server.join();
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:ghaseminya,项目名称:jbake-rtl-jalaali,代码行数:33,代码来源:JettyServer.java

示例12: main

import org.eclipse.jetty.server.handler.ResourceHandler; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
  Server server = new Server(HTTP_PORT);
  ResourceHandler resourceHandler = new ResourceHandler();
  resourceHandler.setWelcomeFiles(new String[] {"index.html"});
  resourceHandler.setDirectoriesListed(false);
  // resource base is relative to the WORKSPACE file
  resourceHandler.setResourceBase("./examples/resources");
  HandlerList handlerList = new HandlerList();
  handlerList.setHandlers(new Handler[] {resourceHandler, new GraphQlServer()});
  server.setHandler(handlerList);
  server.start();
  server.join();
}
 
开发者ID:google,项目名称:rejoiner,代码行数:14,代码来源:GraphQlServer.java

示例13: main

import org.eclipse.jetty.server.handler.ResourceHandler; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    //
    // This example uses Jetty as an embedded HTTP server
    Server server = new Server(PORT);

    //
    // In Jetty, handlers are how your get called back on a request
    ServletContextHandler servletContextHandler = new ServletContextHandler();
    servletContextHandler.setContextPath("/");

    ServletHolder stockTicker = new ServletHolder("ws-stockticker", StockTickerServlet.class);
    servletContextHandler.addServlet(stockTicker, "/stockticker");

    // this allows us to server our index.html and GraphIQL JS code
    ResourceHandler resource_handler = new ResourceHandler();
    resource_handler.setDirectoriesListed(false);
    resource_handler.setWelcomeFiles(new String[]{"index.html"});
    resource_handler.setResourceBase("./src/main/resources/httpmain");

    HandlerList handlers = new HandlerList();
    handlers.setHandlers(new Handler[]{resource_handler, servletContextHandler});
    server.setHandler(handlers);

    server.start();

    server.join();
}
 
开发者ID:graphql-java,项目名称:graphql-java-subscription-example,代码行数:28,代码来源:HttpMain.java

示例14: initWebApp

import org.eclipse.jetty.server.handler.ResourceHandler; //导入方法依赖的package包/类
private void initWebApp() {
    ResourceHandler resourceHandler = new ResourceHandler();
    resourceHandler.setResourceBase(config.getString("web.path"));
    if (config.getBoolean("web.debug")) {
        resourceHandler.setWelcomeFiles(new String[] {"debug.html", "index.html"});
        resourceHandler.setMinMemoryMappedContentLength(-1); // avoid locking files on Windows
    } else {
        String cache = config.getString("web.cacheControl");
        if (cache != null && !cache.isEmpty()) {
            resourceHandler.setCacheControl(cache);
        }
        resourceHandler.setWelcomeFiles(new String[] {"release.html", "index.html"});
    }
    handlers.addHandler(resourceHandler);
}
 
开发者ID:bamartinezd,项目名称:traccar-service,代码行数:16,代码来源:WebServer.java

示例15: getResourceHandlers

import org.eclipse.jetty.server.handler.ResourceHandler; //导入方法依赖的package包/类
private ResourceHandler getResourceHandlers(){
    ResourceHandler rHandler = new ResourceHandler();
    rHandler.setDirectoriesListed(false);
    rHandler.setWelcomeFiles(new String[]{ "index.html" });
    rHandler.setResourceBase(settings.getWebsiteRoot());
    rHandler.setDirAllowed(false);

    return rHandler;
}
 
开发者ID:Rebstorm,项目名称:paul0-application-server,代码行数:10,代码来源:HomeServerConfig.java


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