FileDocCategorySizeDatePackage
ConfigContextImpl.javaAPI DocGlassfish v2 API41659Fri May 04 22:31:18 BST 2007com.sun.enterprise.config.impl

ConfigContextImpl

public class ConfigContextImpl extends Object implements Serializable, DefaultConstants, Cloneable, com.sun.enterprise.config.ConfigContext
A configuration context represents a heirarchical view of the configuration attributes. It reads the configuration attributes from domain.xml The configuration context has a one-to-one realationship with a configuration file. There is no public constructor. Use ConfigFactory to construct ConfigContext. Once ConfigContext is created, then, it is tied to the configuration file forever. This object can be make readOnly and autoCommit during creation but these parameters cannot be changed once the object is created. Note that this object might be shared by number of threads. Here are some examples of code to illustrate lookup: 1. If you want to specifically locate a Node in the configuration: example: jms resource in server.xml
ConfigBean conBean =
ctx.exactLookup("/server/resources/jms-resource[@name='jms1']");
Follow the syntax below for creating xpath expression for use in lookup/exactLookup. This is the only syntax supported.
expression := /tagName | /tagName/tagExpression
tagExpression := tagName| tagName[@name='value'] | tagName/tagExpression | tagName[@name='value']/tagExpression

Fields Summary
protected transient Vector
listeners
private com.sun.enterprise.config.ConfigBean
server
protected String
xmlUrl
private transient long
lastModified
private boolean
readOnly
private boolean
autoCommit
private Class
rootClass
private boolean
isAdministered
private DefaultHandler
defaultHandler
private boolean
resolvePath
private transient com.sun.enterprise.config.pluggable.ConfigBeanInterceptor
configBeanInterceptor
private transient boolean
_lastModifiedCheck
used for checking lastModifiedTimestamps in configBeans Note that it is transient. we do not want the clone to have it enabled by default
private transient ArrayList
configChangeList
private static final String
PRE_CHANGE
private static final String
POST_CHANGE
Constructors Summary
public ConfigContextImpl(String xmlUrl, boolean readOnly, boolean autoCommit, Class rootClass, DefaultHandler dh)
Package private constructor. Not to be called by clients.

param
xmlUrl
param
readOnly
deprecated

            this.xmlUrl = xmlUrl;
            this.readOnly = readOnly; 
            //FIXME: use dom readonly
           /* if(readOnly) {
                ((ElementNode)this.serverInstanceDocument.getDocumentElement()).setReadOnly(true);
            }
            */
            this.autoCommit = autoCommit;
            this.rootClass = rootClass;
            this.defaultHandler = dh;            
	
public ConfigContextImpl(String xmlUrl, boolean readOnly, boolean autoCommit, Class rootClass, DefaultHandler dh, boolean resolvePath)
Package private constructor. Not to be called by clients.

param
xmlUrl
param
readOnly
param
resolvePath
deprecated

            this.xmlUrl = xmlUrl;
            this.readOnly = readOnly; 
            //FIXME: use dom readonly
           /* if(readOnly) {
                ((ElementNode)this.serverInstanceDocument.getDocumentElement()).setReadOnly(true);
            }
            */
            this.autoCommit = autoCommit;
            this.rootClass = rootClass;
            this.defaultHandler = dh;  
            this.resolvePath = resolvePath;
	
public ConfigContextImpl(com.sun.enterprise.config.pluggable.ConfigEnvironment ce)

            try {
            this.xmlUrl = ce.getUrl();
            this.readOnly = ce.isReadOnly(); 
            //FIXME: use dom readonly
           /* if(readOnly) {
                ((ElementNode)this.serverInstanceDocument.getDocumentElement()).setReadOnly(true);
            }
            */
            this.autoCommit = ce.isAutoCommitOn();
            this.rootClass = Class.forName(ce.getRootClass());
            this.defaultHandler = 
                (DefaultHandler) Class.forName(ce.getHandler()).newInstance();  
            this.configBeanInterceptor = ce.getConfigBeanInterceptor();
            } catch (Exception e) {
                throw new ConfigRuntimeException("err_creating_ctx", e);
            }
            
        
