org.eclipse.jetty.webapp.WebAppContext.setWar()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(9.9k)|赞(0)|评价(0)|浏览(199)

本文整理了Java中org.eclipse.jetty.webapp.WebAppContext.setWar()方法的一些代码示例,展示了WebAppContext.setWar()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebAppContext.setWar()方法的具体详情如下:
包路径:org.eclipse.jetty.webapp.WebAppContext
类名称:WebAppContext
方法名:setWar

WebAppContext.setWar介绍

[英]Set the war of the webapp. From this value a #setResourceBase(String)value is computed by WebInfConfiguration, which may be changed from the war URI by unpacking and/or copying.
[中]设定网络应用的战争。WebInfConfiguration根据该值计算#setResourceBase(字符串)值,可以通过解包和/或复制从war URI更改该值。

代码示例

代码示例来源:origin: org.eclipse.jetty/jetty-webapp

/**
 * Set the war of the webapp as a {@link Resource}. 
 * @see #setWar(String)
 * @param war The war to set as a Resource.
 */
public void setWarResource(Resource war)
{
  setWar(war==null?null:war.toString());
}

代码示例来源:origin: org.eclipse.jetty/jetty-webapp

/**
 * @param contextPath The context path
 * @param webApp The URL or filename of the webapp directory or war file.
 */
public WebAppContext(String webApp,String contextPath)
{
  this(null,contextPath,null,null,null,new ErrorPageErrorHandler(),SESSIONS|SECURITY);
  setWar(webApp);
}

代码示例来源:origin: org.eclipse.jetty/jetty-webapp

/**
 * @param parent The parent HandlerContainer.
 * @param contextPath The context path
 * @param webApp The URL or filename of the webapp directory or war file.
 */
public WebAppContext(HandlerContainer parent, String webApp, String contextPath)
{
  this(parent,contextPath,null,null,null,new ErrorPageErrorHandler(),SESSIONS|SECURITY);
  setWar(webApp);
}

代码示例来源:origin: Netflix/eureka

private static void startServer() throws Exception {
  File warFile = findWar();
  server = new Server(8080);
  WebAppContext webapp = new WebAppContext();
  webapp.setContextPath("/");
  webapp.setWar(warFile.getAbsolutePath());
  server.setHandler(webapp);
  server.start();
  eurekaServiceUrl = "http://localhost:8080/v2";
}

代码示例来源:origin: apache/hive

/**
 * Create the web context for the application of specified name
 */
WebAppContext createWebAppContext(Builder b) {
 WebAppContext ctx = new WebAppContext();
 setContextAttributes(ctx.getServletContext(), b.contextAttrs);
 ctx.setDisplayName(b.name);
 ctx.setContextPath("/");
 ctx.setWar(appDir + "/" + b.name);
 return ctx;
}

代码示例来源:origin: stackoverflow.com

bb.setServer(server);
bb.setContextPath("/");
bb.setWar("src/main/webapp");

代码示例来源:origin: apache/geode

webapp.setWar(warFilePath);
webapp.setParentLoaderPriority(false);
webapp.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");

代码示例来源:origin: gocd/gocd

private WebAppContext createWebAppContext() {
  webAppContext = new WebAppContext();
  webAppContext.setDefaultsDescriptor(GoWebXmlConfiguration.configuration(getWarFile()));
  webAppContext.setConfigurationClasses(new String[]{
      WebInfConfiguration.class.getCanonicalName(),
      WebXmlConfiguration.class.getCanonicalName(),
      JettyWebXmlConfiguration.class.getCanonicalName()
  });
  webAppContext.setContextPath(systemEnvironment.getWebappContextPath());
  // delegate all logging to parent classloader to avoid initialization of loggers in multiple classloaders
  webAppContext.addSystemClass("org.apache.log4j.");
  webAppContext.addSystemClass("org.slf4j.");
  webAppContext.addSystemClass("org.apache.commons.logging.");
  webAppContext.setWar(getWarFile());
  webAppContext.setParentLoaderPriority(systemEnvironment.getParentLoaderPriority());
  return webAppContext;
}

代码示例来源:origin: stackoverflow.com

Server server = new Server();
 // Note: if you don't want control over type of connector, etc. you can simply 
 // call new Server(<port>);
 ServerConnector connector = new ServerConnector(server);
 connector.setHost("0.0.0.0");
 connector.setPort(8085);
 // Setting the name allows you to serve different app contexts from different connectors.
 connector.setName("main");
 server.addConnector(connector);
 WebAppContext context = new WebAppContext();
 context.setContextPath("/");
 // For development within an IDE like Eclipse, you can directly point to the web.xml
 context.setWar("src/main/webapp");
 context.addFilter(MyFilter.class, "/", 1);
 HandlerCollection collection = new HandlerCollection();
 RequestLogHandler rlh = new RequestLogHandler();
 // Slf4j - who uses anything else?
 Slf4jRequestLog requestLog = new Slf4jRequestLog();
 requestLog.setExtended(false);
 rlh.setRequestLog(requestLog);
 collection.setHandlers(new Handler[] { context, rlh });
 server.setHandler(collection);
 try {
   server.start();
   server.join();
 } catch (Exception e) {
   // Google guava way
   throw Throwables.propagate(e);
 }

代码示例来源:origin: org.apache.hadoop/hadoop-common

