for (String target : targets) {
Server servr = dmn.getServerNamed(target);
if (servr != null) {
// remove the application-ref from standalone
// server instance
ConfigBeanProxy servr_w = t.enroll(servr);
for (ApplicationRef appRef :
servr.getApplicationRef()) {
if (appRef.getRef().equals(appName)) {
((Server)servr_w).getApplicationRef().remove(
appRef);
break;
}
}
}
Cluster cluster = dmn.getClusterNamed(target);
if (cluster != null) {
// remove the application-ref from cluster
ConfigBeanProxy cluster_w = t.enroll(cluster);
for (ApplicationRef appRef :
cluster.getApplicationRef()) {
if (appRef.getRef().equals(appName)) {
((Cluster)cluster_w).getApplicationRef().remove(
appRef);
break;
}
}
// remove the application-ref from cluster instances
for (Server svr : cluster.getInstances() ) {
ConfigBeanProxy svr_w = t.enroll(svr);
for (ApplicationRef appRef :
svr.getApplicationRef()) {
if (appRef.getRef().equals(appName)) {
((Server)svr_w).getApplicationRef(
).remove(appRef);
break;
}
}
}
}
}
if (!appRefOnly) {
// remove application element
Applications apps = dmn.getApplications();
ConfigBeanProxy apps_w = t.enroll(apps);
for (ApplicationName module : apps.getModules()) {
if (module.getName().equals(appName)) {
((Applications)apps_w).getModules().remove(module);
break;
}