Methods Summary
public voidaddConfigContextEventListener(com.sun.enterprise.config.ConfigContextEventListener ccel)

            if (listeners==null)
                listeners = new Vector();
            listeners.addElement(ccel);
        
public synchronized com.sun.enterprise.config.ConfigChangeaddToConfigChangeList(java.lang.String parentXpath, java.lang.String childXpath, java.lang.String name, com.sun.enterprise.config.ConfigBean cb)
for add

            //adds
            if(!isAdministered) return null;
            
            ConfigChange cChange = ConfigChangeFactory.createConfigAdd
                                        (parentXpath, childXpath, name, cb);
            
            configChangeList.add(cChange);
            persistConfigChanges();
            return cChange;
        
public synchronized com.sun.enterprise.config.ConfigChangeaddToConfigChangeList(java.lang.String xpath)

            if(!isAdministered) return null;
            
            ConfigChange cChange = null;
            if(!removeOtherConfigChanges(xpath)) {
                cChange = ConfigChangeFactory.createConfigDelete(xpath);
                configChangeList.add(cChange);
            }

            persistConfigChanges();
            return cChange;
        
public synchronized com.sun.enterprise.config.ConfigChangeaddToConfigChangeList(java.lang.String parentXpath, java.lang.String name, java.lang.Object cb, java.lang.Object[] cbArray)

            if(!isAdministered) return null;
            
            ConfigChange cChange = ConfigChangeFactory.createConfigSet(
                                parentXpath, 
                                name, 
                                cb, 
                                cbArray);
            configChangeList.add(cChange);
            persistConfigChanges();
            return cChange;
        
public synchronized com.sun.enterprise.config.ConfigChangeaddToConfigChangeList(java.lang.String xpath, java.lang.String attrName, java.lang.String oldValue, java.lang.String newValue)

            //find xpath and add. else create new obj.
           if(!isAdministered) return null;
            
            ConfigChange cChange = null;
            
            try {
                if(oldValue == null && newValue == null) return null;
                if(oldValue != null && oldValue.equals(newValue)) return null;
                
                boolean found = false;
                for(int i=0;i<configChangeList.size();i++) {
                    if(((ConfigChange)configChangeList.get(i)).getConfigChangeType().equals(ConfigChange.TYPE_UPDATE) 
                                    && ((ConfigUpdate)configChangeList.get(i)).getXPath().equals(xpath)) {
                        ((ConfigUpdate)configChangeList.get(i)).addChangedAttribute(attrName, oldValue, newValue);
						//_logger.log(Level.INFO,"config.change_added");
                        persistConfigChanges();
                        found = true;
                        break;
                    }
                }
                if(!found) {
                    cChange = ConfigChangeFactory.createConfigUpdate
                                        (xpath, 
                                        attrName, 
                                        oldValue, 
                                        newValue);
                    configChangeList.add(cChange);
                    persistConfigChanges();
					//_logger.log(Level.INFO,"config.create_config_ch_obj",xpath);
                }
            } catch (Throwable t) {
				//_logger.log(Level.WARNING,"config.add_config_change_exception",t);
            }
           return cChange;
        
private voidassertReadOnly()

            if(readOnly) {
                throw new ConfigException("Read only: you cannot write " + toString() );
            }
        
