FileDocCategorySizeDatePackage
ConfigChangeEvent.javaAPI DocGlassfish v2 API8003Fri May 04 22:33:34 BST 2007com.sun.enterprise.admin.event

ConfigChangeEvent

public class ConfigChangeEvent extends com.sun.enterprise.admin.event.AdminEvent
Configuration Change Event. This event is raised when one or more configuration attributes are changed. The user interface supports a feature because of which edits to configuration attributes are applied only at user request. Therefore, configuration change events can be associated to more than one configuration change.

Fields Summary
static final String
eventType
Event type
private boolean
webCoreReconfigNeeded
Is web core reconfig needed.
private boolean
initOrObjConfChanged
Has init or obj conf file changed.
private HashMap
matchMap
A map to track config changes that match any ConfigChangeCategory regular expression.
Constructors Summary
public ConfigChangeEvent(String instanceName, ArrayList configChangeList)
Create a new ConfigChangeEvent. Every element in configChangeList should be of type com.sun.enterprise.config.ConfigChange.

param
instanceName name of the instance to which this event applies
param
configChangeList list of configuration attribute changes.


                                        
      
              
        super(eventType, instanceName);
        this.configChangeList = configChangeList;
    
Methods Summary
public java.util.ArrayListgetConfigChangeList()
Get config changes list. The list contains objects of type ConfigAdd, ConfigUpdate or ConfigDelete from package com.sun.enterprise.config (all of them are sub-classes of ConfigChange). In some cases, this event may be created by specifying null for Config change list and if no changes are added post creation by invoking package method addConfigChange then this method will return null.

return
list of config changes

        return configChangeList;
    
booleanisAllXPathMatched()
Is all xpath in this event matched to at least one listener. The event contains a list of config changes and if xpaths for all the changes are mactehd to at least one listener then the method returns true. If change list is empty then the method returns false.

        boolean matched = true;
        if (configChangeList == null || matchMap == null) {
            matched = false;
            return matched;
        }
        Iterator iter = configChangeList.iterator();
        while (iter.hasNext()) {
            if (!matchMap.containsKey(iter.next())) {
                matched = false;
                break;
            }
        }
        return matched;
    
booleanisInitOrObjConfChanged()
Is init.conf or obj.conf changed. If true, then a restart will be required to handle this change.

        return initOrObjConfChanged;
    
booleanisNoOp()
Is this event no op. A ConfigChangeEvent is no op, if it does not have any server.xml changes or if it has not been told that web core reconfig is needed.

        boolean isNoOp = false;
        if (configChangeList == null && !webCoreReconfigNeeded) {
            isNoOp = true;
        }
        return isNoOp;
    
booleanisWebCoreReconfigNeeded()
Is web core reconfig needed. Web core reconfig is needed if init.conf, obj.conf or mime type files have been changed or if server.xml elements http-service or web-container have been changed.

        return webCoreReconfigNeeded;
    
booleanmatchXPathToPattern(java.util.regex.Pattern pattern)
Match the specified regular expression pattern against all changed XPath associated to the event.

param
pattern the pattern to match xpath with
return
true if any xpath matches, false otherwise

        boolean match = false;
        if (configChangeList == null) {
            return match;
        }
        Iterator iter = configChangeList.iterator();
        while (iter.hasNext()) {
            ConfigChange change = (ConfigChange)iter.next();
            String xpath = change.getXPath();
            if (xpath != null) {
                Matcher matcher = pattern.matcher(xpath);
                match = matcher.matches();
                if (match) {
                    setConfigChangeMatched(change);
                }
            }
        }
        return match;
    
private voidsetConfigChangeMatched(com.sun.enterprise.config.ConfigChange change)
Set specified config change as matched. This method is called when the change xpath matches a pattern from a ConfigChangeEvent listener.

param
change the config change that contains matched xpath.

        synchronized (this) {
            if (matchMap == null) {
                matchMap = new HashMap();
            }
        }
        matchMap.put(change, change);
    
voidsetInitOrObjConfChanged(boolean changed)
Set whether init.conf or obj.conf files have changed.

param
changed true if init.conf or obj.conf has changed

        initOrObjConfChanged = changed;
    
voidsetWebCoreReconfigNeeded(boolean reconfig)
Set web core reconfig needed status. Some of the changes are handled by reconfig signal in web core. Setting the status to true results in invokation of web core reconfig.

param
reconfig whether web core reconfig is needed

        webCoreReconfigNeeded = reconfig;