本文整理汇总了Java中org.eclipse.jetty.webapp.WebAppContext.setWar方法的典型用法代码示例。如果您正苦于以下问题:Java WebAppContext.setWar方法的具体用法?Java WebAppContext.setWar怎么用?Java WebAppContext.setWar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jetty.webapp.WebAppContext
的用法示例。
在下文中一共展示了WebAppContext.setWar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: beforeClass
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() throws Exception {
jettyServer = new Server(0);
WebAppContext webApp = new WebAppContext();
webApp.setServer(jettyServer);
webApp.setContextPath(CONTEXT_PATH);
webApp.setWar("src/test/webapp");
jettyServer.setHandler(webApp);
jettyServer.start();
serverPort = ((ServerConnector)jettyServer.getConnectors()[0]).getLocalPort();
testRestTemplate = new TestRestTemplate(new RestTemplateBuilder()
.rootUri("http://localhost:" + serverPort + CONTEXT_PATH));
}
示例2: startServer
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public static void startServer(String[] args) throws Exception {
Server server = new Server(8080);
WebAppContext ctx = new WebAppContext();
ctx.setContextPath("/");
ctx.setWar("src/main/webapp/");
HandlerCollection hc = new HandlerCollection();
hc.setHandlers(new Handler[] {ctx});
server.setHandler(hc);
server.setStopAtShutdown(true);
server.start();
server.join();
// server.removeBean(o);
// server.addBean(o);
}
示例3: startJettyServer
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
/**
* 启动jetty服务,加载server.war
*/
public static void startJettyServer(String path) throws Exception{
String configPath=path+ File.separator+"conf"+File.separator+"conf.properties";
InputStream is = new FileInputStream(configPath);;
Properties properties =new Properties();
properties.load(is);
is.close();
int serverPort = Integer.parseInt(properties.getProperty("server.port"));
Server server = new Server(serverPort);
WebAppContext context = new WebAppContext();
context.setContextPath("/");
context.setWar(path+"/bin/service.war");
server.setHandler(context);
server.start();
server.join();
}
示例4: start
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public void start() throws Exception
{
String relativelyPath = System.getProperty("user.dir");
server = new Server(port);
WebAppContext webAppContext = new WebAppContext();
webAppContext.setContextPath("/");
webAppContext.setWar(relativelyPath + "\\rainbow-web\\target\\rainbow-web.war");
webAppContext.setParentLoaderPriority(true);
webAppContext.setServer(server);
webAppContext.setClassLoader(ClassLoader.getSystemClassLoader());
webAppContext.getSessionHandler().getSessionManager()
.setMaxInactiveInterval(10);
server.setHandler(webAppContext);
server.start();
}
示例5: addWebApplication
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public static Server addWebApplication(final Server jetty, final String webAppContext,
final String warFilePath) {
WebAppContext webapp = new WebAppContext();
webapp.setContextPath(webAppContext);
webapp.setWar(warFilePath);
webapp.setParentLoaderPriority(false);
webapp.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
File tmpPath = new File(getWebAppBaseDirectory(webAppContext));
tmpPath.mkdirs();
webapp.setTempDirectory(tmpPath);
((HandlerCollection) jetty.getHandler()).addHandler(webapp);
return jetty;
}
示例6: createWebAppContext
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
private WebAppContext createWebAppContext(URL webXml, Configuration[] configurations) {
WebAppContext context = new WebAppContext();
String war = webXml == null
? "src/main/webapp"
: MY_URL.toExternalForm();
context.setWar(war);
context.setContextPath(prefix);
if (webXml != null) {
context.getMetaData().setWebInfClassesDirs(
Arrays.asList(Resource.newResource(MY_URL)));
}
context.setConfigurations(configurations);
return context;
}
示例7: setupWebAppContext
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
private static WebAppContext setupWebAppContext(
ZeppelinConfiguration conf) {
WebAppContext webApp = new WebAppContext();
webApp.setContextPath(conf.getServerContextPath());
File warPath = new File(conf.getString(ConfVars.ZEPPELIN_WAR));
if (warPath.isDirectory()) {
// Development mode, read from FS
// webApp.setDescriptor(warPath+"/WEB-INF/web.xml");
webApp.setResourceBase(warPath.getPath());
webApp.setParentLoaderPriority(true);
} else {
// use packaged WAR
webApp.setWar(warPath.getAbsolutePath());
File warTempDirectory = new File(conf.getRelativeDir(ConfVars.ZEPPELIN_WAR_TEMPDIR));
warTempDirectory.mkdir();
LOG.info("ZeppelinServer Webapp path: {}", warTempDirectory.getPath());
webApp.setTempDirectory(warTempDirectory);
}
// Explicit bind to root
webApp.addServlet(new ServletHolder(new DefaultServlet()), "/*");
return webApp;
}
示例8: Olingo2SampleServer
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
/**
*
* @param port
* @param resourcePath
*/
public Olingo2SampleServer(int port, String resourcePath) {
this.port = port;
server = new org.eclipse.jetty.server.Server(port);
WebAppContext webappcontext = new WebAppContext();
String contextPath = null;
try {
contextPath = Olingo2SampleServer.class.getResource(resourcePath).toURI().getPath();
} catch (URISyntaxException e) {
LOG.error("Unable to read the resource at {}", resourcePath, e);
}
webappcontext.setContextPath("/");
webappcontext.setWar(contextPath);
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[] {webappcontext, new DefaultHandler()});
server.setHandler(handlers);
}
示例9: main
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
SLF4JBridgeHandler.removeHandlersForRootLogger();
SLF4JBridgeHandler.install();
Server server = new Server();
ServerConnector connector = new ServerConnector(server);
connector.setPort(8080);
server.setConnectors(new Connector[]{connector});
WebAppContext context = new WebAppContext();
context.setServer(server);
context.setContextPath("/");
context.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern", ".*/[^/]*taglibs.*\\.jar$");
context.setAttribute("org.eclipse.jetty.containerInitializers", jspInitializers());
context.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager());
context.addBean(new ServletContainerInitializersStarter(context), true);
// Prevent loading of logging classes
context.getSystemClasspathPattern().add("org.apache.log4j.");
context.getSystemClasspathPattern().add("org.slf4j.");
context.getSystemClasspathPattern().add("org.apache.commons.logging.");
ProtectionDomain protectionDomain = EmbeddedJettyServer.class.getProtectionDomain();
URL location = protectionDomain.getCodeSource().getLocation();
context.setWar(location.toExternalForm());
server.setHandler(context);
try {
server.start();
server.join();
} catch (Exception e) {
e.printStackTrace();
System.exit(-1);
}
}
示例10: start
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public void start() throws Exception
{
server = new Server(port);
WebAppContext webAppContext = new WebAppContext();
webAppContext.setContextPath("/");
webAppContext.setWar("/Users/Jelly/Developer/paraflow/paraflow-http-server/target/paraflow-server.war");
webAppContext.setParentLoaderPriority(true);
webAppContext.setServer(server);
webAppContext.setClassLoader(ClassLoader.getSystemClassLoader());
webAppContext.getSessionHandler().getSessionManager()
.setMaxInactiveInterval(10);
server.setHandler(webAppContext);
server.start();
}
示例11: startServer
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
/**
* Method for starting the Jetty server with the ATS Agent webapp.
* @param port the port on which to start the server.
* @return the started server.
* @throws IOException
*/
private static Server startServer() throws IOException {
addAppender();
final int agentPort = getAgentDefaultPort();
log.info("Starting ATS agent at port: " + agentPort);
final String jettyHome = getJettyHome();
logSystemInformation(jettyHome);
// start the server
Connector connector = new SelectChannelConnector();
connector.setPort(agentPort);
Server server = new Server();
server.setConnectors(new Connector[]{ connector });
WebAppContext webApp = new WebAppContext();
webApp.setContextPath("/agentapp");
webApp.setWar(jettyHome + "/webapp/agentapp.war");
server.setHandler(webApp);
server.setStopAtShutdown(true);
setExtraClasspath(webApp, jettyHome);
try {
server.start();
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
log.info("ATS agent started");
return server;
}
示例12: createWebApp
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
/**
* Creates a web-app deployment for a war file gives as path
* @param webappWar
* path to the war file
* @return
* a webApplication context that can be deployed on the jetty server.
*/
private static WebAppContext createWebApp(final Path webappWar) throws IOException {
// Path tempWar = Files.createTempFile("bdj-", webappWar.getFileName().toString());
// LOG.info("Creating temporary copy of war " + tempWar);
// Files.copy(webappWar, tempWar, StandardCopyOption.REPLACE_EXISTING);
// LOG.info("Deploying web app from " + tempWar);
final WebAppContext webapp = new WebAppContext();
webapp.setSystemClasses(new String[] {
Configuration.class.getName(), ConfigChangeListener.class.getName()
});
webapp.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern",
".*/[^/]*servlet-api-[^/]*\\.jar$|.*/javax.servlet.jsp.jstl-.*\\.jar$|.*/[^/]*taglibs.*\\.jar$");
/*
* Configure the application to support the compilation of JSP files.
* We need a new class loader and some stuff so that Jetty can call the
* onStartup() methods as required.
*/
webapp.setAttribute("org.eclipse.jetty.containerInitializers", jspInitializers());
webapp.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager());
webapp.addBean(new ServletContainerInitializersStarter(webapp), true);
webapp.setContextPath("/");
webapp.setWar(webappWar.toString());
return webapp;
}
示例13: main
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
SLF4JBridgeHandler.removeHandlersForRootLogger();
SLF4JBridgeHandler.install();
int port = 8888;
if (args.length > 0) {
port = Integer.parseInt(args[0]);
}
if (port == 80) {
System.out.println("Dorset web demo running on http://localhost/");
} else {
System.out.println("Dorset web demo running on http://localhost:"
+ String.valueOf(port) + "/");
}
Server server = new Server(port);
WebAppContext context = new WebAppContext();
context.setServer(server);
context.setContextPath("/");
// turn off class loading from WEB-INF due to logging
context.setParentLoaderPriority(true);
ProtectionDomain protectionDomain = Runner.class.getProtectionDomain();
URL location = protectionDomain.getCodeSource().getLocation();
context.setWar(location.toExternalForm());
server.setHandler(context);
server.start();
server.join();
}
示例14: initOldWebApp
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
private void initOldWebApp() {
try {
javax.naming.Context context = new InitialContext();
context.bind("java:/DefaultDS", dataSource);
} catch (Exception error) {
Log.warning(error);
}
WebAppContext app = new WebAppContext();
app.setContextPath("/");
app.getSessionHandler().setSessionManager(sessionManager);
app.setWar(config.getString("web.application"));
handlers.addHandler(app);
}
示例15: startJettyServer
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
/**
* 启动jetty服务,加载server.war
*/
public static void startJettyServer(String path) throws Exception{
String configPath=path+ File.separator+"conf"+File.separator+"conf.properties";
InputStream is = new FileInputStream(configPath);;
Properties properties =new Properties();
properties.load(is);
is.close();
int serverPort = Integer.parseInt(properties.getProperty("server.port"));
Server server = new Server(serverPort);
WebAppContext context = new WebAppContext();
context.setWar(path+"/bin/ROOT.war");
server.setHandler(context);
server.start();
server.join();
}