* @param params a Map<String, String> specifying the other parameters optionally needed for mbean
* @param attributes a Map<String, String> specifying the custom MBean initialization attributes
*/
protected String createMBeanDefinitionAddingReferenceToServer(final String s, final Map<String, String> params, final Map<String, String> attributes) throws CustomMBeanException {
try {
final Mbean mbean = this.createMBeanDefinitionInDomain(params, attributes);
final ObjectName onPostReg = new ObjectName(mbean.getObjectName());
// bug 6308668
// the mbean was created but never deleted IN THE CONTEXT
if (onExists(s, onPostReg)) //use references here, because object-name is NOT a primary key unlike name
{
ServerBeansFactory.removeMbeanDefinition(acc, mbean.getName());
throw new CustomMBeanException(CMBStrings.get("AlreadyExists", onPostReg.toString()));
}
ServerBeansFactory.addMbeanReference(this.acc, mbean.getName(), s);
return ( mbean.getName() );
} catch (final Exception e) {
throw new CustomMBeanException(e);
}
}