org.apache.tamaya.mutableconfig.internal

## Class DefaultMutableConfiguration

- java.lang.Object
- - org.apache.tamaya.mutableconfig.internal.DefaultMutableConfiguration

- All Implemented Interfaces:
    org.apache.tamaya.Configuration, MutableConfiguration

      public class DefaultMutableConfiguration
      extends Object
      implements MutableConfiguration

  Default implementation of a `MutableConfiguration`.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultMutableConfiguration(org.apache.tamaya.Configuration config)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `commitTransaction()` Commits the request.
    `String` | `get(String key)`
    `<T> T` | `get(String key, Class<T> type)`
    `<T> T` | `get(String key, org.apache.tamaya.TypeLiteral<T> type)`
    `boolean` | `getAutoCommit()` Get the current autoCommit policy.
    `ChangePropagationPolicy` | `getChangePropagationPolicy()` Access the active `ChangePropagationPolicy`.This policy controls how configuration changes are written/published to the known `MutablePropertySource` instances of a `Configuration`.
    `org.apache.tamaya.spi.ConfigurationContext` | `getContext()`
    `List<MutablePropertySource>` | `getMutablePropertySources()` Identifies the configuration backend that are targeted by this instance and which are also responsible for writing back the changes applied.
    `<T> T` | `getOrDefault(String key, Class<T> type, T defaultValue)`
    `String` | `getOrDefault(String key, String defaultValue)`
    `<T> T` | `getOrDefault(String key, org.apache.tamaya.TypeLiteral<T> type, T defaultValue)`
    `Map<String,String>` | `getProperties()`
    `List<MutablePropertySource>` | `getPropertySourcesThatCanRemove(String keyExpression)` Identifies the configuration backend that know the given key(s) and support removing it/them.
    `List<MutablePropertySource>` | `getPropertySourcesThatCanWrite(String keyExpression)` Identifies the configuration backends that supports writing the given key(s).
    `List<MutablePropertySource>` | `getPropertySourcesThatKnow(String keyExpression)` Identifies the configuration backend that know the given key(s).
    `UUID` | `getTransactionId()` Get the current transaction id.
    `boolean` | `isExisting(String keyExpression)` Checks if any keys of the given type already exist in the write backend.
    `boolean` | `isRemovable(String keyExpression)` Checks if a configuration key is removable.
    `boolean` | `isWritable(String keyExpression)` Checks if a configuration key is writable (or it can be added).
    `MutableConfiguration` | `put(String key, String value)` Sets a property.
    `MutableConfiguration` | `putAll(Map<String,String> properties)` Puts all given configuration entries.
    `<T> T` | `query(org.apache.tamaya.ConfigQuery<T> query)`
    `MutableConfiguration` | `remove(Collection<String> keys)` Removes all given configuration entries.
    `MutableConfiguration` | `remove(String... keys)` Removes all given configuration entries.
    `void` | `rollbackTransaction()` Rollback any changes leaving everything unchanged.
    `void` | `setAutoCommit(boolean autoCommit)` Set the autoCommit policy to be used for this configuration instance.
    `void` | `setChangePropagationPolicy(ChangePropagationPolicy changePropagationPolicy)` Set the `ChangePropagationPolicy`.
    `UUID` | `startTransaction()` Starts a new transaction, if necessary, and returns the transaction id.
    `String` | `toString()`
    `org.apache.tamaya.Configuration` | `with(org.apache.tamaya.ConfigOperator operator)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### DefaultMutableConfiguration

          public DefaultMutableConfiguration(org.apache.tamaya.Configuration config)

  - ### Method Detail

    - #### setChangePropagationPolicy

          public void setChangePropagationPolicy(ChangePropagationPolicy changePropagationPolicy)

      Description copied from interface: `MutableConfiguration`
      Set the `ChangePropagationPolicy`.
      Specified by:
        `setChangePropagationPolicy` in interface `MutableConfiguration`
      Parameters:
        `changePropagationPolicy` - the policy, not null.
      See Also:
        `MutableConfiguration.getChangePropagationPolicy()`

    - #### getChangePropagationPolicy

          public ChangePropagationPolicy getChangePropagationPolicy()

      Description copied from interface: `MutableConfiguration`
      Access the active `ChangePropagationPolicy`.This policy controls how configuration changes are written/published to the known `MutablePropertySource` instances of a `Configuration`.
      Specified by:
        `getChangePropagationPolicy` in interface `MutableConfiguration`
      Returns:
        he active `ChangePropagationPolicy`, never null.

    - #### setAutoCommit

          public void setAutoCommit(boolean autoCommit)

      Description copied from interface: `MutableConfiguration`
      Set the autoCommit policy to be used for this configuration instance.
      Specified by:
        `setAutoCommit` in interface `MutableConfiguration`
      Parameters:
        `autoCommit` - the new autoCommit policy.

    - #### getTransactionId

          public UUID getTransactionId()

      Description copied from interface: `MutableConfiguration`
      Get the current transaction id.
      Specified by:
        `getTransactionId` in interface `MutableConfiguration`
      Returns:
        the current transaction id, or null, if no transaction is active.

    - #### getAutoCommit

          public boolean getAutoCommit()

      Description copied from interface: `MutableConfiguration`
      Get the current autoCommit policy. AutoCommit will commit the transaction after each change applied.
      Specified by:
        `getAutoCommit` in interface `MutableConfiguration`
      Returns:
        the current autoCommit policy, by default false.

    - #### getMutablePropertySources

          public List<MutablePropertySource> getMutablePropertySources()

      Description copied from interface: `MutableConfiguration`
      Identifies the configuration backend that are targeted by this instance and which are also responsible for writing back the changes applied.
      Specified by:
        `getMutablePropertySources` in interface `MutableConfiguration`
      Returns:
        the property sources identified, in order of their occurrence/priority (most significant first).

    - #### isWritable

          public boolean isWritable(String keyExpression)

      Description copied from interface: `MutableConfiguration`
      Checks if a configuration key is writable (or it can be added).
      Specified by:
        `isWritable` in interface `MutableConfiguration`
      Parameters:
        `keyExpression` - the key to be checked for write access (including creation), not null. Here this could also be a regular expression, such "as a.b.c.*".
      Returns:
        the boolean

    - #### getPropertySourcesThatCanWrite

          public List<MutablePropertySource> getPropertySourcesThatCanWrite(String keyExpression)

      Description copied from interface: `MutableConfiguration`
      Identifies the configuration backends that supports writing the given key(s).
      Specified by:
        `getPropertySourcesThatCanWrite` in interface `MutableConfiguration`
      Parameters:
        `keyExpression` - the key to be checked for write access (including creation), not null. Here this could also be a regular expression, such "as a.b.c.*".
      Returns:
        the property sources identified, in order of their occurrence/priority (most significant first).

    - #### isRemovable

          public boolean isRemovable(String keyExpression)

      Description copied from interface: `MutableConfiguration`
      Checks if a configuration key is removable. This also implies that it is writable, but there might be writable keys that cannot be removedProperties.
      Specified by:
        `isRemovable` in interface `MutableConfiguration`
      Parameters:
        `keyExpression` - the keyExpression the key to be checked for write access (including creation), not null. Here this could also be a regular expression, such "as a.b.c.*".
      Returns:
        the boolean

    - #### getPropertySourcesThatCanRemove

          public List<MutablePropertySource> getPropertySourcesThatCanRemove(String keyExpression)

      Description copied from interface: `MutableConfiguration`
      Identifies the configuration backend that know the given key(s) and support removing it/them.
      Specified by:
        `getPropertySourcesThatCanRemove` in interface `MutableConfiguration`
      Parameters:
        `keyExpression` - the key to be checked for write access (including creation), not null. Here this could also be a regular expression, such "as a.b.c.*".
      Returns:
        the property sources identified, in order of their occurrence/priority (most significant first).

    - #### isExisting

          public boolean isExisting(String keyExpression)

      Description copied from interface: `MutableConfiguration`
      Checks if any keys of the given type already exist in the write backend. NOTE: there may be backends that are not able to support lookups with regular expressions. In most such cases you should pass the keys to lookup explicitly.
      Specified by:
        `isExisting` in interface `MutableConfiguration`
      Parameters:
        `keyExpression` - the key to be checked for write access (including creation), not null. Here this could also be a regular expression, such "as a.b.c.*".
      Returns:
        true, if there is any key found matching the expression.

    - #### getPropertySourcesThatKnow

          public List<MutablePropertySource> getPropertySourcesThatKnow(String keyExpression)

      Description copied from interface: `MutableConfiguration`
      Identifies the configuration backend that know the given key(s).
      Specified by:
        `getPropertySourcesThatKnow` in interface `MutableConfiguration`
      Parameters:
        `keyExpression` - the key to be checked for write access (including creation), not null. Here this could also be a regular expression, such "as a.b.c.*".
      Returns:
        the property sources identified, in order of their occurrence/priority (most significant first).

    - #### put

          public MutableConfiguration put(String key,
                                 String value)

      Description copied from interface: `MutableConfiguration`
      Sets a property.
      Specified by:
        `put` in interface `MutableConfiguration`
      Parameters:
        `key` - the property's key, not null.
        `value` - the property's value, not null.
      Returns:
        the former property value, or null.

    - #### putAll

          public MutableConfiguration putAll(Map<String,String> properties)

      Description copied from interface: `MutableConfiguration`
      Puts all given configuration entries. This method should check that all given properties are basically removable, as defined by #isWritable. If any of the passed keys is not writable during this initial check, the operation should not perform any configuration changes and throw a `ConfigException`. If errors occur afterwards, when the properties are effectively written back to the backends, the errors should be collected and returned as part of the ConfigException payload. Nevertheless the operation should in that case remove all entries as far as possible and abort the writing operation.
      Specified by:
        `putAll` in interface `MutableConfiguration`
      Parameters:
        `properties` - the properties tobe written, not null.
      Returns:
        the config change request

    - #### remove

          public MutableConfiguration remove(String... keys)

      Description copied from interface: `MutableConfiguration`
      Removes all given configuration entries. This method should check that all given properties are basically removable, as defined by #isRemovable. If any of the passed keys is not removable during this initial check, the operation should not perform any configuration changes and throw a `ConfigException`. If errors occur afterwards, when the properties are effectively written back to the backends, the errors should be collected and returned as part of the ConfigException payload. Nevertheless the operation should in that case remove all entries as far as possible and abort the writing operation.
      Specified by:
        `remove` in interface `MutableConfiguration`
      Parameters:
        `keys` - the property's keys to be removedProperties, not null.
      Returns:
        the config change request

    - #### startTransaction

          public UUID startTransaction()

      Description copied from interface: `MutableConfiguration`
      Starts a new transaction, if necessary, and returns the transaction id. New transaction are, similar to Java EE, bound to the current thread. As a consequences all properties added , updated or removed must be managed by a corresponding context, isolated by thread. The `MutablePropertySource` get the right transaction id passed, when writing (committing) any changes applied.
      Specified by:
        `startTransaction` in interface `MutableConfiguration`
      Returns:
        the transaction id, not null.

    - #### commitTransaction

          public void commitTransaction()

      Description copied from interface: `MutableConfiguration`
      Commits the request. After a commit the change is not editable anymore. All changes applied will be written to the corresponding configuration backend. NOTE that changes applied must not necessarily be visible in the current `Configuration` instance, since visibility of changes also depends on the ordinals set on the `PropertySource`s configured.
      Specified by:
        `commitTransaction` in interface `MutableConfiguration`

    - #### rollbackTransaction

          public void rollbackTransaction()

      Description copied from interface: `MutableConfiguration`
      Rollback any changes leaving everything unchanged. This will rollback all changes applied since the last commit.
      Specified by:
        `rollbackTransaction` in interface `MutableConfiguration`

    - #### remove

          public MutableConfiguration remove(Collection<String> keys)

      Description copied from interface: `MutableConfiguration`
      Removes all given configuration entries. This method should check that all given properties are basically removable, as defined by #isRemovable. If any of the passed keys is not removable during this initial check, the operation should not perform any configuration changes and throw a `ConfigException`. If errors occur afterwards, when the properties are effectively written back to the backends, the errors should be collected and returned as part of the ConfigException payload. Nevertheless the operation should in that case remove all entries as far as possible and abort the writing operation.
      Specified by:
        `remove` in interface `MutableConfiguration`
      Parameters:
        `keys` - the property's keys to be removedProperties, not null.
      Returns:
        the config change request

    - #### get

          public String get(String key)

      Specified by:
        `get` in interface `org.apache.tamaya.Configuration`

    - #### getOrDefault

          public String getOrDefault(String key,
                            String defaultValue)

      Specified by:
        `getOrDefault` in interface `org.apache.tamaya.Configuration`

    - #### getOrDefault

          public <T> T getOrDefault(String key,
                           Class<T> type,
                           T defaultValue)

      Specified by:
        `getOrDefault` in interface `org.apache.tamaya.Configuration`

    - #### get

          public <T> T get(String key,
                  Class<T> type)

      Specified by:
        `get` in interface `org.apache.tamaya.Configuration`

    - #### get

          public <T> T get(String key,
                  org.apache.tamaya.TypeLiteral<T> type)

      Specified by:
        `get` in interface `org.apache.tamaya.Configuration`

    - #### getOrDefault

          public <T> T getOrDefault(String key,
                           org.apache.tamaya.TypeLiteral<T> type,
                           T defaultValue)

      Specified by:
        `getOrDefault` in interface `org.apache.tamaya.Configuration`

    - #### getProperties

          public Map<String,String> getProperties()

      Specified by:
        `getProperties` in interface `org.apache.tamaya.Configuration`

    - #### with

          public org.apache.tamaya.Configuration with(org.apache.tamaya.ConfigOperator operator)

      Specified by:
        `with` in interface `org.apache.tamaya.Configuration`

    - #### query

          public <T> T query(org.apache.tamaya.ConfigQuery<T> query)

      Specified by:
        `query` in interface `org.apache.tamaya.Configuration`

    - #### getContext

          public org.apache.tamaya.spi.ConfigurationContext getContext()

      Specified by:
        `getContext` in interface `org.apache.tamaya.Configuration`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2014–2016 Apache Software Foundation. All rights reserved.