Understanding the Configuration class

The Configuration class provides applications with read-only access to the Configuration and Management database. The Configuration class is a singleton whose sole instance can be obtained through the getConfiguration() method.

Attention: In Java EE applications, a singleton does not span multiple JVM instances. Therefore, the semantics of the Configuration singleton are only maintained while in the same JVM instance as the calling code.

You can browse the Configuration and Management database with the Configuration object using one of two modes:

  • Context-free access—Allows the calling code to see the latest values in the Configuration and Management database. One effect of context-free access is that multiple queries on a given configuration item can yield different values if an administrator has changed that item outside of the application. This might be an undesired effect (for example, when an application is processing a business transaction that requires a consistent view of the configuration).

    Context-based access—Ensures that, within the scope of an established context, an application can query a configuration item any number of times and it will still yield the same result, regardless of whether that item has been modified outside of the application.

    For context-based access, it must be noted that the context is valid only within the process (JVM) in which it was created. If an application needs to ensure a consistent view of the configuration across multiple processes, it must itself ensure that the configuration is passed in remote calls from process to process. Another option is the use of a distributed cache for the Configuration singleton.

In addition to providing access to the Configuration and Management database, the Configuration class provides information about the application's name and version. These are retrieved from the manifest file in the application's archive (JAR, WAR, or EAR). The class that triggers the Configuration class to load must itself be loaded from an archive. This archive must contain a manifest file (META-INF/MANIFEST.MF) that, within its main attributes, contains two attributes: Application-Name and Application-Version.