當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。