本文整理汇总了Java中org.apache.catalina.deploy.ContextResource.setType方法的典型用法代码示例。如果您正苦于以下问题:Java ContextResource.setType方法的具体用法?Java ContextResource.setType怎么用?Java ContextResource.setType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.catalina.deploy.ContextResource
的用法示例。
在下文中一共展示了ContextResource.setType方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testListBindings
import org.apache.catalina.deploy.ContextResource; //导入方法依赖的package包/类
@Test
public void testListBindings() throws Exception {
Tomcat tomcat = getTomcatInstance();
tomcat.enableNaming();
// No file system docBase required
StandardContext ctx = (StandardContext) tomcat.addContext("", null);
// Create the resource
ContextResource cr = new ContextResource();
cr.setName("list/foo");
cr.setType("org.apache.naming.resources.TesterObject");
cr.setProperty("factory", "org.apache.naming.resources.TesterFactory");
ctx.getNamingResources().addResource(cr);
// Map the test Servlet
Bug23950Servlet bug23950Servlet = new Bug23950Servlet();
Tomcat.addServlet(ctx, "bug23950Servlet", bug23950Servlet);
ctx.addServletMapping("/", "bug23950Servlet");
tomcat.start();
ByteChunk bc = getUrl("http://localhost:" + getPort() + "/");
assertEquals("org.apache.naming.resources.TesterObject", bc.toString());
}
示例2: testBeanFactory
import org.apache.catalina.deploy.ContextResource; //导入方法依赖的package包/类
@Test
public void testBeanFactory() throws Exception {
Tomcat tomcat = getTomcatInstance();
tomcat.enableNaming();
// No file system docBase required
StandardContext ctx = (StandardContext) tomcat.addContext("", null);
// Create the resource
ContextResource cr = new ContextResource();
cr.setName("bug50351");
cr.setType("org.apache.naming.resources.TesterObject");
cr.setProperty("factory", "org.apache.naming.factory.BeanFactory");
cr.setProperty("foo", "value");
ctx.getNamingResources().addResource(cr);
// Map the test Servlet
Bug50351Servlet bug50351Servlet = new Bug50351Servlet();
Tomcat.addServlet(ctx, "bug50351Servlet", bug50351Servlet);
ctx.addServletMapping("/", "bug50351Servlet");
tomcat.start();
ByteChunk bc = getUrl("http://localhost:" + getPort() + "/");
assertEquals("value", bc.toString());
}
示例3: testListBindings
import org.apache.catalina.deploy.ContextResource; //导入方法依赖的package包/类
@Test
public void testListBindings() throws Exception {
Tomcat tomcat = getTomcatInstance();
tomcat.enableNaming();
// Must have a real docBase - just use temp
StandardContext ctx = (StandardContext)
tomcat.addContext("", System.getProperty("java.io.tmpdir"));
// Create the resource
ContextResource cr = new ContextResource();
cr.setName("list/foo");
cr.setType("org.apache.naming.resources.TesterObject");
cr.setProperty("factory", "org.apache.naming.resources.TesterFactory");
ctx.getNamingResources().addResource(cr);
// Map the test Servlet
Bug23950Servlet bug23950Servlet = new Bug23950Servlet();
Tomcat.addServlet(ctx, "bug23950Servlet", bug23950Servlet);
ctx.addServletMapping("/", "bug23950Servlet");
tomcat.start();
ByteChunk bc = getUrl("http://localhost:" + getPort() + "/");
assertEquals("org.apache.naming.resources.TesterObject", bc.toString());
}
示例4: doTestLookup
import org.apache.catalina.deploy.ContextResource; //导入方法依赖的package包/类
public void doTestLookup(boolean useSingletonResource) throws Exception {
Tomcat tomcat = getTomcatInstance();
tomcat.enableNaming();
// No file system docBase required
StandardContext ctx = (StandardContext) tomcat.addContext("", null);
// Create the resource
ContextResource cr = new ContextResource();
cr.setName("list/foo");
cr.setType("org.apache.naming.resources.TesterObject");
cr.setProperty("factory", "org.apache.naming.resources.TesterFactory");
cr.setSingleton(useSingletonResource);
ctx.getNamingResources().addResource(cr);
// Map the test Servlet
Bug49994Servlet bug49994Servlet = new Bug49994Servlet();
Tomcat.addServlet(ctx, "bug49994Servlet", bug49994Servlet);
ctx.addServletMapping("/", "bug49994Servlet");
tomcat.start();
ByteChunk bc = getUrl("http://localhost:" + getPort() + "/");
String expected;
if (useSingletonResource) {
expected = "EQUAL";
} else {
expected = "NOTEQUAL";
}
assertEquals(expected, bc.toString());
}
示例5: doTestLookup
import org.apache.catalina.deploy.ContextResource; //导入方法依赖的package包/类
public void doTestLookup(boolean useSingletonResource) throws Exception {
Tomcat tomcat = getTomcatInstance();
tomcat.enableNaming();
// Must have a real docBase - just use temp
StandardContext ctx = (StandardContext)
tomcat.addContext("", System.getProperty("java.io.tmpdir"));
// Create the resource
ContextResource cr = new ContextResource();
cr.setName("list/foo");
cr.setType("org.apache.naming.resources.TesterObject");
cr.setProperty("factory", "org.apache.naming.resources.TesterFactory");
cr.setSingleton(useSingletonResource);
ctx.getNamingResources().addResource(cr);
// Map the test Servlet
Bug49994Servlet bug49994Servlet = new Bug49994Servlet();
Tomcat.addServlet(ctx, "bug49994Servlet", bug49994Servlet);
ctx.addServletMapping("/", "bug49994Servlet");
tomcat.start();
ByteChunk bc = getUrl("http://localhost:" + getPort() + "/");
String expected;
if (useSingletonResource) {
expected = "EQUAL";
} else {
expected = "NOTEQUAL";
}
assertEquals(expected, bc.toString());
}
示例6: testBeanFactory
import org.apache.catalina.deploy.ContextResource; //导入方法依赖的package包/类
@Test
public void testBeanFactory() throws Exception {
Tomcat tomcat = getTomcatInstance();
tomcat.enableNaming();
// Must have a real docBase - just use temp
StandardContext ctx = (StandardContext)
tomcat.addContext("", System.getProperty("java.io.tmpdir"));
// Create the resource
ContextResource cr = new ContextResource();
cr.setName("bug50351");
cr.setType("org.apache.naming.resources.TesterObject");
cr.setProperty("factory", "org.apache.naming.factory.BeanFactory");
cr.setProperty("foo", "value");
ctx.getNamingResources().addResource(cr);
// Map the test Servlet
Bug50351Servlet bug50351Servlet = new Bug50351Servlet();
Tomcat.addServlet(ctx, "bug50351Servlet", bug50351Servlet);
ctx.addServletMapping("/", "bug50351Servlet");
tomcat.start();
ByteChunk bc = getUrl("http://localhost:" + getPort() + "/");
assertEquals("value", bc.toString());
}
示例7: applyNamingResources
import org.apache.catalina.deploy.ContextResource; //导入方法依赖的package包/类
/**
* JNDIで取得する名前付きオブジェクトのグローバルリソースへの登録
*
* @param namingResources
* @throws NamingException
*/
protected void applyNamingResources(NamingResources namingResources) throws NamingException {
// --------------------------------
// ネーミングリソースにデータソース・環境変数を登録
// --------------------------------
// (factoryを指定しない場合、BasicDataSourceFactoryが用いられBasicDataSourceが生成される)
ContextResource ctxRes = new ContextResource();
ctxRes.setName("jdbc/ds");
ctxRes.setAuth("Container");
ctxRes.setType("javax.sql.DataSource");
ctxRes.setProperty("factory", DerbyDataSourceFactory.class.getName());
// JNDIによる環境変数
ContextEnvironment ctxEnv = new ContextEnvironment();
ctxEnv.setName("testvalue2");
ctxEnv.setType("java.lang.Integer");
ctxEnv.setValue("12345");
ctxEnv.setOverride(false);
namingResources.addResource(ctxRes);
namingResources.addEnvironment(ctxEnv);
// --------------------------------
// リソースリンクをアプリケーションのコンテキストに設定する.
// ここでプログラム的に構成するため、"context.xml"は不要.
// --------------------------------
ContextResourceLink resourceLink1 = new ContextResourceLink();
resourceLink1.setName("jdbc/ds");
resourceLink1.setGlobal("jdbc/ds");
resourceLink1.setType("javax.sql.DataSource");
ctx.getNamingResources().addResourceLink(resourceLink1);
ContextResourceLink resourceLink2 = new ContextResourceLink();
resourceLink2.setName("testvalue2");
resourceLink2.setGlobal("testvalue2");
resourceLink2.setType("java.lang.Integer");
ctx.getNamingResources().addResourceLink(resourceLink2);
}