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


Java ContextHandler.setResourceBase方法代码示例

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


在下文中一共展示了ContextHandler.setResourceBase方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: start

import org.eclipse.jetty.server.handler.ContextHandler; //导入方法依赖的package包/类
public void start() throws Exception {
	server = new Server(port);

	ContextHandlerCollection contexts = new ContextHandlerCollection();
	server.setHandler(contexts);

	ContextHandler context = new ContextHandler();
	context.setContextPath("/");
	context.setResourceBase(".");
	context.setClassLoader(Thread.currentThread().getContextClassLoader());
	server.setHandler(context);
	server.start();
}
 
开发者ID:jdmp,项目名称:java-data-mining-package,代码行数:14,代码来源:JettyCoreObjectServer.java

示例5: start

import org.eclipse.jetty.server.handler.ContextHandler; //导入方法依赖的package包/类
public void start() throws Exception {
	server = new Server(port);

	ContextHandlerCollection contexts = new ContextHandlerCollection();
	server.setHandler(contexts);

	ContextHandler context = new ContextHandler();
	context.setContextPath("/");
	context.setResourceBase(".");
	context.setClassLoader(Thread.currentThread().getContextClassLoader());
	context.setHandler(new JettyIndexHandler(index));
	server.setHandler(context);
	server.start();
}
 
开发者ID:jdmp,项目名称:java-data-mining-package,代码行数:15,代码来源:JettyIndexServer.java

示例6: start

import org.eclipse.jetty.server.handler.ContextHandler; //导入方法依赖的package包/类
public void start() throws Exception {
	server = new Server(port);

	ContextHandler context = new ContextHandler();
	context.setContextPath("/");
	context.setResourceBase(".");
	context.setClassLoader(Thread.currentThread().getContextClassLoader());
	context.setHandler(new JettyObjectHandler(object));
	server.setHandler(context);
	server.start();
}
 
开发者ID:jdmp,项目名称:java-data-mining-package,代码行数:12,代码来源:JettyObjectServer.java

示例7: initMainWebHandler

import org.eclipse.jetty.server.handler.ContextHandler; //导入方法依赖的package包/类
public void initMainWebHandler(final Server server)
{
    String webDir = System.class.getResource(WEB_ROOT).toExternalForm();
    ContextHandler rootContext = new ContextHandler(server, WEB_ROOT_DIR);
    rootContext.setResourceBase(webDir);
    rootContext.setHandler(new DefaultHandler(rootContext));
    handlerCollection.addHandler(rootContext);
}
 
开发者ID:mvasilchuk,项目名称:webproxy,代码行数:9,代码来源:WebServer.java

示例8: main

import org.eclipse.jetty.server.handler.ContextHandler; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

    Server server = new Server();

    // the ssl context to use
    SslContextFactory sslFactory = new SslContextFactory();
    //NOTE: keystore.jks should not end up in the repo on a real application since it is private
    sslFactory.setKeyStorePath("src/main/resources/keystore.jks");
    sslFactory.setKeyStorePassword("password");
    sslFactory.setProtocol("TLSv1");

    Connector connector = new HTTPSPDYServerConnector(sslFactory);
    connector.setPort(8443);

    // add connector to the server
    server.addConnector(connector);

    // add a handler to serve content
    ContextHandler handler = new ContextHandler();
    handler.setContextPath("/mysite");
    handler.setResourceBase("src/main/webapp/");
    handler.setHandler(new ResourceHandler());

    server.setHandler(handler);

    server.start();
    server.join();
  }
 
开发者ID:mitemitreski,项目名称:spdy-example-apps,代码行数:29,代码来源:SPDYServerLauncher.java

示例9: enableWebServer

import org.eclipse.jetty.server.handler.ContextHandler; //导入方法依赖的package包/类
private void enableWebServer() {
	if (server.isRunning())
		throw new IllegalStateException("Webserver can not be enabled while running");
	ResourceHandler resourceHandler = new ResourceHandler();
	resourceHandler.setDirectoriesListed(true);
	resourceHandler.setWelcomeFiles(new String[] { "index.html" });
	resourceHandler.setResourceBase(webPath);
	resourceHandler.setCacheControl("max-age=600,public"); //cache 10 minutes
	ContextHandler contentHandler = new ContextHandler();
	contentHandler.setContextPath("/");
	contentHandler.setResourceBase(".");
	contentHandler.setClassLoader(Thread.currentThread().getContextClassLoader());
	contentHandler.setHandler(resourceHandler);
	handlers.add(contentHandler);
}
 
开发者ID:Xenoage,项目名称:Zong,代码行数:16,代码来源:Webserver.java

示例10: installJavadocs

import org.eclipse.jetty.server.handler.ContextHandler; //导入方法依赖的package包/类
private void installJavadocs(HandlerList handlers) {
	// Does JavaDoc exist?
	File javadocJar = null;
	try {
		File currentJar = Paths.get(BaleenWebApi.class.getProtectionDomain().getCodeSource().getLocation().toURI())
				.toFile();
		String name = currentJar.getName();
		if (name.endsWith(".jar")) {
			name = name.substring(0, name.length() - 4) + "-javadoc.jar";
			javadocJar = new File(currentJar.getParent(), name);
			if (!javadocJar.exists()) {
				LOGGER.debug("Unable to locate Javadoc JAR '" + name + "' - Javadoc will not be available");
				javadocJar = null;
			}
		} else {
			LOGGER.debug("Couldn't determine name of Javadoc file - Javadoc will not be available");
		}
	} catch (NullPointerException npe) {
		LOGGER.debug(
				"Couldn't get name of current JAR - Javadoc will not be available",
				npe);
	} catch (URISyntaxException use) {
		LOGGER.debug(
				"Couldn't get name of current JAR - Javadoc will not be available",
				use);
	}

	// If Javadoc exists, serve it
	if (javadocJar != null) {
		LOGGER.debug("Adding JavaDoc documentation: {}!/",
				javadocJar.toURI());

		ContextHandler chJavadoc = new ContextHandler("/javadoc");
		chJavadoc.setResourceBase("jar:" + javadocJar.toURI() + "!/");

		ResourceHandler rhJavadoc = new ResourceHandler();
		chJavadoc.setHandler(rhJavadoc);

		handlers.addHandler(chJavadoc);
	} else {
		LOGGER.info("Javadoc will not be available");
	}
}
 
