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


Java WebAppContext類代碼示例

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


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

示例1: main

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

    WebAppContext webappcontext = new WebAppContext( "src/main/webapp", "/reporting" );

    ContextHandlerCollection servlet_contexts = new ContextHandlerCollection();
    webappcontext.setClassLoader( Thread.currentThread().getContextClassLoader() );
    HandlerCollection handlers = new HandlerCollection();
    handlers.setHandlers( new Handler[] { servlet_contexts, webappcontext, new DefaultHandler() } );

    server.setHandler( handlers );

    server.start();
    server.join();
}
 
開發者ID:opensagres,項目名稱:xdocreport.samples,代碼行數:18,代碼來源:EmbeddedServer.java

示例2: createWebAppContext

import org.mortbay.jetty.webapp.WebAppContext; //導入依賴的package包/類
private static WebAppContext createWebAppContext(String name,
    Configuration conf, AccessControlList adminsAcl, final String appDir) {
  WebAppContext ctx = new WebAppContext();
  ctx.setDefaultsDescriptor(null);
  ServletHolder holder = new ServletHolder(new DefaultServlet());
  Map<String, String> params = ImmutableMap. <String, String> builder()
          .put("acceptRanges", "true")
          .put("dirAllowed", "false")
          .put("gzip", "true")
          .put("useFileMappedBuffer", "true")
          .build();
  holder.setInitParameters(params);
  ctx.setWelcomeFiles(new String[] {"index.html"});
  ctx.addServlet(holder, "/");
  ctx.setDisplayName(name);
  ctx.setContextPath("/");
  ctx.setWar(appDir + "/" + name);
  ctx.getServletContext().setAttribute(CONF_CONTEXT_ATTRIBUTE, conf);
  ctx.getServletContext().setAttribute(ADMINS_ACL, adminsAcl);
  addNoCacheFilter(ctx);
  return ctx;
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:23,代碼來源:HttpServer2.java

示例3: invalidateAll

import org.mortbay.jetty.webapp.WebAppContext; //導入依賴的package包/類
public void invalidateAll(String id)
{
    //take the id out of the list of known sessionids for this node
    removeSession(id);
    
    synchronized (_sessionIds)
    {
        //tell all contexts that may have a session object with this id to
        //get rid of them
        Handler[] contexts = _server.getChildHandlersByClass(WebAppContext.class);
        for (int i=0; contexts!=null && i<contexts.length; i++)
        {
            AbstractSessionManager manager = ((AbstractSessionManager)((WebAppContext)contexts[i]).getSessionHandler().getSessionManager());
            if (manager instanceof GigaSessionManager)
            {
                ((GigaSessionManager)manager).invalidateSession(id);
            }
        }
    }
}
 
開發者ID:iMartinezMateu,項目名稱:openbravo-pos,代碼行數:21,代碼來源:GigaSessionIdManager.java

示例4: main

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

    WebAppContext webappcontext = new WebAppContext( "src/main/webapp", "/xdocreport-webapp" );

    ContextHandlerCollection servlet_contexts = new ContextHandlerCollection();
    webappcontext.setClassLoader( Thread.currentThread().getContextClassLoader() );
    HandlerCollection handlers = new HandlerCollection();
    handlers.setHandlers( new Handler[] { servlet_contexts, webappcontext, new DefaultHandler() } );

    server.setHandler( handlers );

    // JSP Servlet + Context
    Context jsp_ctx = new Context( servlet_contexts, "/jsp", Context.SESSIONS );
    jsp_ctx.addServlet( new ServletHolder( new org.apache.jasper.servlet.JspServlet() ), "*.jsp" );

    server.start();
    server.join();
}
 
開發者ID:DistX,項目名稱:Learning,代碼行數:22,代碼來源:EmbeddedServer.java

示例5: setupSolr

