Using Factory Methods

To enable JMX clients to control MBean life cycles, WebLogic Server MBeans contain operations that follow the design pattern for Java bean factory methods: for each child, a parent MBean contains a createChild and destroyChild operation, where Child is the short name of the MBean�s type. (The short name is the MBean�s unqualified type name without the MBean suffix. For example, createServer). The parent also contains a lookupChild operation and a Children attribute, where Children is the plural form of an MBean�s type name.

Creator methods take a name parameter. WebLogic Server encodes the name value into the MBean's JMX object name, thus creating a unique object name for the MBean instance. For example, if you invoke:
MBeanServerConnection.invoke(DomainMBean-object-name,
    "createServer",
    new Object[] {"myserver"}
    new String[] {"java.lang.String"} )
,
WebLogic Server creates an instance of ServerMBean and registers it in the MBean server with the following object name:
mydomain:Name=myserver,Type=Server

Destroyer methods take as a parameter the object name of the MBean that you want to destroy. For example, to destroy the ServerMBean that you created above, get the MBean's object name by doing the following:
ObjectName server = (ObjectName) MBeanServerConnection.invoke(DomainMBean-object-name,
    "lookupServer",
    new Object[] {"myserver"}
    new String[] {"java.lang.String"} )

Then pass the output of this method to the destroyer method:
MBeanServerConnection.invoke(DomainMBean-object-name,
    "destroyServer",
    new Object[] {server}
    new String[] {"javax.management.ObjectName"} )


Oracle Fusion Middleware Oracle WebLogic Server MBean Reference
11g Release 1 (10.3.5)
Part Number E13951-05