if ( mbeanName == null )
{
throw new IllegalArgumentException();
}
final ManagementRuleConfig ruleConfig =
(ManagementRuleConfig)getFactoryContainer();
ActionConfig actionConfig = ruleConfig.getActionConfig();
if ( actionConfig != null )
{
throw new IllegalStateException( "action already exists as " +
actionConfig.getName() + ", " + actionConfig.getActionMBeanName());
}
final String ruleName = ruleConfig.getName();
getOldManagementRules().addActionToManagementRule( ruleName, mbeanName );
// wait till AMX version makes its appearance
// This is clumsy, but unfortunately the MBean name is not returned by addActionToManagementRule()
while ( (actionConfig = ruleConfig.getActionConfig()) == null )
{
sleepMillis( 10 );
}
final ObjectName amxObjectName = Util.getObjectName( actionConfig );
getCallbacks().sendConfigCreatedNotification( amxObjectName );
return amxObjectName;