import org.mortbay.jetty.webapp.WebAppContext; //導入依賴的package包/類
private void setupSolr() throws Exception {
    FileUtils.deleteQuietly(SOLR_WORK_DIR);
    FileUtils.copyDirectory(new File("src/test/resources/solr/"), SOLR_WORK_DIR);
    String configSolrXml = "<solr>" + "  <solrcloud>" + "    <str name=\"host\">${host:}</str>"
            + "    <int name=\"hostPort\">" + solrPort + "</int>"
            + "    <str name=\"hostContext\">${hostContext:solr}</str>"
            + "    <int name=\"zkClientTimeout\">${zkClientTimeout:300000}</int>"
            + "    <bool name=\"genericCoreNodeNames\">${genericCoreNodeNames:true}</bool>" + "  </solrcloud>"
            + "  <shardHandlerFactory name=\"shardHandlerFactory\"" + "    class=\"HttpShardHandlerFactory\">"
            + "    <int name=\"socketTimeout\">${socketTimeout:0}</int>"
            + "    <int name=\"connTimeout\">${connTimeout:0}</int>" + "  </shardHandlerFactory>" + "</solr>";
    File solrConfig = new File(SOLR_WORK_DIR, "solr.xml");
    OutputStream out = new FileOutputStream(solrConfig);
    out.write(configSolrXml.getBytes("UTF-8"));
    out.close();
    server = new Server(solrPort);

    final WebAppContext context = new WebAppContext();
    context.setResourceBase(SOLR_WORK_DIR.getPath());
    context.setContextPath("/");
    context.setClassLoader(Thread.currentThread().getContextClassLoader());
    System.setProperty("solr.solr.home", SOLR_WORK_DIR.getPath());
    server.setHandler(context);
    server.start();
    jenkinsSearchBackend.setSolrBackend(false, solrPort);
}
 
開發者ID:jenkinsci,項目名稱:lucene-search-plugin,代碼行數:27,代碼來源:SolrSearchBackendTest.java

示例6: startWebAppContext

import org.mortbay.jetty.webapp.WebAppContext; //導入依賴的package包/類
/**
 * Starts the Jetty web context class.
 * 
 * @param wac,
 * @throws Exception
 */
private void startWebAppContext(WebAppContext wac) throws Exception {
	HandlerCollection contexts = getJettyContexts();

	// set the TCCL since it's used internally by Jetty
	Thread current = Thread.currentThread();
	ClassLoader old = current.getContextClassLoader();
	try {
		current.setContextClassLoader(wac.getClassLoader());
		if (contexts != null) {
			contexts.addHandler(wac);
		}
		wac.start();
		if (contexts != null) {
			contexts.start();
		}
	}
	finally {
		current.setContextClassLoader(old);
	}
}
 
開發者ID:BeamFoundry,項目名稱:spring-osgi,代碼行數:27,代碼來源:JettyWarDeployer.java

示例7: main

import org.mortbay.jetty.webapp.WebAppContext; //導入依賴的package包/類
/**
 * Run PRE V. 1.0 in Jetty. Override the EvironmentUtility's set environment depending on what web.xml file is used
 * (local or national).
 * 
 * This method expects four command line arguments in the order and type specified. No verification that the arguments
 * are valid is done. If improper arguments are set, expect NullPointerExceptions, IOExceptions, String parsing
 * exceptions, or that the server started simply does not operate as expected.
 * 
 * @param args [0] (int) port, [1] (String) PRE web.xml file path, [2] (String) FDB Images web application directory
 */
public static void main(String[] args) throws Exception {
    Server server = new Server(Integer.parseInt(args[0]));

    ApplicationContext context = new ClassPathXmlApplicationContext(
        "xml/spring/datup/national/test/InterfaceContext.xml");
    DifReportService reportService = (DifReportService) context.getBean("difReportService");

    WebAppContext pre = new WebAppContext();
    pre.setContextPath(PRE_CONTEXT_PATH);
    pre.setWar(PRE_WAR);
    // pre.setOverrideDescriptor(args[1]);

    ReportServlet reportServlet = new ReportServlet();
    reportServlet.setDifReportService(reportService);
    pre.addServlet(new ServletHolder(reportServlet), "/datup");

    TimerServlet timerServlet = new TimerServlet();
    pre.addServlet(new ServletHolder(timerServlet), "/datup/timer");

    server.addHandler(pre);

    server.start();
    System.out.println("Jetty server started on port " + args[0]);
}
 
