本文整理汇总了Java中org.mortbay.jetty.webapp.WebAppContext.setContextPath方法的典型用法代码示例。如果您正苦于以下问题:Java WebAppContext.setContextPath方法的具体用法?Java WebAppContext.setContextPath怎么用?Java WebAppContext.setContextPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mortbay.jetty.webapp.WebAppContext
的用法示例。
在下文中一共展示了WebAppContext.setContextPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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);
}
示例3: 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]);
}
示例4: 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();
}
}
示例5: 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();
}
示例6: 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();
}
示例7: 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);
}
示例8: 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();
}
示例9: 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);
}
示例10: addContext
import org.mortbay.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
/**
* Add a context
* @param pathSpec The path spec for the context
* @param dir The directory containing the context
* @param isFiltered if true, the servlet is added to the filter path mapping
* @throws IOException
*/
protected void addContext(String pathSpec, String dir, boolean isFiltered) throws IOException {
if (0 == webServer.getHandlers().length) {
throw new RuntimeException("Couldn't find handler");
}
WebAppContext webAppCtx = new WebAppContext();
webAppCtx.setContextPath(pathSpec);
webAppCtx.setWar(dir);
addContext(webAppCtx, true);
}
示例11: 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.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;
}
示例12: addContext
import org.mortbay.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
/**
* Add a context
* @param pathSpec The path spec for the context
* @param dir The directory containing the context
* @param isFiltered if true, the servlet is added to the filter path mapping
* @throws IOException
*/
protected void addContext(String pathSpec, String dir, boolean isFiltered) throws IOException {
if (0 == webServer.getHandlers().length) {
throw new RuntimeException("Couldn't find handler");
}
WebAppContext webAppCtx = new WebAppContext();
webAppCtx.setContextPath(pathSpec);
webAppCtx.setWar(dir);
addContext(webAppCtx, true);
}
示例13: 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);
}
}
示例14: main
import org.mortbay.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public static void main(String args[]) throws Exception
{
String jetty_home=System.getProperty("jetty.home","../../..");
String jetty_port=System.getProperty("jetty.port", "8080");
String node_name=System.getProperty("node.name", "red");
Server server = new Server();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(Integer.parseInt(jetty_port));
server.setConnectors(new Connector[]{connector});
HandlerCollection handlers = new HandlerCollection();
ContextHandlerCollection contexts = new ContextHandlerCollection();
//TODO: find a way to dynamically get the endpoint url
WadiCluster wadiCluster = new WadiCluster("CLUSTER", node_name, "http://localhost:"+jetty_port+"/test");
wadiCluster.doStart();
WadiSessionManager wadiManager = new WadiSessionManager(wadiCluster, 2, 24, 360);
WadiSessionHandler wSessionHandler = new WadiSessionHandler(wadiManager);
WebAppContext wah = new WebAppContext(null, wSessionHandler, null, null);
wah.setContextPath("/test");
wah.setResourceBase(jetty_home+"/webapps/test");
contexts.setHandlers(new Handler[]{wah});
handlers.setHandlers(new Handler[]{contexts,new DefaultHandler()});
server.setHandler(handlers);
HashUserRealm hur = new HashUserRealm();
hur.setName("Test Realm");
hur.setConfig(jetty_home+"/etc/realm.properties");
wah.getSecurityHandler().setUserRealm(hur);
server.start();
server.join();
}
示例15: doStart
import org.mortbay.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public static void doStart() throws Exception {
Server server = new Server();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(JETTY_SERVER_PORT);
String webDefault = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + "**/webdefault.xml";
Resource web = resolver.getResources(webDefault)[0];
String descriptor = web.getFile().getAbsolutePath();
String pattern = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + "**/" + SpiderJetty.class.getName() + ".class";
Resource resource = resolver.getResources(pattern)[0];
String resourcePath = resource.getFile().getAbsolutePath().replaceAll("target.*$", "") + "webapp";
WebAppContext context = new WebAppContext();
context.setContextPath("/");
context.setDefaultsDescriptor(descriptor);
context.setResourceBase("file:" + resourcePath);
context.setClassLoader(Thread.currentThread().getContextClassLoader());
server.setConnectors(new Connector[]{connector});
server.setHandler(context);
server.setStopAtShutdown(true);
server.setSendServerVersion(false);
server.setSendDateHeader(false);
server.setGracefulShutdown(1000);
try {
server.start();
server.join();
} catch (Exception e) {
e.printStackTrace();
}
}