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