本文整理汇总了Java中org.apache.catalina.deploy.ContextResource类的典型用法代码示例。如果您正苦于以下问题:Java ContextResource类的具体用法?Java ContextResource怎么用?Java ContextResource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ContextResource类属于org.apache.catalina.deploy包,在下文中一共展示了ContextResource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()]);
}
示例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);
}
示例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);
}
示例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());
}
示例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());
}
示例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()]));
}
示例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()]));
}
示例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);
}
示例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);
}
示例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()]));
}
示例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()]));
}
示例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);
}
示例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);
}
示例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));
}
}
示例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()]);
}