org.apache.catalina.WebResourceRoot.addPreResources()方法的使用及代码示例

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

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

WebResourceRoot.addPreResources介绍

[英]Adds the provided WebResourceSet to this web application as a 'Pre' resource.
[中]将提供的WebResourceSet作为“Pre”资源添加到此web应用程序。

代码示例

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

String webappDirLocation = "src/main/webapp/";
Tomcat tomcat = new Tomcat();
tomcat.setPort(8080);

StandardContext ctx = (StandardContext) tomcat.addWebapp("/embeddedTomcat",
        new File(webappDirLocation).getAbsolutePath());

//declare an alternate location for your "WEB-INF/classes" dir:     
File additionWebInfClasses = new File("target/classes");
WebResourceRoot resources = new StandardRoot(ctx);
resources.addPreResources(new DirResourceSet(resources, "/WEB-INF/classes", additionWebInfClasses.getAbsolutePath(), "/"));
ctx.setResources(resources);

tomcat.start();
tomcat.getServer().await();

代码示例来源:origin: org.apache.tomee/tomee-catalina

@Override
public void addPreResources(final WebResourceSet webResourceSet) {
  delegate.addPreResources(webResourceSet);
}

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

public static void main(String[] args) throws Exception {
   String webappDirLocation = "src/main/webapp/";
   Tomcat tomcat = new Tomcat();
   //The port that we should run on can be set into an environment variable
   //Look for that variable and default to 8080 if it isn't there.
   String webPort = System.getenv("PORT");
   if(webPort == null || webPort.isEmpty()) {
     webPort = "8080";
   }
   tomcat.setPort(Integer.valueOf(webPort));
   StandardContext ctx = (StandardContext) tomcat.addWebapp("/", new File(webappDirLocation).getAbsolutePath());
   System.out.println("configuring app with basedir: " + new File("./" + webappDirLocation).getAbsolutePath());
   // Declare an alternative location for your "WEB-INF/classes" dir
   // Servlet 3.0 annotation will work
   File additionWebInfClasses = new File("target/classes");
   WebResourceRoot resources = new StandardRoot(ctx);
   resources.addPreResources(new DirResourceSet(resources, "/WEB-INF/classes",
       additionWebInfClasses.getAbsolutePath(), "/"));
   ctx.setResources(resources);
   tomcat.start();
   tomcat.getServer().await();
 }

代码示例来源:origin: org.apache.tomee/tomee-catalina

private void addConfiguredDocBases(final StandardContext standardContext, final ContextInfo contextInfo) {
  if (contextInfo.appInfo.path != null) {   // add external web resources
    final String contextPath = standardContext.getServletContext().getContextPath();
    final String name = contextPath.isEmpty() ? "ROOT" : contextPath.substring(1);
    final String webResources = SystemInstance.get().getProperty("tomee." + name + ".docBases", contextInfo.appInfo.properties.getProperty("docBases"));
    if (webResources != null) {
      for (final String alt : webResources.trim().split(",")) {
        final String trim = alt.trim();
        if (trim.isEmpty()) {
          continue;
        }
        if (!new File(trim).isDirectory()) {
          logger.warning("Can't add docBase which are not directory: " + trim);
          continue;
        }
        final WebResourceRoot root = standardContext.getResources();
        root.addPreResources(new DirResourceSet(root, "/", trim, "/"));
      }
    }
  }
}

代码示例来源:origin: brutusin/Brutusin-RPC

resourceSet = new EmptyResourceSet(resources);
resources.addPreResources(resourceSet);
ctx.setResources(resources);

代码示例来源:origin: org.brutusin/rpc-tomcat

resourceSet = new EmptyResourceSet(resources);
resources.addPreResources(resourceSet);
ctx.setResources(resources);

代码示例来源:origin: com.github.bordertech.lde/lde-tomcat

/**
 * @param context the context to configure
 * @throws IOException an IO Exception
 * @throws ServletException a Servlet Exception
 */
protected void configWebApp(final Context context) throws IOException, ServletException {
  final String libDir = getLibDir();
  final String classesDir = getClassesDir();
  configJarScanner(context);
  WebResourceRoot resources = new StandardRoot(context);
  context.setResources(resources);
  // Declare an alternative location for the "WEB-INF/lib" dir
  if (libDir != null && !libDir.isEmpty()) {
    resources.addPreResources(new DirResourceSet(resources, Constants.WEB_INF_LIB, libDir, "/"));
  }
  // Declare an alternative location for the "WEB-INF/classes" dir
  if (classesDir != null && !classesDir.isEmpty()) {
    resources.addPreResources(new DirResourceSet(resources, Constants.WEB_INF_CLASSES, classesDir, "/"));
  }
  // Stop persistent sessions
  StandardManager mgr = new StandardManager();
  mgr.setPathname(null);
  context.setManager(mgr);
  // Delay for requets to stop processing in milliseconds
  ((StandardContext) context).setUnloadDelay(10000);
}

代码示例来源:origin: org.apache.tomee/tomee-catalina

for (final File f : additionalRepos) {
  final DirResourceSet webResourceSet = new PremptiveDirResourceSet(resources, "/", f.getAbsolutePath(), "/");
  resources.addPreResources(webResourceSet);

代码示例来源:origin: ch.rasc/embeddedtc

DirResourceSet dirResource = new DirResourceSet(resourceRoot,
    "/WEB-INF/classes", "./target/classes", "/");
resourceRoot.addPreResources(dirResource);
ctx.setResources(resourceRoot);

相关文章

微信公众号

最新文章

更多