You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by pl...@apache.org on 2016/10/23 20:36:42 UTC
[30/50] [abbrv] incubator-tamaya-extensions git commit: TAMAYA-175
Moved the events module to the directory events after extracting it for the
Tamaya main repository.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/FrozenConfiguration.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/FrozenConfiguration.java b/src/main/java/org/apache/tamaya/events/FrozenConfiguration.java
deleted file mode 100644
index 304ddba..0000000
--- a/src/main/java/org/apache/tamaya/events/FrozenConfiguration.java
+++ /dev/null
@@ -1,194 +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.events;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.ConfigOperator;
-import org.apache.tamaya.ConfigQuery;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.functions.ConfigurationFunctions;
-import org.apache.tamaya.spi.ConfigurationContext;
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-import java.io.Serializable;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * /**
- * Configuration implementation that stores all current values of a given (possibly dynamic, contextual and non server
- * capable instance) and is fully serializable. Note that hereby only the scannable key/value pairs are considered.
- */
-public final class FrozenConfiguration implements Configuration, Serializable {
- private static final long serialVersionUID = -6373137316556444171L;
- /**
- * The properties frozen.
- */
- private Map<String, String> properties = new HashMap<>();
-
- /**
- * Constructor.
- *
- * @param config The base configuration.
- */
- private FrozenConfiguration(Configuration config) {
- this.properties.putAll(config.getProperties());
- this.properties.put("[meta]frozenAt", String.valueOf(System.currentTimeMillis()));
- this.properties = Collections.unmodifiableMap(this.properties);
- }
-
- /**
- * Creates a new FrozenConfiguration instance based on a Configuration given.
- *
- * @param config the configuration to be frozen, not null.
- * @return the frozen Configuration.
- */
- public static FrozenConfiguration of(Configuration config) {
- if (config instanceof FrozenConfiguration) {
- return (FrozenConfiguration) config;
- }
- return new FrozenConfiguration(config);
- }
-
- @Override
- public String get(String key) {
- return this.properties.get(key);
- }
-
- @Override
- public String getOrDefault(String key, String defaultValue) {
- String val = get(key);
- if(val==null){
- return defaultValue;
- }
- return val;
- }
-
- @Override
- public <T> T getOrDefault(String key, Class<T> type, T defaultValue) {
- T val = get(key, type);
- if(val==null){
- return defaultValue;
- }
- return val;
- }
-
- @Override
- public <T> T get(String key, Class<T> type) {
- return (T) get(key, TypeLiteral.of(type));
- }
-
- /**
- * Accesses the current String value for the given key and tries to convert it
- * using the {@link org.apache.tamaya.spi.PropertyConverter} instances provided by the current
- * {@link org.apache.tamaya.spi.ConfigurationContext}.
- *
- * @param key the property's absolute, or relative path, e.g. @code
- * a/b/c/d.myProperty}.
- * @param type The target type required, not null.
- * @param <T> the value type
- * @return the converted value, never null.
- */
- @Override
- public <T> T get(String key, TypeLiteral<T> type) {
- String value = get(key);
- if (value != null) {
- List<PropertyConverter<T>> converters = ConfigurationProvider.getConfigurationContext()
- .getPropertyConverters(type);
- ConversionContext context = new ConversionContext.Builder(this,
- ConfigurationProvider.getConfigurationContext(), key,type).build();
- for (PropertyConverter<T> converter : converters) {
- try {
- T t = converter.convert(value, context);
- if (t != null) {
- return t;
- }
- } catch (Exception e) {
- Logger.getLogger(getClass().getName())
- .log(Level.FINEST, "PropertyConverter: " + converter + " failed to convert value: " + value,
- e);
- }
- }
- throw new ConfigException("Unparseable config value for type: " + type.getRawType().getName() + ": " + key
- + ", supported formats: " + context.getSupportedFormats());
- }
-
- return null;
- }
-
- @Override
- public <T> T getOrDefault(String key, TypeLiteral<T> type, T defaultValue) {
- T val = get(key, type);
- if(val==null){
- return defaultValue;
- }
- return val;
- }
-
- @Override
- public Map<String, String> getProperties() {
- return properties;
- }
-
- @Override
- public Configuration with(ConfigOperator operator) {
- return operator.operate(this);
- }
-
- @Override
- public <T> T query(ConfigQuery<T> query) {
- return query.query(this);
- }
-
- @Override
- public ConfigurationContext getContext() {
- return ConfigurationFunctions.emptyConfigurationContext();
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- FrozenConfiguration that = (FrozenConfiguration) o;
- return properties.equals(that.properties);
- }
-
- @Override
- public int hashCode() {
- return properties.hashCode();
- }
-
- @Override
- public String toString() {
- return "FrozenConfiguration{" +
- "properties=" + properties +
- '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java b/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java
deleted file mode 100644
index 81e6dca..0000000
--- a/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java
+++ /dev/null
@@ -1,126 +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.events;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-
-import java.io.Serializable;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * PropertySource implementation that stores all current values of a given (possibly dynamic, contextual and non server
- * capable instance) and is fully serializable. Note that hereby only the scannable key/value pairs are considered.
- */
-public final class FrozenPropertySource implements PropertySource, Serializable {
- private static final long serialVersionUID = -6373137316556444171L;
- /**
- * The ordinal.
- */
- private final int ordinal;
- /**
- * The properties read.
- */
- private Map<String, String> properties = new HashMap<>();
- /**
- * The PropertySource's name.
- */
- private final String name;
-
- /**
- * Constructor.
- *
- * @param propertySource The base PropertySource.
- */
- private FrozenPropertySource(PropertySource propertySource) {
- this.properties.putAll(propertySource.getProperties());
- this.properties.put("[meta]frozenAt", String.valueOf(System.currentTimeMillis()));
- this.properties = Collections.unmodifiableMap(this.properties);
- this.ordinal = propertySource.getOrdinal();
- this.name = propertySource.getName();
- }
-
- /**
- * Creates a new FrozenPropertySource instance based on a PropertySource given.
- *
- * @param propertySource the property source to be frozen, not null.
- * @return the frozen property source.
- */
- public static FrozenPropertySource of(PropertySource propertySource) {
- if (propertySource instanceof FrozenPropertySource) {
- return (FrozenPropertySource) propertySource;
- }
- return new FrozenPropertySource(propertySource);
- }
-
- @Override
- public String getName() {
- return this.name;
- }
-
- @Override
- public int getOrdinal() {
- return this.ordinal;
- }
-
- @Override
- public PropertyValue get(String key) {
- return PropertyValue.of(key, this.properties.get(key), getName());
- }
-
- @Override
- public Map<String, String> getProperties() {
- return properties;
- }
-
- @Override
- public boolean isScannable() {
- return true;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof FrozenPropertySource)) {
- return false;
- }
- FrozenPropertySource that = (FrozenPropertySource) o;
- return ordinal == that.ordinal && properties.equals(that.properties);
- }
-
- @Override
- public int hashCode() {
- int result = ordinal;
- result = 31 * result + properties.hashCode();
- return result;
- }
-
- @Override
- public String toString() {
- return "FrozenPropertySource{" +
- "name=" + name +
- ", ordinal=" + ordinal +
- ", properties=" + properties +
- '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/PropertySourceChange.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/PropertySourceChange.java b/src/main/java/org/apache/tamaya/events/PropertySourceChange.java
deleted file mode 100644
index 063612c..0000000
--- a/src/main/java/org/apache/tamaya/events/PropertySourceChange.java
+++ /dev/null
@@ -1,242 +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.events;
-
-import org.apache.tamaya.spi.PropertySource;
-
-import java.beans.PropertyChangeEvent;
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-/**
- * Event that contains a set current changes that were applied or could be applied.
- * This class is immutable and thread-safe. To create instances use
- * {@link PropertySourceChangeBuilder}.
- *
- * Created by Anatole on 22.10.2014.
- */
-public final class PropertySourceChange implements ConfigEvent<PropertySource>, Serializable{
-
- private static final long serialVersionUID = 1L;
- /** The base property provider/configuration. */
- private final FrozenPropertySource propertySource;
- /** The base version, usable for optimistic locking. */
- private String version = UUID.randomUUID().toString();
- /** The timestamp of the change set in millis from the epoch. */
- private long timestamp = System.currentTimeMillis();
- /** The recorded changes. */
- private final Map<String,PropertyChangeEvent> changes = new HashMap<>();
- /** The overall type of change. */
- private final ChangeType changeType;
-
- /**
- * Constructor used by {@link PropertySourceChangeBuilder}.
- * @param builder The builder used, not null.
- */
- PropertySourceChange(PropertySourceChangeBuilder builder) {
- this.propertySource = FrozenPropertySource.of(builder.source);
- for (PropertyChangeEvent c : builder.delta.values()) {
- this.changes.put(c.getPropertyName(), c);
- }
- if(builder.version!=null){
- this.version = builder.version;
- }
- if(builder.timestamp!=null){
- this.timestamp = builder.timestamp;
- }
- this.changeType = builder.changeType;
- }
-
- /**
- * Gets the type of change for this PropertySource.
- * @return the type of change for this PropertySource, never null.
- */
- public ChangeType getChangeType(){
- return this.changeType;
- }
-
- @Override
- public Class<PropertySource> getResourceType() {
- return PropertySource.class;
- }
-
- /**
- * Get the underlying property provider/configuration.
- * @return the underlying property provider/configuration, or null, if the change instance was deserialized.
- */
- @Override
- public PropertySource getResource(){
- return this.propertySource;
- }
-
- /**
- * Get the base version, usable for optimistic locking.
- * @return the base version.
- */
- @Override
- public String getVersion(){
- return version;
- }
-
- /**
- * Get the timestamp in millis from the current epoch. it is expected that the timestamp and the version are unique to
- * identify a changeset.
- * @return the timestamp, when this changeset was created.
- */
- @Override
- public long getTimestamp(){
- return timestamp;
- }
-
- /**
- * Get the changes recorded.
- * @return the recorded changes, never null.
- */
- public Collection<PropertyChangeEvent> getChanges(){
- return Collections.unmodifiableCollection(this.changes.values());
- }
-
- /**
- * Access the number current removed entries.
- * @return the number current removed entries.
- */
- public int getRemovedSize() {
- int removedCount = 0;
- for (PropertyChangeEvent ev : this.changes.values()) {
- if (ev.getNewValue() == null) {
- removedCount++;
- }
- }
- return removedCount;
-// return (int) this.changes.values().stream().filter((e) -> e.getNewValue() == null).count();
- }
-
- /**
- * Access the number current added entries.
- * @return the number current added entries.
- */
- public int getAddedSize() {
- int addedCount = 0;
- for (PropertyChangeEvent ev : this.changes.values()) {
- if (ev.getOldValue() == null &&
- ev.getNewValue() != null) {
- addedCount++;
- }
- }
- return addedCount;
-// return (int) this.changes.values().stream().filter((e) -> e.getOldValue() == null).count();
- }
-
- /**
- * Access the number current updated entries.
- * @return the number current updated entries.
- */
- public int getUpdatedSize() {
- int updatedCount = 0;
- for (PropertyChangeEvent ev : this.changes.values()) {
- if (ev.getOldValue() != null && ev.getNewValue() != null) {
- updatedCount++;
- }
- }
- return updatedCount;
-// return (int) this.changes.values().stream().filter((e) -> e.getOldValue()!=null && e.getNewValue()!=null).count();
- }
-
-
- /**
- * Checks if the given key was removed.
- * @param key the target key, not null.
- * @return true, if the given key was removed.
- */
- public boolean isRemoved(String key) {
- PropertyChangeEvent change = this.changes.get(key);
- return change != null && change.getNewValue() == null;
- }
-
- /**
- * Checks if the given key was added.
- * @param key the target key, not null.
- * @return true, if the given key was added.
- */
- public boolean isAdded(String key) {
- PropertyChangeEvent change = this.changes.get(key);
- return change != null && change.getOldValue() == null;
- }
-
- /**
- * Checks if the given key was updated.
- * @param key the target key, not null.
- * @return true, if the given key was updated.
- */
- public boolean isUpdated(String key) {
- PropertyChangeEvent change = this.changes.get(key);
- return change != null && change.getOldValue() != null && change.getNewValue() != null;
- }
-
- /**
- * Checks if the given key is added, or updated AND NOT removed.
- * @param key the target key, not null.
- * @return true, if the given key was added, or updated BUT NOT removed.
- */
- public boolean isKeyAffected(String key) {
- PropertyChangeEvent change = this.changes.get(key);
- return change != null && change.getNewValue() != null;
- }
-
- /**
- * CHecks if the current change set does not contain any changes.
- * @return tru, if the change set is empty.
- */
- public boolean isEmpty(){
- return this.changes.isEmpty();
- }
-
-
- /**
- * Create a change event for a new PropertySource that was added.
- * @param propertySource the new property source, not null.
- * @return a new PropertySourceChange, representing a PropertySource that was added.
- */
- public static PropertySourceChange ofAdded(PropertySource propertySource) {
- return PropertySourceChangeBuilder.of(propertySource, ChangeType.NEW).build();
- }
-
- /**
- * Create a change event for a deleted PropertySource.
- * @param propertySource the deleted property source, not null.
- * @return a new PropertySourceChange, representing a PropertySource that was deleted.
- */
- public static PropertySourceChange ofDeleted(PropertySource propertySource) {
- return PropertySourceChangeBuilder.of(propertySource, ChangeType.DELETED).build();
- }
-
- @Override
- public String toString() {
- return "PropertySourceChange{" +
- "changeType=" + changeType +
- ", propertySource=" + propertySource +
- ", version='" + version + '\'' +
- ", timestamp=" + timestamp +
- '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java b/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java
deleted file mode 100644
index b7a4483..0000000
--- a/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java
+++ /dev/null
@@ -1,263 +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.events;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-
-import java.beans.PropertyChangeEvent;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
-/**
- * Models a set current changes applied to a {@link org.apache.tamaya.spi.PropertySource}. Consumers of these events
- * can observing changes to property sources and
- * <ol>
- * <li>Check if their current configuration instance ({@link org.apache.tamaya.spi.ConfigurationContext}
- * contains the changed {@link org.apache.tamaya.spi.PropertySource} (Note: the reference tova property source is never affected by a
- * change, its only the data of the property source).</li>
- * <li>If so corresponding action may be taken, such as reevaluating the configuration values (depending on
- * the update policy) or reevaluating the complete {@link org.apache.tamaya.Configuration} to create a change
- * event on configuration level.
- * </ol>
- */
-public final class PropertySourceChangeBuilder {
- /**
- * The recorded changes.
- */
- final SortedMap<String, PropertyChangeEvent> delta = new TreeMap<>();
- /**
- * The underlying configuration/provider.
- */
- final PropertySource source;
- /**
- * The version configured, or null, for generating a default.
- */
- String version;
- /**
- * The optional timestamp in millis of this epoch.
- */
- Long timestamp;
-
- /** The type of change. */
- ChangeType changeType;
-
- /**
- * Constructor.
- *
- * @param source the underlying configuration/provider, not null.
- * @param changeType kind of change.
- */
- private PropertySourceChangeBuilder(PropertySource source, ChangeType changeType) {
- this.source = Objects.requireNonNull(source);
- this.changeType = Objects.requireNonNull(changeType);
- }
-
- /**
- * Creates a new instance of this builder.
- *
- * @param source the underlying property provider/configuration, not null.
- * @param changeType kind of change.
- * @return the builder for chaining.
- */
- public static PropertySourceChangeBuilder of(PropertySource source, ChangeType changeType) {
- return new PropertySourceChangeBuilder(source, changeType);
- }
-
- /**
- * Compares the two property config/configurations and creates a collection current all changes
- * that must be applied to render {@code map1} into {@code map2}.
- *
- * @param map1 the source map, not null.
- * @param map2 the target map, not null.
- * @return a collection current change events, never null.
- */
- public static Collection<PropertyChangeEvent> compare(PropertySource map1, PropertySource map2) {
- List<PropertyChangeEvent> changes = new ArrayList<>();
- for (Map.Entry<String, String> en : map1.getProperties().entrySet()) {
- PropertyValue val = map2.get(en.getKey());
- if (val == null) {
- changes.add(new PropertyChangeEvent(map1, en.getKey(), null, en.getValue()));
- } else if (!val.getValue().equals(en.getValue())) {
- changes.add(new PropertyChangeEvent(map1, en.getKey(), val.getValue(), en.getValue()));
- }
- }
- for (Map.Entry<String, String> en : map2.getProperties().entrySet()) {
- PropertyValue val = map1.get(en.getKey());
- if (val == null) {
- changes.add(new PropertyChangeEvent(map1, en.getKey(), en.getValue(), null));
- } else if (!val.equals(en.getValue())) {
- changes.add(new PropertyChangeEvent(map1, en.getKey(), en.getValue(), val.getValue()));
- }
- }
- return changes;
- }
-
- /*
- * Apply a version/UUID to the set being built.
- * @param version the version to apply, or null, to let the system generate a version for you.
- * @return the builder for chaining.
- */
- public PropertySourceChangeBuilder setVersion(String version) {
- this.version = version;
- return this;
- }
-
- /*
- * Apply given timestamp to the set being built.
- * @param version the version to apply, or null, to let the system generate a version for you.
- * @return the builder for chaining.
- */
- public PropertySourceChangeBuilder setTimestamp(long timestamp) {
- this.timestamp = timestamp;
- return this;
- }
-
- /**
- * This method records all changes to be applied to the base property provider/configuration to
- * achieve the given target state.
- *
- * @param newState the new target state, not null.
- * @return the builder for chaining.
- */
- public PropertySourceChangeBuilder addChanges(PropertySource newState) {
- Collection<PropertyChangeEvent> events = PropertySourceChangeBuilder.compare(newState, this.source);
- for (PropertyChangeEvent c : events) {
- this.delta.put(c.getPropertyName(), c);
- }
- return this;
- }
-
- /**
- * Get the current values, also considering any changes recorded within this change set.
- *
- * @param key the key current the entry, not null.
- * @return the keys, or null.
- */
- public String get(String key) {
- PropertyChangeEvent change = this.delta.get(key);
- if (change != null && !(change.getNewValue() == null)) {
- return (String) change.getNewValue();
- }
- return null;
- }
-
- /**
- * Marks the given key(s) fromMap the configuration/properties to be removed.
- *
- * @param key the key current the entry, not null.
- * @param otherKeys additional keys to be removed (convenience), not null.
- * @return the builder for chaining.
- */
- public PropertySourceChangeBuilder remove(String key, String... otherKeys) {
- PropertyValue oldValue = this.source.get(key);
- if (oldValue == null) {
- this.delta.remove(key);
- }
- this.delta.put(key, new PropertyChangeEvent(this.source, key, oldValue, null));
- for (String addKey : otherKeys) {
- oldValue = this.source.get(addKey);
- if (oldValue == null) {
- this.delta.remove(addKey);
- }
- this.delta.put(addKey, new PropertyChangeEvent(this.source, addKey, oldValue, null));
- }
- return this;
- }
-
- /**
- * Apply all the given values to the base configuration/properties.
- * Note that all values passed must be convertible to String, either
- * <ul>
- * <li>the registered codecs provider provides codecs for the corresponding keys, or </li>
- * <li>default codecs are present for the given type, or</li>
- * <li>the value is an instanceof String</li>
- * </ul>
- *
- * @param changes the changes to be applied, not null.
- * @return the builder for chaining.
- */
- public PropertySourceChangeBuilder putAll(Map<String, String> changes) {
- for (Map.Entry<String, String> en : this.source.getProperties().entrySet()) {
- this.delta.put(en.getKey(), new PropertyChangeEvent(this.source, en.getKey(), null, en.getValue()));
- }
- return this;
- }
-
- /**
- * This method will create a change set that clears all entries fromMap the given base configuration/properties.
- *
- * @return the builder for chaining.
- */
- public PropertySourceChangeBuilder deleteAll() {
- this.delta.clear();
- for (Map.Entry<String, String> en : this.source.getProperties().entrySet()) {
- this.delta.put(en.getKey(), new PropertyChangeEvent(this.source, en.getKey(), en.getValue(), null));
- }
- return this;
- }
-
- /**
- * Checks if the change set is empty, i.e. does not contain any changes.
- *
- * @return true, if the set is empty.
- */
- public boolean isEmpty() {
- return this.delta.isEmpty();
- }
-
- /**
- * Resets this change set instance. This will clear all changes done to this builder, so the
- * set will be empty.
- */
- public void reset() {
- this.delta.clear();
- }
-
- public PropertySourceChangeBuilder setChangeType(ChangeType changeType) {
- this.changeType = changeType;
- return this;
- }
-
- /**
- * Builds the corresponding change set.
- *
- * @return the new change set, never null.
- */
- public PropertySourceChange build() {
- return new PropertySourceChange(this);
- }
-
- /*
- * (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "PropertiesChangeBuilder [source=" + source + ", " +
- ", delta=" + delta + "]";
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/delta/package-info.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/delta/package-info.java b/src/main/java/org/apache/tamaya/events/delta/package-info.java
deleted file mode 100644
index 2006717..0000000
--- a/src/main/java/org/apache/tamaya/events/delta/package-info.java
+++ /dev/null
@@ -1,23 +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.
- */
-/**
- * This package contains artifacts to describe the changes (delta) of a
- * Configuration or a PropertySource.
- */
-package org.apache.tamaya.events.delta;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeListener.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeListener.java b/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeListener.java
deleted file mode 100644
index 283719e..0000000
--- a/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeListener.java
+++ /dev/null
@@ -1,144 +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.events.folderobserver;
-
-import org.apache.tamaya.ConfigException;
-
-import java.io.IOException;
-import java.nio.file.FileSystem;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.StandardWatchEventKinds;
-import java.nio.file.WatchEvent;
-import java.nio.file.WatchKey;
-import java.nio.file.WatchService;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-
-/**
- * Class that has the responsibility to watch the folder and then publish the changes to a
- * {@link org.apache.tamaya.events.PropertySourceChange}.
- * @see ObservingPropertySourceProvider
- * This listener will wait to events and wait to one second to watch again.
- * <p>If new file was created or modified will commit from this file.</p>
- * <p>If a file was removed then the listener will load using all files left.</p>
- * @author otaviojava
- */
-class FileChangeListener implements Runnable {
-
- private static final Logger LOGGER = Logger.getLogger(FileChangeListener.class.getName());
-
- private final WatchService watchService;
-
- private final FileChangeObserver observer;
-
- private final Path directory;
-
- private volatile boolean running = true;
-
- public FileChangeListener(Path directory, FileChangeObserver observer) {
- this.observer = observer;
- this.directory = directory;
- this.watchService = getWatchService();
-
- if (watchService!=null && directory!=null) {
- try {
- directory.register(watchService,
- StandardWatchEventKinds.ENTRY_DELETE,
- StandardWatchEventKinds.ENTRY_MODIFY,
- StandardWatchEventKinds.ENTRY_CREATE);
- } catch (IOException e) {
- throw new FileChangeListenerException("An error happened when does try to registry to watch the folder", e);
- }
- }
- }
-
- /**
- * Stops the listener service from observing the target directory.
- */
- public void stopListener(){
- running = false;
- }
-
- @Override
- public void run() {
- if (watchService!=null || directory!=null) {
- return;
- }
- while (running) {
- watchFolder();
- }
- }
-
- /**
- * Start watching the current folder.
- */
- private void watchFolder() {
- try {
- WatchKey watckKey = watchService.take();
- for (WatchEvent<?> event : watckKey.pollEvents()) {
- Path filePath = (Path) watckKey.watchable();
- if(event.kind().equals(StandardWatchEventKinds.ENTRY_CREATE)||
- event.kind().equals(StandardWatchEventKinds.ENTRY_MODIFY) ||
- event.kind().equals(StandardWatchEventKinds.ENTRY_DELETE)){
- LOGGER.info("File change detected in: " + filePath.getFileName());
- observer.directoryChanged(filePath);
- }
- }
- watckKey.reset();
- Thread.sleep(1_000L);
- } catch (Exception e) {
- throw new FileChangeListenerException("An error happened when does try to watch the folder", e);
- }
- }
-
- /**
- * Get the watch service.
- * @return the watch service, or null, if the watch service is not supported.
- */
- private WatchService getWatchService() {
- try {
- FileSystem fileSystem = Paths.get(".").getFileSystem();
- return fileSystem.newWatchService();
- } catch (IOException e) {
- LOGGER.log(Level.WARNING, "The file System does not supports WatchService", e);
- return null;
- }
-
- }
-
- /**
- * Exception if file listening fails.
- */
- static class FileChangeListenerException extends ConfigException {
- /** Serialversion UID. */
- private static final long serialVersionUID = -8965486770881001513L;
-
- /**
- * Constructor.
- * @param message a message
- * @param cause an (optional) root cause.
- */
- public FileChangeListenerException(String message, Throwable cause) {
- super(message, cause);
- }
-
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeObserver.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeObserver.java b/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeObserver.java
deleted file mode 100644
index 63d25cd..0000000
--- a/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeObserver.java
+++ /dev/null
@@ -1,33 +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.events.folderobserver;
-
-import java.nio.file.Path;
-
-/**
- * Observer to be used in {@link FileChangeListener} to commit all configurations and provider.
- */
-interface FileChangeObserver {
- /**
- * Called when a file has been modified.
- * @param path the file path, not null.
- */
- void directoryChanged(Path path);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java b/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java
deleted file mode 100644
index feddd70..0000000
--- a/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java
+++ /dev/null
@@ -1,209 +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.events.folderobserver;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.events.ConfigEventManager;
-import org.apache.tamaya.events.ConfigurationContextChange;
-import org.apache.tamaya.events.ConfigurationContextChangeBuilder;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertySourceProvider;
-import org.apache.tamaya.spisupport.BasePropertySource;
-
-/**
- * This implementation runs in a folder taking up all files compatible with the given
- * ConfigurationFormats. When a file is added, deleted or modified the PropertySourceProvider
- * will adapt the changes automatically and trigger according
- * {@link org.apache.tamaya.events.PropertySourceChange} events.
- * The default folder is META-INF/config, but you can change it via an absolute path in the
- * "-Dtamaya.configdir" parameter.
- */
-public class ObservingPropertySourceProvider implements PropertySourceProvider, FileChangeObserver {
- /**
- * The logger.
- */
- private static final Logger LOG = Logger.getLogger(ObservingPropertySourceProvider.class.getName());
- /**
- * The current active property sources of this provider.
- */
- private final List<PropertySource> propertySources = Collections.synchronizedList(new LinkedList<PropertySource>());
- /**
- * The thread pool used.
- */
- private final ExecutorService executor = Executors.newSingleThreadExecutor();
-
- /**
- * Constructorm using an explicit directory, ignoring all kind of configuration, if set.
- *
- * @param directory the target directory. If null, the default configuration and system property are used.
- */
- public ObservingPropertySourceProvider(Path directory) {
- if (directory == null) {
- directory = getDirectory();
- }
- if (directory!=null){
- synchronized (this.propertySources) {
- this.propertySources.addAll(readConfiguration(directory));
- }
- final Runnable runnable = new FileChangeListener(directory, this);
- executor.execute(runnable);
- } else {
- executor.shutdown();
- }
- }
-
- /**
- * Read the initial configuration.
- *
- * @param directory the target directory, not null.
- */
- private List<PropertySource> readConfiguration(Path directory) {
- final List<PropertySource> result = new ArrayList<>();
- try {
- synchronized (propertySources) {
- for (final Path path : Files.newDirectoryStream(directory, "*")) {
- result.addAll(getPropertySources(path));
- }
- return result;
- }
- } catch (final IOException e) {
- LOG.log(Level.WARNING, "Failed to read configuration from dir: " + directory, e);
- }
- return result;
- }
-
- /**
- * Read property sources from the given file.
- *
- * @param file source of the property sources.
- * @return property sources from the given file.
- */
- protected Collection<PropertySource> getPropertySources(final Path file) {
- return Arrays.asList(new PropertySource[]{new BasePropertySource() {
- private final Map<String,String> props = readProperties(file);
-
- @Override
- public Map<String, String> getProperties() {
- return props;
- }
- }});
- }
-
- /**
- * Load a single file.
- *
- * @param file the file, not null.
- * @return properties as read from the given file.
- */
- protected static Map<String,String> readProperties(Path file) {
- try (InputStream is = file.toUri().toURL().openStream()){
- final Properties props = new Properties();
- props.load(is);
- final Map<String,String> result = new HashMap<>();
- for(final Map.Entry<Object,Object> en:props.entrySet()){
- result.put(String.valueOf(en.getKey()), String.valueOf(en.getValue()));
- }
- return result;
- } catch (final Exception e) {
- LOG.log(Level.INFO, "Error reading file: " + file.toString() +
- ", using format: properties", e);
- }
- return Collections.emptyMap();
- }
-
-
- /**
- * Evaluates the target directory from system property (tamaya.configdir) or classpath.
- *
- * @return the directory to be read, or null.
- */
- private Path getDirectory() {
- final String absolutePath = System.getProperty("tamaya.configdir");
- if (null!=absolutePath) {
- final Path path = Paths.get(absolutePath);
- if (Files.isDirectory(path)) {
- return path;
- }
- }
- final URL resource = ObservingPropertySourceProvider.class.getResource("/META-INF/config/");
- if (null!=resource) {
- try {
- return Paths.get(resource.toURI());
- } catch (final URISyntaxException e) {
- throw new ConfigException("An error to find the directory to watch", e);
- }
- }
- return null;
- }
-
-
- @Override
- public void directoryChanged(Path directory) {
- synchronized (this.propertySources) {
- final List<PropertySource> existingPropertySources = new ArrayList<>(propertySources);
- propertySources.clear();
- final Collection<PropertySource> sourcesRead = readConfiguration(directory);
- this.propertySources.addAll(sourcesRead);
- triggerConfigChange(existingPropertySources, propertySources);
- }
- }
-
-
- private void triggerConfigChange(List<PropertySource> originalPropertySources,
- List<PropertySource> newPropertySources) {
- final ConfigurationContextChangeBuilder b = ConfigurationContextChangeBuilder.of();
- for (final PropertySource ps : originalPropertySources) {
- b.removedPropertySource(ps);
- }
- for (final PropertySource ps : newPropertySources) {
- b.newPropertySource(ps);
- }
- final ConfigurationContextChange changeEvent = b.build();
- LOG.fine("Trigger Config Context Change: " + changeEvent);
- ConfigEventManager.fireEvent(changeEvent);
- }
-
- @Override
- public Collection<PropertySource> getPropertySources() {
- synchronized (propertySources) {
- return new ArrayList<>(this.propertySources);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/folderobserver/package-info.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/folderobserver/package-info.java b/src/main/java/org/apache/tamaya/events/folderobserver/package-info.java
deleted file mode 100644
index 347f2d8..0000000
--- a/src/main/java/org/apache/tamaya/events/folderobserver/package-info.java
+++ /dev/null
@@ -1,24 +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.
- */
-/**
- * This package contains code to observe a folder for file changes and to trigger
- * corresponding events, that are handled by an according {@link org.apache.tamaya.events.folderobserver.ObservingPropertySourceProvider}
- * instance.
- */
-package org.apache.tamaya.events.folderobserver;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/internal/DefaultConfigChangeObserver.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/internal/DefaultConfigChangeObserver.java b/src/main/java/org/apache/tamaya/events/internal/DefaultConfigChangeObserver.java
deleted file mode 100644
index f4457b2..0000000
--- a/src/main/java/org/apache/tamaya/events/internal/DefaultConfigChangeObserver.java
+++ /dev/null
@@ -1,111 +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.events.internal;
-
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.events.ConfigEventManager;
-import org.apache.tamaya.events.ConfigurationChange;
-import org.apache.tamaya.events.ConfigurationChangeBuilder;
-import org.apache.tamaya.events.FrozenConfiguration;
-
-import java.util.*;
-import java.util.logging.Logger;
-
-/**
- * Timer task that regularly checks the configuration for changes.
- */
-public class DefaultConfigChangeObserver {
-
- private static final long START_DELAY = 5000L;
-
- private static final Logger LOG = Logger.getLogger(DefaultConfigChangeObserver.class.getName());
-
- private Timer timer = new Timer("DefaultConfigChangeObserver", true);
-
- private long checkPeriod = 2000L;
-
- private volatile FrozenConfiguration lastConfig;
-
- private volatile boolean running;
-
- /**
- * Constructor. Also loads all registered listeners.
- */
- public DefaultConfigChangeObserver() {
- LOG.info("Registering config change observer, rechecking config changes every " + checkPeriod + " ms.");
- timer.scheduleAtFixedRate(new TimerTask() {
- @Override
- public void run() {
- if(running) {
- checkConfigurationUpdate();
- }
- }
- }, START_DELAY, checkPeriod);
- }
-
-
- public void checkConfigurationUpdate() {
- LOG.finest("Checking configuration for changes...");
- FrozenConfiguration newConfig = FrozenConfiguration.of(ConfigurationProvider.getConfiguration());
- ConfigurationChange changes;
- if(lastConfig==null){
- changes = ConfigurationChangeBuilder.of(newConfig).putAll(newConfig.getProperties())
- .build();
- }else{
- changes = ConfigurationChangeBuilder.of(lastConfig).addChanges(newConfig)
- .build();
- }
- if(!changes.isEmpty()) {
- LOG.info("Identified configuration changes, publishing change event...");
- ConfigEventManager.fireEvent(changes);
- }
- }
-
- public long getCheckPeriod() {
- return checkPeriod;
- }
-
- public boolean isMonitoring(){
- return running;
- }
-
- public void enableMonitoring(boolean enable){
- this.running = true;
- }
-
- /**
- * Sets the new check period, cancels the currently running timer and schedules a new task with the new checkperiod
- * and a startup delay of 500ms.
- * @param checkPeriod the period in ms, for checking on changes.
- */
- public void setCheckPeriod(long checkPeriod) {
- LOG.finest("Resetting check period to " + checkPeriod + " ms, reregistering timer.");
- this.checkPeriod = checkPeriod;
- timer.cancel();
- timer = new Timer("DefaultConfigChangeObserver", true);
- timer.scheduleAtFixedRate(new TimerTask() {
- @Override
- public void run() {
- if(running) {
- checkConfigurationUpdate();
- }
- }
- }, 500L, checkPeriod);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpi.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpi.java b/src/main/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpi.java
deleted file mode 100644
index 586df5c..0000000
--- a/src/main/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpi.java
+++ /dev/null
@@ -1,202 +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.events.internal;
-
-import org.apache.tamaya.events.ConfigEvent;
-import org.apache.tamaya.events.ConfigEventListener;
-import org.apache.tamaya.events.spi.ConfigEventManagerSpi;
-import org.apache.tamaya.spi.ServiceContextManager;
-
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Default implementation of {@link DefaultConfigEventManagerSpi} just forwarding all
- * events synchronously to the listeners.
- */
-public class DefaultConfigEventManagerSpi implements ConfigEventManagerSpi {
-
- private static final Logger LOG = Logger.getLogger(DefaultConfigEventManagerSpi.class.getName());
-
- private final Map<Class,List<ConfigEventListener>> listeners = new ConcurrentHashMap<>();
-
- private final ExecutorService publisher = Executors.newCachedThreadPool();
-
- private final DefaultConfigChangeObserver changeObserver = new DefaultConfigChangeObserver();
-
- /**
- * Constructor. Also loads all registered listeners.
- */
- public DefaultConfigEventManagerSpi() {
- try {
- for (ConfigEventListener l : ServiceContextManager.getServiceContext().getServices(ConfigEventListener.class)) {
- try {
- addListener(l);
- } catch (Exception e) {
- LOG.log(Level.WARNING, "Failed to load configured listener: " + l.getClass().getName(), e);
- }
- }
- } catch (Exception e) {
- LOG.log(Level.WARNING, "Failed to load configured listeners.", e);
- }
- }
-
- @Override
- public void addListener(ConfigEventListener l){
- addListener(l, ConfigEvent.class);
- }
-
- @Override
- public <T extends ConfigEvent> void addListener(ConfigEventListener l, Class<T> eventType){
- List<ConfigEventListener> ls = listeners.get(eventType);
- if(ls==null){
- ls = Collections.synchronizedList(new ArrayList<ConfigEventListener>());
- listeners.put(eventType, ls);
- }
- synchronized (ls){
- if(!ls.contains(l)){
- ls.add(l);
- }
- }
- }
-
- @Override
- public void removeListener(ConfigEventListener l){
- removeListener(l, ConfigEvent.class);
- }
-
- @Override
- public <T extends ConfigEvent> void removeListener(ConfigEventListener l, Class<T> eventType) {
- List<ConfigEventListener> targets = this.listeners.get(eventType);
- if(targets!=null) {
- // forward to explicit listeners
- synchronized (targets) {
- targets.remove(l);
- }
- }
- }
-
- @Override
- public Collection<? extends ConfigEventListener> getListeners(Class<? extends ConfigEvent> eventType) {
- List<ConfigEventListener> targets = this.listeners.get(eventType);
- if(targets!=null){
- synchronized(targets){
- return new ArrayList<>(targets);
- }
- }
- return Collections.emptyList();
- }
-
- @Override
- public Collection<? extends ConfigEventListener> getListeners() {
- Set<ConfigEventListener> targets = new HashSet<>();
- for(List<ConfigEventListener> l:this.listeners.values()){
- targets.addAll(l);
- }
- return targets;
- }
-
- @Override
- public void fireEvent(ConfigEvent<?> event) {
- List<ConfigEventListener> targets = this.listeners.get(event.getClass());
- if(targets!=null) {
- // forward to explicit listeners
- synchronized (targets) {
- for (ConfigEventListener l : targets) {
- l.onConfigEvent(event);
- }
- }
- }
- // forward to global listeners
- targets = this.listeners.get(ConfigEvent.class);
- if(targets!=null) {
- synchronized (targets) {
- for (ConfigEventListener l : targets) {
- l.onConfigEvent(event);
- }
- }
- }
- }
-
- @Override
- public void fireEventAsynch(ConfigEvent<?> event) {
- List<ConfigEventListener> targets = this.listeners.get(event.getClass());
- if(targets!=null) {
- // forward to explicit listeners
- synchronized (targets) {
- for (ConfigEventListener l : targets) {
- publisher.execute(new PublishConfigChangeTask(l, event));
- }
- }
- }
- // forward to global listeners
- targets = this.listeners.get(ConfigEvent.class);
- if(targets!=null) {
- synchronized (targets) {
- for (ConfigEventListener l : targets) {
- publisher.execute(new PublishConfigChangeTask(l, event));
- }
- }
- }
- }
-
- @Override
- public long getChangeMonitoringPeriod() {
- return changeObserver.getCheckPeriod();
- }
-
- @Override
- public void setChangeMonitoringPeriod(long millis){
- changeObserver.setCheckPeriod(millis);
- }
-
- @Override
- public boolean isChangeMonitorActive() {
- return changeObserver.isMonitoring();
- }
-
- @Override
- public void enableChangeMonitor(boolean enable) {
- changeObserver.enableMonitoring(enable);
- }
-
-
- /**
- * Tasks to inform observers on detected configuration changes.
- */
- private static final class PublishConfigChangeTask implements Runnable{
-
- private final ConfigEventListener l;
- private final ConfigEvent<?> changes;
-
- public PublishConfigChangeTask(ConfigEventListener l, ConfigEvent<?> changes) {
- this.l = Objects.requireNonNull(l);
- this.changes = Objects.requireNonNull(changes);
- }
-
- @Override
- public void run() {
- l.onConfigEvent(changes);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/internal/DefaultConfigurationContextChangeListener.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/internal/DefaultConfigurationContextChangeListener.java b/src/main/java/org/apache/tamaya/events/internal/DefaultConfigurationContextChangeListener.java
deleted file mode 100644
index e49856d..0000000
--- a/src/main/java/org/apache/tamaya/events/internal/DefaultConfigurationContextChangeListener.java
+++ /dev/null
@@ -1,74 +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.events.internal;
-
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.events.ConfigEvent;
-import org.apache.tamaya.events.ConfigEventListener;
-import org.apache.tamaya.events.ConfigurationContextChange;
-import org.apache.tamaya.spi.ConfigurationContext;
-import org.apache.tamaya.spi.ConfigurationContextBuilder;
-import org.apache.tamaya.spi.PropertySource;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Default ConfigEventListener for ConfigurationContextChange events that updates the current context, if resources were
- * affected.
- */
-public class DefaultConfigurationContextChangeListener implements ConfigEventListener {
-
- private static final Logger LOG = Logger.getLogger(DefaultConfigurationContextChangeListener.class.getName());
-
- @Override
- public void onConfigEvent(ConfigEvent<?> event) {
- if(event.getClass() == ConfigurationContextChange.class) {
- ConfigurationContextChange contextChange = (ConfigurationContextChange) event;
- ConfigurationContext context = ConfigurationProvider.getConfigurationContext();
- List<PropertySource> affectedPropertySources = new ArrayList<>();
- for (PropertySource ps : context.getPropertySources()) {
- if (contextChange.isAffected(ps)) {
- affectedPropertySources.add(ps);
- }
- }
- ConfigurationContextBuilder newContextBuilder = ConfigurationProvider.getConfigurationContextBuilder()
- .setContext(context);
- if (!affectedPropertySources.isEmpty()) {
- Set<String> propertySourceNames = new HashSet<>();
- for (PropertySource removed : contextChange.getRemovedPropertySources()) {
- propertySourceNames.add(removed.getName());
- }
- newContextBuilder.removePropertySources(propertySourceNames);
- }
- newContextBuilder.addPropertySources(contextChange.getAddedPropertySources());
- newContextBuilder.addPropertySources(contextChange.getUpdatedPropertySources());
- ConfigurationContext newContext = newContextBuilder.build();
- try {
- ConfigurationProvider.setConfigurationContext(newContext);
- } catch (Exception e) {
- LOG.log(Level.INFO, "Failed to update the current ConfigurationContext due to config model changes", e);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/internal/LoggingConfigListener.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/internal/LoggingConfigListener.java b/src/main/java/org/apache/tamaya/events/internal/LoggingConfigListener.java
deleted file mode 100644
index be8c404..0000000
--- a/src/main/java/org/apache/tamaya/events/internal/LoggingConfigListener.java
+++ /dev/null
@@ -1,40 +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.events.internal;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.events.ConfigEvent;
-import org.apache.tamaya.events.ConfigEventListener;
-
-import java.util.logging.Logger;
-
-/**
- * Simple ConfigListener that simply logs any detected config changes to INFO level.
- */
-public class LoggingConfigListener implements ConfigEventListener {
-
- private static final Logger LOG = Logger.getLogger(LoggingConfigListener.class.getName());
-
- @Override
- public void onConfigEvent(ConfigEvent<?> event) {
- if(event.getResourceType()== Configuration.class) {
- LOG.info("Configuration changed: " + event);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/internal/package-info.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/internal/package-info.java b/src/main/java/org/apache/tamaya/events/internal/package-info.java
deleted file mode 100644
index 9df5ac3..0000000
--- a/src/main/java/org/apache/tamaya/events/internal/package-info.java
+++ /dev/null
@@ -1,22 +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.
- */
-/**
- * This package contains internal default implementations for the config events module.
- */
-package org.apache.tamaya.events.internal;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/package-info.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/package-info.java b/src/main/java/org/apache/tamaya/events/package-info.java
deleted file mode 100644
index e175ceb..0000000
--- a/src/main/java/org/apache/tamaya/events/package-info.java
+++ /dev/null
@@ -1,24 +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.
- */
-/**
- * This package provides the main building blocks for handling configuration changes, such as
- * {@link org.apache.tamaya.events.ConfigEventManager}, {@link org.apache.tamaya.events.ConfigEventListener} and
- * artifacts to describe the changes (delta) of a Configuration or a PropertySource.
- */
-package org.apache.tamaya.events;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/spi/BaseConfigEvent.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/spi/BaseConfigEvent.java b/src/main/java/org/apache/tamaya/events/spi/BaseConfigEvent.java
deleted file mode 100644
index f6856d9..0000000
--- a/src/main/java/org/apache/tamaya/events/spi/BaseConfigEvent.java
+++ /dev/null
@@ -1,69 +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.events.spi;
-
-import org.apache.tamaya.events.ConfigEvent;
-
-import java.util.Objects;
-import java.util.UUID;
-
-/**
- * Abstract base class for implementing your own configuration events.
- * @param <T> the vent type
- */
-public abstract class BaseConfigEvent<T> implements ConfigEvent<T> {
- protected long timestamp = System.currentTimeMillis();
- protected String version = UUID.randomUUID().toString();
- protected final T paylod;
- private final Class<T> type;
-
- public BaseConfigEvent(T paylod, Class<T> type){
- this.paylod = Objects.requireNonNull(paylod);
- this.type = Objects.requireNonNull(type);
- }
-
- @Override
- public Class<T> getResourceType() {
- return type;
- }
-
- @Override
- public T getResource() {
- return paylod;
- }
-
- @Override
- public String getVersion() {
- return version;
- }
-
- @Override
- public long getTimestamp() {
- return timestamp;
- }
-
- @Override
- public String toString() {
- return getClass().getSimpleName() + '{' +
- "timestamp=" + timestamp +
- ", version='" + version + '\'' +
- ", paylod='" + paylod + '\'' +
- '}';
- }
- }
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/spi/ConfigEventManagerSpi.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/spi/ConfigEventManagerSpi.java b/src/main/java/org/apache/tamaya/events/spi/ConfigEventManagerSpi.java
deleted file mode 100644
index 66a8f73..0000000
--- a/src/main/java/org/apache/tamaya/events/spi/ConfigEventManagerSpi.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.events.spi;
-
-import org.apache.tamaya.events.ConfigEvent;
-import org.apache.tamaya.events.ConfigEventListener;
-
-import java.util.Collection;
-
-/**
- * SPI interface to implement the {@link org.apache.tamaya.events.ConfigEventManager} singleton.
- * Implementations of this interface must be registered with the current {@link org.apache.tamaya.spi.ServiceContext},
- * by default this equals to registering it with {@link java.util.ServiceLoader}. Add {@link javax.annotation.Priority}
- * annotations for overriding (higher values override lower values).
- */
-public interface ConfigEventManagerSpi {
- /**
- * Adds a listener for observing events. References of this
- * component to the listeners must be managed as weak references.
- *
- * @param <T> the type of the events listened to.
- * @param l the listener not null.
- */
- <T> void addListener(ConfigEventListener l);
-
- /**
- * Adds a listener for observing events of a given type.
- *
- * @param <T> the type of the events listened to.
- * @param l the listener not null.
- * @param eventType the type of concrete configuration event this listeners should be informed about. All other
- * event types will never be delivered to this listener instance.
- */
- <T extends ConfigEvent> void addListener(ConfigEventListener l, Class<T> eventType);
-
- /**
- * Removes a listener for observing events.
- *
- * @param l the listener not null.
- */
- void removeListener(ConfigEventListener l);
-
- /**
- * Removes a listener for observing events of a certain type.
- *
- * @param <T> the type of the events listened to.
- * @param l the listener not null.
- * @param eventType the type of concrete configuration event this listeners should be informed about. All other
- * event types will never be delivered toe this listener instance.
- */
- <T extends ConfigEvent> void removeListener(ConfigEventListener l, Class<T> eventType);
-
- /**
- * Access all globally registered listeners.
- *
- * @return the listeners found, never null.
- */
- Collection<? extends ConfigEventListener> getListeners();
-
- /**
- * Access all listeners listening for a certain event type, including any global listeners.
- * @param eventType the type of concrete configuration event this listeners should be informed about. All other
- * event types will never be delivered toe this listener instance.
- * @return the listeners found, never null.
- */
- Collection<? extends ConfigEventListener> getListeners(Class<? extends ConfigEvent> eventType);
-
- /**
- * Publishes an event to all interested listeners, hereby executing all registered listeners sequentually and
- * synchronously.,
- *
- * @param event the event, not null.
- */
- void fireEvent(ConfigEvent<?> event);
-
- /**
- * Publishes an event to all interested listeners, hereby publishing the change events asynchrously and in
- * parallel (multithreaded).
- *
- * @param event the event, not null.
- */
- void fireEventAsynch(ConfigEvent<?> event);
-
- /**
- * Get the current check period to check for configuration changes.
- *
- * @return the check period in ms.
- */
- long getChangeMonitoringPeriod();
-
- void setChangeMonitoringPeriod(long millis);
-
- /**
- * Check if the observer is running currently.
- *
- * @return true, if the change monitoring service is currently running.
- */
- boolean isChangeMonitorActive();
-
- /**
- * Start/stop the change monitoring service, which will observe/reevaluate the current configuration regularly
- * and trigger ConfigurationChange events if something is changed. This is quite handy for publishing
- * configuration changes to whatever systems are interested in. Hereby the origin of a configuration change
- * can be on this machine, or also remotedly. For handling corresponding {@link ConfigEventListener} have
- * to be registered, e.g. listening on {@link org.apache.tamaya.events.ConfigurationChange} events.
- *
- * @param enable whether to enable or disable the change monitoring.
- */
- void enableChangeMonitor(boolean enable);
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/java/org/apache/tamaya/events/spi/package-info.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/events/spi/package-info.java b/src/main/java/org/apache/tamaya/events/spi/package-info.java
deleted file mode 100644
index 63d2b3b..0000000
--- a/src/main/java/org/apache/tamaya/events/spi/package-info.java
+++ /dev/null
@@ -1,23 +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.
- */
-/**
- * This package contains the SPI to implement the
- * {@link org.apache.tamaya.events.ConfigEventManager} singleton.
- */
-package org.apache.tamaya.events.spi;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/resources/META-INF/services/org.apache.tamaya.events.ConfigEventListener
----------------------------------------------------------------------
diff --git a/src/main/resources/META-INF/services/org.apache.tamaya.events.ConfigEventListener b/src/main/resources/META-INF/services/org.apache.tamaya.events.ConfigEventListener
deleted file mode 100644
index f9942c1..0000000
--- a/src/main/resources/META-INF/services/org.apache.tamaya.events.ConfigEventListener
+++ /dev/null
@@ -1,19 +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 current 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.
-#
-org.apache.tamaya.events.internal.DefaultConfigurationContextChangeListener
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/main/resources/META-INF/services/org.apache.tamaya.events.spi.ConfigEventManagerSpi
----------------------------------------------------------------------
diff --git a/src/main/resources/META-INF/services/org.apache.tamaya.events.spi.ConfigEventManagerSpi b/src/main/resources/META-INF/services/org.apache.tamaya.events.spi.ConfigEventManagerSpi
deleted file mode 100644
index d45dc43..0000000
--- a/src/main/resources/META-INF/services/org.apache.tamaya.events.spi.ConfigEventManagerSpi
+++ /dev/null
@@ -1,19 +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 current 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.
-#
-org.apache.tamaya.events.internal.DefaultConfigEventManagerSpi
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/test/java/org/apache/tamaya/events/ChangeableGlobalPropertySource.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/events/ChangeableGlobalPropertySource.java b/src/test/java/org/apache/tamaya/events/ChangeableGlobalPropertySource.java
deleted file mode 100644
index 0384064..0000000
--- a/src/test/java/org/apache/tamaya/events/ChangeableGlobalPropertySource.java
+++ /dev/null
@@ -1,62 +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.events;
-
-import org.apache.tamaya.core.propertysource.BasePropertySource;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * PropertySource implementation that accesses properties that are statically stored.
- */
-public class ChangeableGlobalPropertySource extends BasePropertySource{
-
- private static final Map<String,String> STORED_ENTRIES = new ConcurrentHashMap<>();
-
- @Override
- public String getName() {
- return getClass().getSimpleName();
- }
-
- @Override
- public Map<String, String> getProperties() {
- return null;
- }
-
- /**
- * Put a value (globally) into this property source.
- * @param key the key, not null
- * @param value the value, not null
- * @return the entry replaced, or null.
- */
- public static String put(String key, String value){
- return STORED_ENTRIES.put(key,value);
- }
-
- /**
- * Put all the properties, overriding any existing ones with the same key.
- * @param properties the properties, not null.
- */
- public static void putAll(Map<String,String> properties){
- STORED_ENTRIES.putAll(properties);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89223dcd/src/test/java/org/apache/tamaya/events/ChangeableThreadLocalPropertySource.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/events/ChangeableThreadLocalPropertySource.java b/src/test/java/org/apache/tamaya/events/ChangeableThreadLocalPropertySource.java
deleted file mode 100644
index cc6c812..0000000
--- a/src/test/java/org/apache/tamaya/events/ChangeableThreadLocalPropertySource.java
+++ /dev/null
@@ -1,57 +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.events;
-
-import org.apache.tamaya.core.propertysource.BasePropertySource;
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-/**
- * PropertySource implementation that accesses properties that are stored on ThreadLocal level, e.g. good to use for
- * testing..
- */
-public class ChangeableThreadLocalPropertySource extends BasePropertySource{
-
- private static final ThreadLocal<Map<String,String>> STORED_ENTRIES = new ThreadLocal<Map<String,String>>(){
- protected Map<String,String> initialValue(){
- return new HashMap<>();
- }
- };
-
- @Override
- public String getName() {
- return getClass().getSimpleName();
- }
-
- @Override
- public Map<String, String> getProperties() {
- return null;
- }
-
- public static String put(String key, String value){
- return STORED_ENTRIES.get().put(key,value);
- }
-
- public static void putAll(Map<String,String> properties){
- STORED_ENTRIES.get().putAll(properties);
- }
-
-}