private voidchange(java.lang.String when, com.sun.enterprise.config.ConfigContextEvent ne)

        if (listeners==null)
            return;
        
        //ConfigContextEvent ne = new ConfigContextEvent(this, type);
        String type = ne.getType();
        
        Vector listenersClone = null;
        synchronized (listeners) {
            listenersClone = (Vector) listeners.clone();
        }
        for (Enumeration e = listenersClone.elements(); e.hasMoreElements();) {
            ConfigContextEventListener nl = (ConfigContextEventListener) e.nextElement();
            if(when.equals(PRE_CHANGE)) {
                /*
                if(type.equals(ConfigContextEvent.PRE_ACCESS) || type.equals(ConfigContextEvent.POST_ACCESS))
                    nl.preAccessNotification(ne);
                else
                 */
                    nl.preChangeNotification(ne);
            } else {
                /*
                if(type.equals(ConfigContextEvent.PRE_ACCESS) || type.equals(ConfigContextEvent.POST_ACCESS))
                    nl.postAccessNotification(ne);
                else
                 */
                    nl.postChangeNotification(ne);
            }
        }
    
public voidcleanup()
recursive method that cleansup the config context and allows better memory model This should be called when we know that the tree in this context is used in future

            //set ctx and xpath
            //_logger.fine("Cleaning up config context");
	    if(server != null)
                cleanup(server);
            //_logger.fine("Finished setting xpath for the whole tree");
	    server = null;
      
private voidcleanup(com.sun.enterprise.config.ConfigBean cb)

            cb.cleanup();
            //_logger.finer("   " + cb.name() + " cleaned up");
            
            //if cb is leaf. return.
            ConfigBean[] chChildArr = cb.getAllChildBeans();
            if(chChildArr == null || chChildArr.length <= 0) return;
            for(int i = 0; i<chChildArr.length; i++) {
                if(chChildArr[i] == null) continue;
                //_logger.finest("Child " + chChildArr[i].name());
                try {
                    cleanup(chChildArr[i]);
                } catch(Throwable t) {
                    //ignore this node and its children and continue with rest
                    //_logger.fine("Warning: Cannot cleanup configbean " + chChildArr[i].name());
                    //_logger.fine("Warning: Exception is: " + t.getMessage());
                    //_logger.fine("Warning: Continuing with rest of settings");
                }
            }    
       
private voidclearPersistentConfigChanges()

             if(!LOAD_PERSISTENT_CONFIG_CHANGES) return;
             
            //remove change file on disk
            try {
                File f = new File(getConfigChangeUrl());
                f.delete();
            } catch(Throwable t) {
                //ignore.
            }
        
public java.lang.Objectclone()

            ConfigContextImpl ctxClone = 
                new ConfigContextImpl(this.xmlUrl, false, false, this.rootClass, this.defaultHandler);
			ctxClone.configBeanInterceptor = getConfigBeanInterceptor();
			/*
				server is initialized on refresh(). What if someone calls clone()
				before server is initialized.
			 */
			if (server != null) {
				ConfigBean rootClone = (ConfigBean)this.server.clone();
				ctxClone.setRootConfigBean(rootClone);
				rootClone.setConfigContext(ctxClone);
				rootClone.setInterceptor(ctxClone.configBeanInterceptor);
				try {
			            ((ConfigContextImpl)ctxClone).setXPathInAllBeans();
				} catch (Exception e) {
					//ignore
				}
			}
            ctxClone.setIsAdministered(true);
            
            return ctxClone;
        
public java.lang.StringconfigBeanToString()
get the ConfigBean information as a String String is in a schema2beans proprietory format Note that this method is not exposed in ConfigContext.

return
String representation of config bean. return "null bean" if there is no associated config bean

            if(server == null) return "null bean";
            return this.server.dumpBeanNode();
        
public synchronized booleanenableLastModifiedCheck(boolean value)
This method is used to activate the lastModified checking for a configContext If activated, configbeans will carry a lastmodified timestamp in every bean. This time is also carried onto the configChangeList and also to clones. When configContext.updateFromConfigChangeList is called, the timestamp is first checked to see if the bean has not changed since the clone and then the update is made. If a modification to the bean is detected, a staleWriteConfigException is thrown.

