}
// If class is given, instantiate it
String code = mbeanElement.getAttribute("code");
if ( code == null || "".equals(code))
{
throw new ConfigurationException("missing 'code' attribute");
}
// get the constructor params/sig to use
ConstructorInfo constructor = ConstructorInfo.create(mbeanElement);
// Check for xmbean specific attributes
String xmbeandd = null;
Attr xmbeanddAttr = mbeanElement.getAttributeNode("xmbean-dd");
if( xmbeanddAttr != null )
xmbeandd = xmbeanddAttr.getValue();
String xmbeanCode = mbeanElement.getAttribute("xmbean-code");
if( xmbeanCode.length() == 0 )
xmbeanCode = XMBEAN_CODE;
// Create the mbean instance
ObjectInstance instance = null;
try
{
if ( xmbeandd == null )
{
// Check for the explicit management interface in case of a standard MBean
Attr itfAttr = mbeanElement.getAttributeNode("interface");
if (itfAttr != null)
{
// Get the good class loader
ClassLoader classLoader = server.getClassLoader(loaderName);
// Load interface class
String itf = itfAttr.getValue();
Class itfClass = classLoader.loadClass(itf);
log.debug("About to create bean resource: " + mbeanName + " with code: " + code);
Object resource = server.instantiate(code,
loaderName,
constructor.params,
constructor.signature);
//
log.debug("About to register StandardMBean : " + mbeanName);
instance = server.createMBean("javax.management.StandardMBean",
mbeanName,
loaderName,
new Object[]{resource,itfClass},
new String[]{Object.class.getName(),Class.class.getName()});
}
else
{
// This is a standard or dynamic mbean
log.debug("About to create bean: " + mbeanName + " with code: " + code);
instance = server.createMBean(code,
mbeanName,
loaderName,
constructor.params,
constructor.signature);
}
} // end of if ()
else if( xmbeandd.length() == 0 )
{
// This is an xmbean with an embedded mbean descriptor
log.debug("About to create xmbean object: " + mbeanName
+ " with code: " + code + " with embedded descriptor");
//xmbean: construct object first.
Object resource = server.instantiate(code, loaderName,
constructor.params, constructor.signature);
NodeList mbeans = mbeanElement.getElementsByTagName("xmbean");
if( mbeans.getLength() == 0 )
throw new ConfigurationException("No nested mbean element given for xmbean");
Element mbeanDescriptor = (Element) mbeans.item(0);
Object[] args = {resource, mbeanDescriptor,
ServiceConstants.PUBLIC_JBOSSMX_XMBEAN_DTD_1_0};
String[] sig = {Object.class.getName(), Element.class.getName(),
String.class.getName()};