Search in sources :

Example 1 with ManagedBean

use of org.apache.tomcat.util.modeler.ManagedBean in project tomcat by apache.

the class MBeanUtils method createMBean.

/**
     * Create, register, and return an MBean for this
     * <code>Role</code> object.
     *
     * @param role The Role to be managed
     * @return a new MBean
     * @exception Exception if an MBean cannot be created or registered
     */
static DynamicMBean createMBean(Role role) throws Exception {
    String mname = createManagedName(role);
    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(role);
    ObjectName oname = createObjectName(domain, role);
    if (mserver.isRegistered(oname)) {
        mserver.unregisterMBean(oname);
    }
    mserver.registerMBean(mbean, oname);
    return (mbean);
}
Also used : DynamicMBean(javax.management.DynamicMBean) MBeanException(javax.management.MBeanException) ManagedBean(org.apache.tomcat.util.modeler.ManagedBean) MalformedObjectNameException(javax.management.MalformedObjectNameException) MBeanException(javax.management.MBeanException) ObjectName(javax.management.ObjectName)

Example 2 with ManagedBean

use of org.apache.tomcat.util.modeler.ManagedBean in project tomcat by apache.

the class MBeanUtils method destroyMBean.

/**
     * Deregister the MBean for this
     * <code>ContextResourceLink</code> object.
     *
     * @param resourceLink The ContextResourceLink to be managed
     *
     * @exception Exception if an MBean cannot be deregistered
     */
public static void destroyMBean(ContextResourceLink resourceLink) throws Exception {
    String mname = createManagedName(resourceLink);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        return;
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ObjectName oname = createObjectName(domain, resourceLink);
    if (mserver.isRegistered(oname))
        mserver.unregisterMBean(oname);
}
Also used : ManagedBean(org.apache.tomcat.util.modeler.ManagedBean) ObjectName(javax.management.ObjectName)

Example 3 with ManagedBean

use of org.apache.tomcat.util.modeler.ManagedBean in project tomcat by apache.

the class MBeanUtils method createMBean.

/**
     * Create, register, and return an MBean for this
     * <code>ContextResource</code> object.
     *
     * @param resource The ContextResource to be managed
     * @return a new MBean
     * @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);
}
Also used : DynamicMBean(javax.management.DynamicMBean) MBeanException(javax.management.MBeanException) ManagedBean(org.apache.tomcat.util.modeler.ManagedBean) MalformedObjectNameException(javax.management.MalformedObjectNameException) MBeanException(javax.management.MBeanException) ObjectName(javax.management.ObjectName)

Example 4 with ManagedBean

use of org.apache.tomcat.util.modeler.ManagedBean in project tomcat by apache.

the class MBeanUtils method destroyMBean.

/**
     * Deregister the MBean for this
     * <code>Group</code> object.
     *
     * @param group The Group to be managed
     *
     * @exception Exception if an MBean cannot be deregistered
     */
static void destroyMBean(Group group) throws Exception {
    String mname = createManagedName(group);
    ManagedBean managed = registry.findManagedBean(mname);
    if (managed == null) {
        return;
    }
    String domain = managed.getDomain();
    if (domain == null)
        domain = mserver.getDefaultDomain();
    ObjectName oname = createObjectName(domain, group);
    if (mserver.isRegistered(oname))
        mserver.unregisterMBean(oname);
}
Also used : ManagedBean(org.apache.tomcat.util.modeler.ManagedBean) ObjectName(javax.management.ObjectName)

Example 5 with ManagedBean

use of org.apache.tomcat.util.modeler.ManagedBean in project tomcat by apache.

the class MBeanUtils method createMBean.

/**
     * Create, register, and return an MBean for this
     * <code>UserDatabase</code> object.
     *
     * @param userDatabase The UserDatabase to be managed
     * @return a new MBean
     * @exception Exception if an MBean cannot be created or registered
     */
static DynamicMBean createMBean(UserDatabase userDatabase) throws Exception {
    String mname = createManagedName(userDatabase);
    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(userDatabase);
    ObjectName oname = createObjectName(domain, userDatabase);
    if (mserver.isRegistered(oname)) {
        mserver.unregisterMBean(oname);
    }
    mserver.registerMBean(mbean, oname);
    return (mbean);
}
Also used : DynamicMBean(javax.management.DynamicMBean) MBeanException(javax.management.MBeanException) ManagedBean(org.apache.tomcat.util.modeler.ManagedBean) MalformedObjectNameException(javax.management.MalformedObjectNameException) MBeanException(javax.management.MBeanException) ObjectName(javax.management.ObjectName)

Aggregations

ManagedBean (org.apache.tomcat.util.modeler.ManagedBean)19 ObjectName (javax.management.ObjectName)16 DynamicMBean (javax.management.DynamicMBean)7 MBeanException (javax.management.MBeanException)7 MalformedObjectNameException (javax.management.MalformedObjectNameException)7 NamingResourcesImpl (org.apache.catalina.deploy.NamingResourcesImpl)3 InputStream (java.io.InputStream)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 Hashtable (java.util.Hashtable)1 ContextEnvironment (org.apache.tomcat.util.descriptor.web.ContextEnvironment)1 ContextResource (org.apache.tomcat.util.descriptor.web.ContextResource)1 ContextResourceLink (org.apache.tomcat.util.descriptor.web.ContextResourceLink)1 AttributeInfo (org.apache.tomcat.util.modeler.AttributeInfo)1 OperationInfo (org.apache.tomcat.util.modeler.OperationInfo)1 ParameterInfo (org.apache.tomcat.util.modeler.ParameterInfo)1