public class DefaultMutableConfiguration extends Object implements MutableConfiguration
MutableConfiguration
.Constructor and Description |
---|
DefaultMutableConfiguration(org.apache.tamaya.Configuration config) |
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) |
public DefaultMutableConfiguration(org.apache.tamaya.Configuration config)
public void setChangePropagationPolicy(ChangePropagationPolicy changePropagationPolicy)
MutableConfiguration
ChangePropagationPolicy
.setChangePropagationPolicy
in interface MutableConfiguration
changePropagationPolicy
- the policy, not null.MutableConfiguration.getChangePropagationPolicy()
public ChangePropagationPolicy getChangePropagationPolicy()
MutableConfiguration
ChangePropagationPolicy
.This policy controls how configuration changes are written/published
to the known MutablePropertySource
instances of a Configuration
.getChangePropagationPolicy
in interface MutableConfiguration
ChangePropagationPolicy
, never null.public void setAutoCommit(boolean autoCommit)
MutableConfiguration
setAutoCommit
in interface MutableConfiguration
autoCommit
- the new autoCommit policy.public UUID getTransactionId()
MutableConfiguration
getTransactionId
in interface MutableConfiguration
public boolean getAutoCommit()
MutableConfiguration
getAutoCommit
in interface MutableConfiguration
public List<MutablePropertySource> getMutablePropertySources()
MutableConfiguration
getMutablePropertySources
in interface MutableConfiguration
public boolean isWritable(String keyExpression)
MutableConfiguration
isWritable
in interface MutableConfiguration
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.*".public List<MutablePropertySource> getPropertySourcesThatCanWrite(String keyExpression)
MutableConfiguration
getPropertySourcesThatCanWrite
in interface MutableConfiguration
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.*".public boolean isRemovable(String keyExpression)
MutableConfiguration
isRemovable
in interface MutableConfiguration
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.*".public List<MutablePropertySource> getPropertySourcesThatCanRemove(String keyExpression)
MutableConfiguration
getPropertySourcesThatCanRemove
in interface MutableConfiguration
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.*".public boolean isExisting(String keyExpression)
MutableConfiguration
isExisting
in interface MutableConfiguration
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.*".public List<MutablePropertySource> getPropertySourcesThatKnow(String keyExpression)
MutableConfiguration
getPropertySourcesThatKnow
in interface MutableConfiguration
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.*".public MutableConfiguration put(String key, String value)
MutableConfiguration
put
in interface MutableConfiguration
key
- the property's key, not null.value
- the property's value, not null.public MutableConfiguration putAll(Map<String,String> properties)
MutableConfiguration
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.putAll
in interface MutableConfiguration
properties
- the properties tobe written, not null.public MutableConfiguration remove(String... keys)
MutableConfiguration
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.remove
in interface MutableConfiguration
keys
- the property's keys to be removedProperties, not null.public UUID startTransaction()
MutableConfiguration
MutablePropertySource
get the right transaction id
passed, when writing (committing) any changes applied.startTransaction
in interface MutableConfiguration
public void commitTransaction()
MutableConfiguration
Configuration
instance,
since visibility of changes also depends on the ordinals set on the PropertySource
s
configured.commitTransaction
in interface MutableConfiguration
public void rollbackTransaction()
MutableConfiguration
rollbackTransaction
in interface MutableConfiguration
public MutableConfiguration remove(Collection<String> keys)
MutableConfiguration
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.remove
in interface MutableConfiguration
keys
- the property's keys to be removedProperties, not null.public String getOrDefault(String key, String defaultValue)
getOrDefault
in interface org.apache.tamaya.Configuration
public <T> T getOrDefault(String key, Class<T> type, T defaultValue)
getOrDefault
in interface org.apache.tamaya.Configuration
public <T> T get(String key, Class<T> type)
get
in interface org.apache.tamaya.Configuration
public <T> T get(String key, org.apache.tamaya.TypeLiteral<T> type)
get
in interface org.apache.tamaya.Configuration
public <T> T getOrDefault(String key, org.apache.tamaya.TypeLiteral<T> type, T defaultValue)
getOrDefault
in interface org.apache.tamaya.Configuration
public Map<String,String> getProperties()
getProperties
in interface org.apache.tamaya.Configuration
public org.apache.tamaya.Configuration with(org.apache.tamaya.ConfigOperator operator)
with
in interface org.apache.tamaya.Configuration
public <T> T query(org.apache.tamaya.ConfigQuery<T> query)
query
in interface org.apache.tamaya.Configuration
public org.apache.tamaya.spi.ConfigurationContext getContext()
getContext
in interface org.apache.tamaya.Configuration
Copyright © 2014–2016 Apache Software Foundation. All rights reserved.