Merged with master changes.
diff --git a/code/api/src/main/java/org/apache/tamaya/spi/FilterContext.java b/code/api/src/main/java/org/apache/tamaya/spi/FilterContext.java
index 934fafb..8a1642f 100644
--- a/code/api/src/main/java/org/apache/tamaya/spi/FilterContext.java
+++ b/code/api/src/main/java/org/apache/tamaya/spi/FilterContext.java
@@ -48,15 +48,11 @@
* @param configurationContext the current configurationContext, not {@code null}.
*/
public FilterContext(PropertyValue value, Map<String,PropertyValue> configEntries, ConfigurationContext configurationContext) {
- Objects.requireNonNull(value, "Value must not be null.");
- Objects.requireNonNull(configEntries, "Initial configuration entries must be not null.");
- Objects.requireNonNull(configurationContext, "Context must be not null.");
-
- this.singlePropertyScoped = false;
- this.values = Collections.singletonList(Objects.requireNonNull(value));
- this.configurationContext = Objects.requireNonNull(configurationContext);
- this.configEntries.putAll(configEntries);
+ this.values = Collections.singletonList(Objects.requireNonNull(value, "Value must not be null."));
+ this.configurationContext = Objects.requireNonNull(configurationContext, "Context must be non null");
+ this.configEntries.putAll(Objects.requireNonNull(configEntries, "Initial configuration entries must be not null."));
this.configEntries = Collections.unmodifiableMap(this.configEntries);
+ this.singlePropertyScoped = false;
}
/**
@@ -66,13 +62,7 @@
* @param configurationContext the current configurationContext, not {@code null}.
*/
public FilterContext(PropertyValue value, ConfigurationContext configurationContext) {
- Objects.requireNonNull(value, "Value must not be null.");
- Objects.requireNonNull(configurationContext, "Context must be not null.");
-
- this.singlePropertyScoped = true;
- this.configurationContext = Objects.requireNonNull(configurationContext);
- this.values = Collections.singletonList(Objects.requireNonNull(value));
- this.configEntries = Collections.unmodifiableMap(this.configEntries);
+ this(Collections.singletonList(Objects.requireNonNull(value)), configurationContext);
}
/**
@@ -82,13 +72,10 @@
* @param configurationContext the current configurationContext, not {@code null}.
*/
public FilterContext(List<PropertyValue> values, ConfigurationContext configurationContext) {
- Objects.requireNonNull(values, "Value must not be null.");
- Objects.requireNonNull(configurationContext, "Context must be not null.");
-
- this.singlePropertyScoped = true;
- this.configurationContext = Objects.requireNonNull(configurationContext);
- this.values = Collections.unmodifiableList(new ArrayList<>(values));
+ this.configurationContext = Objects.requireNonNull(configurationContext, "Context must not be null.");
+ this.values = Collections.unmodifiableList(new ArrayList<>(Objects.requireNonNull(values, "Value must not be null.")));
this.configEntries = Collections.unmodifiableMap(this.configEntries);
+ this.singlePropertyScoped = true;
}
/**
diff --git a/code/api/src/main/java/org/apache/tamaya/spi/ListValue.java b/code/api/src/main/java/org/apache/tamaya/spi/ListValue.java
index ff7d69d..e70988c 100644
--- a/code/api/src/main/java/org/apache/tamaya/spi/ListValue.java
+++ b/code/api/src/main/java/org/apache/tamaya/spi/ListValue.java
@@ -49,6 +49,7 @@
* Get the item's current createValue type.
* @return the createValue type, never null.
*/
+ @Override
public ValueType getValueType() {
return ValueType.ARRAY;
}
diff --git a/code/api/src/main/java/org/apache/tamaya/spi/ObjectValue.java b/code/api/src/main/java/org/apache/tamaya/spi/ObjectValue.java
index 801260c..ea244ef 100644
--- a/code/api/src/main/java/org/apache/tamaya/spi/ObjectValue.java
+++ b/code/api/src/main/java/org/apache/tamaya/spi/ObjectValue.java
@@ -20,7 +20,6 @@
import java.util.*;
import java.util.function.Supplier;
-import java.util.logging.Logger;
/**
* Class modelling the result of a request for a property value. A property value is basically identified by its key.
@@ -36,8 +35,6 @@
private static final long serialVersionUID = 1L;
- private static final Logger LOG = Logger.getLogger(ObjectValue.class.getName());
-
/** List of child properties. */
private Map<String, PropertyValue> fields = new HashMap<>();
@@ -54,6 +51,7 @@
* Get the item's current value type.
* @return the value type, never null.
*/
+ @Override
public ValueType getValueType() {
return ValueType.MAP;
}
@@ -121,7 +119,6 @@
* @param valueSupplier the supplier to create a new instance, if no value is present, not null.
* @param <T> the target type.
* @return the child found or created, never null.
- * @throws IllegalArgumentException if multiple getPropertyValues with the given name are existing (ambigous).
* @throws IllegalStateException if the instance is immutable.
* @see #isImmutable()
*/
@@ -190,7 +187,6 @@
array.setParent(getParent());
array.setMeta(getMeta());
array.setVersion(getVersion());
- int index = 0;
for(PropertyValue val:fields.values()){
array.addPropertyValue(val.deepClone());
}
@@ -292,29 +288,27 @@
}
/**
- * Convert the getValue tree to a property mapProperties.
- * @return the corresponding property mapProperties, not null.
+ * Convert the value tree to a property map.
+ * @return the corresponding property map, not null.
*/
@Override
public Map<String,String> toMap(){
Map<String, String> map = new TreeMap<>();
for (PropertyValue n : fields.values()) {
- switch(n.getValueType()){
- case VALUE:
- map.put(n.getQualifiedKey(), n.getValue());
- break;
- default:
- for(PropertyValue val:n) {
- map.putAll(val.toMap());
- }
+ if (ValueType.VALUE.equals(n.getValueType())) {
+ map.put(n.getQualifiedKey(), n.getValue());
+ } else {
+ for(PropertyValue val:n) {
+ map.putAll(val.toMap());
+ }
}
}
return map;
}
/**
- * Convert the value tree to a local property mapProperties.
- * @return the corresponding local mapProperties, not null.
+ * Convert the value tree to a local property map.
+ * @return the corresponding local map, not null.
*/
@Override
public Map<String,String> toLocalMap(){
diff --git a/code/api/src/main/java/org/apache/tamaya/spi/PropertyValue.java b/code/api/src/main/java/org/apache/tamaya/spi/PropertyValue.java
index 6fdaadf..712f1d6 100644
--- a/code/api/src/main/java/org/apache/tamaya/spi/PropertyValue.java
+++ b/code/api/src/main/java/org/apache/tamaya/spi/PropertyValue.java
@@ -21,7 +21,6 @@
import java.io.Serializable;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
-import java.util.function.Predicate;
/**
* Class modelling the result of a request for a property createValue. A property createValue is basically identified by its key.
@@ -36,6 +35,8 @@
public class PropertyValue implements Serializable, Iterable<PropertyValue>{
private static final long serialVersionUID = 2L;
+ private static final int EMPTY = 0;
+ private static final String SOURCE = "source";
/** The requested key. */
private String key;
/** The createValue. */
@@ -61,6 +62,23 @@
VALUE
}
+
+// /**
+// * Creates a new builder instance.
+// * @param key the key, not {@code null}.
+// * @param source the source, typically the name of the {@link PropertySource}
+// * providing the createValue, not {@code null}.
+// * @return a new builder instance.
+// * @deprecated Will be removed, use {@link PropertyValue} directly.
+// */
+// @Deprecated
+// public static PropertyValueBuilder builder(String key, String source){
+// Objects.requireNonNull(key, "Key must be given.");
+// Objects.requireNonNull(source, "Source must be given");
+//
+// return new PropertyValueBuilder(key, null).setSource(source);
+// }
+
/**
* Creates a new (invisible) root, which is a node with an empty name.
* @return a new empty root, never null.
@@ -148,7 +166,7 @@
pv.setMeta(metaData);
}
if(source!=null){
- pv.setMeta("source", source);
+ pv.setMeta(SOURCE, source);
}
if(prefix==null) {
result.put(en.getKey(), pv);
@@ -237,7 +255,7 @@
*/
@Deprecated
public String getSource() {
- return this.metaEntries.get("source");
+ return this.metaEntries.get(SOURCE);
}
@@ -325,9 +343,9 @@
}
/**
- * Creates a full configuration mapProperties for this key, createValue pair and all its getMeta context data. This mapProperties
+ * Creates a full configuration map for this key, createValue pair and all its getMeta context data. This map
* is also used for subsequent processing, like createValue filtering.
- * @return the property createValue entry mapProperties.
+ * @return the property createValue entry map.
*/
public final Map<String, String> getMeta() {
return Collections.unmodifiableMap(metaEntries);
@@ -341,7 +359,7 @@
*/
@Deprecated
public String getMetaEntry(String key) {
- return (String)this.metaEntries.get(Objects.requireNonNull(key));
+ return this.metaEntries.get(Objects.requireNonNull(key));
}
/**
@@ -359,7 +377,7 @@
* @return the getNumChilds of this multi createValue.
*/
public int getSize() {
- return 0;
+ return EMPTY;
}
@Override
@@ -423,8 +441,8 @@
/**
- * Convert the value tree to a property mapProperties using full keys.
- * @return the corresponding property mapProperties, not null.
+ * Convert the value tree to a property map.
+ * @return the corresponding property map, not null.
*/
public Map<String,String> toMap(){
Map<String, String> map = new TreeMap<>();
diff --git a/code/api/src/main/java/org/apache/tamaya/spi/ServiceContextManager.java b/code/api/src/main/java/org/apache/tamaya/spi/ServiceContextManager.java
index 4a5de3a..2acbfca 100644
--- a/code/api/src/main/java/org/apache/tamaya/spi/ServiceContextManager.java
+++ b/code/api/src/main/java/org/apache/tamaya/spi/ServiceContextManager.java
@@ -41,7 +41,7 @@
/**
* The ServiceProvider used.
*/
- private static volatile Map<ClassLoader, ServiceContext> serviceContexts = new ConcurrentHashMap<>();
+ private static final Map<ClassLoader, ServiceContext> SERVICE_CONTEXTS = new ConcurrentHashMap<>();
/**
* Private singletons constructor.
@@ -104,7 +104,7 @@
ServiceContext previousContext;
synchronized (ServiceContextManager.class) {
- previousContext = ServiceContextManager.serviceContexts
+ previousContext = ServiceContextManager.SERVICE_CONTEXTS
.put(cl, serviceContext);
}
if(previousContext!=null) {
@@ -127,7 +127,7 @@
*/
public static ServiceContext getServiceContext(ClassLoader classLoader) {
Objects.requireNonNull(classLoader, "Classloader required.");
- return serviceContexts.computeIfAbsent(classLoader, ServiceContextManager::loadDefaultServiceProvider);
+ return SERVICE_CONTEXTS.computeIfAbsent(classLoader, ServiceContextManager::loadDefaultServiceProvider);
}
/**
diff --git a/code/api/src/main/resources/tamaya-banner.txt b/code/api/src/main/resources/tamaya-banner.txt
index b4ceca4..e66f1a4 100644
--- a/code/api/src/main/resources/tamaya-banner.txt
+++ b/code/api/src/main/resources/tamaya-banner.txt
@@ -6,6 +6,6 @@
██║ ██║██║ ██║ ██║╚██████╗██║ ██║███████╗ ██║ ██║ ██║██║ ╚═╝ ██║██║ ██║ ██║ ██║ ██║
╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝
-Apache Tamaya Configuration API: http://tamaya.incubator.apache.org
+Apache Tamaya Configuration API: https://tamaya.incubator.apache.org
diff --git a/code/api/src/test/java/org/apache/tamaya/ConfigurationTest.java b/code/api/src/test/java/org/apache/tamaya/ConfigurationTest.java
index 1c4f071..f4e438c 100644
--- a/code/api/src/test/java/org/apache/tamaya/ConfigurationTest.java
+++ b/code/api/src/test/java/org/apache/tamaya/ConfigurationTest.java
@@ -266,7 +266,7 @@
public void testMap() throws Exception {
UnaryOperator<Configuration> noop = (Configuration config) -> config;
assertThat(Configuration.current().map(noop)).isNotNull();
- assertThat(Configuration.current().map(noop)== Configuration.current());
+ assertThat(Configuration.current().map(noop)).isEqualTo(Configuration.current());
}
@Test
diff --git a/code/api/src/test/java/org/apache/tamaya/spi/PropertySourceTest.java b/code/api/src/test/java/org/apache/tamaya/spi/PropertySourceTest.java
index a3b7fdc..3614d93 100644
--- a/code/api/src/test/java/org/apache/tamaya/spi/PropertySourceTest.java
+++ b/code/api/src/test/java/org/apache/tamaya/spi/PropertySourceTest.java
@@ -26,6 +26,7 @@
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatCode;
import static org.mockito.Mockito.mock;
public class PropertySourceTest {
@@ -63,18 +64,18 @@
@Test
public void addChangeListener(){
BiConsumer<Set<String>,PropertySource> l = mock(BiConsumer.class);
- new PropertySourceImpl().addChangeListener(l);
+ assertThatCode(() -> new PropertySourceImpl().addChangeListener(l)).doesNotThrowAnyException();
}
@Test
public void removeChangeListener(){
BiConsumer<Set<String>,PropertySource> l = mock(BiConsumer.class);
- new PropertySourceImpl().removeChangeListener(l);
+ assertThatCode(() -> new PropertySourceImpl().removeChangeListener(l)).doesNotThrowAnyException();
}
@Test
public void removeAllChangeListeners(){
- new PropertySourceImpl().removeAllChangeListeners();
+ assertThatCode(() -> new PropertySourceImpl().removeAllChangeListeners()).doesNotThrowAnyException();
}
@Test
diff --git a/code/api/src/test/java/org/apache/tamaya/spi/PropertyValueTest.java b/code/api/src/test/java/org/apache/tamaya/spi/PropertyValueTest.java
index 1f2e5fd..b3f03ff 100644
--- a/code/api/src/test/java/org/apache/tamaya/spi/PropertyValueTest.java
+++ b/code/api/src/test/java/org/apache/tamaya/spi/PropertyValueTest.java
@@ -25,10 +25,28 @@
import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatCode;
@SuppressWarnings("unchecked")
public class PropertyValueTest {
+// @Test
+// public void builder() throws Exception {
+// PropertyValueBuilder b = PropertyValue.builder("a", "b");
+// assertThat(b).isNotNull();
+// assertThat("a").isEqualTo(b.key);
+// assertThat("b").isEqualTo(b.source);
+// }
+//
+//
+// @Test
+// public void builder() throws Exception {
+// PropertyValueBuilder b = PropertyValue.builder("a", "b");
+// assertThat(b).isNotNull();
+// assertThat("a").isEqualTo(b.key);
+// assertThat("b").isEqualTo(b.source);
+// }
+
@Test
public void from(){
@@ -164,12 +182,12 @@
@Test
public void testInstantiateNoValue2() throws Exception {
- new PropertyValue("k", null);
+ assertThatCode(() -> PropertyValue.createValue("k", null)).doesNotThrowAnyException();
}
@Test
public void testInstantiateNoSource2() throws Exception {
- new PropertyValue("k", "v");
+ assertThatCode(() -> PropertyValue.createValue("k", "v")).doesNotThrowAnyException();
}
@Test(expected = NullPointerException.class)
diff --git a/code/core/pom.xml b/code/core/pom.xml
index 8220e62..51397cf 100644
--- a/code/core/pom.xml
+++ b/code/core/pom.xml
@@ -98,7 +98,7 @@
<!--
! Add -Djava.security.debug=all for debugging if needed
!-->
- <argLine>-Djava.security.policy=${project.basedir}/src/test/resources/java-security.policy</argLine>
+ <argLine>-Djava.security.policy=${project.basedir}/src/test/resources/java-security.policy ${argLine}</argLine>
</configuration>
</plugin>
</plugins>
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/BannerManager.java b/code/core/src/main/java/org/apache/tamaya/core/internal/BannerManager.java
index 5ec3bfe..2481ecf 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/BannerManager.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/internal/BannerManager.java
@@ -61,7 +61,7 @@
/**
* The resouce path to the file containing the banner of Tamaya.
*/
- protected final static String BANNER_RESOURCE_PATH = "/tamaya-banner.txt";
+ protected static final String BANNER_RESOURCE_PATH = "/tamaya-banner.txt";
/**
* The target for the Tamaya banner output.
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/CoreConfigurationBuilder.java b/code/core/src/main/java/org/apache/tamaya/core/internal/CoreConfigurationBuilder.java
index 3aeac8c..ae76062 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/CoreConfigurationBuilder.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/internal/CoreConfigurationBuilder.java
@@ -79,6 +79,7 @@
}
@SuppressWarnings("unchecked")
+ @Override
protected void addCorePropertyConverters() {
addPropertyConverters(TypeLiteral.<BigDecimal>of(BigDecimal.class), new BigDecimalConverter());
addPropertyConverters(TypeLiteral.<BigInteger>of(BigInteger.class), new BigIntegerConverter());
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/OSGIServiceContext.java b/code/core/src/main/java/org/apache/tamaya/core/internal/OSGIServiceContext.java
index 15c7b54..2d67dc8 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/OSGIServiceContext.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/internal/OSGIServiceContext.java
@@ -130,7 +130,7 @@
this.osgiServiceLoader.getBundleContext().registerService(serviceType, t, new Hashtable<>());
}
} catch (Exception e) {
- e.printStackTrace();
+ LOG.log(Level.SEVERE, "Error while getting service.", e);
}
}
return services;
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/OSGIServiceLoader.java b/code/core/src/main/java/org/apache/tamaya/core/internal/OSGIServiceLoader.java
index 91367a7..b97c7bf 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/OSGIServiceLoader.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/internal/OSGIServiceLoader.java
@@ -22,6 +22,7 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
+import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -48,9 +49,9 @@
private static final Logger LOG = Logger.getLogger(OSGIServiceLoader.class.getName());
private static final String META_INF_SERVICES = "META-INF/services/";
- private BundleContext context;
+ private final BundleContext context;
- private Set<Bundle> resourceBundles = Collections.synchronizedSet(new HashSet<Bundle>());
+ private final Set<Bundle> resourceBundles = Collections.synchronizedSet(new HashSet<>());
public OSGIServiceLoader(BundleContext context) {
this.context = Objects.requireNonNull(context);
@@ -75,11 +76,10 @@
@Override
public void bundleChanged(BundleEvent bundleEvent) {
// Parse and createObject metadata when installed
+ Bundle bundle = bundleEvent.getBundle();
if (bundleEvent.getType() == BundleEvent.STARTED) {
- Bundle bundle = bundleEvent.getBundle();
checkAndLoadBundle(bundle);
} else if (bundleEvent.getType() == BundleEvent.STOPPED) {
- Bundle bundle = bundleEvent.getBundle();
checkAndUnloadBundle(bundle);
}
}
@@ -129,16 +129,10 @@
URL child = bundle.getEntry(entryPath);
InputStream inStream = child.openStream();
LOG.info("Loading Services " + serviceClass.getName() + " from bundle...: " + bundle.getSymbolicName());
- try (BufferedReader br = new BufferedReader(new InputStreamReader(inStream, "UTF-8"))) {
- String implClassName = br.readLine();
- while (implClassName != null) {
- int hashIndex = implClassName.indexOf("#");
- if (hashIndex > 0) {
- implClassName = implClassName.substring(0, hashIndex - 1);
- } else if (hashIndex == 0) {
- implClassName = "";
- }
- implClassName = implClassName.trim();
+ try (BufferedReader br = new BufferedReader(new InputStreamReader(inStream, StandardCharsets.UTF_8))) {
+ String line = br.readLine();
+ while (line != null) {
+ String implClassName = getImplClassName(line);
if (implClassName.length() > 0) {
try {
// Load the service class
@@ -164,13 +158,11 @@
BundleContext bundleContext = bundle.getBundleContext();
bundleContext.registerService(serviceName, factory, props);
LOG.info("Registered Tamaya service class: " + implClassName + "(" + serviceName + ")");
- } catch (Exception e) {
- LOG.log(Level.SEVERE, "Failed to load service: " + implClassName, e);
- } catch (NoClassDefFoundError err) {
+ } catch (NoClassDefFoundError | Exception err) {
LOG.log(Level.SEVERE, "Failed to load service: " + implClassName, err);
}
}
- implClassName = br.readLine();
+ line = br.readLine();
}
}
} catch (RuntimeException rte) {
@@ -192,39 +184,31 @@
URL child = bundle.getEntry(entryPath);
InputStream inStream = child.openStream();
- BufferedReader br = new BufferedReader(new InputStreamReader(inStream, "UTF-8"));
- String implClassName = br.readLine();
- while (implClassName != null) {
- int hashIndex = implClassName.indexOf("#");
- if (hashIndex > 0) {
- implClassName = implClassName.substring(0, hashIndex - 1);
- } else if (hashIndex == 0) {
- implClassName = "";
- }
- implClassName = implClassName.trim();
- if (implClassName.length() > 0) {
- LOG.fine("Unloading Service (" + serviceName + "): " + implClassName);
- try {
- // Load the service class
- Class<?> implClass = bundle.loadClass(implClassName);
- if (!serviceClass.isAssignableFrom(implClass)) {
- LOG.warning("Configured service: " + implClassName + " is not assignable to "
- + serviceClass.getName());
- continue;
+ try (BufferedReader br = new BufferedReader(new InputStreamReader(inStream, StandardCharsets.UTF_8))) {
+ String line = br.readLine();
+ while (line != null) {
+ String implClassName = getImplClassName(line);
+ if (implClassName.length() > 0) {
+ LOG.fine("Unloading Service (" + serviceName + "): " + implClassName);
+ try {
+ // Load the service class
+ Class<?> implClass = bundle.loadClass(implClassName);
+ if (!serviceClass.isAssignableFrom(implClass)) {
+ LOG.warning("Configured service: " + implClassName + " is not assignable to "
+ + serviceClass.getName());
+ continue;
+ }
+ ServiceReference<?> ref = bundle.getBundleContext().getServiceReference(implClass);
+ if (ref != null) {
+ bundle.getBundleContext().ungetService(ref);
+ }
+ } catch (NoClassDefFoundError | Exception err) {
+ LOG.log(Level.SEVERE, "Failed to unload service: " + implClassName, err);
}
- ServiceReference<?> ref = bundle.getBundleContext().getServiceReference(implClass);
- if (ref != null) {
- bundle.getBundleContext().ungetService(ref);
- }
- } catch (Exception e) {
- LOG.log(Level.SEVERE, "Failed to unload service: " + implClassName, e);
- } catch (NoClassDefFoundError err) {
- LOG.log(Level.SEVERE, "Failed to unload service: " + implClassName, err);
}
+ line = br.readLine();
}
- implClassName = br.readLine();
}
- br.close();
} catch (RuntimeException rte) {
throw rte;
} catch (Exception e) {
@@ -232,13 +216,24 @@
}
}
+ private String getImplClassName(String line) {
+ int hashIndex = line.indexOf('#');
+ if (hashIndex > 0) {
+ return line.substring(0, hashIndex - 1).trim();
+ } else if (hashIndex == 0) {
+ return "";
+ } else {
+ return line.trim();
+ }
+ }
+
/**
* Service factory simply instantiating the configured service.
*/
static class JDKUtilServiceFactory implements ServiceFactory {
private final Class<?> serviceClass;
- public JDKUtilServiceFactory(Class<?> serviceClass) {
+ JDKUtilServiceFactory(Class<?> serviceClass) {
this.serviceClass = serviceClass;
}
@@ -248,7 +243,6 @@
LOG.fine("Creating Service...:" + serviceClass.getName());
return serviceClass.getConstructor().newInstance();
} catch (Exception ex) {
- ex.printStackTrace();
throw new IllegalStateException("Failed to createObject service: " + serviceClass.getName(), ex);
}
}
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/BooleanConverter.java b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/BooleanConverter.java
index 989e4da..77d954f 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/BooleanConverter.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/BooleanConverter.java
@@ -32,7 +32,7 @@
@Component(service = PropertyConverter.class)
public class BooleanConverter implements PropertyConverter<Boolean> {
- private final Logger LOG = Logger.getLogger(getClass().getName());
+ private static final Logger LOG = Logger.getLogger(BooleanConverter.class.getName());
@Override
public Boolean convert(String value, ConversionContext ctx) {
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/ByteConverter.java b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/ByteConverter.java
index a07015f..8b43738 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/ByteConverter.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/ByteConverter.java
@@ -47,7 +47,7 @@
@Component(service = PropertyConverter.class)
public class ByteConverter implements PropertyConverter<Byte>{
- private final Logger LOG = Logger.getLogger(getClass().getName());
+ private static final Logger LOG = Logger.getLogger(ByteConverter.class.getName());
@Override
public Byte convert(String value, ConversionContext ctx) {
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/ClassConverter.java b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/ClassConverter.java
index d3dc31f..4c3b4ee 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/ClassConverter.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/ClassConverter.java
@@ -36,7 +36,7 @@
@Component(service = PropertyConverter.class)
public class ClassConverter implements PropertyConverter<Class<?>>{
- private final Logger LOG = Logger.getLogger(getClass().getName());
+ private static final Logger LOG = Logger.getLogger(ClassConverter.class.getName());
@Override
public Class<?> convert(String value, ConversionContext ctx) {
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/DurationConverter.java b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/DurationConverter.java
index c58e0af..f8239ce 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/DurationConverter.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/DurationConverter.java
@@ -34,7 +34,7 @@
@Component(service = PropertyConverter.class)
public class DurationConverter implements PropertyConverter<Duration> {
- private final Logger LOG = Logger.getLogger(getClass().getName());
+ private static final Logger LOG = Logger.getLogger(DurationConverter.class.getName());
@Override
public Duration convert(String value, ConversionContext ctx) {
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/FileConverter.java b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/FileConverter.java
index b911e31..e9b21a9 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/FileConverter.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/FileConverter.java
@@ -33,7 +33,7 @@
@Component(service = PropertyConverter.class)
public class FileConverter implements PropertyConverter<File> {
- private final Logger LOG = Logger.getLogger(getClass().getName());
+ private static final Logger LOG = Logger.getLogger(FileConverter.class.getName());
@Override
public File convert(String value, ConversionContext ctx) {
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/InstantConverter.java b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/InstantConverter.java
index 4a0994f..5c3b6ec 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/InstantConverter.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/InstantConverter.java
@@ -33,7 +33,7 @@
@Component(service = PropertyConverter.class)
public class InstantConverter implements PropertyConverter<Instant> {
- private final Logger LOG = Logger.getLogger(getClass().getName());
+ private static final Logger LOG = Logger.getLogger(InstantConverter.class.getName());
@Override
public Instant convert(String value, ConversionContext ctx) {
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/LocalDateConverter.java b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/LocalDateConverter.java
index 5f09ec4..ced145e 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/LocalDateConverter.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/LocalDateConverter.java
@@ -33,7 +33,7 @@
@Component(service = PropertyConverter.class)
public class LocalDateConverter implements PropertyConverter<LocalDate> {
- private final Logger LOG = Logger.getLogger(getClass().getName());
+ private static final Logger LOG = Logger.getLogger(LocalDateConverter.class.getName());
@Override
public LocalDate convert(String value, ConversionContext ctx) {
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/LocalDateTimeConverter.java b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/LocalDateTimeConverter.java
index ea92f6c..92f2d75 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/LocalDateTimeConverter.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/LocalDateTimeConverter.java
@@ -33,7 +33,7 @@
@Component(service = PropertyConverter.class)
public class LocalDateTimeConverter implements PropertyConverter<LocalDateTime> {
- private final Logger LOG = Logger.getLogger(getClass().getName());
+ private static final Logger LOG = Logger.getLogger(LocalDateTimeConverter.class.getName());
@Override
public LocalDateTime convert(String value, ConversionContext ctx) {
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/LocalTimeConverter.java b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/LocalTimeConverter.java
index 5fbaa47..2507b37 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/LocalTimeConverter.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/LocalTimeConverter.java
@@ -33,7 +33,7 @@
@Component(service = PropertyConverter.class)
public class LocalTimeConverter implements PropertyConverter<LocalTime> {
- private final Logger LOG = Logger.getLogger(getClass().getName());
+ private static final Logger LOG = Logger.getLogger(LocalTimeConverter.class.getName());
@Override
public LocalTime convert(String value, ConversionContext ctx) {
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/OffsetDateTimeConverter.java b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/OffsetDateTimeConverter.java
index 3ef70db..f266ceb 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/OffsetDateTimeConverter.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/OffsetDateTimeConverter.java
@@ -33,7 +33,7 @@
@Component(service = PropertyConverter.class)
public class OffsetDateTimeConverter implements PropertyConverter<OffsetDateTime> {
- private final Logger LOG = Logger.getLogger(getClass().getName());
+ private static final Logger LOG = Logger.getLogger(OffsetDateTimeConverter.class.getName());
@Override
public OffsetDateTime convert(String value, ConversionContext ctx) {
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/OffsetTimeConverter.java b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/OffsetTimeConverter.java
index 9eb7b0a..a51b99a 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/OffsetTimeConverter.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/OffsetTimeConverter.java
@@ -33,7 +33,7 @@
@Component(service = PropertyConverter.class)
public class OffsetTimeConverter implements PropertyConverter<OffsetTime> {
- private final Logger LOG = Logger.getLogger(getClass().getName());
+ private static final Logger LOG = Logger.getLogger(OffsetTimeConverter.class.getName());
@Override
public OffsetTime convert(String value, ConversionContext ctx) {
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/PathConverter.java b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/PathConverter.java
index 57e739b..2a36d3b 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/PathConverter.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/PathConverter.java
@@ -34,7 +34,7 @@
@Component(service = PropertyConverter.class)
public class PathConverter implements PropertyConverter<Path> {
- private final Logger LOG = Logger.getLogger(getClass().getName());
+ private static final Logger LOG = Logger.getLogger(PathConverter.class.getName());
@Override
public Path convert(String value, ConversionContext ctx) {
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/URIConverter.java b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/URIConverter.java
index 19aa341..41c5ca4 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/URIConverter.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/URIConverter.java
@@ -33,7 +33,7 @@
@Component(service = PropertyConverter.class)
public class URIConverter implements PropertyConverter<URI> {
- private final Logger LOG = Logger.getLogger(getClass().getName());
+ private static final Logger LOG = Logger.getLogger(URIConverter.class.getName());
@Override
public URI convert(String value, ConversionContext ctx) {
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/URLConverter.java b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/URLConverter.java
index 2939e85..f7c90e6 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/converters/URLConverter.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/internal/converters/URLConverter.java
@@ -33,7 +33,7 @@
@Component(service = PropertyConverter.class)
public class URLConverter implements PropertyConverter<URL> {
- private final Logger LOG = Logger.getLogger(getClass().getName());
+ private static final Logger LOG = Logger.getLogger(URLConverter.class.getName());
@Override
public URL convert(String value, ConversionContext ctx) {
diff --git a/code/core/src/main/java/org/apache/tamaya/core/propertysource/BasePropertySource.java b/code/core/src/main/java/org/apache/tamaya/core/propertysource/BasePropertySource.java
index 0a3bc1b..0f74b09 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/propertysource/BasePropertySource.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/propertysource/BasePropertySource.java
@@ -36,7 +36,7 @@
/** default ordinal that will be used, if no ordinal is provided with the config. */
private int defaultOrdinal;
/** Used if the ordinal has been setCurrent explicitly. */
- private volatile Integer ordinal;
+ private Integer ordinal;
/** The name of the property source. */
private String name;
diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/CoreConfigurationProviderTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/CoreConfigurationProviderTest.java
index d3f8174..e9d1cfb 100644
--- a/code/core/src/test/java/org/apache/tamaya/core/internal/CoreConfigurationProviderTest.java
+++ b/code/core/src/test/java/org/apache/tamaya/core/internal/CoreConfigurationProviderTest.java
@@ -22,6 +22,7 @@
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatCode;
/**
* Created by atsticks on 11.09.16.
@@ -30,7 +31,7 @@
@Test
public void testInstantiation() throws Exception {
- new CoreConfigurationProvider();
+ assertThatCode(() -> new CoreConfigurationProvider()).doesNotThrowAnyException();
}
@Test
@@ -53,11 +54,11 @@
@SuppressWarnings("deprecation")
@Test
public void setConfiguration() throws Exception {
- new CoreConfigurationProvider()
+ assertThatCode(() -> new CoreConfigurationProvider()
.setConfiguration(new CoreConfigurationProvider().getConfiguration(
getClass().getClassLoader()),
getClass().getClassLoader()
- );
+ )).doesNotThrowAnyException();
}
@SuppressWarnings("deprecation")
diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/CoreConfigurationTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/CoreConfigurationTest.java
index 0075784..3d707eb 100644
--- a/code/core/src/test/java/org/apache/tamaya/core/internal/CoreConfigurationTest.java
+++ b/code/core/src/test/java/org/apache/tamaya/core/internal/CoreConfigurationTest.java
@@ -48,6 +48,7 @@
@Test
public void testToString() throws Exception {
String toString = Configuration.current().getContext().toString();
+ assertThat(toString).contains("Property Filters").contains("Property Converters");
}
@Test
diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/BasePropertySource.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/BasePropertySource.java
index dc490b7..68be9d1 100644
--- a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/BasePropertySource.java
+++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/BasePropertySource.java
@@ -18,7 +18,6 @@
*/
package org.apache.tamaya.spisupport.propertysource;
-import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.logging.Level;
@@ -36,7 +35,7 @@
/** default ordinal that will be used, if no ordinal is provided with the config. */
private int defaultOrdinal;
/** Used if the ordinal has been setCurrent explicitly. */
- private volatile Integer ordinal;
+ private Integer ordinal;
/** The name of the property source. */
private String name;
diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/PropertiesResourcePropertySource.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/PropertiesResourcePropertySource.java
index 33ea194..13dfd7d 100644
--- a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/PropertiesResourcePropertySource.java
+++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/PropertiesResourcePropertySource.java
@@ -39,7 +39,7 @@
/** The logger used. */
private static final Logger LOGGER = Logger.getLogger(PropertiesResourcePropertySource.class.getName());
- private volatile PropertySourceChangeSupport cachedProperties = new PropertySourceChangeSupport(
+ private final PropertySourceChangeSupport cachedProperties = new PropertySourceChangeSupport(
ChangeSupport.SUPPORTED, this);
/**
diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/SystemPropertySource.java b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/SystemPropertySource.java
index b853e2d..73df268 100644
--- a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/SystemPropertySource.java
+++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/SystemPropertySource.java
@@ -37,9 +37,9 @@
*/
public static final int DEFAULT_ORDINAL = 1000;
- private AtomicInteger savedHashcode = new AtomicInteger();
+ private final AtomicInteger savedHashcode = new AtomicInteger();
- private volatile PropertySourceChangeSupport cachedProperties = new PropertySourceChangeSupport(
+ private final PropertySourceChangeSupport cachedProperties = new PropertySourceChangeSupport(
ChangeSupport.SUPPORTED, this);
/**
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigurationBuilderTest.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigurationBuilderTest.java
index 18df2d8..7c53001 100644
--- a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigurationBuilderTest.java
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigurationBuilderTest.java
@@ -32,6 +32,7 @@
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatCode;
/**
* Tests for {@link DefaultConfigurationBuilder} by atsticks on 06.09.16.
@@ -358,7 +359,7 @@
@Test
public void bla() throws Exception {
ConfigurationBuilder builder = ConfigurationProvider.getConfigurationBuilder();
- builder.addDefaultPropertyConverters();
+ assertThatCode(() -> builder.addDefaultPropertyConverters()).doesNotThrowAnyException();
}
private static class TestPropertySource implements PropertySource {
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigurationSnapshotTest.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigurationSnapshotTest.java
index 1538d44..4169b4a 100644
--- a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigurationSnapshotTest.java
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigurationSnapshotTest.java
@@ -45,6 +45,7 @@
Configuration config = Configuration.current();
DefaultConfigurationSnapshot snapshot = new DefaultConfigurationSnapshot(config,
Arrays.asList("confkey1", "confkey2", "confkey3"));
+ assertThat(snapshot).isNotNull();
}
@Test
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultMetaDataProviderTest.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultMetaDataProviderTest.java
index a3a9846..c6aca71 100644
--- a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultMetaDataProviderTest.java
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultMetaDataProviderTest.java
@@ -25,6 +25,7 @@
import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatCode;
/**
* Tests for {@link DefaultMetaDataProvider}.
@@ -33,7 +34,7 @@
@Test
public void cretion() {
- new DefaultMetaDataProvider();
+ assertThatCode(() -> new DefaultMetaDataProvider()).doesNotThrowAnyException();
}
@Test
@@ -85,8 +86,10 @@
assertThat(provider.getMetaData("foo")).isNotNull().isEmpty();
}
-
@Test
public void testToString() {
+ DefaultMetaDataProvider provider = new DefaultMetaDataProvider();
+ assertThat(provider.init(ConfigurationContext.EMPTY).toString())
+ .isEqualTo("DefaultMetaDataProvider[additionalProperties = {}, context = ConfigurationContext.EMPTY]");
}
}
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/PropertySourceChangeSupportTest.java b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/PropertySourceChangeSupportTest.java
index c6ce987..ddbe8a1 100644
--- a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/PropertySourceChangeSupportTest.java
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/PropertySourceChangeSupportTest.java
@@ -30,6 +30,7 @@
import java.util.function.BiConsumer;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatCode;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -115,7 +116,7 @@
public void update() {
PropertySource ps = BuildablePropertySource.builder().withName("test").build();
PropertySourceChangeSupport support = new PropertySourceChangeSupport(ChangeSupport.IMMUTABLE, ps);
- support.load(Collections.emptyMap());
+ assertThatCode(() -> support.load(Collections.emptyMap())).doesNotThrowAnyException();
}
@Test
diff --git a/examples/11-distributed/pom.xml b/examples/11-distributed/pom.xml
index 8ed7412..1879dfe 100644
--- a/examples/11-distributed/pom.xml
+++ b/examples/11-distributed/pom.xml
@@ -36,6 +36,7 @@
<maven.compile.optimize>false</maven.compile.optimize>
<maven.compile.deprecation>true</maven.compile.deprecation>
<tamaya.version>0.3-incubating-SNAPSHOT</tamaya.version>
+ <vertx.version>3.5.4</vertx.version>
<junit.version>4.12</junit.version>
<!--
@@ -64,7 +65,7 @@
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-core</artifactId>
- <version>3.3.3</version>
+ <version>${vertx.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tamaya.ext</groupId>
@@ -74,7 +75,7 @@
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-hazelcast</artifactId>
- <version>3.3.3</version>
+ <version>${vertx.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tamaya.ext</groupId>
@@ -90,6 +91,7 @@
</dependencies>
<build>
+ <defaultGoal>clean install</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
diff --git a/examples/pom.xml b/examples/pom.xml
index 0a2e67f..b498821 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -31,8 +31,6 @@
<groupId>org.apache.tamaya.examples</groupId>
<artifactId>examples</artifactId>
- <version>0.4-incubating-SNAPSHOT</version>
-
<name>Apache Tamaya Core Examples</name>
<packaging>pom</packaging>