return;
}
}
catch (Exception e)
{
throw new InitialisationException(e, this);
}
if (mBeanServer == null && createServer)
{
// here we create a new mbean server, not using a platform one
mBeanServer = MBeanServerFactory.createMBeanServer();
serverCreated.set(true);
}
if (mBeanServer == null && locateServer)
{
mBeanServer = ManagementFactory.getPlatformMBeanServer();
}
if (mBeanServer == null)
{
throw new InitialisationException(ManagementMessages.cannotLocateOrCreateServer(), this);
}
if (StringUtils.isBlank(muleContext.getConfiguration().getId()))
{
// TODO i18n the message properly
throw new IllegalArgumentException(
"Manager ID is mandatory when running with JmxAgent. Give your Mule configuration a valid ID.");
}
try
{
// We need to register all the services once the server has initialised
muleContext.registerListener(new MuleContextStartedListener());
// and unregister once context stopped
muleContext.registerListener(new MuleContextStoppedListener());
}
catch (NotificationException e)
{
throw new InitialisationException(e, this);
}
initialized.compareAndSet(false, true);
}