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


Java WebAppContext.setServer方法代碼示例

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


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

示例1: main

import org.mortbay.jetty.webapp.WebAppContext; //導入方法依賴的package包/類
public static void main(String[] args) {
    Server server = new Server();
    SocketConnector connector = new SocketConnector();

    // Set some timeout options to make debugging easier.
    connector.setMaxIdleTime(1000 * 60 * 60);
    connector.setSoLingerTime(-1);
    connector.setPort(9080);
    server.setConnectors(new Connector[]{connector});

    WebAppContext context = new WebAppContext();
    context.setServer(server);
    context.setContextPath("/");

    ProtectionDomain protectionDomain = Main.class.getProtectionDomain();
    URL location = protectionDomain.getCodeSource().getLocation();
    context.setWar(location.toExternalForm());

    server.addHandler(context);
    try {
        server.start();
        System.in.read();
        server.stop();
        server.join();
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(100);
    }
}
 
開發者ID:nkasvosve,項目名稱:beyondj,代碼行數:30,代碼來源:WebLauncher.java

示例2: startServer

import org.mortbay.jetty.webapp.WebAppContext; //導入方法依賴的package包/類
public void startServer() throws NamingException {
    LOG.info("Configuring jetty web server ...");

    final Server server = new Server();
    SocketConnector connector = new SocketConnector();
    // Set some timeout options to make debugging easier.
    connector.setMaxIdleTime(1000 * 60 * 60);
    connector.setSoLingerTime(-1);
    connector.setPort(Integer.parseInt(System.getProperty("jetty.port", "8086")));

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

    WebAppContext demo = new WebAppContext();
    demo.setServer(server);
    demo.setContextPath("/superfly-demo");
    demo.setWar("src/main/webapp");
    demo.setConfigurationClasses(new String[] {
            "org.mortbay.jetty.webapp.WebInfConfiguration",
            "org.mortbay.jetty.plus.webapp.EnvConfiguration",
            "org.mortbay.jetty.plus.webapp.Configuration",
            "org.mortbay.jetty.webapp.JettyWebXmlConfiguration"
    });

    server.addHandler(demo);

    try {
        System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP");
        server.start();

        while (System.in.available() == 0) {
            Thread.sleep(5000);
        }
        server.stop();
        server.join();
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(100);
    }
}
 
開發者ID:payneteasy,項目名稱:superfly,代碼行數:40,代碼來源:Demo.java

示例3: main

import org.mortbay.jetty.webapp.WebAppContext; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
	Server server = new Server();
	SocketConnector connector = new SocketConnector();
	// Set some timeout options to make debugging easier.
	connector.setMaxIdleTime(1000 * 60 * 60);
	connector.setSoLingerTime(-1);
	connector.setPort(8080);
	server.setConnectors(new Connector[] { connector });

	WebAppContext bb = new WebAppContext();
	bb.setServer(server);
	bb.setContextPath("/");
	bb.setWar("src/main/webapp");

	
	// START JMX SERVER
	// MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
	// MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer);
	// server.getContainer().addEventListener(mBeanContainer);
	// mBeanContainer.start();
	
	server.addHandler(bb);

	try {
		System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP");
		server.start();
		while (System.in.available() == 0) {
			Thread.sleep(5000);
		}
		server.stop();
		server.join();
	} catch (Exception e) {
		e.printStackTrace();
		System.exit(100);
	}
}
 
開發者ID:r-h,項目名稱:wicket-notes-demo,代碼行數:37,代碼來源:Start.java

示例4: start

import org.mortbay.jetty.webapp.WebAppContext; //導入方法依賴的package包/類
public void start(String appName) {
  try {
    jetty = new Server(8080);
    WebAppContext context = new WebAppContext();
    context.setContextPath("/" + appName);
    context.setWar("src/main/webapp");
    context.setServer(jetty);
    jetty.addHandler(context);
    jetty.start();
    jetty.setStopAtShutdown(true);
  } catch (Exception e) {
    throw new RuntimeException(e);
   }
}
 
開發者ID:keensoft,項目名稱:icearchiva,代碼行數:15,代碼來源:EmbeddedJetty.java

示例5: addSecurityFile

import org.mortbay.jetty.webapp.WebAppContext; //導入方法依賴的package包/類
private void addSecurityFile(HashUserRealm realm, String securityFile, Context root) throws Exception
{
    // create a temp Jetty context to parse the security portion of the web.xml file

    /*
        TODO

        This code assumes far too much internal knowledge of Jetty. I don't know
        of simple way to parse the web.xml though and don't want to write it myself.
     */

    final URL url = new URL("file", null, securityFile);
    final WebXmlConfiguration webXmlConfiguration = new WebXmlConfiguration();
    WebAppContext context = new WebAppContext();
    context.setServer(server);
    webXmlConfiguration.setWebAppContext(context);
    ContextHandler contextHandler = new ContextHandler("/")
    {
        @Override
        protected void startContext() throws Exception
        {
            super.startContext();
            setServer(server);
            webXmlConfiguration.configure(url.toString());
        }
    };
    contextHandler.start();
    try
    {
        SecurityHandler securityHandler = webXmlConfiguration.getWebAppContext().getSecurityHandler();

        if ( realm != null )
        {
            securityHandler.setUserRealm(realm);
        }

        root.setSecurityHandler(securityHandler);
    }
    finally
    {
        contextHandler.stop();
    }
}
 