param
value boolean to enable/disable
return
boolean previous value that was set (not the changed value)

        boolean prev = _lastModifiedCheck;
        _lastModifiedCheck = value;
        return prev;
    
public booleanequals(java.lang.Object obj)

            try {
                if(this.getRootConfigBean().equals(((ConfigContext)obj).getRootConfigBean())) {
                    return true;
                }
            } catch(Throwable t) {
                //ignore
            }
            return false;
        
public com.sun.enterprise.config.ConfigBeanexactLookup(java.lang.String xpath)
Retrieves the named object. The parameter passed is a XPath version 1.0 used as the path notation for navigating the hierarchical structure. Only the AbsoluteLocationPath and Relative LocationPath elements are used. The code below returns a ConfigBeam representing an application with appId="app1"
ConfigBean cn = conCtx.exactLookup(ServerXPathHelper.getAppIdXpathExpression("app1"));

return
a ConfigBean representing a node in the tree.
param
xpath
throws
ConfigException

            if(server == null) {
                refresh();
            }
            return ConfigBeansFactory.getConfigBeanByXPath(this,xpath); 
	
public synchronized voidflush(boolean overwrite)
saves all the changes in ConfigContext to storage Throws ConfigException if there is any problem writing to storage. or the file has been modified after last read. However, if overwrite is true, then it overwrites any manual changes on disk

            if(!overwrite && isFileChangedExternally()) {
                throw new StaleWriteConfigException
                    ("ConfigContext Flush failed: File Changed Externally");
            }
            
            // <addition> srini@sun.com server.xml verifier
            //preChange(ConfigContextEvent.PRE_FLUSH_CHANGE);
            ConfigContextEvent ccce = new ConfigContextEvent(this,ConfigContextEvent.PRE_FLUSH_CHANGE);
            preChange(ccce);
            // </addition> server.xml verifier
         
            try {
                FileOutputStream fos = new FileOutputStream(this.xmlUrl);
                server.write(fos);
            } catch(Exception e) {
                throw new ConfigException("Error Flushing ConfigContext " + toString());
            }
            initLastModified();
            // <addition> srini@sun.com
            //postChange(ConfigContextEvent.POST_FLUSH_CHANGE);
            ccce = new ConfigContextEvent(this,ConfigContextEvent.POST_FLUSH_CHANGE);
            postChange(ccce);
            // </addition> server.xml verifier
            
            //FIXME: should I not write out persistentConfigChanges now??
        
public voidflush()
is equivalent to flush(true)

            flush(true);
        
public java.lang.StringgetAttributeValue(java.lang.String xpath, java.lang.String attributeName)
Get the Value of an attribute with One call This equivalent of doing an exactLookup to get a bean and then a getAttributeValue on that bean

            ConfigBean c = null;
            try {
                c = this.exactLookup(xpath);
            } catch(Exception e) {}
            
            if(c!= null) {
                if(!isResolvingPaths()) {
                    return c.getRawAttributeValue(attributeName);
                } else {
                    return c.getAttributeValue(attributeName);
                }
            }
            
            return null;
        
public booleangetBooleanAttributeValue(java.lang.String xpath, java.lang.String attributeName)
similar to getAttributeValue but returns a boolean

            String ret = getAttributeValue(xpath, attributeName);
            if(ret == null) return false;
            
            if (ret.equals("true"))
                return true;

            return false;
        
private com.sun.enterprise.config.ConfigBeangetConfigBeanFromConfigChange(com.sun.enterprise.config.ConfigChange configChange)

        ConfigBean result = null;
        try {
            if(configChange.getConfigChangeType().equals(ConfigChange.TYPE_UPDATE)) {
                result = ConfigBeansFactory.getConfigBeanByXPath(this,configChange.getXPath());
            } else if (configChange.getConfigChangeType().equals(ConfigChange.TYPE_DELETE)) {
                String xpath = configChange.getXPath();
                ConfigBean child = ConfigBeansFactory.getConfigBeanByXPath(this,xpath);
                if(child != null) {
                    result = (ConfigBean) child.parent();
                }
            } else { // add/set
                result = ConfigBeansFactory.getConfigBeanByXPath(this, configChange.getParentXPath());
            }
        } catch (ConfigException ce) {
            //ignore
        }
        return result;
    
