org.apache.catalina.mbeans

## Class MBeanUtils

- java.lang.Object
- - org.apache.catalina.mbeans.MBeanUtils

    public class MBeanUtils
    extends Object

Public utility methods in support of the server side MBeans implementation.

Author:
  Craig R. McClanahan, Amy Roh

### Constructor Summary

Constructors
Constructor and Description
`MBeanUtils()`

### Method Summary

Methods
`static DynamicMBean` `createMBean(ContextEnvironment environment)` Create, register, and return an MBean for this `ContextEnvironment` object.
`static DynamicMBean` `createMBean(ContextResource resource)` Create, register, and return an MBean for this `ContextResource` object.
`static DynamicMBean` `createMBean(ContextResourceLink resourceLink)` Create, register, and return an MBean for this `ContextResourceLink` object.
`static ObjectName` `createObjectName(String domain, ContextEnvironment environment)` Create an `ObjectName` for this `Service` object.
`static ObjectName` `createObjectName(String domain, ContextResource resource)` Create an `ObjectName` for this `ContextResource` object.
`static ObjectName` `createObjectName(String domain, ContextResourceLink resourceLink)` Create an `ObjectName` for this `ContextResourceLink` object.
`static Registry` `createRegistry()` Create and configure (if necessary) and return the registry of managed object descriptions.
`static MBeanServer` `createServer()` Create and configure (if necessary) and return the `MBeanServer` with which we will be registering our `DynamicMBean` implementations.
`static void` `destroyMBean(ContextEnvironment environment)` Deregister the MBean for this `ContextEnvironment` object.
`static void` `destroyMBean(ContextResource resource)` Deregister the MBean for this `ContextResource` object.
`static void` `destroyMBean(ContextResourceLink resourceLink)` Deregister the MBean for this `ContextResourceLink` object.
`static String` `getContainerKeyProperties(Container container)` Deprecated. To be removed since to creates a circular dependency. Will be replaced in Tomcat 8 by a new method on `Container`.
`static String` `getDomain(Container container)` Deprecated. To be removed since to creates a circular dependency. Will be replaced in Tomcat 8 by a new method on `Container`.
`static String` `getDomain(Service service)` Deprecated. To be removed since to creates a circular dependency. Will be replaced in Tomcat 8 by a new method on `Service`.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### MBeanUtils

    public MBeanUtils()

### Method Detail

#### createMBean

    public static DynamicMBean createMBean(ContextEnvironment environment)
                                    throws Exception

Create, register, and return an MBean for this `ContextEnvironment` object.

Parameters:
  `environment` - The ContextEnvironment to be managed
Throws:
  `Exception` - if an MBean cannot be created or registered

#### createMBean

    public static DynamicMBean createMBean(ContextResource resource)
                                    throws Exception

Create, register, and return an MBean for this `ContextResource` object.

Parameters:
  `resource` - The ContextResource to be managed
Throws:
  `Exception` - if an MBean cannot be created or registered

#### createMBean

    public static DynamicMBean createMBean(ContextResourceLink resourceLink)
                                    throws Exception

Create, register, and return an MBean for this `ContextResourceLink` object.

Parameters:
  `resourceLink` - The ContextResourceLink to be managed
Throws:
  `Exception` - if an MBean cannot be created or registered

#### createObjectName

    public static ObjectName createObjectName(String domain,
                              ContextEnvironment environment)
                                       throws MalformedObjectNameException

Create an `ObjectName` for this `Service` object.

Parameters:
  `domain` - Domain in which this name is to be created
  `environment` - The ContextEnvironment to be named
Throws:
  `MalformedObjectNameException` - if a name cannot be created

#### createObjectName

    public static ObjectName createObjectName(String domain,
                              ContextResource resource)
                                       throws MalformedObjectNameException

Create an `ObjectName` for this `ContextResource` object.

Parameters:
  `domain` - Domain in which this name is to be created
  `resource` - The ContextResource to be named
Throws:
  `MalformedObjectNameException` - if a name cannot be created

#### createObjectName

    public static ObjectName createObjectName(String domain,
                              ContextResourceLink resourceLink)
                                       throws MalformedObjectNameException

Create an `ObjectName` for this `ContextResourceLink` object.

Parameters:
  `domain` - Domain in which this name is to be created
  `resourceLink` - The ContextResourceLink to be named
Throws:
  `MalformedObjectNameException` - if a name cannot be created

#### createRegistry

    public static Registry createRegistry()

Create and configure (if necessary) and return the registry of managed object descriptions.

#### createServer

    public static MBeanServer createServer()

Create and configure (if necessary) and return the `MBeanServer` with which we will be registering our `DynamicMBean` implementations.

#### destroyMBean

    public static void destroyMBean(ContextEnvironment environment)
                             throws Exception

Deregister the MBean for this `ContextEnvironment` object.

Parameters:
  `environment` - The ContextEnvironment to be managed
Throws:
  `Exception` - if an MBean cannot be deregistered

#### destroyMBean

    public static void destroyMBean(ContextResource resource)
                             throws Exception

Deregister the MBean for this `ContextResource` object.

Parameters:
  `resource` - The ContextResource to be managed
Throws:
  `Exception` - if an MBean cannot be deregistered

#### destroyMBean

    public static void destroyMBean(ContextResourceLink resourceLink)
                             throws Exception

Deregister the MBean for this `ContextResourceLink` object.

Parameters:
  `resourceLink` - The ContextResourceLink to be managed
Throws:
  `Exception` - if an MBean cannot be deregistered

#### getDomain

    @Deprecated
    public static String getDomain(Service service)

Deprecated. To be removed since to creates a circular dependency. Will be replaced in Tomcat 8 by a new method on `Service`.
Determine the name of the domain to register MBeans for from a given Service.

Parameters:
  `service` -

#### getDomain

    @Deprecated
    public static String getDomain(Container container)

Deprecated. To be removed since to creates a circular dependency. Will be replaced in Tomcat 8 by a new method on `Container`.
Determine the name of the domain to register MBeans for from a given Container.

Parameters:
  `container` -

#### getContainerKeyProperties

    @Deprecated
    public static String getContainerKeyProperties(Container container)

Deprecated. To be removed since to creates a circular dependency. Will be replaced in Tomcat 8 by a new method on `Container`.
Calculate the key properties string to be added to an object's `ObjectName` to indicate that it is associated with that container.

Parameters:
  `container` - The container the object is associated with
Returns:
  A string suitable for appending to the ObjectName