use of com.sun.enterprise.config.modularity.customization.ConfigCustomizationToken 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.modularity.customization.ConfigCustomizationToken in project Payara by payara.
the class ConfigModularityUtils method replacePropertiesWithCurrentValue.
public String replacePropertiesWithCurrentValue(String xmlConfiguration, ConfigBeanDefaultValue value) throws InvocationTargetException, IllegalAccessException {
for (ConfigCustomizationToken token : value.getCustomizationTokens()) {
String toReplace = "${" + token.getName() + "}";
ConfigBeanProxy current = getCurrentConfigBeanForDefaultValue(value);
String propertyValue = getPropertyValue(token, current);
if (propertyValue != null) {
xmlConfiguration = xmlConfiguration.replace(toReplace, propertyValue);
}
}
return xmlConfiguration;
}
use of com.sun.enterprise.config.modularity.customization.ConfigCustomizationToken in project Payara by payara.
the class ConfigModularityUtils method addSystemPropertyForToken.
public void addSystemPropertyForToken(List<ConfigCustomizationToken> tokens, SystemPropertyBag bag) throws TransactionFailure, PropertyVetoException {
for (ConfigCustomizationToken token : tokens) {
if (!bag.containsProperty(token.getName())) {
SystemProperty prop = bag.createChild(SystemProperty.class);
prop.setName(token.getName());
prop.setDescription(token.getDescription());
prop.setValue(token.getValue());
bag.getSystemProperty().add(prop);
}
}
}
use of com.sun.enterprise.config.modularity.customization.ConfigCustomizationToken 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.modularity.customization.ConfigCustomizationToken in project Payara by payara.
the class CreateModuleConfigCommand method replacePropertiesWithDefaultValues.
private String replacePropertiesWithDefaultValues(List<ConfigCustomizationToken> tokens, String xmlConfig) {
for (ConfigCustomizationToken token : tokens) {
String toReplace = "\\$\\{" + token.getName() + "\\}";
xmlConfig = xmlConfig.replaceAll(toReplace, token.getValue());
}
return xmlConfig;
}
Aggregations