• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ContextResource类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



ContextResource类属于org.apache.catalina.deploy包,在下文中一共展示了ContextResource类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getResources

import org.apache.catalina.deploy.ContextResource; //导入依赖的package包/类
/**
 * Return the MBean Names of all the defined resource references for this
 * application.
 */
public String[] getResources() {
    
    ContextResource[] resources = 
                        ((NamingResources)this.resource).findResources();
    ArrayList<String> results = new ArrayList<String>();
    for (int i = 0; i < resources.length; i++) {
        try {
            ObjectName oname =
                MBeanUtils.createObjectName(managed.getDomain(), resources[i]);
            results.add(oname.toString());
        } catch (MalformedObjectNameException e) {
            IllegalArgumentException iae = new IllegalArgumentException
                ("Cannot create object name for resource " + resources[i]);
            iae.initCause(e);
            throw iae;
        }
    }
    return results.toArray(new String[results.size()]);

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


示例2: createMBean

import org.apache.catalina.deploy.ContextResource; //导入依赖的package包/类
/**
 * Create, register, and return an MBean for this
 * <code>ContextResource</code> object.
 *
 * @param resource The ContextResource to be managed
 *
 * @exception Exception if an MBean cannot be created or registered
 */
public static DynamicMBean createMBean(ContextResource resource)
    throws Exception {

    String mname = createManagedName(resource);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        Exception e = new Exception("ManagedBean is not found with "+mname);
        throw new MBeanException(e);
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    DynamicMBean mbean = managed.createMBean(resource);
    ObjectName oname = createObjectName(domain, resource);
    if( mserver.isRegistered( oname ))  {
        mserver.unregisterMBean(oname);
    }
    mserver.registerMBean(mbean, oname);
    return (mbean);

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


示例3: destroyMBean

import org.apache.catalina.deploy.ContextResource; //导入依赖的package包/类
/**
 * Deregister the MBean for this
 * <code>ContextResource</code> object.
 *
 * @param resource The ContextResource to be managed
 *
 * @exception Exception if an MBean cannot be deregistered
 */
public static void destroyMBean(ContextResource resource)
    throws Exception {

    // If this is a user database resource need to destroy groups, roles,
    // users and UserDatabase mbean
    if ("org.apache.catalina.UserDatabase".equals(resource.getType())) {
        destroyMBeanUserDatabase(resource.getName());
    }

    String mname = createManagedName(resource);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        return;
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ObjectName oname = createObjectName(domain, resource);
    if( mserver.isRegistered(oname ))
        mserver.unregisterMBean(oname);

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


示例4: 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


示例5: 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


示例6: getResources

import org.apache.catalina.deploy.ContextResource; //导入依赖的package包/类
/**
 * Return the MBean Names of all the defined resource references for this
 * application.
 */
public String[] getResources() {
    
    ContextResource[] resources = 
                        ((NamingResources)this.resource).findResources();
    ArrayList results = new ArrayList();
    for (int i = 0; i < resources.length; i++) {
        try {
            ObjectName oname =
                MBeanUtils.createObjectName(managed.getDomain(), resources[i]);
            results.add(oname.toString());
        } catch (MalformedObjectNameException e) {
            IllegalArgumentException iae = new IllegalArgumentException
                ("Cannot create object name for resource " + resources[i]);
            iae.initCause(e);
            throw iae;
        }
    }
    return ((String[]) results.toArray(new String[results.size()]));

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:NamingResourcesMBean.java


示例7: getResources

import org.apache.catalina.deploy.ContextResource; //导入依赖的package包/类
/**
 * Return the MBean Names of all the defined resource references for this
 * application.
 */
public String[] getResources() {
    
    ContextResource[] resources = getNamingResources().findResources();
    ArrayList results = new ArrayList();
    for (int i = 0; i < resources.length; i++) {
        try {
            ObjectName oname =
                MBeanUtils.createObjectName(managed.getDomain(), resources[i]);
            results.add(oname.toString());
        } catch (MalformedObjectNameException e) {
            IllegalArgumentException iae = new IllegalArgumentException
                ("Cannot create object name for resource " + resources[i]);
            iae.initCause(e);
            throw iae;
        }
    }
    return ((String[]) results.toArray(new String[results.size()]));

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:StandardContextMBean.java


示例8: createMBean

import org.apache.catalina.deploy.ContextResource; //导入依赖的package包/类
/**
 * Create, register, and return an MBean for this
 * <code>ContextResource</code> object.
 *
 * @param resource The ContextResource to be managed
 *
 * @exception Exception if an MBean cannot be created or registered
 */
static DynamicMBean createMBean(ContextResource resource)
    throws Exception {

    String mname = createManagedName(resource);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        Exception e = new Exception("ManagedBean is not found with "+mname);
        throw new MBeanException(e);
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    DynamicMBean mbean = managed.createMBean(resource);
    ObjectName oname = createObjectName(domain, resource);
    if( mserver.isRegistered( oname ))  {
        mserver.unregisterMBean(oname);
    }
    mserver.registerMBean(mbean, oname);
    return (mbean);

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:30,代码来源:MBeanUtils.java


示例9: destroyMBean

import org.apache.catalina.deploy.ContextResource; //导入依赖的package包/类
/**
 * Deregister the MBean for this
 * <code>ContextResource</code> object.
 *
 * @param resource The ContextResource to be managed
 *
 * @exception Exception if an MBean cannot be deregistered
 */
static void destroyMBean(ContextResource resource)
    throws Exception {

    String mname = createManagedName(resource);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        return;
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ObjectName oname = createObjectName(domain, resource);
    if( mserver.isRegistered(oname ))
        mserver.unregisterMBean(oname);

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:MBeanUtils.java


示例10: getResources

import org.apache.catalina.deploy.ContextResource; //导入依赖的package包/类
/**
 * Return the MBean Names of all the defined resource references for this
 * application.
 */
public String[] getResources() {
    
    ContextResource[] resources = 
                        ((NamingResources)this.resource).findResources();
    ArrayList results = new ArrayList();
    for (int i = 0; i < resources.length; i++) {
        try {
            ObjectName oname =
                MBeanUtils.createObjectName(managed.getDomain(), resources[i]);
            results.add(oname.toString());
        } catch (MalformedObjectNameException e) {
            throw new IllegalArgumentException
                ("Cannot create object name for resource " + resources[i]);
        }
    }
    return ((String[]) results.toArray(new String[results.size()]));

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:23,代码来源:NamingResourcesMBean.java


示例11: getResources

import org.apache.catalina.deploy.ContextResource; //导入依赖的package包/类
/**
 * Return the MBean Names of all the defined resource references for this
 * application.
 */
public String[] getResources() {
    
    ContextResource[] resources = getNamingResources().findResources();
    ArrayList results = new ArrayList();
    for (int i = 0; i < resources.length; i++) {
        try {
            ObjectName oname =
                MBeanUtils.createObjectName(managed.getDomain(), resources[i]);
            results.add(oname.toString());
        } catch (MalformedObjectNameException e) {
            throw new IllegalArgumentException
                ("Cannot create object name for resource " + resources[i]);
        }
    }
    return ((String[]) results.toArray(new String[results.size()]));

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:22,代码来源:StandardContextMBean.java


示例12: createMBean

import org.apache.catalina.deploy.ContextResource; //导入依赖的package包/类
/**
 * Create, register, and return an MBean for this
 * <code>ContextResource</code> object.
 *
 * @param resource The ContextResource to be managed
 *
 * @exception Exception if an MBean cannot be created or registered
 */
public static ModelMBean createMBean(ContextResource resource)
    throws Exception {

    String mname = createManagedName(resource);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        Exception e = new Exception("ManagedBean is not found with "+mname);
        throw new MBeanException(e);
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ModelMBean mbean = managed.createMBean(resource);
    ObjectName oname = createObjectName(domain, resource);
    mserver.registerMBean(mbean, oname);
    return (mbean);

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:27,代码来源:MBeanUtils.java


示例13: destroyMBean

import org.apache.catalina.deploy.ContextResource; //导入依赖的package包/类
/**
 * Deregister the MBean for this
 * <code>ContextResource</code> object.
 *
 * @param resource The ContextResource to be managed
 *
 * @exception Exception if an MBean cannot be deregistered
 */
public static void destroyMBean(ContextResource resource)
    throws Exception {

    String mname = createManagedName(resource);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        return;
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ObjectName oname = createObjectName(domain, resource);
    mserver.unregisterMBean(oname);

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:24,代码来源:MBeanUtils.java


示例14: addResource

import org.apache.catalina.deploy.ContextResource; //导入依赖的package包/类
/**
 * Set the specified resources in the naming context.
 */
public void addResource(ContextResource resource) {

    // Create a reference to the resource.
    Reference ref = new ResourceRef
        (resource.getType(), resource.getDescription(),
         resource.getScope(), resource.getAuth());
    // Adding the additional parameters, if any
    addAdditionalParameters(resource.getNamingResources(), ref, 
                            resource.getName());
    try {
        if (debug >= 2) {
            log("  Adding resource ref " + resource.getName());
            log("  " + ref);
        }
        createSubcontexts(envCtx, resource.getName());
        envCtx.bind(resource.getName(), ref);
    } catch (NamingException e) {
        log(sm.getString("naming.bindFailed", e));
    }

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:25,代码来源:NamingContextListener.java


示例15: getResources

import org.apache.catalina.deploy.ContextResource; //导入依赖的package包/类
/**
 * Return the MBean Names of all the defined resource references for this
 * application.
 */
public String[] getResources() {

	ContextResource[] resources = ((NamingResources) this.resource).findResources();
	ArrayList<String> results = new ArrayList<String>();
	for (int i = 0; i < resources.length; i++) {
		try {
			ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), resources[i]);
			results.add(oname.toString());
		} catch (MalformedObjectNameException e) {
			IllegalArgumentException iae = new IllegalArgumentException(
					"Cannot create object name for resource " + resources[i]);
			iae.initCause(e);
			throw iae;
		}
	}
	return results.toArray(new String[results.size()]);

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:23,代码来源:NamingResourcesMBean.java


示例16: createMBean

import org.apache.catalina.deploy.ContextResource; //导入依赖的package包/类
/**
 * Create, register, and return an MBean for this
 * <code>ContextResource</code> object.
 *
 * @param resource
 *            The ContextResource to be managed
 *
 * @exception Exception
 *                if an MBean cannot be created or registered
 */
public static DynamicMBean createMBean(ContextResource resource) throws Exception {

	String mname = createManagedName(resource);
	ManagedBean managed = registry.findManagedBean(mname);
	if (managed == null) {
		Exception e = new Exception("ManagedBean is not found with " + mname);
		throw new MBeanException(e);
	}
	String domain = managed.getDomain();
	if (domain == null)
		domain = mserver.getDefaultDomain();
	DynamicMBean mbean = managed.createMBean(resource);
	ObjectName oname = createObjectName(domain, resource);
	if (mserver.isRegistered(oname)) {
		mserver.unregisterMBean(oname);
	}
	mserver.registerMBean(mbean, oname);
	return (mbean);

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:31,代码来源:MBeanUtils.java


示例17: destroyMBean

import org.apache.catalina.deploy.ContextResource; //导入依赖的package包/类
/**
 * Deregister the MBean for this <code>ContextResource</code> object.
 *
 * @param resource
 *            The ContextResource to be managed
 *
 * @exception Exception
 *                if an MBean cannot be deregistered
 */
public static void destroyMBean(ContextResource resource) throws Exception {

	// If this is a user database resource need to destroy groups, roles,
	// users and UserDatabase mbean
	if ("org.apache.catalina.UserDatabase".equals(resource.getType())) {
		destroyMBeanUserDatabase(resource.getName());
	}

	String mname = createManagedName(resource);
	ManagedBean managed = registry.findManagedBean(mname);
	if (managed == null) {
		return;
	}
	String domain = managed.getDomain();
	if (domain == null)
		domain = mserver.getDefaultDomain();
	ObjectName oname = createObjectName(domain, resource);
	if (mserver.isRegistered(oname))
		mserver.unregisterMBean(oname);

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:31,代码来源:MBeanUtils.java


示例18: addContextResource

import org.apache.catalina.deploy.ContextResource; //导入依赖的package包/类
@Override
public void addContextResource(Context context, List<ApplicationResource> resourceList,
    boolean contextBound) {
  NamingResources namingResources = context.getNamingResources();
  for (ContextResource contextResource : namingResources.findResources()) {
    ApplicationResource resource = new ApplicationResource();

    logger.info("reading resource: {}", contextResource.getName());
    resource.setApplicationName(context.getName());
    resource.setName(contextResource.getName());
    resource.setType(contextResource.getType());
    resource.setScope(contextResource.getScope());
    resource.setAuth(contextResource.getAuth());
    resource.setDescription(contextResource.getDescription());

    resourceList.add(resource);
  }
}
 
开发者ID:psi-probe,项目名称:psi-probe,代码行数:19,代码来源:Tomcat70ContainerAdapter.java


示例19: 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


示例20: addContextResource

import org.apache.catalina.deploy.ContextResource; //导入依赖的package包/类
public void addContextResource(Context context, List resourceList,
		boolean contextBound) {
	NamingResources namingResources = context.getNamingResources();
	ContextResource[] resources = namingResources.findResources();
           
	for (int i = 0; i < resources.length; i++) {
	    ContextResource contextResource = resources[i];
	    ApplicationResource resource = new ApplicationResource();

	    logger.info("reading resource: " + contextResource.getName());
	    resource.setApplicationName(context.getName());
	    resource.setName(contextResource.getName());
	    resource.setType(contextResource.getType());
	    resource.setScope(contextResource.getScope());
	    resource.setAuth(contextResource.getAuth());
	    resource.setDescription(contextResource.getDescription());

	    //lookupResource(resource, contextBound, false);

	    resourceList.add(resource);
	}
}
 
开发者ID:andresol,项目名称:psi-probe-plus,代码行数:23,代码来源:Tomcat55ContainerAdaptor.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Painter类代码示例发布时间:2022-05-22
下一篇:
Java NamenodeProtocols类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap