Search in sources :

Example 1 with ConfigCustomizationToken

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;
    }
}
Also used : ConfigBeanProxy(org.jvnet.hk2.config.ConfigBeanProxy) ConfigCustomizationToken(com.sun.enterprise.config.modularity.customization.ConfigCustomizationToken) SystemPropertyBag(com.sun.enterprise.config.serverbeans.SystemPropertyBag)

Example 2 with ConfigCustomizationToken

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;
}
Also used : ConfigBeanProxy(org.jvnet.hk2.config.ConfigBeanProxy) ConfigCustomizationToken(com.sun.enterprise.config.modularity.customization.ConfigCustomizationToken)

Example 3 with ConfigCustomizationToken

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);
        }
    }
}
Also used : ConfigCustomizationToken(com.sun.enterprise.config.modularity.customization.ConfigCustomizationToken) SystemProperty(com.sun.enterprise.config.serverbeans.SystemProperty)

Example 4 with ConfigCustomizationToken

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);
            }
        }
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) TransactionFailure(org.jvnet.hk2.config.TransactionFailure) ConfigBeanProxy(org.jvnet.hk2.config.ConfigBeanProxy) ConfigCustomizationToken(com.sun.enterprise.config.modularity.customization.ConfigCustomizationToken) SystemPropertyBag(com.sun.enterprise.config.serverbeans.SystemPropertyBag)

Example 5 with ConfigCustomizationToken

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;
}
Also used : ConfigCustomizationToken(com.sun.enterprise.config.modularity.customization.ConfigCustomizationToken)

Aggregations

ConfigCustomizationToken (com.sun.enterprise.config.modularity.customization.ConfigCustomizationToken)8 ConfigBeanProxy (org.jvnet.hk2.config.ConfigBeanProxy)3 FileTypeDetails (com.sun.enterprise.config.modularity.customization.FileTypeDetails)2 PortTypeDetails (com.sun.enterprise.config.modularity.customization.PortTypeDetails)2 SystemPropertyBag (com.sun.enterprise.config.serverbeans.SystemPropertyBag)2 DomainException (com.sun.enterprise.admin.servermgmt.DomainException)1 ConfigBeanDefaultValue (com.sun.enterprise.config.modularity.customization.ConfigBeanDefaultValue)1 CustomizationTokensProvider (com.sun.enterprise.config.modularity.customization.CustomizationTokensProvider)1 TokenTypeDetails (com.sun.enterprise.config.modularity.customization.TokenTypeDetails)1 SystemProperty (com.sun.enterprise.config.serverbeans.SystemProperty)1 ConfigApiTest (com.sun.enterprise.configapi.tests.ConfigApiTest)1 PropertyVetoException (java.beans.PropertyVetoException)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Properties (java.util.Properties)1 XMLEventReader (javax.xml.stream.XMLEventReader)1 XMLInputFactory (javax.xml.stream.XMLInputFactory)1