Search in sources :

Example 1 with ChangePair

use of com.sun.enterprise.admin.servermgmt.xml.stringsubs.ChangePair in project Payara by payara.

the class StringSubstitutionEngine method buildChangePairsMap.

/**
 * Build's a HashMap containing an entry for each <change-pair> in the string-subs
 * configuration file. The HashMap is created so that <change-pair> elements do not
 * need to be re-analyzed each time they're referenced.
 */
private void buildChangePairsMap() {
    if (_changePairsMap == null || _changePairsMap.isEmpty()) {
        Defaults defaults = _root.getDefaults();
        if (defaults != null) {
            List<Property> properties = defaults.getProperty();
            if (!properties.isEmpty()) {
                _defaultProperties = new HashMap<String, Property>(properties.size(), 1);
                for (Property prop : properties) {
                    _defaultProperties.put(prop.getKey(), prop);
                }
            }
        }
        List<? extends ChangePair> changePairList = _root.getChangePair();
        _changePairsMap = new HashMap<String, Pair>(changePairList.size());
        for (ChangePair pair : _root.getChangePair()) {
            String id = pair.getId();
            String beforeValue = pair.getBefore();
            String afterValue = pair.getAfter();
            if (id == null || beforeValue == null || afterValue == null) {
                _logger.log(Level.INFO, SLogger.EMPTY_CHANGE_PAIR);
                continue;
            }
            beforeValue = _attrPreprocessor.substituteBefore(beforeValue);
            afterValue = _attrPreprocessor.substituteAfter(afterValue);
            _changePairsMap.put(id, new Pair(beforeValue, afterValue));
        }
    }
}
Also used : Defaults(com.sun.enterprise.admin.servermgmt.xml.stringsubs.Defaults) ChangePair(com.sun.enterprise.admin.servermgmt.xml.stringsubs.ChangePair) Property(com.sun.enterprise.admin.servermgmt.xml.stringsubs.Property) ChangePair(com.sun.enterprise.admin.servermgmt.xml.stringsubs.ChangePair)

Aggregations

ChangePair (com.sun.enterprise.admin.servermgmt.xml.stringsubs.ChangePair)1 Defaults (com.sun.enterprise.admin.servermgmt.xml.stringsubs.Defaults)1 Property (com.sun.enterprise.admin.servermgmt.xml.stringsubs.Property)1