public com.sun.enterprise.config.pluggable.ConfigBeanInterceptorgetConfigBeanInterceptor()

        ConfigBeanInterceptor cbiClone = null;
        if (null != configBeanInterceptor) {
            cbiClone = (ConfigBeanInterceptor)configBeanInterceptor.clone();
        }
        return cbiClone;
    
public java.util.ArrayListgetConfigChangeList()

        
           
            return configChangeList;
        
private java.lang.StringgetConfigChangeUrl()

            return this.xmlUrl + ".changes";
        
private longgetLastModified()

            long ts = INVALID_LAST_MODIFIED;
            try {
                File f = new File(this.xmlUrl);
                ts = f.lastModified();
            } catch(Exception e) {
                //ignore
            }
            return ts;
        
public synchronized com.sun.enterprise.config.ConfigBeangetRootConfigBean()

            if(server == null) {
                refresh();
            }
            return server;
        
public java.lang.StringgetUrl()

         return this.xmlUrl;
    
java.lang.StringgetXmlUrl()

deprecated
use getUrl()

            return this.xmlUrl;
        
public inthashCode()

            try {
                return this.getRootConfigBean().hashCode();
            } catch(Throwable t) {
                //ignore
            }
           return super.hashCode();
        
private voidinitConfigChanges()

            if(!LOAD_PERSISTENT_CONFIG_CHANGES) return;
            
            FileInputStream istream = null;
            try {
                istream = new FileInputStream(getConfigChangeUrl());
                ObjectInputStream p = new ObjectInputStream(istream);

                this.configChangeList = (ArrayList)p.readObject();

            } catch(Throwable t) {
                //ignore.
            } finally {
                try {
                    istream.close();
                } catch(Exception e){}
            }
            
        
private voidinitLastModified()
init to be called from constructor

            this.lastModified = getLastModified();
        
public booleanisAdministered()

            return isAdministered;
        
public booleanisChanged()

            if(configChangeList == null || configChangeList.size() ==0)
                return false;
            return true;
        
public booleanisFileChangedExternally()
checks if file has changed externally after the config context last updated the file

            
            if(getLastModified() == this.lastModified)
                return false;
            return true;
        
public booleanisLastModifiedCheckEnabled()

        return _lastModifiedCheck;
    
public booleanisResolvingPaths()
Returns boolean true is this is the config context for admin.

        return this.resolvePath;
    
public com.sun.enterprise.config.ConfigBean[]lookup(java.lang.String xpath)

            // FIXME NYI
            return null;
        
private voidpersistConfigChanges()

            
            //We donot need to write if persistent
            //config changes are not required
            if(!LOAD_PERSISTENT_CONFIG_CHANGES) return;
            
            FileOutputStream ostream = null;
            ObjectOutputStream p = null;
            try {
                ostream = new FileOutputStream(getConfigChangeUrl());
                p = new ObjectOutputStream(ostream);
                p.writeObject(this.configChangeList);
                p.flush();
            } catch(Throwable t) {
                //ignore.
            } finally {
                try {
                    p.close();
                    ostream.close();
                } catch(Exception e){}
            }
            
        
public voidpostChange(com.sun.enterprise.config.ConfigContextEvent ccce)

        
        //change(POST_CHANGE, type);
        change(POST_CHANGE, ccce);
    
public voidpreChange(com.sun.enterprise.config.ConfigContextEvent ccce)
Notify all my listeners that I will change!

    
                 
    
    // <addition> srini@sun.com server.xml verifier
    //public void preChange(String type) {
        
        //change(PRE_CHANGE, type);
        change(PRE_CHANGE, ccce);
    
