{
String msg = localStrings.getString( "admin.server.core.mbean.config.null_name" );
throw new IllegalArgumentException( msg );
}
ServerManager sm = ServerManager.instance();
/* get running status */
if(!sm.instanceExists(instanceName))
{
String msg = localStrings.getString(
"admin.server.core.mbean.config.instance_does_not_exist",
instanceName);
throw new ControlException(msg);
}
boolean alive = false;
RMIClient serverInstancePinger = AdminChannel.getRMIClient(instanceName);
alive = serverInstancePinger.isAlive();
if(alive)
{
String msg = localStrings.getString(
"admin.server.core.mbean.config.delete_alive_instance",
instanceName);
throw new ControlException(msg);
}
try
{
// Unregister all instance related MBeans
MBeanServer mbs = MBeanServerFactory.getMBeanServer();
ObjectName[] objectNames = ObjectNameHelper.
getInstanceRelatedMBeans(mbs, instanceName);
for(int i=0; i<objectNames.length; i++)
{
try
{
mbs.unregisterMBean(objectNames[i]);
}
catch(Exception e)
{
sLogger.log(Level.CONFIG, "delete_unregistration_failed",
objectNames[i]);
}
}
// Message to Config to refresh contexts
InstanceEnvironment instanceEnvironment = new
InstanceEnvironment(instanceName);
String fileUrl = instanceEnvironment.getConfigFilePath();
ConfigFactory.removeConfigContext(fileUrl);
String instanceRoot = instanceEnvironment.getInstancesRoot();
deleteJMSProviderInstance(instanceRoot, instanceName);
// Now stop it delete the files from file system */
sm.deleteServerInstance(instanceName);
sLogger.log(Level.INFO, "mbean.del_instance_ok", instanceName);
}
catch(Exception e)
{
sLogger.log(Level.WARNING, "mbean.del_instance_failed", e);