本文整理汇总了Java中org.mortbay.jetty.webapp.WebAppContext.setWar方法的典型用法代码示例。如果您正苦于以下问题:Java WebAppContext.setWar方法的具体用法?Java WebAppContext.setWar怎么用?Java WebAppContext.setWar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mortbay.jetty.webapp.WebAppContext
的用法示例。
在下文中一共展示了WebAppContext.setWar方法的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: 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]);
}
示例3: 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();
}
}
示例4: 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);
}
示例5: 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;
}
示例6: 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);
}
示例7: 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);
}
}
示例8: main
import org.mortbay.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public static void main(String[] args) {
try {
String confPath = args[0];
confPath = confPath.trim();
Properties conf = new Properties();
InputStream is = new FileInputStream(new File(confPath + "/conf/lts-admin.cfg"));
conf.load(is);
String port = conf.getProperty("port");
if (port == null || port.trim().equals("")) {
port = "8081";
}
Server server = new Server(Integer.parseInt(port));
WebAppContext webapp = new WebAppContext();
webapp.setWar(confPath + "/lts-admin.war");
Map<String, String> initParams = new HashMap<String, String>();
initParams.put("lts.admin.config.path", confPath + "/conf");
webapp.setInitParams(initParams);
server.setHandler(webapp);
server.setStopAtShutdown(true);
server.start();
System.out.println("LTS-Admin started. http://" + NetUtils.getLocalHost() + ":" + port + "/index.htm");
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
示例9: jettyServer
import org.mortbay.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
@BeforeClass
public static void jettyServer() throws Exception {
server = new Server();
Connector connector = new SelectChannelConnector();
connector.setPort(PORT);
server.setConnectors(new Connector[] { connector });
ConstraintMapping cm = new ConstraintMapping();
Constraint constraint = new Constraint();
constraint.setName(Constraint.__BASIC_AUTH);
constraint.setRoles(new String[] { ROLE_NAME });
constraint.setAuthenticate(true);
cm.setConstraint(constraint);
cm.setPathSpec("/*");
sh = new SecurityHandler();
userRealm = new HashUserRealm(REALM);
userRealm.put(USERNAME, PASSWORD);
userRealm.addUserToRole(USERNAME, ROLE_NAME);
sh.setUserRealm(userRealm);
sh.setConstraintMappings(new ConstraintMapping[] { cm });
WebAppContext webappcontext = new WebAppContext();
webappcontext.setContextPath("/");
URL htmlRoot = HTTPAuthenticatorIT.class.getResource(HTML);
assertNotNull("Could not find " + HTML, htmlRoot);
webappcontext.setWar(htmlRoot.toExternalForm());
webappcontext.addHandler(sh);
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[] { webappcontext,
new DefaultHandler() });
server.setHandler(handlers);
server.start();
}
示例10: run
import org.mortbay.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
protected void run() {
LOG.debug("Starting Server");
server = new org.mortbay.jetty.Server();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(9080);
server.setConnectors(new Connector[] { connector });
WebAppContext webappcontext = new WebAppContext();
String contextPath = null;
try {
contextPath = getClass().getResource(".").toURI().getPath();
} catch (URISyntaxException e1) {
e1.printStackTrace();
}
System.out.println(contextPath);
webappcontext.setContextPath("/api");
webappcontext.setWar(contextPath);
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[] { webappcontext, new DefaultHandler() });
server.setHandler(handlers);
try {
server.start();
} catch (Exception e) {
e.printStackTrace();
}
}
示例11: setUp
import org.mortbay.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
tmpdir = new File(System.getProperty("java.io.tmpdir") + "/oiosaml-" + Math.random());
if (tmpdir.exists()) {
FileUtils.cleanDirectory(tmpdir);
}
tmpdir.mkdir();
// Reinitialize SAMLConfiguration
Map<String,String> params=new HashMap<String, String>();
params.put(Constants.INIT_OIOSAML_HOME, tmpdir.getAbsolutePath());
SAMLConfigurationFactory.getConfiguration().setInitConfiguration(params);
//FileConfiguration.setSystemConfiguration(null);
IdpMetadata.setMetadata(null);
SPMetadata.setMetadata(null);
System.setProperty(SAMLUtil.OIOSAML_HOME, tmpdir.getAbsolutePath());
server = new Server(8808);
WebAppContext wac = new WebAppContext();
wac.setClassLoader(Thread.currentThread().getContextClassLoader());
wac.setContextPath("/saml");
wac.setWar("webapp/");
server.setHandler(wac);
server.start();
client = new WebClient();
page = (HtmlPage) client.getPage(BASE + "/saml/configure");
}
示例12: 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);
}
}
示例13: createWebAppContext
import org.mortbay.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
protected WebAppContext createWebAppContext() {
try {
Resource jettyEnv = Resource.newResource(String.format("%s/WEB-INF/jetty-env.xml", mojo.getAppDir()));
XmlConfiguration conf = new XmlConfiguration(jettyEnv.getInputStream());
WebAppContext webapp = (WebAppContext) conf.configure();
webapp.setWar(mojo.getAppDir());
System.setProperty("java.naming.factory.url.pkgs", "org.mortbay.naming");
System.setProperty("java.naming.factory.initial", "org.mortbay.naming.InitialContextFactory");
return webapp;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例14: 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);
}
}
示例15: HttpServer
import org.mortbay.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
/**
* Create a status server on the given port.
* The jsp scripts are taken from src/webapps/<name>.
* @param name The name of the server
* @param port The port to use on the server
* @param findPort whether the server should start at the given port and
* increment by 1 until it finds a free port.
* @param conf Configuration
*/
public HttpServer(String name, String bindAddress, int port,
boolean findPort, Configuration conf) throws IOException {
webServer = new Server();
this.findPort = findPort;
listener = createBaseListener(conf);
listener.setHost(bindAddress);
listener.setPort(port);
webServer.addConnector(listener);
int maxThreads = conf.getInt(HTTP_MAX_THREADS, -1);
// If HTTP_MAX_THREADS is not configured, QueueThreadPool() will use the
// default value (currently 254).
QueuedThreadPool threadPool = maxThreads == -1 ?
new QueuedThreadPool() : new QueuedThreadPool(maxThreads);
webServer.setThreadPool(threadPool);
final String appDir = getWebAppsPath();
ContextHandlerCollection contexts = new ContextHandlerCollection();
webServer.setHandler(contexts);
webAppContext = new WebAppContext();
webAppContext.setContextPath("/");
webAppContext.setWar(appDir + "/" + name);
webAppContext.getServletContext().setAttribute(CONF_CONTEXT_ATTRIBUTE, conf);
webServer.addHandler(webAppContext);
addDefaultApps(contexts, appDir);
addGlobalFilter("safety", QuotingInputFilter.class.getName(), null);
final FilterInitializer[] initializers = getFilterInitializers(conf);
if (initializers != null) {
for(FilterInitializer c : initializers) {
c.initFilter(this);
}
}
addDefaultServlets();
}