當前位置: 首頁>>代碼示例>>Java>>正文


Java ContextHandler.setContextPath方法代碼示例

本文整理匯總了Java中org.eclipse.jetty.server.handler.ContextHandler.setContextPath方法的典型用法代碼示例。如果您正苦於以下問題:Java ContextHandler.setContextPath方法的具體用法?Java ContextHandler.setContextPath怎麽用?Java ContextHandler.setContextPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jetty.server.handler.ContextHandler的用法示例。


在下文中一共展示了ContextHandler.setContextPath方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getAllServices

import org.eclipse.jetty.server.handler.ContextHandler; //導入方法依賴的package包/類
private HandlerList getAllServices() throws Exception{
    // File server & Context Handler for root, also setting the index.html
    // to be the "welcome file", i.e, autolink on root addresses.
    ContextHandler rootContext = new ContextHandler();
    rootContext.setContextPath("/*");
    rootContext.setHandler(getResourceHandlers());

    // Possible servlet lists, for all servlets or custom services you want to access later.
    // Warning, it might become a little bit nested if you add to many classes.
    ServletHandler questionHandler = new ServletHandler();
    questionHandler.addServletWithMapping(QuestionHandler.class, "/question");

    // Add the ResourceHandler to the server.
    HandlerList handlers = new HandlerList();
    handlers.setHandlers(new Handler[] {
            rootContext ,
            questionHandler,
    });

    return handlers;
}
 
開發者ID:Rebstorm,項目名稱:paul0-application-server,代碼行數:22,代碼來源:HomeServerConfig.java

示例2: main

import org.eclipse.jetty.server.handler.ContextHandler; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
        Server server = new Server(8080);
        
        // connector
//        server.getConnectors()[0].getConnectionFactory(HttpConnectionFactory.class)
//                .setHttpCompliance(HttpCompliance.LEGACY);
//        server.setHandler(new HelloHandler("Hi JettyEmbeded "," light測試"));
        
        // Add a single handler on context "/hello"
        ContextHandler context = new ContextHandler();
        context.setContextPath( "/hello" );
        context.setHandler( new HelloHandler("Hi JettyEmbeded "," light測試") );
        // Can be accessed using http://localhost:8080/hello
        server.setHandler( context );

        server.start();
        server.join();
    }
 
開發者ID:lrtdc,項目名稱:book_ldrtc,代碼行數:19,代碼來源:OneHandler.java

示例3: main

import org.eclipse.jetty.server.handler.ContextHandler; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    final ApiServer api = new ApiServer(new InetSocketAddress(9998));

    PrometheusConfig cfg = createPrometheusConfig(args);
    final Optional<File> _cfg = cfg.getConfiguration();
    if (_cfg.isPresent())
        registry_ = new PipelineBuilder(_cfg.get()).build();
    else
        registry_ = new PipelineBuilder(Configuration.DEFAULT).build();

    api.start();
    Runtime.getRuntime().addShutdownHook(new Thread(api::close));

    Server server = new Server(cfg.getPort());
    ContextHandler context = new ContextHandler();
    context.setClassLoader(Thread.currentThread().getContextClassLoader());
    context.setContextPath(cfg.getPath());
    context.setHandler(new DisplayMetrics(registry_));
    server.setHandler(context);
    server.start();
    server.join();
}
 
開發者ID:groupon,項目名稱:monsoon,代碼行數:23,代碼來源:PrometheusServer.java

示例4: setUpGuiHandler

import org.eclipse.jetty.server.handler.ContextHandler; //導入方法依賴的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

示例5: systemRestart

import org.eclipse.jetty.server.handler.ContextHandler; //導入方法依賴的package包/類
private ContextHandler systemRestart() {
	AbstractHandler system = new AbstractHandler() {
		@Override
		public void handle(String target, Request baseRequest,
				HttpServletRequest request, HttpServletResponse response)
				throws IOException, ServletException {
			restartContexts();
			response.setContentType("text/html;charset=utf-8");
			response.setStatus(HttpServletResponse.SC_OK);
			baseRequest.setHandled(true);
			response.getWriter().println("<h1>Done</h1>");
		}
	};
	ContextHandler context = new ContextHandler();
	context.setContextPath("/vraptor/restart");
	context.setResourceBase(".");
	context.setClassLoader(Thread.currentThread().getContextClassLoader());
	context.setHandler(system);
	return context;
}
 
開發者ID:caelum,項目名稱:mamute,代碼行數:21,代碼來源:VRaptorServer.java

示例6: doPreStart