開發者ID:OSEHRA-Sandbox,項目名稱:MOCHA,代碼行數:35,代碼來源:LaunchNationalJetty.java

示例8: main3

import org.mortbay.jetty.webapp.WebAppContext; //導入依賴的package包/類
public static void main3(String args[])
{
  try {
    final Server jettyServer = new Server();
  
    WebAppContext wah = new WebAppContext();
    wah.setContextPath("/jeql");
    wah.setWar("webapp");
    
    jettyServer.setHandler(wah);
    //wah.setTempDirectory(new File("target/work"));
    //this allows to send large SLD's from the styles form
    wah.getServletContext().getContextHandler().setMaxFormContentSize(1024 * 1024 * 2);


    jettyServer.start();
  }
  catch (Exception ex) {
    ex.printStackTrace();
  }
}
 
開發者ID:dr-jts,項目名稱:jeql,代碼行數:22,代碼來源:TestJeqlServlet.java

示例9: main

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

    SelectChannelConnector connector = new SelectChannelConnector();
    connector.setPort(PORT);
    server.addConnector(connector);
    server.setStopAtShutdown(true);

    // the orders of handlers is very important!
    ContextHandler contextHandler = new ContextHandler();
    contextHandler.setContextPath("/reports");
    contextHandler.setResourceBase("./reports/");
    contextHandler.addHandler(new ResourceHandler());
    server.addHandler(contextHandler);

    server.addHandler(new WebAppContext("webapp", "/nextreports-server"));

    long t = System.currentTimeMillis();
    server.start();
    t = System.currentTimeMillis() - t;
    String version = server.getClass().getPackage().getImplementationVersion();
    System.out.println("Started Jetty Server " + version + " on port " + PORT + " in " + t / 1000 + "s");
    
    server.join();
}
 
開發者ID:nextreports,項目名稱:nextreports-server,代碼行數:26,代碼來源:JettyLauncher.java

示例10: setUpBeforeClass

import org.mortbay.jetty.webapp.WebAppContext; //導入依賴的package包/類
/**
 * @throws java.lang.Exception
 */
@BeforeClass
public static void setUpBeforeClass() throws Exception
{
	// start the server:
	server = new Server(port);
	WebAppContext context = new WebAppContext();

	uri = "http://localhost:20100";

	// see if this can be set more dynamically:
	context.setContextPath("/");
	context.setResourceBase(new File("src/main/webapp/").getCanonicalPath());
	context.setDescriptor(new File("src/main/webapp/").getCanonicalPath() + "/WEB-INF/web.xml");

	server.setHandler(context);
	server.start();
}
 
開發者ID:beeldengeluid,項目名稱:zieook,代碼行數:21,代碼來源:TemplateCRUDImplTest.java

示例11: setUpBeforeClass

import org.mortbay.jetty.webapp.WebAppContext; //導入依賴的package包/類
/**
 * @throws java.lang.Exception
 */
@BeforeClass
public static void setUpBeforeClass() throws Exception
{
	// start the server:
	server = new Server(port);
	WebAppContext context = new WebAppContext();

	uri = "http://localhost:20100";

	// see if this can be set more dynamically:
	context.setContextPath("/");
	context.setResourceBase(new File("src/main/webapp/").getCanonicalPath());
	context.setDescriptor(new File("src/main/webapp/").getCanonicalPath() + "/WEB-INF/web.xml");

	server.setHandler(context);
	server.start();

	ContentProviderCRUD proxy = ProxyFactory.create(ContentProviderCRUD.class, uri);
	proxy.deleteContentProvider(ConstantsTest.CP);
}
 
