TAMAYA-274/353 Added revapi reports to control/report backward compatibility
breaks.
Removed deprecated artifacts (ConfigurationContextBuilder) and
implementations/deps.
TAMAYA-355 Removed PropertyValueCombinationPolicy (not needed anymore).
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/repo
Commit:
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/commit/e6e92976
Tree:
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/tree/e6e92976
Diff:
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/diff/e6e92976
Branch: refs/heads/master
Commit: e6e92976f0aeb6b23bb5b4c7989dad9a2dd8dc75
Parents: a4bfdb4
Author: Anatole Tresch <[email protected]>
Authored: Tue Nov 6 18:47:52 2018 +0100
Committer: Anatole Tresch <[email protected]>
Committed: Tue Nov 6 18:47:52 2018 +0100
----------------------------------------------------------------------
.../collections/AdaptiveCombinationPolicy.java | 131 -------------------
.../tamaya/collections/ItemTokenizer.java | 5 +-
...he.tamaya.spi.PropertyValueCombinationPolicy | 19 ---
.../internal/CombinationPolicyReader.java | 63 ---------
.../DSLLoadingConfigurationProviderSpi.java | 26 +---
5 files changed, 5 insertions(+), 239 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/e6e92976/collections/src/main/java/org/apache/tamaya/collections/AdaptiveCombinationPolicy.java
----------------------------------------------------------------------
diff --git
a/collections/src/main/java/org/apache/tamaya/collections/AdaptiveCombinationPolicy.java
b/collections/src/main/java/org/apache/tamaya/collections/AdaptiveCombinationPolicy.java
deleted file mode 100644
index c6daec8..0000000
---
a/collections/src/main/java/org/apache/tamaya/collections/AdaptiveCombinationPolicy.java
+++ /dev/null
@@ -1,131 +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.collections;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.spi.ClassloaderAware;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-import org.apache.tamaya.spi.PropertyValueCombinationPolicy;
-
-import javax.annotation.Priority;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * PropertyValueCombinationPolicy that allows to configure a
PropertyValueCombinationPolicy
- * for each key individually, by adding a configured entry of the form
- * {@code _key.combination-policy=collect|override|fqPolicyClassName}.
- */
-@Priority(100)
-public class AdaptiveCombinationPolicy implements
PropertyValueCombinationPolicy, ClassloaderAware {
- /** Logger. */
- private static final Logger LOG =
Logger.getLogger(AdaptiveCombinationPolicy.class.getName());
-
- private ClassLoader classLoader;
-
- @Override
- public void init(ClassLoader classLoader) {
- this.classLoader = classLoader;
- }
-
- @Override
- public ClassLoader getClassLoader() {
- return classLoader;
- }
-
- /**
- * Collecting combination policy using (optional) {@code item-separator}
parameter for determining the separator
- * to combine multiple config entries found.
- */
- private static final PropertyValueCombinationPolicy COLLECTING_POLICY =
new PropertyValueCombinationPolicy(){
- @Override
- public PropertyValue collect(PropertyValue currentValue, String key,
PropertySource propertySource) {
- // check for default collection combination policies for lists,
sets, maps etc.
- PropertyValue newValue = propertySource.get(key);
- if(newValue!=null){
- if(currentValue==null){
- return newValue;
- }
- return newValue.toListValue().add(currentValue);
- }else{
- if(currentValue!=null){
- return currentValue;
- }
- return null;
- }
- }
- };
-
- /** Cache for loaded custom combination policies. */
- private Map<Class, PropertyValueCombinationPolicy> configuredPolicies =
new ConcurrentHashMap<>();
-
- @Override
- public PropertyValue collect(PropertyValue currentValue, String key,
PropertySource propertySource){
- if(key.startsWith("_")){
- PropertyValue newValue = propertySource.get(key);
- if(newValue!=null){
- return newValue;
- }
- return currentValue;
- }
- String adaptiveCombinationPolicyClass =
Configuration.current().getOrDefault(
- '_' + key+".combination-policy", "override");
- PropertyValueCombinationPolicy combinationPolicy = null;
- switch(adaptiveCombinationPolicyClass){
- case "collect":
- case "COLLECT":
- if(LOG.isLoggable(Level.FINEST)){
- LOG.finest("Using collecting combination policy for key: "
+ key + "");
- }
- combinationPolicy = COLLECTING_POLICY;
- break;
- case "override":
- case "OVERRIDE":
- if(LOG.isLoggable(Level.FINEST)){
- LOG.finest("Using default (overriding) combination policy
for key: " + key + "");
- }
- combinationPolicy =
PropertyValueCombinationPolicy.DEFAULT_OVERRIDING_POLICY;
- break;
- default:
- try{
- Class<PropertyValueCombinationPolicy> clazz =
(Class<PropertyValueCombinationPolicy>)
- Class.forName(adaptiveCombinationPolicyClass);
- combinationPolicy = configuredPolicies.get(clazz);
- if(combinationPolicy==null){
- combinationPolicy = clazz.newInstance();
- configuredPolicies.put(clazz, combinationPolicy);
- }
- if(LOG.isLoggable(Level.FINEST)){
- LOG.finest("Using custom combination policy
"+adaptiveCombinationPolicyClass+" for " +
- "key: " + key + "");
- }
- } catch(Exception e){
- LOG.log(Level.SEVERE, "Error loading configured
PropertyValueCombinationPolicy for " +
- "key: " + key + ", using default (overriding)
policy.", e);
- combinationPolicy =
PropertyValueCombinationPolicy.DEFAULT_OVERRIDING_POLICY;
- }
- }
- return combinationPolicy.collect(currentValue, key, propertySource);
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/e6e92976/collections/src/main/java/org/apache/tamaya/collections/ItemTokenizer.java
----------------------------------------------------------------------
diff --git
a/collections/src/main/java/org/apache/tamaya/collections/ItemTokenizer.java
b/collections/src/main/java/org/apache/tamaya/collections/ItemTokenizer.java
index 7b4b61e..98f5473 100644
--- a/collections/src/main/java/org/apache/tamaya/collections/ItemTokenizer.java
+++ b/collections/src/main/java/org/apache/tamaya/collections/ItemTokenizer.java
@@ -133,12 +133,13 @@ final class ItemTokenizer {
List<PropertyConverter<T>> valueConverters = new ArrayList<>(1);
if (converterClass != null) {
try {
- valueConverters.add((PropertyConverter<T>)
Class.forName(converterClass).newInstance());
+ valueConverters.add((PropertyConverter<T>)
Class.forName(converterClass).getConstructor()
+ .newInstance());
} catch (Exception e) {
LOG.log(Level.SEVERE, "Error convertion config to ArrayList
type.", e);
}
}
-
valueConverters.addAll(context.getConfigurationContext().getPropertyConverters(targetType));
+
valueConverters.addAll(context.getConfiguration().getContext().getPropertyConverters(targetType));
if (valueConverters.isEmpty()) {
if(targetType.getRawType().equals(String.class)) {
return (T)value;
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/e6e92976/collections/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyValueCombinationPolicy
----------------------------------------------------------------------
diff --git
a/collections/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyValueCombinationPolicy
b/collections/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyValueCombinationPolicy
deleted file mode 100644
index 277c753..0000000
---
a/collections/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyValueCombinationPolicy
+++ /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.collections.AdaptiveCombinationPolicy
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/e6e92976/metamodel/src/main/java/org/apache/tamaya/metamodel/internal/CombinationPolicyReader.java
----------------------------------------------------------------------
diff --git
a/metamodel/src/main/java/org/apache/tamaya/metamodel/internal/CombinationPolicyReader.java
b/metamodel/src/main/java/org/apache/tamaya/metamodel/internal/CombinationPolicyReader.java
deleted file mode 100644
index fc2c625..0000000
---
a/metamodel/src/main/java/org/apache/tamaya/metamodel/internal/CombinationPolicyReader.java
+++ /dev/null
@@ -1,63 +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.metamodel.internal;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.metamodel.spi.ItemFactory;
-import org.apache.tamaya.metamodel.spi.ItemFactoryManager;
-import org.apache.tamaya.metamodel.spi.MetaConfigurationReader;
-import org.apache.tamaya.spi.ConfigurationBuilder;
-import org.apache.tamaya.spi.PropertyValueCombinationPolicy;
-import org.osgi.service.component.annotations.Component;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import java.util.logging.Logger;
-
-
-/**
- * Metaconfiguration reader that reads the configuration combination policy to
be used.
- */
-@Component
-public class CombinationPolicyReader implements MetaConfigurationReader{
-
- private static final Logger LOG =
Logger.getLogger(CombinationPolicyReader.class.getName());
-
- @Override
- public void read(Document document, ConfigurationBuilder configBuilder) {
- NodeList nodeList =
document.getDocumentElement().getElementsByTagName("combination-policy");
- if(nodeList.getLength()==0){
- LOG.finest("No explicit combination policy configured, using
default.");
- return;
- }
- if(nodeList.getLength()>1){
- throw new ConfigException("Only one combination policy can be
applied.");
- }
- Node node = nodeList.item(0);
- String type =
node.getAttributes().getNamedItem("class").getNodeValue();
- LOG.finest("Loading combination policy configured: " + type);
- ItemFactory<PropertyValueCombinationPolicy> policyFactory =
ItemFactoryManager.getInstance().getFactory(PropertyValueCombinationPolicy.class,
type);
- PropertyValueCombinationPolicy policy =
policyFactory.create(ComponentConfigurator.extractParameters(node));
- ComponentConfigurator.configure(policy, node);
- configBuilder.setPropertyValueCombinationPolicy(policy);
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/e6e92976/metamodel/src/main/java/org/apache/tamaya/metamodel/internal/DSLLoadingConfigurationProviderSpi.java
----------------------------------------------------------------------
diff --git
a/metamodel/src/main/java/org/apache/tamaya/metamodel/internal/DSLLoadingConfigurationProviderSpi.java
b/metamodel/src/main/java/org/apache/tamaya/metamodel/internal/DSLLoadingConfigurationProviderSpi.java
index c402b1b..2ad6869 100644
---
a/metamodel/src/main/java/org/apache/tamaya/metamodel/internal/DSLLoadingConfigurationProviderSpi.java
+++
b/metamodel/src/main/java/org/apache/tamaya/metamodel/internal/DSLLoadingConfigurationProviderSpi.java
@@ -41,11 +41,6 @@ public class DSLLoadingConfigurationProviderSpi implements
ConfigurationProvider
private final Object LOCK = new Object();
@Override
- public ConfigurationContextBuilder getConfigurationContextBuilder() {
- return
ServiceContextManager.getServiceContext().create(ConfigurationContextBuilder.class);
- }
-
- @Override
public ConfigurationBuilder getConfigurationBuilder() {
return new DefaultConfigurationBuilder();
}
@@ -61,16 +56,6 @@ public class DSLLoadingConfigurationProviderSpi implements
ConfigurationProvider
}
@Override
- public void setConfigurationContext(ConfigurationContext context){
- this.config = Objects.requireNonNull(createConfiguration(context));
- }
-
- @Override
- public boolean isConfigurationContextSettable() {
- return true;
- }
-
- @Override
public Configuration getConfiguration(ClassLoader classLoader) {
checkInitialized();
return config;
@@ -81,25 +66,18 @@ public class DSLLoadingConfigurationProviderSpi implements
ConfigurationProvider
return new DefaultConfiguration(context);
}
- @Override
- public ConfigurationContext getConfigurationContext() {
- checkInitialized();
- return config.getContext();
- }
-
private void checkInitialized() {
if(config==null){
synchronized (LOCK) {
if(config==null){
// load defaults
- this.config = new DefaultConfiguration(
- new DefaultConfigurationContextBuilder()
+ this.config = new DefaultConfigurationBuilder()
.addDefaultPropertyConverters()
.addDefaultPropertyFilters()
.addDefaultPropertySources()
.sortPropertyFilter(PropertyFilterComparator.getInstance())
.sortPropertySources(PropertySourceComparator.getInstance())
- .build());
+ .build();
}
}
}