}
private void deleteServerFromLBConfig(String configName,String serverName)
throws MBeanException
{
LbConfig lbConfig = getLbConfig(configName);
ServerRef sRef = lbConfig.getServerRefByRef(serverName);
if (sRef == null) {
// does not exist, just return from here
_logger.log(Level.FINEST," server " + serverName +
" does not exist in any cluster in the domain");
String msg = _strMgr.getString("ServerNotDefined",
serverName);
throw new MBeanException(new RuntimeException(msg));
}
if (sRef.isLbEnabled()) {
String msg = _strMgr.getString("ServerNeedsToBeDisabled", serverName);
throw new MBeanException ( new ConfigException(msg));
}
// check if its applications are LB disabled.
Server s = null;
try {
ConfigContext ctx =AdminService.getAdminService().getAdminContext()
.getAdminConfigContext();
s = ServerHelper.getServerByName(ctx, sRef.getRef());
} catch(ConfigException ce) {
throw new MBeanException(ce);
}
if (s == null ) {
String msg = _strMgr.getString("ServerNotDefined", serverName);
throw new MBeanException ( new ConfigException(msg));
}
ApplicationRef[] appRef = s.getApplicationRef();
if (appRef == null ) {
String msg = _strMgr.getString("AppRefsNotDefined", serverName);
throw new MBeanException ( new ConfigException(msg));
}
int i =0;
for(i=0; i < appRef.length; i++) {
if (appRef[i].isLbEnabled()) {
break;
}
}
if ( i < appRef.length) {
String msg = _strMgr.getString("AppsNotDisabled");
throw new MBeanException ( new ConfigException(msg));
}
lbConfig.removeServerRef(sRef);
}