Java Doc for CombinedConfiguration.java in  » Library » Apache-commons-configuration-1.4-src » org » apache » commons » configuration » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Library » Apache commons configuration 1.4 src » org.apache.commons.configuration 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.apache.commons.configuration.AbstractConfiguration
   org.apache.commons.configuration.HierarchicalConfiguration
      org.apache.commons.configuration.CombinedConfiguration

CombinedConfiguration
public class CombinedConfiguration extends HierarchicalConfiguration implements ConfigurationListener,Cloneable(Code)

A hierarchical composite configuration class.

This class maintains a list of configuration objects, which can be added using the divers addConfiguration() methods. After that the configurations can be accessed either by name (if one was provided when the configuration was added) or by index. For the whole set of managed configurations a logical node structure is constructed. For this purpose a org.apache.commons.configuration.tree.NodeCombiner NodeCombiner object can be set. This makes it possible to specify different algorithms for the combination process.

The big advantage of this class is that it creates a truely hierarchical structure of all the properties stored in the contained configurations - even if some of them are no hierarchical configurations per se. So all enhanced features provided by a hierarchical configuration (e.g. choosing an expression engine) are applicable.

The class works by registering itself as an event listener add all added configurations. So it gets notified whenever one of these configurations is changed and can invalidate its internal node structure. The next time a property is accessed the node structure will be re-constructed using the current state of the managed configurations. Node that, depending on the used NodeCombiner, this may be a complex operation.

It is not strictly forbidden to manipulate a CombinedConfiguration directly, but the results may be unpredictable. For instance some node combiners use special view nodes for linking parts of the original configurations' data together. If new properties are added to such a special node, they do not belong to any of the managed configurations and thus hang in the air. It is also possible that direct updates on a CombinedConfiguration are incompatible with the used node combiner (e.g. if the org.apache.commons.configuration.tree.OverrideCombiner OverrideCombiner is used and properties are removed the resulting node structure may be incorrect because some properties that were hidden by the removed properties are not visible). So it is recommended to perform updates only on the managed configurations.

Whenever the node structure of a CombinedConfiguration becomes invalid (either because one of the contained configurations was modified or because the invalidate() method was directly called) an event is generated. So this can be detected by interested event listeners. This also makes it possible to add a combined configuration into another one.

Implementation note: Adding and removing configurations to and from a combined configuration is not thread-safe. If a combined configuration is manipulated by multiple threads, the developer has to take care about properly synchronization.


author:
   author:
   href="http://jakarta.apache.org/commons/configuration/team-list.html">Commons
author:
   Configuration team
since:
   1.3
version:
   $Id: CombinedConfiguration.java 484692 2006-12-08 18:30:15Z oheger $

Inner Class :static class ConfigData

Field Summary
final public static  intEVENT_COMBINED_INVALIDATE
     Constant for the invalidate event that is fired when the internal node structure becomes invalid.

Constructor Summary
public  CombinedConfiguration(NodeCombiner comb)
     Creates a new instance of CombinedConfiguration and initializes the combiner to be used.
public  CombinedConfiguration()
     Creates a new instance of CombinedConfiguration that uses a union combiner.

Method Summary
public  voidaddConfiguration(AbstractConfiguration config, String name, String at)
     Adds a new configuration to this combined configuration.
public  voidaddConfiguration(AbstractConfiguration config, String name)
     Adds a new configuration to this combined configuration with an optional name.
public  voidaddConfiguration(AbstractConfiguration config)
     Adds a new configuration to this combined configuration.
public  voidclear()
     Clears this configuration.
public  Objectclone()
     Returns a copy of this object.
public  voidconfigurationChanged(ConfigurationEvent event)
     Event listener call back for configuration update events.
public  ConfigurationgetConfiguration(int index)
     Returns the configuration at the specified index.
public  ConfigurationgetConfiguration(String name)
     Returns the configuration with the given name.
public  SetgetConfigurationNames()
     Returns a set with the names of all configurations contained in this combined configuration.
public  NodeCombinergetNodeCombiner()
     Returns the node combiner that is used for creating the combined node structure.
public  intgetNumberOfConfigurations()
     Returns the number of configurations that are contained in this combined configuration.
public  ObjectgetProperty(String key)
     Returns the value of the specified property.
public  ConfigurationNodegetRootNode()
     Returns the configuration root node of this combined configuration.
public  voidinvalidate()
     Invalidates this combined configuration.
public  booleanisForceReloadCheck()
     Returns a flag whether an enhanced reload check must be performed.
public  booleanremoveConfiguration(Configuration config)
     Removes the specified configuration from this combined configuration.
public  ConfigurationremoveConfiguration(String name)
     Removes the configuration with the specified name.
public  ConfigurationremoveConfigurationAt(int index)
     Removes the configuration at the specified index.