import org.eclipse.jetty.server.handler.ContextHandler; //導入方法依賴的package包/類
@Override
protected void doPreStart() {
    ContextHandler welcomeContext = new ContextHandler("/");
    welcomeContext.setContextPath("/");
    welcomeContext.setHandler(new WelcomeHandler(gpapProjectsFolder));

    ContextHandler projectsListContext = new ContextHandler("/stage_gplist_download");
    projectsListContext.setHandler(new ProjectListHandler(gpapProjectsFolder));

    ContextHandler projectDownloadContext = new ContextHandler("/stage_gpproject_download");
    projectDownloadContext.setHandler(new ProjectDownloadHandler(gpapProjectsFolder));

    ContextHandler projectUploadContext = new ContextHandler("/stage_gpproject_upload");
    projectUploadContext.setHandler(new ProjectUploadHandler(gpapProjectsFolder));

    ContextHandlerCollection contexts = new ContextHandlerCollection();
    contexts.setHandlers(new Handler[]{welcomeContext, projectDownloadContext, projectUploadContext, projectsListContext});

    _server.setHandler(contexts);

}
 
開發者ID:TheHortonMachine,項目名稱:hortonmachine,代碼行數:22,代碼來源:GeopaparazziServer.java

示例7: listen

import org.eclipse.jetty.server.handler.ContextHandler; //導入方法依賴的package包/類
@Override
public HttpServer listen(int port) throws Exception {

    SessionHandler sessionHandler = new SessionHandler(app.configuration(SessionManager.class));
    sessionHandler.setHandler(new MiddlewareHandler(app));

    ContextHandler context = new ContextHandler();
    context.setContextPath("/");
    context.setResourceBase(".");
    context.setClassLoader(Thread.currentThread().getContextClassLoader());
    context.setHandler(sessionHandler);

    Server server = new Server(port);

    server.setSessionIdManager(new HashSessionIdManager());
    server.setHandler(context);

    server.start();
    server.join();

    return this;
}
 
開發者ID:wmluke,項目名稱:pipes,代碼行數:23,代碼來源:JettyHttpServer.java

示例8: main

import org.eclipse.jetty.server.handler.ContextHandler; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    Server server = new Server(8085);
    
    ContextHandler context = new ContextHandler("/");
    context.setContextPath("/");
    
    context.setHandler(new HandlerGUI("Root Hello"));
    
    ContextHandler contextFR = new ContextHandler("/fr");
    contextFR.setHandler(new HandlerGUI("Bonjoir"));
    
    ContextHandler contextIT = new ContextHandler("/it");
    contextIT.setHandler(new HandlerGUI("Bongiorno"));
    
    ContextHandler contextV = new ContextHandler("/");
    contextV.setVirtualHosts(new String[] { "127.0.0.2" });
    contextV.setHandler(new HandlerGUI("Virtual Hello"));
    
    ContextHandlerCollection contexts = new ContextHandlerCollection();
    
    contexts.setHandlers(new Handler[] { context, contextFR, contextIT, contextV });
    
    server.setHandler(contexts);
    server.start();
    server.join();
}
 
開發者ID:jimjonesbr,項目名稱:lod4wfs,代碼行數:27,代碼來源:ManyContexts.java

示例9: configServer

import org.eclipse.jetty.server.handler.ContextHandler; //導入方法依賴的package包/類
@Override
protected void configServer(Server server, int port) {
    ServerConnector connector = new ServerConnector(server);
    connector.setPort(port);
    server.setConnectors(new Connector[]{connector});

    ResourceHandler handler = new ResourceHandler();
    ContextHandler context = new ContextHandler();
    context.setContextPath("/dbus/");

    context.setResourceBase(SystemUtils.USER_DIR + File.separator + "html");
    context.setHandler(handler);

    server.setHandler(context);
}
 
開發者ID:BriData,項目名稱:DBus,代碼行數:16,代碼來源:ResourceHttpServer.java

示例10: run

import org.eclipse.jetty.server.handler.ContextHandler; //導入方法依賴的package包/類
public void run()  {
try {
    System.out.println("Listening on Reqs...");

  Server server = new Server(Config.PORT);

  // Handler for the voting API
  ContextHandler votingContext = new ContextHandler();
  votingContext.setContextPath("/vote");
  votingContext.setHandler(new VoteHandler());
  // Handler for the stats API
  ContextHandler statContext = new ContextHandler();
  statContext.setContextPath("/stats");
  statContext.setHandler(new StatsHandler());

  // summing all the Handlers up to one
  ContextHandlerCollection contexts = new ContextHandlerCollection();
  contexts.setHandlers(new Handler[] { votingContext, statContext});
  server.setHandler(contexts);
  server.start();
  server.join();

  } catch (Exception e) {
    e.printStackTrace();
  }

}
 
開發者ID:Sigma-News,項目名稱:Backend,代碼行數:28,代碼來源:RequestManager.java

示例11: main

