FileDocCategorySizeDatePackage
ConfigContext.javaAPI DocGlassfish v2 API10973Fri May 04 22:31:18 BST 2007com.sun.enterprise.config

ConfigContext

public interface ConfigContext
A configuration context represents a heirarchical view of the configuration attributes. It reads the configuration attributes from server.xml The configuration context has a one-to-one realationship with a configuration file. There is no public constructor. Use ConfigFactory to construct ConfigContext. This object can be made 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
Config API documentation: Config API is a powerful set of APIs that handle comples operations like:
1. Basic Configuration (set and get elements and attributes APIs)
2. Event Notification
3. Cloning
4. XPath support
5. Change Mananagement (add, update, delete, set)
6. readonly
7. Auto Commit
8. Advanced Configuration (1 API to access attributes--ctx.getAttribute())
9. Intelligent refresh
10. Get dtd default values
11. DOM like API support (appendChild, removeChild)
12. Find APIs
13. Support Serialization and DeSerialization
14. Other Misc APIs (getChildBeansByName, getXPath, etc)
15. Merge APIs

Fields Summary
Constructors Summary
Methods Summary
public voidaddConfigContextEventListener(ConfigContextEventListener ccel)

public ConfigChangeaddToConfigChangeList(java.lang.String xpath, java.lang.String attrName, java.lang.String oldValue, java.lang.String newValue)
add config update to the ConfigChangeList

return
ConfigChange that was just added to ConfigChangeList

public ConfigChangeaddToConfigChangeList(java.lang.String xpath, java.lang.String childXpath, java.lang.String name, ConfigBean cb)
add config add to the ConfigChangeList

return
ConfigChange that was just added to ConfigChangeList

public ConfigChangeaddToConfigChangeList(java.lang.String xpath)
add config delete to the ConfigChangeList

return
ConfigChange that was just added to ConfigChangeList

public ConfigChangeaddToConfigChangeList(java.lang.String xpath, java.lang.String name, java.lang.Object cb, java.lang.Object[] cbArray)
add config set to the ConfigChangeList

return
ConfigChange that was just added to ConfigChangeList

public voidcleanup()

public java.lang.Objectclone()
Clone entire config context. Note that configChangeList is not cloned.

public 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

public 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

public voidflush()
is equivalent to flush(false)

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

return
value of attribute. null if it cannot find exactly 1 element or that attribute

public booleangetBooleanAttributeValue(java.lang.String xpath, java.lang.String attributeName)
similar to getAttributeValue but returns a boolean

return
true if it finds 1 element and attributeName has value=true else returns false.

public java.util.ArrayListgetConfigChangeList()
returns the list of config changes done to this config context since the last reset or refresh or flush

public ConfigBeangetRootConfigBean()
Get the config bean for the root of the xml tree.

public java.lang.StringgetUrl()
gets the url of the file/storage that this configcontext is representing. It could be null in the case when the context has been cloned or deserialized

public booleanisChanged()
Tells you if this configcontext has changed since it was read in or changes were reset

public booleanisFileChangedExternally()
returns true if File has changed externally (not by this configcontext) after the configcontext was created Depends on whether it is enabled. if disabled, returns false

public ConfigBean[]lookup(java.lang.String xpath)
Note the constraints on xpath

public voidpostChange(com.sun.enterprise.config.ConfigContextEvent ccce)
used only by impl for getting changes

public voidpreChange(com.sun.enterprise.config.ConfigContextEvent ccce)
used only by impl for getting changes

public 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. throws configexception if force is false and isDirty

public voidrefresh()
is equivalent to refresh(false).

public voidremoveConfigChange(ConfigChange change)

public voidremoveConfigContextEventListener(ConfigContextEventListener ccel)

public voidresetConfigChangeList()
reset config change list.

public voidupdateFromConfigChange(ConfigChange configChange)
update this context with a configuration change. Changes done to configContext are maintained as a list of configChange objects This method is a convenient way of updating a context with a list of changes done to another context (may be in another VM)

public java.util.ArrayListupdateFromConfigChange(java.util.ArrayList configChangeList)
see updateFromConfigChange(ConfigChange configChange) This method can be used for updating from a list of changes It is also used to check last modified so that all of them succeed for fail due to the changes.

return
ArrayList of all failed updates