private static WebAppContext createWebAppContext(Builder b,
  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(b.name);
 ctx.setContextPath("/");
 ctx.setWar(appDir + "/" + b.name);
 String tempDirectory = b.conf.get(HTTP_TEMP_DIR_KEY);
 if (tempDirectory != null && !tempDirectory.isEmpty()) {
  ctx.setTempDirectory(new File(tempDirectory));
  ctx.setAttribute("javax.servlet.context.tempdir", tempDirectory);
 }
 ctx.getServletContext().setAttribute(CONF_CONTEXT_ATTRIBUTE, b.conf);
 ctx.getServletContext().setAttribute(ADMINS_ACL, adminsAcl);
 addNoCacheFilter(ctx);
 return ctx;
}

代码示例来源:origin: apache/hbase

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);
 // for org.apache.hadoop.metrics.MetricsServlet
 ctx.getServletContext().setAttribute(
  org.apache.hadoop.http.HttpServer2.CONF_CONTEXT_ATTRIBUTE, conf);
 ctx.getServletContext().setAttribute(ADMINS_ACL, adminsAcl);
 addNoCacheFilter(ctx);
 return ctx;
}

代码示例来源:origin: yahoo/mysql_perf_analyzer

private WebAppContext createDeployedApplicationInstance(File workDirectory,
    String deployedApplicationPath) {
  WebAppContext deployedApplication = new WebAppContext();
  deployedApplication.setContextPath(this.getContextPath());
  deployedApplication.setWar(deployedApplicationPath);
  deployedApplication.setAttribute("javax.servlet.context.tempdir",
      workDirectory.getAbsolutePath());
  deployedApplication
      .setAttribute(
          "org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern",
          ".*/[^/]*servlet-api-[^/]*\\.jar$|.*/javax.servlet.jsp.jstl-.*\\.jar$|.*/.*taglibs.*\\.jar$");
  deployedApplication.setAttribute(
      "org.eclipse.jetty.containerInitializers", jspInitializers());
  deployedApplication.setAttribute(InstanceManager.class.getName(),
      new SimpleInstanceManager());
  deployedApplication.addBean(new ServletContainerInitializersStarter(
      deployedApplication), true);
  // webapp.setClassLoader(new URLClassLoader(new
  // URL[0],App.class.getClassLoader()));
  deployedApplication.addServlet(jspServletHolder(), "*.jsp");
  return deployedApplication;
}

代码示例来源:origin: stackoverflow.com

webapp.setWar("/"); // Appropriate file system path.

代码示例来源:origin: apache/shiro

ctx.setWar(webapp);
ctx.setServer(server);

代码示例来源:origin: stackoverflow.com

WebAppContext webapp = new WebAppContext();
 webapp.setContextPath("/");
 webapp.setWar(warURL);
 server.setHandler(webapp);

代码示例来源:origin: stackoverflow.com

Server server = new Server( port );
WebAppContext root = new WebAppContext();

root.setWar("/path/to/somewhere");
root.setContextPath("/");

server.addHandler( root );
server.start();

代码示例来源:origin: jamesagnew/hapi-fhir

WebAppContext root = new WebAppContext();
root.setAllowDuplicateFragmentNames(true);
root.setWar(tempWarFile.getAbsolutePath());
root.setParentLoaderPriority(true);
root.setContextPath("/");

代码示例来源:origin: apache/cloudstack

private HandlerCollection createHandlers() {
  final WebAppContext webApp = new WebAppContext();
  webApp.setContextPath(contextPath);
  webApp.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
  webApp.getSessionHandler().setMaxInactiveInterval(sessionTimeout * 60);
  // GZIP handler
  final GzipHandler gzipHandler = new GzipHandler();
  gzipHandler.addIncludedMimeTypes("text/html", "text/xml", "text/css", "text/plain", "text/javascript", "application/javascript", "application/json", "application/xml");
  gzipHandler.setIncludedMethods("GET", "POST");
  gzipHandler.setCompressionLevel(9);
  gzipHandler.setHandler(webApp);
  if (Strings.isNullOrEmpty(webAppLocation)) {
    webApp.setWar(getShadedWarUrl());
  } else {
    webApp.setWar(webAppLocation);
  }
  // Request log handler
  final RequestLogHandler log = new RequestLogHandler();
  log.setRequestLog(createRequestLog());
  // Redirect root context handler
  MovedContextHandler rootRedirect = new MovedContextHandler();
  rootRedirect.setContextPath("/");
  rootRedirect.setNewContextURL(contextPath);
  rootRedirect.setPermanent(true);
  // Put rootRedirect at the end!
  return new HandlerCollection(log, gzipHandler, rootRedirect);
}

代码示例来源:origin: apache/activemq-artemis

private WebAppContext deployWar(String url, String warFile, Path warDirectory) throws IOException {
 WebAppContext webapp = new WebAppContext();
 if (url.startsWith("/")) {
   webapp.setContextPath(url);
 } else {
   webapp.setContextPath("/" + url);
 }
 webapp.setWar(warDirectory.resolve(warFile).toString());
 handlers.addHandler(webapp);
 return webapp;
}

代码示例来源:origin: org.apache.hive/hive-common

/**
 * Create the web context for the application of specified name
 */
WebAppContext createWebAppContext(Builder b) {
 WebAppContext ctx = new WebAppContext();
 setContextAttributes(ctx.getServletContext(), b.contextAttrs);
 ctx.setDisplayName(b.name);
 ctx.setContextPath("/");
 ctx.setWar(appDir + "/" + b.name);
 return ctx;
}

相关文章

微信公众号

最新文章

更多

WebAppContext类方法