public synchronized voidrefresh(boolean force)
discards all the changes and reloads the xml from storage based on the force flag

param
force forces a reload from disk even if dirty bit is not set

            try {
                if(!force && isChanged()) {
                    throw new ConfigException
                        ("ConfigContext has changed in Memory. cannot refresh " + toString());
                }
                
                FileInputStream in = new FileInputStream(this.xmlUrl);
                if(this.defaultHandler != null) {
                    server = (ConfigBean) BaseBean.createGraph(
                                rootClass, 
                                in, 
                                true, 
                                this.defaultHandler, 
                                this.defaultHandler);
                } else {
                    server = (ConfigBean) BaseBean.createGraph(rootClass, in, true);
                }
                 
                initConfigChanges(); // not reset. load it up.
                
                initLastModified();
                
                //setXpath for the tree of readwrite mode
                if(INITIALIZE_XPATH) {
                    if(!this.readOnly) {
                        setXPathInAllBeans();
                    }
                }
                setIsAdministered(true);
                server.setInterceptor(this.configBeanInterceptor);
            } catch (Exception e) {
                throw new ConfigException("Error refreshing ConfigContext:" + this.xmlUrl, e);
            }
        
public voidrefresh()
discards all the changes and reloads the xml from storage if dirty flag is true

           refresh(true);
        
public synchronized voidremoveConfigChange(com.sun.enterprise.config.ConfigChange change)

            if (!isAdministered) return;

            int ndx = configChangeList.indexOf(change);
            if (ndx != -1) {
                configChangeList.remove(ndx);
            }
            persistConfigChanges();
        
public voidremoveConfigContextEventListener(com.sun.enterprise.config.ConfigContextEventListener ccel)

             if (listeners==null)
                listeners = new Vector();
            listeners.removeElement(ccel);
        
private booleanremoveOtherConfigChanges(java.lang.String xpath)

	    boolean ret = false;
            try {
                //Bug# 4884726 Begin
                final Iterator it = configChangeList.iterator();
                while (it.hasNext()) {
                    final ConfigChange cc = (ConfigChange)it.next();
                    if(xpath.indexOf(cc.getXPath()) >= 0) {
		        if(cc instanceof ConfigAdd) 
			    ret = true;
                        it.remove();
                    }
                }
                //Bug# 4884726 End
            } catch (Throwable t) {
		//_logger.log(Level.WARNING,"config.remove_config_change_exception",t);
            }
            return ret;	
        
public synchronized voidresetConfigChangeList()

            configChangeList = new ArrayList();
            clearPersistentConfigChanges();
            
            //FIXME
            isAdministered = true;
        
public voidsetIsAdministered(boolean value)

            isAdministered = value;
        
voidsetRootConfigBean(com.sun.enterprise.config.ConfigBean c)

            this.server = c;
        
public voidsetXPathInAllBeans()
sets xpath in all beans

            if(this.readOnly) return;
            
            ConfigBean cb = this.getRootConfigBean();
            //set ctx and xpath
            //_logger.fine("Setting xpath for the whole tree");
            setXPathInTree(cb,"");
            //_logger.fine("Finished setting xpath for the whole tree");
        
private voidsetXPathInTree(com.sun.enterprise.config.ConfigBean cb, java.lang.String parentXpath)
recursive method

            cb.setConfigContext(this);
            String xp = cb.getAbsoluteXPath(parentXpath);
            //_logger.finer("   " + cb.name() + " " + xp);
            cb.setXPath(xp);
            
            //if cb is leaf. return.
            ConfigBean[] chChildArr = cb.getAllChildBeans();
            if(chChildArr == null || chChildArr.length <= 0) return;
            for(int i = 0; i<chChildArr.length; i++) {
                if(chChildArr[i] == null) continue;
                //_logger.finest("Child " + chChildArr[i].name());
                try {
                    setXPathInTree(chChildArr[i], cb.getXPath());
                } catch(Throwable t) {
                    //ignore this node and its children and continue with rest
                    //_logger.fine("Error: Cannot setXpath for " + chChildArr[i].name());
                    //_logger.fine("Error: Xpath is " + cb.getXPath());
                    //_logger.fine("Error: Exception is: " + t.getMessage());
                    //_logger.fine("Error: Continuing with rest of settings");
                }
                
            }
        
