当前位置: 首页>>代码示例>>Java>>正文


Java ContextResource.setProperty方法代码示例

本文整理汇总了Java中org.apache.catalina.deploy.ContextResource.setProperty方法的典型用法代码示例。如果您正苦于以下问题:Java ContextResource.setProperty方法的具体用法?Java ContextResource.setProperty怎么用?Java ContextResource.setProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.catalina.deploy.ContextResource的用法示例。


在下文中一共展示了ContextResource.setProperty方法的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());
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:26,代码来源:TestNamingContext.java

示例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());
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:27,代码来源:TestNamingContext.java

示例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());
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:27,代码来源:TestNamingContext.java

示例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());

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:34,代码来源:TestNamingContext.java

示例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());

}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:35,代码来源:TestNamingContext.java

示例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());
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:28,代码来源:TestNamingContext.java

示例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);
}
 
开发者ID:seraphy,项目名称:EmbeddedTomcatLauncher,代码行数:44,代码来源:SimpleServerConfigurator3.java


注:本文中的org.apache.catalina.deploy.ContextResource.setProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。