Fixed compile issue. Signed-off-by: Anatole Tresch <[email protected]>
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/2abb7a77 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/2abb7a77 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/2abb7a77 Branch: refs/heads/configjsr Commit: 2abb7a772772ef7af993f470efa6bad4c2dbbf4c Parents: 319f435 Author: Anatole Tresch <[email protected]> Authored: Sun Apr 22 19:00:58 2018 +0200 Committer: Anatole Tresch <[email protected]> Committed: Sun Apr 22 19:00:58 2018 +0200 ---------------------------------------------------------------------- .../internal/DefaultMutableConfig.java | 148 +++++++++++++++++++ .../internal/DefaultMutableConfiguration.java | 128 ---------------- .../DefaultMutableConfigurationSpi.java | 4 +- 3 files changed, 150 insertions(+), 130 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2abb7a77/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/internal/DefaultMutableConfig.java ---------------------------------------------------------------------- diff --git a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/internal/DefaultMutableConfig.java b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/internal/DefaultMutableConfig.java new file mode 100644 index 0000000..4af5103 --- /dev/null +++ b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/internal/DefaultMutableConfig.java @@ -0,0 +1,148 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tamaya.mutableconfig.internal; + +import org.apache.tamaya.base.ConfigContext; +import org.apache.tamaya.base.ConfigContextSupplier; +import org.apache.tamaya.base.DefaultConfigValue; +import org.apache.tamaya.mutableconfig.ChangePropagationPolicy; +import org.apache.tamaya.mutableconfig.MutableConfig; +import org.apache.tamaya.mutableconfig.ConfigChangeRequest; +import org.apache.tamaya.mutableconfig.spi.MutableConfigSource; +import org.osgi.service.component.annotations.Component; + +import javax.config.Config; +import javax.config.ConfigValue; +import javax.config.spi.ConfigSource; +import java.util.*; +import java.util.function.Consumer; +import java.util.logging.Logger; + + +/** + * Default implementation of a {@link MutableConfig}. + */ +@Component +public class DefaultMutableConfig implements MutableConfig, ConfigContextSupplier { + private static final Logger LOG = Logger.getLogger(DefaultMutableConfig.class.getName()); + private ConfigChangeRequest changeRequest = new ConfigChangeRequest(UUID.randomUUID().toString()); + private final Config config; + private ChangePropagationPolicy changePropagationPolicy; + + public DefaultMutableConfig(Config config, ChangePropagationPolicy changePropagationPolicy){ + this.config = Objects.requireNonNull(config); + this.changePropagationPolicy = Objects.requireNonNull(changePropagationPolicy); + } + + @Override + public ConfigValue<String> access(String key) { + return new DefaultConfigValue(this, this, key, String.class); + } + + @Override + public void registerConfigChangedListener(Consumer<Set<String>> consumer) { + throw new UnsupportedOperationException("Not yet implemented."); + } + + @Override + public ConfigContext getConfigContext() { + return ConfigContext.from(config); + } + + @Override + public ChangePropagationPolicy getChangePropagationPolicy(){ + return changePropagationPolicy; + } + + @Override + public ConfigChangeRequest getConfigChangeRequest(){ + return changeRequest; + } + + protected List<MutableConfigSource> getMutablePropertySources() { + List<MutableConfigSource> result = new ArrayList<>(); + for(ConfigSource propertySource:this.config.getConfigSources()) { + if(propertySource instanceof MutableConfigSource){ + result.add((MutableConfigSource)propertySource); + } + } + return result; + } + + + @Override + public MutableConfig put(String key, String value) { + changeRequest.put(key, value); + return this; + } + + @Override + public MutableConfig putAll(Map<String, String> properties) { + changeRequest.putAll(properties); + return this; + } + + @Override + public MutableConfig remove(String... keys) { + changeRequest.removeAll(Arrays.asList(keys)); + return this; + } + + + @Override + public void store() { + this.changePropagationPolicy.applyChange(changeRequest, config.getConfigSources()); + } + + @Override + public MutableConfig remove(Collection<String> keys) { + for(MutableConfigSource target:getMutablePropertySources()) { + changeRequest.removeAll(keys); + } + return this; + } + + @Override + public <T> T getValue(String key, Class<T> type) { + return this.config.getValue(key, type); + } + + @Override + public <T> Optional<T> getOptionalValue(String key, Class<T> type) { + return this.config.getOptionalValue(key,type); + } + + @Override + public Iterable<String> getPropertyNames() { + return this.config.getPropertyNames(); + } + + @Override + public Iterable<ConfigSource> getConfigSources() { + return this.config.getConfigSources(); + } + + @Override + public String toString() { + return "DefaultMutableConfiguration{" + + "config=" + config + + '}'; + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2abb7a77/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/internal/DefaultMutableConfiguration.java ---------------------------------------------------------------------- diff --git a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/internal/DefaultMutableConfiguration.java b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/internal/DefaultMutableConfiguration.java deleted file mode 100644 index d8d137d..0000000 --- a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/internal/DefaultMutableConfiguration.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tamaya.mutableconfig.internal; - -import org.apache.tamaya.mutableconfig.ChangePropagationPolicy; -import org.apache.tamaya.mutableconfig.MutableConfig; -import org.apache.tamaya.mutableconfig.ConfigChangeRequest; -import org.apache.tamaya.mutableconfig.spi.MutableConfigSource; -import org.osgi.service.component.annotations.Component; - -import javax.config.Config; -import javax.config.spi.ConfigSource; -import java.util.*; -import java.util.logging.Logger; - - -/** - * Default implementation of a {@link MutableConfig}. - */ -@Component -public class DefaultMutableConfiguration implements MutableConfig { - private static final Logger LOG = Logger.getLogger(DefaultMutableConfiguration.class.getName()); - private ConfigChangeRequest changeRequest = new ConfigChangeRequest(UUID.randomUUID().toString()); - private final Config config; - private ChangePropagationPolicy changePropagationPolicy; - - public DefaultMutableConfiguration(Config config, ChangePropagationPolicy changePropagationPolicy){ - this.config = Objects.requireNonNull(config); - this.changePropagationPolicy = Objects.requireNonNull(changePropagationPolicy); - } - - @Override - public ChangePropagationPolicy getChangePropagationPolicy(){ - return changePropagationPolicy; - } - - @Override - public ConfigChangeRequest getConfigChangeRequest(){ - return changeRequest; - } - - protected List<MutableConfigSource> getMutablePropertySources() { - List<MutableConfigSource> result = new ArrayList<>(); - for(ConfigSource propertySource:this.config.getConfigSources()) { - if(propertySource instanceof MutableConfigSource){ - result.add((MutableConfigSource)propertySource); - } - } - return result; - } - - - @Override - public MutableConfig put(String key, String value) { - changeRequest.put(key, value); - return this; - } - - @Override - public MutableConfig putAll(Map<String, String> properties) { - changeRequest.putAll(properties); - return this; - } - - @Override - public MutableConfig remove(String... keys) { - changeRequest.removeAll(Arrays.asList(keys)); - return this; - } - - - @Override - public void store() { - this.changePropagationPolicy.applyChange(changeRequest, config.getConfigSources()); - } - - @Override - public MutableConfig remove(Collection<String> keys) { - for(MutableConfigSource target:getMutablePropertySources()) { - changeRequest.removeAll(keys); - } - return this; - } - - @Override - public <T> T getValue(String key, Class<T> type) { - return this.config.getValue(key, type); - } - - @Override - public <T> Optional<T> getOptionalValue(String key, Class<T> type) { - return this.config.getOptionalValue(key,type); - } - - @Override - public Iterable<String> getPropertyNames() { - return this.config.getPropertyNames(); - } - - @Override - public Iterable<ConfigSource> getConfigSources() { - return this.config.getConfigSources(); - } - - @Override - public String toString() { - return "DefaultMutableConfiguration{" + - "config=" + config + - '}'; - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2abb7a77/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/internal/DefaultMutableConfigurationSpi.java ---------------------------------------------------------------------- diff --git a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/internal/DefaultMutableConfigurationSpi.java b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/internal/DefaultMutableConfigurationSpi.java index d21366a..52813f1 100644 --- a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/internal/DefaultMutableConfigurationSpi.java +++ b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/internal/DefaultMutableConfigurationSpi.java @@ -27,7 +27,7 @@ import javax.config.Config; /** - * SPI implementation that creates instances of {@link DefaultMutableConfiguration}, hereby for + * SPI implementation that creates instances of {@link DefaultMutableConfig}, hereby for * each instance of {@link Config} a new instance has to be returned. */ @Component @@ -36,6 +36,6 @@ public class DefaultMutableConfigurationSpi implements MutableConfigProviderSpi @Override public MutableConfig createMutableConfig(Config configuration, ChangePropagationPolicy propagationPolicy){ - return new DefaultMutableConfiguration(configuration, propagationPolicy); + return new DefaultMutableConfig(configuration, propagationPolicy); } }
