当前位置: 首页>>代码示例>>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;未经允许,请勿转载。