本文整理汇总了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();
}
示例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;
}
示例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);
}
}
}
}
示例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();
}
示例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);
}
示例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);
}
}
示例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]);
}
示例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();
}
}
示例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();
}
示例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();
}
示例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);
}
示例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();
}
示例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);
}
示例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();
}
示例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();
}