開發者ID:dcos,項目名稱:exhibitor,代碼行數:44,代碼來源:ExhibitorMain.java

示例6: startWebApp

import org.mortbay.jetty.webapp.WebAppContext; //導入方法依賴的package包/類
public static void startWebApp() {
  Server server = new Server();
  SocketConnector connector = new SocketConnector();

  connector.setMaxIdleTime(1000 * 60 * 60);
  connector.setSoLingerTime(-1);
  connector.setPort(3030);
  server.setConnectors(new Connector[]{connector});

  WebAppContext webAppContext = new WebAppContext();
  webAppContext.setServer(server);

  String path = "sample/src/main/webapp";
  path = findWarPath(path);
  System.out.println("path = " + path);

  webAppContext.setWar(path);

  server.addHandler(webAppContext);

  try {
    String msg = "http://localhost:3030/";
    log("Starting " + msg + " (please wait)...");
    server.start();
    log("Started " + msg);
    System.out.println("PRESS ANY KEY TO STOP");
    while (System.in.available() == 0) {
      Thread.sleep(5000);
    }
    log("Stopping the webapp...");
    webAppContext.stop();
    log("The webapp was stopped.");

    server.stop();
    server.join();
  } catch (Exception e) {
    e.printStackTrace();
    System.exit(100);
  }

}
 
開發者ID:DNSBelgium,項目名稱:rdap-server-sample-gtld,代碼行數:42,代碼來源:StartJetty.java

示例7: createJettyWebContext

import org.mortbay.jetty.webapp.WebAppContext; //導入方法依賴的package包/類
/**
 * Creates the Jetty specific web context for the given OSGi bundle.
 * 
 * @param bundle
 * @return
 * @throws Exception
 */
private WebAppContext createJettyWebContext(Bundle bundle, String contextPath) throws Exception {

	WebAppContext wac = new WebAppContext();

	// create a jetty web app context

	// the server is being used to generate the temp folder (so we have to set it)
	wac.setServer(serverService);
	// set the war string since it's used to generate the temp path
	wac.setWar(OsgiStringUtils.nullSafeName(bundle));
	// same goes for the context path (add leading "/" -> w/o the context will not work)
	wac.setContextPath(contextPath);
	// no hot deployment (at least not through directly Jetty)
	wac.setCopyWebDir(false);
	wac.setExtractWAR(true);

	//
	// 1. resource settings
	//

	// start with the slow, IO activity
	Resource rootResource = getRootResource(bundle, wac);

	// wac needs access to the WAR root
	// we have to make sure we don't trigger any direct file lookup
	// so instead of calling .setWar()
	// we set the base resource directly
	wac.setBaseResource(rootResource);
	// reset the war setting (so that the base resource is used)
	wac.setWar(null);

	// 
	// 2. class-loading behaviour
	//

	// obey the servlet spec class-loading contract
	wac.setSystemClasses(systemClasses);
	wac.setServerClasses(serverClasses);

	// no java 2 loading compliance
	wac.setParentLoaderPriority(false);
	// create special classloader
	wac.setClassLoader(Utils.createWebAppClassLoader(bundle, Server.class));

	return wac;
}
 
開發者ID:BeamFoundry,項目名稱:spring-osgi,代碼行數:54,代碼來源:JettyWarDeployer.java

示例8: doStart

import org.mortbay.jetty.webapp.WebAppContext; //導入方法依賴的package包/類
protected void doStart() throws Exception {

		server = new Server();

		if (this.minThreads != -1 && this.maxThreads != -1) {
			BoundedThreadPool btp = new BoundedThreadPool();
			server.setThreadPool(btp);
		}

		SelectChannelConnector connector = new SelectChannelConnector();

		// Set some timeout options to make debugging easier.
		connector.setSoLingerTime(-1);
		connector.setPort(port);

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

		WebAppContext wac = new WebAppContext();

		wac.setServer(server);
		wac.setContextPath(contextPath);
		wac.setWar(webappPath);

		server.setHandler(wac);

		log.info("Starting jetty server actually.");
		server.start();
	}
 
開發者ID:sayi21cn,項目名稱:athena-rest,代碼行數:29,代碼來源:JettyServer.java


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