public java.lang.StringtoString()
get all the important attributes of this configcontext as a String Each attribute is separated by a comma

return
String representation of this configContext

            return "com.sun.enterprise.config.ConfigContext: Url=" + this.xmlUrl 
                        + ", ReadOnly=" + this.readOnly 
                        + ", ResolvePath=" + (resolvePath)
                        + ", LastModified Timestamp=" + this.lastModified
                        + ", isChanged=" + this.isChanged()
                        + ", Autocommit=" + this.autoCommit
                        + ", isConfigBeanNull=" + (server==null);
        
private voidupdateFromConfigAdd(com.sun.enterprise.config.ConfigAdd configChange)

            ConfigBean parent = ConfigBeansFactory.getConfigBeanByXPath(this,configChange.getParentXPath());
            if(parent == null) 
                throw new ConfigException("updateFromConfigAdd: Cannot find parent");
            
            ConfigBean rootBean = configChange.getConfigBean();
            if(rootBean == null)
                throw new ConfigException("updateFromConfigAdd: Cannot find root bean");
            
            ConfigBean childBean = ConfigBeansFactory.getConfigBeanByXPath(rootBean, configChange.getXPath());
            
            if(childBean == null) 
                throw new ConfigException("updateFromConfigAdd: Cannot find childBean");
            
            //lastModified Check
            if(isLastModifiedCheckEnabled()) {
                validateLastModified(parent, configChange);
            }
            
            childBean = (ConfigBean)childBean.clone();
            //System.out.println("++++++++++before add +++++++++++++++");
            //System.out.println("this childBean:");
            //System.out.println(childBean.dumpBeanNode());
            //System.out.println("++++++++++++++++++++++++++++++++");
            //System.out.println(childBean.dumpDomNode());
            //System.out.println("++++++++++before add +++++++++++++++");
            
            parent.addValue(configChange.getName(), childBean);
            //System.out.println("++++++++++after add +++++++++++++++");
            //System.out.println("this configcontxt:");
            //this.getRootConfigBean().dumpXml();
            //System.out.println("++++++++++after add +++++++++++++++");
        
public synchronized voidupdateFromConfigChange(com.sun.enterprise.config.ConfigChange configChange)

            if(configChange == null) return;
            
            //disable configChangeList while updating.
            //otherwise, we get unnecessary changes in the list.
            boolean tmpAdministered = isAdministered;
            isAdministered = false;
            
            if(configChange.getConfigChangeType().equals(ConfigChange.TYPE_ADD))
                updateFromConfigAdd((ConfigAdd)configChange);
            else if(configChange.getConfigChangeType().equals(ConfigChange.TYPE_UPDATE))
                updateFromConfigUpdate((ConfigUpdate)configChange);
            else if(configChange.getConfigChangeType().equals(ConfigChange.TYPE_DELETE))
                updateFromConfigDelete((ConfigDelete)configChange);
            else if(configChange.getConfigChangeType().equals(ConfigChange.TYPE_SET))
                updateFromConfigSet((ConfigSet)configChange);
            
            //enable if needed.
            isAdministered = tmpAdministered;
        
