public void updateAppEnabledAttributeInDomainXML(final String appName,
final String target, final boolean enabled) throws TransactionFailure {
ConfigSupport.apply(new SingleConfigCode() {
public Object run(ConfigBeanProxy param) throws PropertyVetoException, TransactionFailure {
// get the transaction
Transaction t = Transaction.getTransaction(param);
if (t!=null) {
Domain dmn;
if (param instanceof Domain) {
dmn = (Domain)param;
} else {
return Boolean.FALSE;
}
if (enabled || DeploymentUtils.isDomainTarget(target)) {
Application app = dmn.getApplications().getApplication(appName);
ConfigBeanProxy app_w = t.enroll(app);
((Application)app_w).setEnabled(String.valueOf(enabled));
}
List<String> targets = new ArrayList<String>();
if (!DeploymentUtils.isDomainTarget(target)) {
targets.add(target);
} else {
targets = domain.getAllReferencedTargetsForApplication(appName);
}
for (String target : targets) {
Server servr = dmn.getServerNamed(target);
if (servr != null) {
// update the application-ref from standalone
// server instance
for (ApplicationRef appRef :
servr.getApplicationRef()) {
if (appRef.getRef().equals(appName)) {
ConfigBeanProxy appRef_w = t.enroll(appRef);
((ApplicationRef)appRef_w).setEnabled(String.valueOf(enabled));
break;
}
}
updateClusterAppRefWithInstanceUpdate(t, servr, appName, enabled);
}
Cluster cluster = dmn.getClusterNamed(target);
if (cluster != null) {
// update the application-ref from cluster
for (ApplicationRef appRef :
cluster.getApplicationRef()) {
if (appRef.getRef().equals(appName)) {
ConfigBeanProxy appRef_w = t.enroll(appRef);
((ApplicationRef)appRef_w).setEnabled(String.valueOf(enabled));
break;
}
}
// update the application-ref from cluster instances
for (Server svr : cluster.getInstances() ) {
for (ApplicationRef appRef :
svr.getApplicationRef()) {
if (appRef.getRef().equals(appName)) {
ConfigBeanProxy appRef_w = t.enroll(appRef);
((ApplicationRef)appRef_w).setEnabled(String.valueOf(enabled));
break;
}
}
}