public  voidsetForceReloadCheck(boolean forceReloadCheck)
     Sets the force reload check flag.
public  voidsetNodeCombiner(NodeCombiner nodeCombiner)
     Sets the node combiner.

Field Detail
EVENT_COMBINED_INVALIDATE
final public static int EVENT_COMBINED_INVALIDATE(Code)
Constant for the invalidate event that is fired when the internal node structure becomes invalid.




Constructor Detail
CombinedConfiguration
public CombinedConfiguration(NodeCombiner comb)(Code)
Creates a new instance of CombinedConfiguration and initializes the combiner to be used.
Parameters:
  comb - the node combiner (can be null, then a union combineris used as default)



CombinedConfiguration
public CombinedConfiguration()(Code)
Creates a new instance of CombinedConfiguration that uses a union combiner.
See Also:   org.apache.commons.configuration.tree.UnionCombiner




Method Detail
addConfiguration
public void addConfiguration(AbstractConfiguration config, String name, String at)(Code)
Adds a new configuration to this combined configuration. It is possible (but not mandatory) to give the new configuration a name. This name must be unique, otherwise a ConfigurationRuntimeException will be thrown. With the optional at argument you can specify where in the resulting node structure the content of the added configuration should appear. This is a string that uses dots as property delimiters (independent on the current expression engine). For instance if you pass in the string "database.tables", all properties of the added configuration will occur in this branch.
Parameters:
  config - the configuration to add (must not be null)
Parameters:
  name - the name of this configuration (can be null)
Parameters:
  at - the position of this configuration in the combined tree (can benull)



addConfiguration
public void addConfiguration(AbstractConfiguration config, String name)(Code)
Adds a new configuration to this combined configuration with an optional name. The new configuration's properties will be added under the root of the combined node structure.
Parameters:
  config - the configuration to add (must not be null)
Parameters:
  name - the name of this configuration (can be null)



addConfiguration
public void addConfiguration(AbstractConfiguration config)(Code)
Adds a new configuration to this combined configuration. The new configuration is not given a name. Its properties will be added under the root of the combined node structure.
Parameters:
  config - the configuration to add (must not be null)



clear
public void clear()(Code)
Clears this configuration. All contained configurations will be removed.



clone
public Object clone()(Code)
Returns a copy of this object. This implementation performs a deep clone, i.e. all contained configurations will be cloned, too. For this to work, all contained configurations must be cloneable. Registered event listeners won't be cloned. The clone will use the same node combiner than the original. the copied object



configurationChanged
public void configurationChanged(ConfigurationEvent event)(Code)
Event listener call back for configuration update events. This method is called whenever one of the contained configurations was modified. It invalidates this combined configuration.
Parameters:
  event - the update event



getConfiguration
public Configuration getConfiguration(int index)(Code)
Returns the configuration at the specified index. The contained configurations are numbered in the order they were added to this combined configuration. The index of the first configuration is 0.
Parameters:
  index - the index the configuration at this index



getConfiguration
public Configuration getConfiguration(String name)(Code)
Returns the configuration with the given name. This can be null if no such configuration exists.
Parameters:
  name - the name of the configuration the configuration with this name



getConfigurationNames
public Set getConfigurationNames()(Code)
Returns a set with the names of all configurations contained in this combined configuration. Of course here are only these configurations listed, for which a name was specified when they were added. a set with the names of the contained configurations (nevernull)



getNodeCombiner
public NodeCombiner getNodeCombiner()(Code)
Returns the node combiner that is used for creating the combined node structure. the node combiner



getNumberOfConfigurations
public int getNumberOfConfigurations()(Code)
Returns the number of configurations that are contained in this combined configuration. the number of contained configurations



getProperty
public Object getProperty(String key)(Code)
Returns the value of the specified property. This implementation evaluates the force reload check flag. If it is set, all contained configurations will be triggered before the value of the requested property is retrieved.
Parameters:
  key - the key of the desired property the value of this property
since:
   1.4



getRootNode
public ConfigurationNode getRootNode()(Code)
Returns the configuration root node of this combined configuration. This method will construct a combined node structure using the current node combiner if necessary. the combined root node



invalidate
public void invalidate()(Code)
Invalidates this combined configuration. This means that the next time a property is accessed the combined node structure must be re-constructed. Invalidation of a combined configuration also means that an event of type EVENT_COMBINED_INVALIDATE is fired. Note that while other events most times appear twice (once before and once after an update), this event is only fired once (after update).



isForceReloadCheck
public boolean isForceReloadCheck()(Code)
Returns a flag whether an enhanced reload check must be performed. the force reload check flag
since:
   1.4



