use of com.sun.enterprise.config.serverbeans.SystemPropertyBag in project Payara by payara.
the class CreateSystemProperties method execute.
/**
* Executes the command with the command parameters passed as Properties
* where the keys are the paramter names and the values the parameter values
*
* @param context information
*/
@Override
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
String sysPropName = "";
try {
for (final Object key : properties.keySet()) {
final String propName = (String) key;
sysPropName = propName;
// value of an existing property
try {
TranslatedConfigView.doSubstitution.set(Boolean.FALSE);
if (spb.containsProperty(sysPropName) && spb.getSystemProperty(sysPropName).getValue().equals(properties.getProperty(propName))) {
continue;
}
} finally {
TranslatedConfigView.doSubstitution.set(Boolean.TRUE);
}
ConfigSupport.apply(new SingleConfigCode<SystemPropertyBag>() {
@Override
public Object run(SystemPropertyBag param) throws PropertyVetoException, TransactionFailure {
// update existing system property
for (SystemProperty sysProperty : param.getSystemProperty()) {
if (sysProperty.getName().equals(propName)) {
Transaction t = Transaction.getTransaction(param);
sysProperty = t.enroll(sysProperty);
sysProperty.setValue(properties.getProperty(propName));
return sysProperty;
}
}
// create system-property
SystemProperty newSysProp = param.createChild(SystemProperty.class);
newSysProp.setName(propName);
newSysProp.setValue(properties.getProperty(propName));
param.getSystemProperty().add(newSysProp);
return newSysProp;
}
}, spb);
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
} catch (TransactionFailure tfe) {
report.setMessage(localStrings.getLocalString("create.system.properties.failed", "System property {0} creation failed", sysPropName));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(tfe);
} catch (Exception e) {
report.setMessage(localStrings.getLocalString("create.system.properties.failed", "System property {0} creation failed", sysPropName));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
}
}
use of com.sun.enterprise.config.serverbeans.SystemPropertyBag in project Payara by payara.
the class DeleteModuleConfigCommand method removeCustomTokens.
private static <T extends ConfigBeanProxy> boolean removeCustomTokens(final ConfigBeanDefaultValue configBeanDefaultValue, T finalConfigBean, ConfigBeanProxy parent) throws TransactionFailure, PropertyVetoException {
if (parent instanceof SystemPropertyBag) {
removeSystemPropertyForTokens(configBeanDefaultValue.getCustomizationTokens(), (SystemPropertyBag) parent);
return true;
} else {
ConfigBeanProxy curParent = finalConfigBean;
while (!(curParent instanceof SystemPropertyBag)) {
curParent = curParent.getParent();
}
if (!configBeanDefaultValue.getCustomizationTokens().isEmpty()) {
final SystemPropertyBag bag = (SystemPropertyBag) curParent;
final List<ConfigCustomizationToken> tokens = configBeanDefaultValue.getCustomizationTokens();
removeSystemPropertyForTokens(tokens, bag);
return true;
}
return false;
}
}
use of com.sun.enterprise.config.serverbeans.SystemPropertyBag in project Payara by payara.
the class ConfigModularityUtils method applyCustomTokens.
public synchronized <T extends ConfigBeanProxy> void applyCustomTokens(final ConfigBeanDefaultValue configBeanDefaultValue, T finalConfigBean, ConfigBeanProxy parent) throws TransactionFailure, PropertyVetoException {
// then that is the freaking parent, get it and set the SystemProperty :D
if (parent instanceof SystemPropertyBag) {
addSystemPropertyForToken(configBeanDefaultValue.getCustomizationTokens(), (SystemPropertyBag) parent);
} else {
ConfigBeanProxy curParent = finalConfigBean;
while (!(curParent instanceof SystemPropertyBag)) {
curParent = curParent.getParent();
}
if (configBeanDefaultValue.getCustomizationTokens().size() != 0) {
final boolean oldIP = isIgnorePersisting();
try {
setIgnorePersisting(true);
final SystemPropertyBag bag = (SystemPropertyBag) curParent;
final List<ConfigCustomizationToken> tokens = configBeanDefaultValue.getCustomizationTokens();
ConfigSupport.apply(new SingleConfigCode<SystemPropertyBag>() {
public Object run(SystemPropertyBag param) throws PropertyVetoException, TransactionFailure {
addSystemPropertyForToken(tokens, bag);
return param;
}
}, bag);
} finally {
setIgnorePersisting(oldIP);
}
}
}
}
use of com.sun.enterprise.config.serverbeans.SystemPropertyBag in project Payara by payara.
the class CLIUtil method chooseTarget.
static SystemPropertyBag chooseTarget(final Domain domain, final String target) {
SystemPropertyBag spb = null;
Property domainProp = domain.getProperty("administrative.domain.name");
String domainName = domainProp.getValue();
if ("domain".equals(target) || target.equals(domainName)) {
spb = domain;
} else {
spb = domain.getConfigNamed(target);
if (spb == null) {
spb = domain.getClusterNamed(target);
}
if (spb == null) {
spb = domain.getServerNamed(target);
}
}
return spb;
}
Aggregations