import org.eclipse.jetty.server.handler.ContextHandler; //導入方法依賴的package包/類
public static void main( String[] args ) throws Exception
{
    Server server = new Server(8080);

    ContextHandler context = new ContextHandler("/");
    context.setContextPath("/");
    context.setHandler(new HelloHandler("Root Hello"));

    ContextHandler contextFR = new ContextHandler("/fr");
    contextFR.setHandler(new HelloHandler("Bonjoir"));

    ContextHandler contextIT = new ContextHandler("/it");
    contextIT.setHandler(new HelloHandler("Bongiorno"));

    ContextHandler contextV = new ContextHandler("/");
    contextV.setVirtualHosts(new String[] { "127.0.0.2" });
    contextV.setHandler(new HelloHandler("Virtual Hello"));

    ContextHandlerCollection contexts = new ContextHandlerCollection();
    contexts.setHandlers(new Handler[] { context, contextFR, contextIT,
            contextV });

    server.setHandler(contexts);

    server.start();
    server.join();
}
 
開發者ID:lrtdc,項目名稱:book_ldrtc,代碼行數:28,代碼來源:ManyContexts.java

示例12: main

import org.eclipse.jetty.server.handler.ContextHandler; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    Map<String, String> settings = System.getenv();

    // When run from app-runner, you must use the port set in the environment variable APP_PORT
    int port = Integer.parseInt(settings.getOrDefault("APP_PORT", "8081"));
    // All URLs must be prefixed with the app name, which is got via the APP_NAME env var.
    String appName = settings.getOrDefault("APP_NAME", "my-app");
    String env = settings.getOrDefault("APP_ENV", "local"); // "prod" or "local"
    boolean isLocal = "local".equals(env);
    log.info("Starting " + appName + " in " + env + " on port " + port);

    Server jettyServer = new Server(new InetSocketAddress("localhost", port));
    jettyServer.setStopAtShutdown(true);

    HandlerList handlers = new HandlerList();
    // TODO: set your own handlers
    handlers.addHandler(resourceHandler(isLocal));

    // you must serve everything from a directory named after your app
    ContextHandler ch = new ContextHandler();
    ch.setContextPath("/" + appName);
    ch.setHandler(handlers);
    jettyServer.setHandler(ch);

    try {
        jettyServer.start();
    } catch (Throwable e) {
        log.error("Error on start", e);
        System.exit(1);
    }

    log.info("Started app at http://localhost:" + port + ch.getContextPath());
    jettyServer.join();
}
 
開發者ID:danielflower,項目名稱:app-runner,代碼行數:35,代碼來源:App.java

示例13: addStaticResources

import org.eclipse.jetty.server.handler.ContextHandler; //導入方法依賴的package包/類
public void addStaticResources(String basePath, String resourcePath) {
    ContextHandler capHandler = new ContextHandler();
    capHandler.setContextPath(basePath);
    ResourceHandler resHandler = new ResourceHandler();
    resHandler.setBaseResource(Resource.newClassPathResource(resourcePath));
    resHandler.setEtags(true);
    resHandler.setCacheControl(WebService.HANDLER_CACHE_CONTROL);
    capHandler.setHandler(resHandler);
    handlers.add(capHandler);
}
 
開發者ID:apache,項目名稱:incubator-pulsar,代碼行數:11,代碼來源:WebService.java

示例14: swaggerUI

import org.eclipse.jetty.server.handler.ContextHandler; //導入方法依賴的package包/類
private static ContextHandler swaggerUI() throws Exception {
    final ResourceHandler swaggerUIResourceHandler = new ResourceHandler();
    String swaggerui = HServer.class.getClassLoader().getResource("swaggerui").toURI().toString();
    swaggerUIResourceHandler.setResourceBase(swaggerui);
    final ContextHandler swaggerUIContext = new ContextHandler();
    swaggerUIContext.setContextPath("/docs/");
    swaggerUIContext.setHandler(swaggerUIResourceHandler);

    return swaggerUIContext;
}
 
開發者ID:rndsolutions,項目名稱:hawkcd,代碼行數:11,代碼來源:HServer.java

示例15: setupServer

import org.eclipse.jetty.server.handler.ContextHandler; //導入方法依賴的package包/類
private static Server setupServer() throws Exception {
    // String webDir = "target/classes/webui";
    // String webDir = "src/main/resources/webui";
    String webDir = WebServer.class.getClassLoader().getResource("webui").toExternalForm();
    log.info("Base webdir is {}", webDir);

    int httpPort = ConfigFactory.load().getInt("resource-reporting.visualization.webui-port");
    log.info("Resource reporting web ui port is ", httpPort);

    // Create Jetty server
    Server server = new Server(httpPort);

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

    WebSocketHandler wsHandler = new WebSocketHandler.Simple(PubSubProxyWebSocket.class);

    ContextHandler context = new ContextHandler();
    context.setContextPath("/ws");
    context.setHandler(wsHandler);

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

    server.setHandler(handlers);

    ClusterResources.subscribeToAll(callback);

    return server;
}
 
開發者ID:brownsys,項目名稱:tracing-framework,代碼行數:33,代碼來源:WebServer.java


注:本文中的org.eclipse.jetty.server.handler.ContextHandler.setContextPath方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。