removeConfiguration
public boolean removeConfiguration(Configuration config)(Code)
Removes the specified configuration from this combined configuration.
Parameters:
  config - the configuration to be removed a flag whether this configuration was found and could be removed



removeConfiguration
public Configuration removeConfiguration(String name)(Code)
Removes the configuration with the specified name.
Parameters:
  name - the name of the configuration to be removed the removed configuration (null if this configurationwas not found)



removeConfigurationAt
public Configuration removeConfigurationAt(int index)(Code)
Removes the configuration at the specified index.
Parameters:
  index - the index the removed configuration



setForceReloadCheck
public void setForceReloadCheck(boolean forceReloadCheck)(Code)
Sets the force reload check flag. If this flag is set, each property access on this configuration will cause a reload check on the contained configurations. This is a workaround for a problem with some reload implementations that only check if a reload is required when they are triggered. Per default this mode is disabled. If the force reload check flag is set to true, accessing properties will be less performant, but reloads on contained configurations will be detected.
Parameters:
  forceReloadCheck - the value of the flag
since:
   1.4



setNodeCombiner
public void setNodeCombiner(NodeCombiner nodeCombiner)(Code)
Sets the node combiner. This object will be used when the combined node structure is to be constructed. It must not be null, otherwise an IllegalArgumentException exception is thrown. Changing the node combiner causes an invalidation of this combined configuration, so that the new combiner immediately takes effect.
Parameters:
  nodeCombiner - the node combiner



Fields inherited from org.apache.commons.configuration.HierarchicalConfiguration
final public static int EVENT_ADD_NODES(Code)(Java Doc)
final public static int EVENT_CLEAR_TREE(Code)(Java Doc)

Methods inherited from org.apache.commons.configuration.HierarchicalConfiguration
public void addNodes(String key, Collection nodes)(Code)(Java Doc)
protected void addPropertyDirect(String key, Object obj)(Code)(Java Doc)
protected void clearNode(Node node)(Code)(Java Doc)
protected void clearNode(ConfigurationNode node)(Code)(Java Doc)
public void clearProperty(String key)(Code)(Java Doc)
protected static void clearReferences(ConfigurationNode node)(Code)(Java Doc)
public void clearTree(String key)(Code)(Java Doc)
public Object clone()(Code)(Java Doc)
public SubnodeConfiguration configurationAt(String key)(Code)(Java Doc)
public List configurationsAt(String key)(Code)(Java Doc)
public boolean containsKey(String key)(Code)(Java Doc)
protected Node createAddPath(ConfigurationKey.KeyIterator keyIt, Node root)(Code)(Java Doc)
protected Node createNode(String name)(Code)(Java Doc)
protected SubnodeConfiguration createSubnodeConfiguration(ConfigurationNode node)(Code)(Java Doc)
protected Node fetchAddNode(ConfigurationKey.KeyIterator keyIt, Node startNode)(Code)(Java Doc)
protected List fetchNodeList(String key)(Code)(Java Doc)
protected Node findLastPathNode(ConfigurationKey.KeyIterator keyIt, Node node)(Code)(Java Doc)
protected void findPropertyNodes(ConfigurationKey.KeyIterator keyPart, Node node, Collection nodes)(Code)(Java Doc)
public static ExpressionEngine getDefaultExpressionEngine()(Code)(Java Doc)
public ExpressionEngine getExpressionEngine()(Code)(Java Doc)
public Iterator getKeys()(Code)(Java Doc)
public Iterator getKeys(String prefix)(Code)(Java Doc)
public int getMaxIndex(String key)(Code)(Java Doc)
public Object getProperty(String key)(Code)(Java Doc)
public Node getRoot()(Code)(Java Doc)
public ConfigurationNode getRootNode()(Code)(Java Doc)
public boolean isEmpty()(Code)(Java Doc)
protected boolean nodeDefined(Node node)(Code)(Java Doc)
protected boolean nodeDefined(ConfigurationNode node)(Code)(Java Doc)
protected void removeNode(Node node)(Code)(Java Doc)
protected void removeNode(ConfigurationNode node)(Code)(Java Doc)
public static void setDefaultExpressionEngine(ExpressionEngine engine)(Code)(Java Doc)
public void setExpressionEngine(ExpressionEngine expressionEngine)(Code)(Java Doc)
public void setProperty(String key, Object value)(Code)(Java Doc)
public void setRoot(Node node)(Code)(Java Doc)
public void setRootNode(ConfigurationNode rootNode)(Code)(Java Doc)
public Configuration subset(String prefix)(Code)(Java Doc)

Fields inherited from org.apache.commons.configuration.AbstractConfiguration
final protected static String END_TOKEN(Code)(Java Doc)
final public static int EVENT_ADD_PROPERTY(Code)(Java Doc)
final public static int EVENT_CLEAR(Code)(Java Doc)
final public static int EVENT_CLEAR_PROPERTY(Code)(Java Doc)
final public static int EVENT_READ_PROPERTY(Code)(Java Doc)
final public static int EVENT_SET_PROPERTY(Code)(Java Doc)
final protected static String START_TOKEN(Code)(Java Doc)

