org.apache.tamaya.mutableconfig.propertysources

## Class AbstractMutablePropertySource

- java.lang.Object
- - org.apache.tamaya.spisupport.BasePropertySource
  - - org.apache.tamaya.mutableconfig.propertysources.AbstractMutablePropertySource

- All Implemented Interfaces:
    MutablePropertySource, org.apache.tamaya.spi.PropertySource
  Direct Known Subclasses:
    MutablePropertiesPropertySource, MutableXmlPropertiesPropertySource

      public abstract class AbstractMutablePropertySource
      extends org.apache.tamaya.spisupport.BasePropertySource
      implements MutablePropertySource

  Base class for implementing a `MutablePropertySource`.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Map<UUID,ConfigChangeContext>` | `transactions` Map with the curren transactions, identified by transactionId.

    - ### Fields inherited from interface org.apache.tamaya.spi.PropertySource

      `EMPTY, TAMAYA_ORDINAL`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AbstractMutablePropertySource()` Constructor udsing zero' as default ordinal.
    `protected` | `AbstractMutablePropertySource(int defaultOrdinal)` Constructor allow to pass the default ordinal to be used.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract void` | `commitInternal(ConfigChangeContext context)` Commit of the changes to the current property source.
    `void` | `commitTransaction(UUID transactionId)` Commits the request.
    `protected Map<String,String>` | `getAddedProperties(UUID transactionId)` Get a list with property keys added within the given transaction.
    `protected Set<String>` | `getRemovedProperties(UUID transactionId)` Get a list with property keys removed within the given transaction.
    `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).
    `MutablePropertySource` | `put(UUID transactionId, String key, String value)` Sets a property.
    `MutablePropertySource` | `putAll(UUID transactionId, Map<String,String> properties)` Puts all given configuration entries.
    `MutablePropertySource` | `remove(UUID transactionId, Collection<String> keys)` Removes all given configuration entries.
    `MutablePropertySource` | `remove(UUID transactionId, String... keys)` Removes all given configuration entries.
    `void` | `rollbackTransaction(UUID transactionId)` Rollback any changes leaving everything unchanged.
    `void` | `startTransaction(UUID transactionId)` Start a new transaction context with the given isolation policy.

    - ### Methods inherited from class org.apache.tamaya.spisupport.BasePropertySource

      `get, getDefaultOrdinal, getOrdinal, isScannable`

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

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

    - ### Methods inherited from interface org.apache.tamaya.spi.PropertySource

      `get, getName, getOrdinal, getProperties, isScannable`

- - ### Field Detail

    - #### transactions

          protected final Map<UUID,ConfigChangeContext> transactions

      Map with the curren transactions, identified by transactionId.

  - ### Constructor Detail

    - #### AbstractMutablePropertySource

          protected AbstractMutablePropertySource()

      Constructor udsing zero' as default ordinal.

    - #### AbstractMutablePropertySource

          protected AbstractMutablePropertySource(int defaultOrdinal)

      Constructor allow to pass the default ordinal to be used.
      Parameters:
        `defaultOrdinal` - the default ordinal.

  - ### Method Detail

    - #### getRemovedProperties

          protected final Set<String> getRemovedProperties(UUID transactionId)

      Get a list with property keys removed within the given transaction.
      Parameters:
        `transactionId` - the transaction id, not null.
      Returns:
        the removed property keys, never null.

    - #### getAddedProperties

          protected final Map<String,String> getAddedProperties(UUID transactionId)

      Get a list with property keys added within the given transaction.
      Parameters:
        `transactionId` - the transaction id, not null.
      Returns:
        the added property keys, never null.

    - #### isWritable

          public boolean isWritable(String keyExpression)

      Description copied from interface: `MutablePropertySource`
      Checks if a configuration key is writable (or it can be added).
      Specified by:
        `isWritable` in interface `MutablePropertySource`
      Parameters:
        `keyExpression` - the key to be checked for write access (including creation), not null.
      Returns:
        true if the key can be added or updated.

    - #### isRemovable

          public boolean isRemovable(String keyExpression)

      Description copied from interface: `MutablePropertySource`
      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 `MutablePropertySource`
      Parameters:
        `keyExpression` - the key to be checked for removal, not null.
      Returns:
        true, if the key can be removed.

    - #### put

          public final MutablePropertySource put(UUID transactionId,
                                  String key,
                                  String value)

      Description copied from interface: `MutablePropertySource`
      Sets a property.
      Specified by:
        `put` in interface `MutablePropertySource`
      Parameters:
        `transactionId` - the transactionId used to isolate the change, not null.
        `key` - the property's key, not null.
        `value` - the property's value, not null.
      Returns:
        this instance for optional chaining of operations, nrvrt null.

    - #### putAll

          public final MutablePropertySource putAll(UUID transactionId,
                                     Map<String,String> properties)

      Description copied from interface: `MutablePropertySource`
      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 `MutablePropertySource`
      Parameters:
        `transactionId` - the transactionId used to isolate the change, not null.
        `properties` - the properties tobe written, not null.
      Returns:
        this instance for optional chaining of operations, nrvrt null.

    - #### remove

          public final MutablePropertySource remove(UUID transactionId,
                                     String... keys)

      Description copied from interface: `MutablePropertySource`
      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 `MutablePropertySource`
      Parameters:
        `transactionId` - the transactionId used to isolate the change, not null.
        `keys` - the property's keys to be removedProperties, not null.
      Returns:
        this instance for optional chaining of operations, nrvrt null.

    - #### remove

          public final MutablePropertySource remove(UUID transactionId,
                                     Collection<String> keys)

      Description copied from interface: `MutablePropertySource`
      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 `MutablePropertySource`
      Parameters:
        `transactionId` - the transactionId used to isolate the change, not null.
        `keys` - the property's keys to be removedProperties, not null.
      Returns:
        this instance for optional chaining of operations, nrvrt null.

    - #### startTransaction

          public final void startTransaction(UUID transactionId)

      Description copied from interface: `MutablePropertySource`
      Start a new transaction context with the given isolation policy.
      Specified by:
        `startTransaction` in interface `MutablePropertySource`
      Parameters:
        `transactionId` - the transaction id, not null.

    - #### commitTransaction

          public final void commitTransaction(UUID transactionId)

      Description copied from interface: `MutablePropertySource`
      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 `MutablePropertySource`
      Parameters:
        `transactionId` - the transaction id, not null.

    - #### commitInternal

          protected abstract void commitInternal(ConfigChangeContext context)

      Commit of the changes to the current property source. This is the last chance to get changes written back to the property source. On return the transactional context will be removed.
      Parameters:
        `context` - The configuration change to be committed/applied.

    - #### rollbackTransaction

          public final void rollbackTransaction(UUID transactionId)

      Description copied from interface: `MutablePropertySource`
      Rollback any changes leaving everything unchanged. This will rollback all changes applied since the last commit.
      Specified by:
        `rollbackTransaction` in interface `MutablePropertySource`
      Parameters:
        `transactionId` - the transaction id, not null.

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