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 anddestroyChildoperation, whereChildis the short name of the MBean�s type. (The short name is the MBean�s unqualified type name without theMBean suffix. For example,createServer). The parent also contains alookupChild operation and aChildrenattribute, whereChildrenis the plural form of an MBean�s type name.Creator methods take a
name parameter. WebLogic Server encodes thename 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 ofServerMBean and registers it in the MBean server with the following object name:
mydomain:Name=myserver,Type=ServerDestroyer 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"} )