本文整理汇总了Java中org.apache.catalina.webresources.DirResourceSet类的典型用法代码示例。如果您正苦于以下问题:Java DirResourceSet类的具体用法?Java DirResourceSet怎么用?Java DirResourceSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DirResourceSet类属于org.apache.catalina.webresources包,在下文中一共展示了DirResourceSet类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: main
import org.apache.catalina.webresources.DirResourceSet; //导入依赖的package包/类
public static void main(String[] args) throws Exception
{
String userDir = System.getProperty("user.dir") + File.separator + "server.tomcat";
String webappDirLocation = userDir + File.separator +"src/main/webapp/";
Tomcat tomcat = new Tomcat();
String webPort = System.getenv("PORT");
if (webPort == null || webPort.isEmpty())
{
webPort = "8080";
}
tomcat.setPort(Integer.valueOf(webPort));
System.out.println("configuring app with basedir: " + new File(webappDirLocation).getAbsolutePath());
StandardContext standardContext = (StandardContext) tomcat.addWebapp("/", new File(webappDirLocation).getAbsolutePath());
File additionWebInfClasses = new File(userDir + File.separator + "build/classes");
WebResourceRoot resourceRoot = new StandardRoot(standardContext);
resourceRoot.addPreResources(new DirResourceSet(resourceRoot, "/WEB-INF/classes", additionWebInfClasses.getAbsolutePath(), "/"));
standardContext.setResources(resourceRoot);
tomcat.start();
tomcat.getServer().await();
}
开发者ID:geekflow,项目名称:light,代码行数:26,代码来源:TomcatMain.java
示例2: embeddedJarWithoutAppResources
import org.apache.catalina.webresources.DirResourceSet; //导入依赖的package包/类
@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(1);
}
开发者ID:joinfaces,项目名称:joinfaces,代码行数:20,代码来源:JsfTomcatApplicationListenerIT.java
示例3: embeddedJarWithoutAppResources2
import org.apache.catalina.webresources.DirResourceSet; //导入依赖的package包/类
@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(1);
}
开发者ID:joinfaces,项目名称:joinfaces,代码行数:20,代码来源:JsfTomcatApplicationListenerIT.java
示例4: embeddedWarWithoutAppResources
import org.apache.catalina.webresources.DirResourceSet; //导入依赖的package包/类
@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);
}
开发者ID:joinfaces,项目名称:joinfaces,代码行数:20,代码来源:JsfTomcatApplicationListenerIT.java
示例5: setUpClass
import org.apache.catalina.webresources.DirResourceSet; //导入依赖的package包/类
/**
* Sets up the test environment, generates data to upload, starts a
* Tomcat instance which will receive the client requests.
* @throws Exception If an error occurred with the servlets
*/
@BeforeClass
public static void setUpClass() throws Exception {
server = new Tomcat();
Path base = Paths.get("build/tomcat");
Files.createDirectories(base);
server.setPort(8100);
server.setBaseDir("build/tomcat");
server.getHost().setAppBase("build/tomcat");
server.getHost().setAutoDeploy(true);
server.getHost().setDeployOnStartup(true);
StandardContext context = (StandardContext) server.addWebapp("/", base.toAbsolutePath().toString());
Path additionWebInfClasses = Paths.get("build/classes");
WebResourceRoot resources = new StandardRoot(context);
resources.addPreResources(new DirResourceSet(resources, "/WEB-INF/classes",
additionWebInfClasses.toAbsolutePath().toString(), "/"));
context.setResources(resources);
context.getJarScanner().setJarScanFilter((jarScanType, jarName) -> false);
server.start();
}
开发者ID:Elopteryx,项目名称:upload-parser,代码行数:30,代码来源:TomcatIntegrationTest.java
示例6: main
import org.apache.catalina.webresources.DirResourceSet; //导入依赖的package包/类
public static void main(String[] args) {
Connector connector = new Connector();
connector.setPort(80);
Tomcat tomcat = new Tomcat();
tomcat.setPort(80);
tomcat.getService().addConnector(connector);
tomcat.setConnector(connector);
try {
Context ctx = tomcat.addWebapp("", Conf.getAbsolutePath("../src/main/webapp"));
WebResourceRoot resources = new StandardRoot(ctx);
resources.addPreResources(new DirResourceSet(resources,
"/WEB-INF/classes", Conf.getAbsolutePath("classes"), "/"));
ctx.setResources(resources);
Server server = tomcat.getServer();
server.start();
server.setPort(8005);
server.await();
server.stop();
} catch (ServletException | LifecycleException e) {
Log.e(e);
}
}
开发者ID:xqbase,项目名称:metric,代码行数:24,代码来源:Startup.java
示例7: testingResources
import org.apache.catalina.webresources.DirResourceSet; //导入依赖的package包/类
@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);
}
开发者ID:joinfaces,项目名称:joinfaces,代码行数:15,代码来源:JsfTomcatApplicationListenerIT.java
示例8: main
import org.apache.catalina.webresources.DirResourceSet; //导入依赖的package包/类
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();
}
开发者ID:salesforceidentity,项目名称:heroku-identity-java,代码行数:29,代码来源:Main.java
示例9: main
import org.apache.catalina.webresources.DirResourceSet; //导入依赖的package包/类
public static void main(String[] args) {
Connector connector = new Connector();
connector.setPort(80);
Tomcat tomcat = new Tomcat();
tomcat.setPort(80);
tomcat.getService().addConnector(connector);
tomcat.setConnector(connector);
try {
Context ctx = tomcat.addWebapp("", Conf.getAbsolutePath("../src/main/webapp"));
// Ensure to Load All Classes in the Same Class Loader
ctx.setLoader(new WebappLoader(Startup.class.getClassLoader()) {
@Override
public ClassLoader getClassLoader() {
return Startup.class.getClassLoader();
}
});
WebResourceRoot resources = new StandardRoot(ctx);
resources.addPreResources(new DirResourceSet(resources,
"/WEB-INF/classes", Conf.getAbsolutePath("classes"), "/"));
ctx.setResources(resources);
Server server = tomcat.getServer();
server.start();
server.setPort(8005);
server.await();
server.stop();
} catch (ServletException | LifecycleException e) {
Log.e(e);
}
}
开发者ID:xqbase,项目名称:metric,代码行数:31,代码来源:Startup.java
注:本文中的org.apache.catalina.webresources.DirResourceSet类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论