org.apache.catalina.webresources.DirResourceSet Java Examples
The following examples show how to use
org.apache.catalina.webresources.DirResourceSet.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JsfTomcatApplicationListenerIT.java From joinfaces with Apache License 2.0 | 6 votes |
@Test public void embeddedJarWithoutAppResources() throws LifecycleException { ContextMock contextMock = new ContextMock(); File file = new File(TARGET + File.separator + TEST_CLASSES + File.separator + "test.jar"); JarWarResourceSet jarWarResourceSet = new JarWarResourceSet(contextMock.getWebResourceRoot(), "/", file.getAbsolutePath(), INTERNAL_JAR, METAINF_RESOURCES); jarWarResourceSet.init(); DirResourceSet dirResourceSet = new DirResourceSet(contextMock.getWebResourceRoot(), TEST, TEST, TEST); contextMock.init(jarWarResourceSet, dirResourceSet); callApplicationEvent(contextMock); assertThat(contextMock.getWebResourceRoot().getCreateWebResourceSetCalls()) .isEqualTo(2); }
Example #2
Source File: JsfTomcatApplicationListenerIT.java From joinfaces with Apache License 2.0 | 6 votes |
@Test public void embeddedJarWithoutAppResources2() throws LifecycleException { ContextMock contextMock = new ContextMock(); File file = new File(TARGET + File.separator + TEST_CLASSES + File.separator + "test.jar"); JarWarResourceSet jarWarResourceSet = new JarWarResourceSet(contextMock.getWebResourceRoot(), "/", file.getAbsolutePath(), INTERNAL_JAR, METAINF_RESOURCES); jarWarResourceSet.init(); DirResourceSet dirResourceSet = new DirResourceSet(contextMock.getWebResourceRoot(), TEST, TEST, TEST); contextMock.init(dirResourceSet, jarWarResourceSet); callApplicationEvent(contextMock); assertThat(contextMock.getWebResourceRoot().getCreateWebResourceSetCalls()) .isEqualTo(2); }
Example #3
Source File: JsfTomcatApplicationListenerIT.java From joinfaces with Apache License 2.0 | 6 votes |
@Test public void embeddedWarWithoutAppResources() throws LifecycleException { ContextMock contextMock = new ContextMock(); File file = new File(TARGET + File.separator + TEST_CLASSES + File.separator + "test.war"); JarWarResourceSet jarWarResourceSet = new JarWarResourceSet(contextMock.getWebResourceRoot(), "/", file.getAbsolutePath(), INTERNAL_JAR, METAINF_RESOURCES); jarWarResourceSet.init(); DirResourceSet dirResourceSet = new DirResourceSet(contextMock.getWebResourceRoot(), TEST, TEST, TEST); contextMock.init(jarWarResourceSet, dirResourceSet); callApplicationEvent(contextMock); assertThat(contextMock.getWebResourceRoot().getCreateWebResourceSetCalls()) .isEqualTo(0); }
Example #4
Source File: TomcatServer.java From redisson with Apache License 2.0 | 6 votes |
public TomcatServer(String contextPath, int port, String appBase) throws MalformedURLException, ServletException { if(contextPath == null || appBase == null || appBase.length() == 0) { throw new IllegalArgumentException("Context path or appbase should not be null"); } if(!contextPath.startsWith("/")) { contextPath = "/" + contextPath; } tomcat.setBaseDir("."); // location where temp dir is created tomcat.setPort(port); tomcat.getHost().setAppBase("."); ctx = (StandardContext) tomcat.addWebapp(contextPath, appBase); ctx.setDelegate(true); File additionWebInfClasses = new File("target/test-classes"); StandardRoot resources = new StandardRoot(); DirResourceSet webResourceSet = new DirResourceSet(); webResourceSet.setBase(additionWebInfClasses.toString()); webResourceSet.setWebAppMount("/WEB-INF/classes"); resources.addPostResources(webResourceSet); ctx.setResources(resources); }
Example #5
Source File: Main.java From problematic-microservices with BSD 3-Clause "New" or "Revised" License | 5 votes |
@SuppressWarnings("deprecation") public static void main(String[] args) throws ServletException, LifecycleException { OpenTracingUtil.configureOpenTracing("RobotShop-Factory-Service"); String webappDirLocation = "src/main/webapp/"; Tomcat tomcat = new Tomcat(); String webPort = System.getenv("PORT"); if (webPort == null || webPort.isEmpty()) { webPort = DEFAULT_PORT; } tomcat.setPort(Integer.valueOf(webPort)); StandardContext ctx = (StandardContext) tomcat.addWebapp("", new File(webappDirLocation).getAbsolutePath()); System.out.println("Basedir: " + new File("./" + webappDirLocation).getAbsolutePath()); File additionWebInfClasses = new File("target/classes"); WebResourceRoot resources = new StandardRoot(ctx); resources.addPreResources( new DirResourceSet(resources, "/WEB-INF/classes", additionWebInfClasses.getAbsolutePath(), "/")); ctx.setResources(resources); // Add servlet that will register Jersey REST resources Tomcat.addServlet(ctx, "jersey-container-servlet", resourceConfig()); ctx.addServletMapping("/*", "jersey-container-servlet"); tomcat.start(); tomcat.getServer().await(); }
Example #6
Source File: Main.java From problematic-microservices with BSD 3-Clause "New" or "Revised" License | 5 votes |
@SuppressWarnings("deprecation") public static void main(String[] args) throws ServletException, LifecycleException { OpenTracingUtil.configureOpenTracing("RobotShop-Customer-Service"); String webappDirLocation = "src/main/webapp/"; Tomcat tomcat = new Tomcat(); String webPort = System.getenv("PORT"); if (webPort == null || webPort.isEmpty()) { webPort = DEFAULT_PORT; } tomcat.setPort(Integer.valueOf(webPort)); StandardContext ctx = (StandardContext) tomcat.addWebapp("", new File(webappDirLocation).getAbsolutePath()); System.out.println("Basedir: " + new File("./" + webappDirLocation).getAbsolutePath()); File additionWebInfClasses = new File("target/classes"); WebResourceRoot resources = new StandardRoot(ctx); resources.addPreResources( new DirResourceSet(resources, "/WEB-INF/classes", additionWebInfClasses.getAbsolutePath(), "/")); ctx.setResources(resources); // Add servlet that will register Jersey REST resources Tomcat.addServlet(ctx, "jersey-container-servlet", resourceConfig()); ctx.addServletMapping("/*", "jersey-container-servlet"); tomcat.start(); tomcat.getServer().await(); }
Example #7
Source File: Main.java From problematic-microservices with BSD 3-Clause "New" or "Revised" License | 5 votes |
@SuppressWarnings("deprecation") public static void main(String[] args) throws ServletException, LifecycleException { OpenTracingUtil.configureOpenTracing("RobotShop-Order-Service"); String webappDirLocation = "src/main/webapp/"; Tomcat tomcat = new Tomcat(); String webPort = System.getenv("PORT"); if (webPort == null || webPort.isEmpty()) { webPort = DEFAULT_PORT; } tomcat.setPort(Integer.valueOf(webPort)); StandardContext ctx = (StandardContext) tomcat.addWebapp("", new File(webappDirLocation).getAbsolutePath()); System.out.println("Basedir: " + new File("./" + webappDirLocation).getAbsolutePath()); File additionWebInfClasses = new File("target/classes"); WebResourceRoot resources = new StandardRoot(ctx); resources.addPreResources( new DirResourceSet(resources, "/WEB-INF/classes", additionWebInfClasses.getAbsolutePath(), "/")); ctx.setResources(resources); // Add servlet that will register Jersey REST resources Tomcat.addServlet(ctx, "jersey-container-servlet", resourceConfig()); ctx.addServletMapping("/*", "jersey-container-servlet"); tomcat.start(); tomcat.getServer().await(); }
Example #8
Source File: JsfTomcatApplicationListenerIT.java From joinfaces with Apache License 2.0 | 5 votes |
@Test public void testingResources() throws LifecycleException { ContextMock contextMock = new ContextMock(); DirResourceSet dirResourceSet = new DirResourceSet(contextMock.getWebResourceRoot(), TEST, TEST, TEST); contextMock.init(dirResourceSet); callApplicationEvent(contextMock); assertThat(contextMock.getWebResourceRoot().getCreateWebResourceSetCalls()) .isEqualTo(0); }
Example #9
Source File: Main.java From heroku-identity-java with Apache License 2.0 | 5 votes |
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(); }
Example #10
Source File: StatsServer.java From cxf with Apache License 2.0 | 4 votes |
private static WebResourceRoot resourcesFrom(final Context context, final String path) { final File additionResources = new File(path); final WebResourceRoot resources = new StandardRoot(context); resources.addPreResources(new DirResourceSet(resources, "/", additionResources.getAbsolutePath(), "/")); return resources; }