Search in sources :

Example 1 with Defaults

use of com.sun.enterprise.admin.servermgmt.xml.stringsubs.Defaults 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)

Example 2 with Defaults

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

the class StringSubstitutionEngine method getDefaultProperties.

@Override
public List<Property> getDefaultProperties(PropertyType type) {
    Defaults defaults = _root.getDefaults();
    if (defaults == null) {
        return Collections.emptyList();
    }
    if (type == null) {
        return defaults.getProperty();
    }
    List<Property> props = new ArrayList<Property>();
    for (Property prop : defaults.getProperty()) {
        if (prop.getType().equals(type)) {
            props.add(prop);
        }
    }
    return props;
}
Also used : Defaults(com.sun.enterprise.admin.servermgmt.xml.stringsubs.Defaults) ArrayList(java.util.ArrayList) Property(com.sun.enterprise.admin.servermgmt.xml.stringsubs.Property)

Aggregations

Defaults (com.sun.enterprise.admin.servermgmt.xml.stringsubs.Defaults)2 Property (com.sun.enterprise.admin.servermgmt.xml.stringsubs.Property)2 ChangePair (com.sun.enterprise.admin.servermgmt.xml.stringsubs.ChangePair)1 ArrayList (java.util.ArrayList)1