開發者ID:beeldengeluid,項目名稱:zieook,代碼行數:24,代碼來源:ContentProviderCRUDImplTest.java

示例12: setUpBeforeClass

import org.mortbay.jetty.webapp.WebAppContext; //導入依賴的package包/類
/**
 * @throws java.lang.Exception
 */
@BeforeClass
public static void setUpBeforeClass() throws Exception
{

	// start the server:
	server = new Server(port);
	WebAppContext context = new WebAppContext();

	uri = "http://localhost:20100";

	// see if this can be set more dynamically:
	context.setContextPath("/");
	context.setResourceBase(new File("src/main/webapp/").getCanonicalPath());
	context.setDescriptor(new File("src/main/webapp/").getCanonicalPath() + "/WEB-INF/web.xml");

	server.setHandler(context);
	server.start();
}
 
開發者ID:beeldengeluid,項目名稱:zieook,代碼行數:22,代碼來源:RecommenderImplTest.java

示例13: setUpBeforeClass

import org.mortbay.jetty.webapp.WebAppContext; //導入依賴的package包/類
/**
 * @throws java.lang.Exception
 */
@BeforeClass
public static void setUpBeforeClass() throws Exception
{
	// start the server:
	server = new Server(port);
	WebAppContext context = new WebAppContext();

	uri = "http://localhost:20100";

	// see if this can be set more dynamically:
	context.setContextPath("/");
	context.setResourceBase(new File("src/main/webapp/").getCanonicalPath());
	context.setDescriptor(new File("src/main/webapp/").getCanonicalPath() + "/WEB-INF/web.xml");

	server.setHandler(context);
	server.start();

	ContentProviderCRUD proxy1 = ProxyFactory.create(ContentProviderCRUD.class, uri);
	proxy1.createContentProvider(new ContentProvider(ConstantsTest.CP, System.currentTimeMillis() / 1000, true));

	CollectionImport proxy2 = ProxyFactory.create(CollectionImport.class, uri);
	proxy2.deleteCollection(ConstantsTest.CP, ConstantsTest.COLLECTION);
}
 
開發者ID:beeldengeluid,項目名稱:zieook,代碼行數:27,代碼來源:CollectionImportImplTest.java

示例14: setUpBeforeClass

import org.mortbay.jetty.webapp.WebAppContext; //導入依賴的package包/類
/**
 * @throws java.lang.Exception
 */
@BeforeClass
public static void setUpBeforeClass() throws Exception
{
	// start the server:
	server = new Server(port);
	WebAppContext context = new WebAppContext();

	uri = "http://localhost:20200";

	// see if this can be set more dynamically:
	context.setContextPath("/");
	context.setResourceBase(new File("src/main/webapp/").getCanonicalPath());
	context.setDescriptor(new File("src/main/webapp/").getCanonicalPath() + "/WEB-INF/web.xml");

	server.setHandler(context);
	server.start();
}
 
開發者ID:beeldengeluid,項目名稱:zieook,代碼行數:21,代碼來源:UserDataImplTest.java

示例15: setUp

import org.mortbay.jetty.webapp.WebAppContext; //導入依賴的package包/類
/**
 * @throws java.lang.Exception
 */
@BeforeClass
public static void setUp() throws Exception
{
	// start the server:
	server = new Server(port);
	WebAppContext context = new WebAppContext();

	uri = "http://localhost:20200";

	// see if this can be set more dynamically:
	context.setContextPath("/");
	context.setResourceBase(new File("src/main/webapp/").getCanonicalPath());
	context.setDescriptor(new File("src/main/webapp/").getCanonicalPath() + "/WEB-INF/web.xml");

	server.setHandler(context);
	server.start();
}
 
開發者ID:beeldengeluid,項目名稱:zieook,代碼行數:21,代碼來源:RecommenderImplTest.java


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