开发者ID:dstl,项目名称:baleen,代码行数:44,代码来源:BaleenWebApi.java

示例11: configure

import org.eclipse.jetty.server.handler.ContextHandler; //导入方法依赖的package包/类
@Override
public void configure(ComponentDTO config, String artemisInstance, String artemisHome) throws Exception {
   webServerConfig = (WebServerDTO) config;
   uri = new URI(webServerConfig.bind);
   server = new Server();
   String scheme = uri.getScheme();

   if ("https".equals(scheme)) {
      SslContextFactory sslFactory = new SslContextFactory();
      sslFactory.setKeyStorePath(webServerConfig.keyStorePath == null ? artemisInstance + "/etc/keystore.jks" : webServerConfig.keyStorePath);
      sslFactory.setKeyStorePassword(webServerConfig.keyStorePassword == null ? "password" : webServerConfig.keyStorePassword);
      if (webServerConfig.clientAuth != null) {
         sslFactory.setNeedClientAuth(webServerConfig.clientAuth);
         if (webServerConfig.clientAuth) {
            sslFactory.setTrustStorePath(webServerConfig.trustStorePath);
            sslFactory.setTrustStorePassword(webServerConfig.trustStorePassword);
         }
      }

      SslConnectionFactory sslConnectionFactory = new SslConnectionFactory(sslFactory, "HTTP/1.1");

      HttpConfiguration https = new HttpConfiguration();
      https.addCustomizer(new SecureRequestCustomizer());
      HttpConnectionFactory httpFactory = new HttpConnectionFactory(https);

      connector = new ServerConnector(server, sslConnectionFactory, httpFactory);

   } else {
      connector = new ServerConnector(server);
   }
   connector.setPort(uri.getPort());
   connector.setHost(uri.getHost());

   server.setConnectors(new Connector[]{connector});

   handlers = new HandlerList();

   Path warDir = Paths.get(artemisHome != null ? artemisHome : ".").resolve(webServerConfig.path).toAbsolutePath();

   if (webServerConfig.apps != null && webServerConfig.apps.size() > 0) {
      webContexts = new ArrayList<>();
      for (AppDTO app : webServerConfig.apps) {
         WebAppContext webContext = deployWar(app.url, app.war, warDir);
         webContexts.add(webContext);
         if (app.war.startsWith("console")) {
            consoleUrl = webServerConfig.bind + "/" + app.url;
         }
      }
   }

   ResourceHandler resourceHandler = new ResourceHandler();
   resourceHandler.setResourceBase(warDir.toString());
   resourceHandler.setDirectoriesListed(true);
   resourceHandler.setWelcomeFiles(new String[]{"index.html"});

   DefaultHandler defaultHandler = new DefaultHandler();
   defaultHandler.setServeIcon(false);

   ContextHandler context = new ContextHandler();
   context.setContextPath("/");
   context.setResourceBase(warDir.toString());
   context.setHandler(resourceHandler);

   handlers.addHandler(context);
   handlers.addHandler(defaultHandler);
   server.setHandler(handlers);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:68,代码来源:WebServerComponent.java

示例12: initialiseStaticJettyConfig

import org.eclipse.jetty.server.handler.ContextHandler; //导入方法依赖的package包/类
public void initialiseStaticJettyConfig() throws Exception {
        server.initialiseConnectors();

        ErrorHandler errorHandler = new CougarErrorHandler();
        wsdlStaticHandler = new StaticContentServiceHandler(
                wsdlContextPath,
                wsdlRegex,
                wsdlMediaType,
                uuidHeader,
                uuidParentsHeader,
                deserializer,
                geoIPLocator,
                requestLogger,
                true);
        wsdlStaticHandler.setUnknownCipherKeyLength(unknownCipherKeyLength);

        htmlStaticHandler = new StaticContentServiceHandler(
                htmlContextPath,
                htmlRegex,
                htmlMediaType,
                uuidHeader,
                uuidParentsHeader,
                deserializer,
                geoIPLocator,
                requestLogger,
                suppressCommasInAccessLogForStaticHtml);
        htmlStaticHandler.setUnknownCipherKeyLength(unknownCipherKeyLength);

        StatisticsHandler statisticsHandler = new StatisticsHandler();
        statisticsHandler.setServer(server.getJettyServer());

        handlerCollection.setServer(server.getJettyServer());

        JettyHandler defaultJettyServiceHandler = new AliasHandler(defaultCommandProcessor, suppressCommasInAccessLogForCalls, pathAliases);
        ContextHandler context = new ContextHandler();
        context.setContextPath("");
        context.setResourceBase(".");
        context.setHandler(defaultJettyServiceHandler);
        handlerCollection.addHandler(context);

        handlerCollection.addHandler(wsdlStaticHandler);
        handlerCollection.addHandler(htmlStaticHandler);
//        handlerCollection.addHandler(aliasHandler);
        statisticsHandler.setHandler(handlerCollection);

        // Register the errorhandler with the server itself
        server.addBean(errorHandler);
        server.setHandler(statisticsHandler);
    }
 
开发者ID:betfair,项目名称:cougar,代码行数:50,代码来源:JettyHttpTransport.java


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