public synchronized java.util.ArrayListupdateFromConfigChange(java.util.ArrayList configChangeList)

        
        ArrayList errList = new ArrayList();
        if (configChangeList == null || configChangeList.size() == 0) return errList;
        
        validateAllLastModified(configChangeList);
        
        boolean prev = enableLastModifiedCheck(false);
        try {
            for(int i = 0 ; i < configChangeList.size(); i++ ) {
                ConfigChange cc = (ConfigChange) configChangeList.get(i);
                try {
                    updateFromConfigChange(cc);
                } catch (Exception e) {
                    errList.add(cc);
                }
            }
	// save the context. TBD
        } finally {
            enableLastModifiedCheck(prev);
        }
        return errList;
    
private voidupdateFromConfigDelete(com.sun.enterprise.config.ConfigDelete configChange)

            //delete
            String xpath = configChange.getXPath();
            ConfigBean child = ConfigBeansFactory.getConfigBeanByXPath(this,xpath);
            if(child != null) {
                //throw new ConfigException("Child not found:" + xpath);
            ConfigBean parent = (ConfigBean) child.parent();
            
            //lastModified Check
            if(isLastModifiedCheckEnabled()) {
                validateLastModified(parent, configChange);
            }
            
            parent.removeChild(child);
            }
        
private voidupdateFromConfigSet(com.sun.enterprise.config.ConfigSet configChange)

            ConfigBean parent = ConfigBeansFactory.getConfigBeanByXPath(this,configChange.getParentXPath());
            
            if(parent == null) 
                throw new ConfigException("updateFromConfigSet: Cannot update. Could not get parent");
            Object child = configChange.getConfigBean();
            
            //lastModified Check
            if(isLastModifiedCheckEnabled()) {
                validateLastModified(parent, configChange);
            }
            
            if(child != null) {
                parent.setValue(configChange.getName(), child);
            } else { //it is an array
                Object[] childArray = configChange.getConfigBeanArray();
                parent.setValue(configChange.getName(), childArray);
            }
        
private voidupdateFromConfigUpdate(com.sun.enterprise.config.ConfigUpdate configChange)

            //set all the attributes
            //System.out.println("configchange is:" + configChange);
            //System.out.println("++++++++++++++++++++++++++++");
            //System.out.println("this configcontext:" + this);
            //System.out.println("++++++++++++++++++++++++++++");
            ConfigBean b = ConfigBeansFactory.getConfigBeanByXPath(this,configChange.getXPath());
  	    //_logger.log(Level.FINE,"xpath="+ configChange.getXPath());
            if(b == null) 
                throw new ConfigException("updateFromConfigUpdate:Could not find ConfigBean to update");
            
            //lastModified Check
            if(isLastModifiedCheckEnabled()) {
                validateLastModified(b, configChange);
            }
            
            Set s = configChange.getAttributeSet();
            for (Iterator i = s.iterator();i.hasNext();) {   
                String name = (String) i.next();
                b.setAttributeValue(name, configChange.getNewValue(name));
            }
        
private voidvalidateAllLastModified(java.util.ArrayList arr)

        if(arr == null || arr.size() == 0) return;
        
        for(int i = 0 ; i < arr.size(); i++ ) {
           ConfigChange cc = (ConfigChange) arr.get(i);
           validateLastModified(cc);
        }
    
private voidvalidateLastModified(com.sun.enterprise.config.ConfigBean cb, com.sun.enterprise.config.ConfigChange cc)
throws StaleWriteConfigException if lastmodified is initialized and there is any modifications

                                           
        if(cb == null || cc == null) return;
        
        long beanLM = cb.getThisLastModified();
        if(beanLM == -1) return; // not initialized. so, don't validate
        
        long ccLM = cc.getGlobalLastModified();
        if(ccLM == -1) return; // not initialized. so, don't validate
        
        if (beanLM == ccLM) return; // okay.
        
        throw new StaleWriteConfigException("validateLastModified failed for cb=" + cb);
    
private voidvalidateLastModified(com.sun.enterprise.config.ConfigChange cc)

        ConfigBean bean = getConfigBeanFromConfigChange(cc);
        validateLastModified(bean, cc);