FileDocCategorySizeDatePackage
PEDomainConfigValidator.javaAPI DocGlassfish v2 API10451Fri May 04 22:24:32 BST 2007com.sun.enterprise.admin.servermgmt.pe

PEDomainConfigValidator

public class PEDomainConfigValidator extends com.sun.enterprise.admin.servermgmt.DomainConfigValidator
This class defines the domain config entries that are required to create a PE Tomcat domain.

Fields Summary
private static final com.sun.enterprise.util.i18n.StringManager
strMgr
i18n strings manager object
private static final String
lInstallRoot
private static final String
lDomainsRoot
private static final String
lJavaHome
private static final String
lAdminPort
private static final String
lInstancePort
private static final String
lHostName
private static final String
lJmsUser
private static final String
lJmsPasswd
private static final String
lJmsPort
private static final String
lOrbPort
static DomainConfigEntryInfo[]
entries
Constructors Summary
PEDomainConfigValidator()
Creates a new instance of PEDomainConfigValidator


           
    
    
        super(entries);
    
Methods Summary
private final voidaddEntryToMap(java.lang.Object key, java.lang.Object value, java.util.Map map)
Add the given key/value pair, but reversing it, in the given map. reversal means that the values in the map must be sets.

        if (!map.containsKey(value)){
            map.put(value, new TreeSet());
        }
        ((Set)map.get(value)).add(key);
    
final java.lang.StringgetDuplicatePorts(java.util.Map ports)

        return printDuplicatesFromMap(reverseMap(ports));
    
private final java.lang.StringgetLocalizedString(java.lang.String key, java.lang.Object o)

        return strMgr.getString(key, o);
    
private final java.lang.StringgetMessage(java.util.Map ports)

        return getLocalizedString("duplicatePorts", getDuplicatePorts(ports));
    
private final java.util.Map.EntrygetNextDuplicate(java.util.Iterator it)
Get next entry from iterator whose value is a set of cardinality greater than 1

        while (it.hasNext()){
            Map.Entry result = (Map.Entry) it.next();
            if (((Set)result.getValue()).size() > 1){
                return result;
            }
        }
        return null;
    
protected booleanisValidate(java.lang.String name, java.lang.Object domainConfig)

        boolean isPortEntry =   DomainConfig.K_ADMIN_PORT.equals(name) ||
                                DomainConfig.K_INSTANCE_PORT.equals(name) ||
                                DomainConfig.K_ORB_LISTENER_PORT.equals(name) ||
                                DomainConfig.K_JMS_PORT.equals(name);
        return (isPortEntry) ? isValidatePorts((Map)domainConfig) : true;
    
private booleanisValidatePorts(java.util.Map domainConfig)

        Boolean isValidatePorts = 
            (Boolean)domainConfig.get(DomainConfig.K_VALIDATE_PORTS);
        return (null != isValidatePorts) ? 
                    isValidatePorts.booleanValue() : true;
    
private final java.lang.StringprintDuplicatesFromMap(java.util.Map map)
Return a string representation of the given map, but only for those entries where the value has a size greater than 1

param
map a map of key to Set of value

        final StringBuffer sb = new StringBuffer();
        final Iterator it = map.entrySet().iterator();
        Map.Entry entry = getNextDuplicate(it);
        if (entry != null){
            printEntry(sb, entry);
            while ((entry = getNextDuplicate(it)) != null){
                sb.append(", ");
                printEntry(sb, entry);
            }
        }
        return sb.toString();
    
private final voidprintEntry(java.lang.StringBuffer sb, java.util.Map.Entry entry)

        printEntry(sb, (Object) entry.getKey(), (Set) entry.getValue());
    
private final voidprintEntry(java.lang.StringBuffer sb, java.lang.Object key, java.util.Set dups)
Print the given key and set onto the given string buffer. Note that the set is considered to contain more than one object

        sb.append(key).append(" -> ");
        printSet(sb, dups);
    
private final voidprintSet(java.lang.StringBuffer sb, java.util.Set set)
Print the given set on the given string buffer

        sb.append("{");
        String separator = "";
        for (Iterator it = set.iterator(); it.hasNext(); ){
            sb.append(separator).append(it.next());
            separator = ", ";
        }
        sb.append("}");
    
private final java.util.MapreverseMap(java.util.Map inputMap)
Reverse the given map. i.e. a keys in the input map are values in the output map, and values in the input map are kays in the output map. Note that the values in the output map must be sets, to allow for many to 1 relations in the input map.

        final Map outputMap = new TreeMap();
        for (Iterator entries = inputMap.entrySet().iterator(); entries.hasNext(); ){
            Map.Entry entry = (Map.Entry) entries.next();
            addEntryToMap(entry.getKey(), entry.getValue(), outputMap);
        }
        return outputMap;
    
final voiduniquePorts(com.sun.enterprise.admin.servermgmt.DomainConfig dc)

        final Map ports = dc.getPorts();
        final Set portValues = new HashSet(ports.values());
        if (ports.keySet().size() != portValues.size()){
            throw new InvalidConfigException(getMessage(ports));
        }
    
public voidvalidate(java.lang.Object domainConfig)

        super.validate(domainConfig);
        uniquePorts((DomainConfig) domainConfig);