Methods inherited from org.apache.commons.configuration.AbstractConfiguration
public void addErrorLogListener()(Code)(Java Doc)
public void addProperty(String key, Object value)(Code)(Java Doc)
abstract protected void addPropertyDirect(String key, Object value)(Code)(Java Doc)
public void clear()(Code)(Java Doc)
public void clearProperty(String key)(Code)(Java Doc)
protected void clearPropertyDirect(String key)(Code)(Java Doc)
abstract public boolean containsKey(String key)(Code)(Java Doc)
protected ConfigurationInterpolator createInterpolator()(Code)(Java Doc)
public BigDecimal getBigDecimal(String key)(Code)(Java Doc)
public BigDecimal getBigDecimal(String key, BigDecimal defaultValue)(Code)(Java Doc)
public BigInteger getBigInteger(String key)(Code)(Java Doc)
public BigInteger getBigInteger(String key, BigInteger defaultValue)(Code)(Java Doc)
public boolean getBoolean(String key)(Code)(Java Doc)
public boolean getBoolean(String key, boolean defaultValue)(Code)(Java Doc)
public Boolean getBoolean(String key, Boolean defaultValue)(Code)(Java Doc)
public byte getByte(String key)(Code)(Java Doc)
public byte getByte(String key, byte defaultValue)(Code)(Java Doc)
public Byte getByte(String key, Byte defaultValue)(Code)(Java Doc)
public static char getDefaultListDelimiter()(Code)(Java Doc)
public static char getDelimiter()(Code)(Java Doc)
public double getDouble(String key)(Code)(Java Doc)
public double getDouble(String key, double defaultValue)(Code)(Java Doc)
public Double getDouble(String key, Double defaultValue)(Code)(Java Doc)
public float getFloat(String key)(Code)(Java Doc)
public float getFloat(String key, float defaultValue)(Code)(Java Doc)
public Float getFloat(String key, Float defaultValue)(Code)(Java Doc)
public int getInt(String key)(Code)(Java Doc)
public int getInt(String key, int defaultValue)(Code)(Java Doc)
public Integer getInteger(String key, Integer defaultValue)(Code)(Java Doc)
public ConfigurationInterpolator getInterpolator()(Code)(Java Doc)
abstract public Iterator getKeys()(Code)(Java Doc)
public Iterator getKeys(String prefix)(Code)(Java Doc)
public List getList(String key)(Code)(Java Doc)
public List getList(String key, List defaultValue)(Code)(Java Doc)
public char getListDelimiter()(Code)(Java Doc)
public Log getLogger()(Code)(Java Doc)
public long getLong(String key)(Code)(Java Doc)
public long getLong(String key, long defaultValue)(Code)(Java Doc)
public Long getLong(String key, Long defaultValue)(Code)(Java Doc)
public Properties getProperties(String key)(Code)(Java Doc)
public Properties getProperties(String key, Properties defaults)(Code)(Java Doc)
public short getShort(String key)(Code)(Java Doc)
public short getShort(String key, short defaultValue)(Code)(Java Doc)
public Short getShort(String key, Short defaultValue)(Code)(Java Doc)
public String getString(String key)(Code)(Java Doc)
public String getString(String key, String defaultValue)(Code)(Java Doc)
public String[] getStringArray(String key)(Code)(Java Doc)
public synchronized StrSubstitutor getSubstitutor()(Code)(Java Doc)
protected String interpolate(String base)(Code)(Java Doc)
protected Object interpolate(Object value)(Code)(Java Doc)
protected String interpolateHelper(String base, List priorVariables)(Code)(Java Doc)
public boolean isDelimiterParsingDisabled()(Code)(Java Doc)
abstract public boolean isEmpty()(Code)(Java Doc)
public boolean isThrowExceptionOnMissing()(Code)(Java Doc)
protected Object resolveContainerStore(String key)(Code)(Java Doc)
public static void setDefaultListDelimiter(char delimiter)(Code)(Java Doc)
public static void setDelimiter(char delimiter)(Code)(Java Doc)
public void setDelimiterParsingDisabled(boolean delimiterParsingDisabled)(Code)(Java Doc)
public void setListDelimiter(char listDelimiter)(Code)(Java Doc)
public void setLogger(Log log)(Code)(Java Doc)
public void setProperty(String key, Object value)(Code)(Java Doc)
public void setThrowExceptionOnMissing(boolean throwExceptionOnMissing)(Code)(Java Doc)
public Configuration subset(String prefix)(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.