throws Exception
{
final ConfigContext configContext = getConfigContext();
//create instance property
final Server server = ServerHelper.getServerByName(configContext,
target.getName());
//Add the properties
final ArrayList removedProperties = new ArrayList();
for (Enumeration e = props.propertyNames(); e.hasMoreElements();) {
final String name = (String)e.nextElement();
//If the property exists, remove it
final SystemProperty sysProp = server.getSystemPropertyByName(name);
if (sysProp != null) {
//Keep track of the properties we have removed in case we have
//to "rollback". WARNING: after calling removeSystemProperty, the
//sysProp will be side affected (with null contents), so make a
//copy of it first.
SystemProperty newProp = new SystemProperty();
newProp.setName(sysProp.getName());
newProp.setValue(sysProp.getValue());
server.removeSystemProperty(sysProp, OVERWRITE);
removedProperties.add(newProp);
}
server.addSystemProperty(getSystemProperty(props, name),
OVERWRITE);
}
//Check for a port conflict after modifying server. If a port conflict occurs,
//we "rollback" the addition of the system properties.
try {
PortConflictCheckerConfigBean portChecker = getPortConflictCheckerConfigBean();
ServersConfigBean scb = getServersConfigBean();
portChecker.checkForPortConflicts(server, props,
scb.isRunning(server.getName()));
} catch (Exception ex2) {
try {
//Delete all the properties that we have added
for (Enumeration e = props.propertyNames(); e.hasMoreElements();) {
final String name = (String)e.nextElement();
final SystemProperty sysProp = server.getSystemPropertyByName(name);
if (sysProp != null) {
server.removeSystemProperty(sysProp, OVERWRITE);
}
}
//Re-add any of the overwritten properties that were deleted.
for (int i = 0; i < removedProperties.size(); i++) {
SystemProperty sysProp = (SystemProperty)removedProperties.get(i);
server.addSystemProperty((SystemProperty)removedProperties.get(i),
OVERWRITE);
}
} catch (Exception ex3) {
//Log
StringManagerBase sm = StringManagerBase.getStringManager(