incubator-tamaya git commit: TAMAYA-54 added @Priority support to DefaultServiceContext and Test
Repository: incubator-tamaya Updated Branches: refs/heads/master 8c3883e1f -> b5f409357 TAMAYA-54 added @Priority support to DefaultServiceContext and Test Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/b5f40935 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/b5f40935 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/b5f40935 Branch: refs/heads/master Commit: b5f409357c9edfdfb209c286edc543b65f793b7d Parents: 8c3883e Author: Reinhard Sandtner Authored: Thu Jan 8 09:33:00 2015 +0100 Committer: Mark Struberg Committed: Sun Jan 11 21:06:04 2015 +0100 -- .../core/internal/DefaultServiceContext.java| 51 ++- .../internal/DefaultServiceContextTest.java | 133 +++ ...tServiceContextTest$InvalidPriorityInterface | 19 +++ ...efaultServiceContextTest$MultiImplsInterface | 20 +++ 4 files changed, 222 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b5f40935/java8/core/src/main/java/org/apache/tamaya/core/internal/DefaultServiceContext.java -- diff --git a/java8/core/src/main/java/org/apache/tamaya/core/internal/DefaultServiceContext.java b/java8/core/src/main/java/org/apache/tamaya/core/internal/DefaultServiceContext.java index 8e27d4a..d5b132a 100644 --- a/java8/core/src/main/java/org/apache/tamaya/core/internal/DefaultServiceContext.java +++ b/java8/core/src/main/java/org/apache/tamaya/core/internal/DefaultServiceContext.java @@ -18,8 +18,11 @@ */ package org.apache.tamaya.core.internal; +import org.apache.tamaya.ConfigException; import org.apache.tamaya.spi.ServiceContext; +import javax.annotation.Priority; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -52,7 +55,7 @@ public final class DefaultServiceContext implements ServiceContext { if (services.isEmpty()) { cached = Optional.empty(); } else { -cached = Optional.of(services.get(0)); +cached = Optional.of(getServiceWithHighestPriority(services, serviceType)); } singletons.put(serviceType, cached); } @@ -86,4 +89,50 @@ public final class DefaultServiceContext implements ServiceContext { return previousServices != null ? previousServices : services; } + +/** + * @param services to scan + * @param type of the service + * + * @return the service with the highest {@link javax.annotation.Priority#value()} + * + * @throws ConfigException if there are multiple service implementations with the maximum priority + */ +private T getServiceWithHighestPriority(List services, Class serviceType) { + +// we do not need the priority stuff if the list contains only one element +if (services.size() == 1) { +return services.get(0); +} + +Integer highestPriority = null; +int highestPriorityServiceCount = 0; +T highestService = null; + +for (T service : services) { +int prio = 1; //X TODO discuss default priority +Priority priority = service.getClass().getAnnotation(Priority.class); +if (priority != null) { +prio = priority.value(); +} + +if (highestPriority == null || highestPriority < prio) { +highestService = service; +highestPriorityServiceCount = 1; +highestPriority = prio; +} else if (highestPriority == prio) { +highestPriorityServiceCount++; +} +} + +if (highestPriorityServiceCount > 1) { +throw new ConfigException(MessageFormat.format("Found {0} implementations for Service {1} with Priority {2}", + highestPriorityServiceCount, + serviceType.getName(), + highestPriority)); +} + +return highestService; +} + } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b5f40935/java8/core/src/test/java/org/apache/tamaya/core/test/internal/DefaultServiceContextTest.java -- diff --git a/java8/core/src/test/java/org/apache/tamaya/core/test/internal/DefaultServiceContextTest.java b/java8/core/src/test/java/org/apache/tamaya/core/test/internal/DefaultServiceContextTest.java new file mode 100644 index 000..0aaf63f --- /dev/null +++ b/java8
[2/2] incubator-tamaya git commit: TAMAYA-32 remove unused imports
TAMAYA-32 remove unused imports Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/ae666753 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/ae666753 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/ae666753 Branch: refs/heads/master Commit: ae6667533b751b3acf350465a6cecc7bd50ad29d Parents: c3441b0 Author: Mark Struberg Authored: Thu Jan 8 08:35:41 2015 +0100 Committer: Mark Struberg Committed: Thu Jan 8 08:35:41 2015 +0100 -- .../java/org/apache/tamaya/core/testdata/TestPropertyFilter.java | 1 - .../org/apache/tamaya/modules/json/JSONPropertySourceTest.java | 2 -- 2 files changed, 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/ae666753/java8/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertyFilter.java -- diff --git a/java8/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertyFilter.java b/java8/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertyFilter.java index 0713fee..6faa831 100644 --- a/java8/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertyFilter.java +++ b/java8/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertyFilter.java @@ -21,7 +21,6 @@ package org.apache.tamaya.core.testdata; import org.apache.tamaya.spi.PropertyFilter; import javax.annotation.Priority; -import java.util.function.Function; /** * Simple PropertyFilter that filters exact one value, registered using ServiceLoader. http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/ae666753/modules/json/src/test/java/org/apache/tamaya/modules/json/JSONPropertySourceTest.java -- diff --git a/modules/json/src/test/java/org/apache/tamaya/modules/json/JSONPropertySourceTest.java b/modules/json/src/test/java/org/apache/tamaya/modules/json/JSONPropertySourceTest.java index 0c48534..ad61374 100644 --- a/modules/json/src/test/java/org/apache/tamaya/modules/json/JSONPropertySourceTest.java +++ b/modules/json/src/test/java/org/apache/tamaya/modules/json/JSONPropertySourceTest.java @@ -19,7 +19,6 @@ package org.apache.tamaya.modules.json; import org.apache.tamaya.ConfigException; -import org.apache.tamaya.core.propertysource.DefaultOrdinal; import org.apache.tamaya.spi.PropertySource; import org.hamcrest.CoreMatchers; import org.hamcrest.Matchers; @@ -35,7 +34,6 @@ import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.hasSize; -import static org.junit.Assert.fail; public class JSONPropertySourceTest {
[1/2] incubator-tamaya git commit: TAMAYA-49 re-enable java7 build again.
Repository: incubator-tamaya Updated Branches: refs/heads/master 6d15f753d -> ae6667533 TAMAYA-49 re-enable java7 build again. Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/c3441b00 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/c3441b00 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/c3441b00 Branch: refs/heads/master Commit: c3441b00f696330ddbdaf746753c5b249852668a Parents: 6d15f75 Author: Mark Struberg Authored: Thu Jan 8 08:33:18 2015 +0100 Committer: Mark Struberg Committed: Thu Jan 8 08:33:18 2015 +0100 -- README.md | 19 ++ java7/pom.xml | 30 toolchains.xml | 56 + 3 files changed, 76 insertions(+), 29 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c3441b00/README.md -- diff --git a/README.md b/README.md index d23963e..1eba0ac 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,26 @@ Building Apache Tamaya (incubating) +The Apache Tamaya project contains modules which are intended to be used with Java8 and others +which are for Java7. -The Apache Tamaya project contains classes which are intended to be built with Java7 and others -which are for Java8. This means you need to have both JDK-1.7 and JDK-1.8 installed on your computer. +This means if we like to release then we need to have both JDK-1.7 and JDK-1.8 +installed on your computer. -To tell maven which JDK it should use for each of the projects we do leverage the +To tell Maven which JDK it should use for each of the projects we do leverage the maven-toolchains-plugin and Mavens toolchains support. See the following links for more information http://maven.apache.org/ref/3.2.5/maven-core/toolchains.html http://maven.apache.org/guides/mini/guide-using-toolchains.html -Please copy the provided toolchains.xml sample to ~.m2/toolchains.xml \ No newline at end of file +The easiest way to setup your computer for being able to use toolchains is to +simply copy the provided ./toolchains.xml sample to ~.m2/toolchains.xml and +edit the paths to your own JDK installations. +We activate the maven-toolchains-plugin with a 'java7' profile in all +the modules we need it. + +For building the java7 modules with JDK-1.7 you simply need to build Tamaya with + +$> mvn clean install -Pjava7 + http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c3441b00/java7/pom.xml -- diff --git a/java7/pom.xml b/java7/pom.xml index 2bf889f..78dd929 100644 --- a/java7/pom.xml +++ b/java7/pom.xml @@ -40,4 +40,34 @@ under the License. core --> + + + +java7 + + + + +org.apache.maven.plugins +maven-toolchains-plugin +1.1 + + + +toolchain + + + + + + +[1.7,) + + + + + + + + http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c3441b00/toolchains.xml -- diff --git a/toolchains.xml b/toolchains.xml index 98617b2..c58bb0d 100644 --- a/toolchains.xml +++ b/toolchains.xml @@ -1,27 +1,33 @@ http://maven.apache.org/TOOLCHAINS/1.1.0"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; - xsi:schemaLocation="http://maven.apache.org/TOOLCHAINS/1.1.0 http://maven.apache.org/xsd/toolchains-1.1.0.xsd";> - - - -jdk - - 1.7 - Oracle - - - /path/to/jdk/1.7 - - - - - -jdk - - 1.8 - Oracle - - - /path/to/jdk/1.8 - - +xsi:schemaLocation="http://maven.apache.org/TOOLCHAINS/1.1.0 http://maven.apache.org/xsd/toolchains-1.1.0.xsd";> + + + + + +jdk + +1.7 +Oracle + + +/path/to/jdk/1.7 + + + + + +jdk + +1.8 +Oracle + + +/path/to/jdk/1.8 + +
[4/9] incubator-tamaya git commit: TAMAYA-49 move api and core to java8 module
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/328a4ac7/java8/api/pom.xml -- diff --git a/java8/api/pom.xml b/java8/api/pom.xml new file mode 100644 index 000..6f40b45 --- /dev/null +++ b/java8/api/pom.xml @@ -0,0 +1,43 @@ + +http://maven.apache.org/POM/4.0.0"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd";> +4.0.0 + + +org.apache.tamaya +tamaya-java8 +0.2-incubating-SNAPSHOT +../pom.xml + + +tamaya-api + +The API defines a complete SE based API for reading of configuration data. + + + + +junit +junit +test + + + + http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/328a4ac7/java8/api/src/main/java/org/apache/tamaya/ConfigException.java -- diff --git a/java8/api/src/main/java/org/apache/tamaya/ConfigException.java b/java8/api/src/main/java/org/apache/tamaya/ConfigException.java new file mode 100644 index 000..bac2ef4 --- /dev/null +++ b/java8/api/src/main/java/org/apache/tamaya/ConfigException.java @@ -0,0 +1,44 @@ +/* + * 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; + +/** + * Exception class (runtime exception) for configuration issues. + */ +public class ConfigException extends RuntimeException{ + +private static final long serialVersionUID = -5886094818057522680L; + +/** + * Creates a new configuration exception. + * @param message the exception message, not null. + */ +public ConfigException(String message){ +super(message); +} + +/** + * Creates a new configuration exception. + * @param message the exception message, not null. + * @param t the throwable. + */ +public ConfigException(String message, Throwable t){ +super(message, t); +} +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/328a4ac7/java8/api/src/main/java/org/apache/tamaya/Configuration.java -- diff --git a/java8/api/src/main/java/org/apache/tamaya/Configuration.java b/java8/api/src/main/java/org/apache/tamaya/Configuration.java new file mode 100644 index 000..2786af7 --- /dev/null +++ b/java8/api/src/main/java/org/apache/tamaya/Configuration.java @@ -0,0 +1,204 @@ +/* + * 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; + +import org.apache.tamaya.spi.PropertyConverter; +import org.apache.tamaya.spi.ServiceContext; + +import java.util.*; +import java.util.function.Function; +import java.util.function.UnaryOperator; + +/** + * A configuration models a aggregated set current properties, identified by a unique key, but adds higher level access functions to + * a {@link org.apache.tamaya.spi.PropertySource}. Hereby in most cases a configuration is a wrapper around a composite + * {@link org.apache.tamaya.spi.PropertySource} instance, which may combine multiple child config in well defined tree like structure, + * where nodes define logically the rules current priority, filtering, combination and overriding. + * + * Implementation Requirements + * Implementations current this interface must be + * + * Thread
[6/9] incubator-tamaya git commit: TAMAYA-49 move api and core to java8 module
TAMAYA-49 move api and core to java8 module Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/328a4ac7 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/328a4ac7 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/328a4ac7 Branch: refs/heads/master Commit: 328a4ac73d5bcbc7f9700348e4f2a122966ddca0 Parents: 7985c03 Author: Mark Struberg Authored: Tue Jan 6 18:10:28 2015 +0100 Committer: Mark Struberg Committed: Wed Jan 7 23:17:58 2015 +0100 -- api/pom.xml | 43 .../java/org/apache/tamaya/ConfigException.java | 44 .../java/org/apache/tamaya/Configuration.java | 204 --- .../apache/tamaya/spi/ConfigurationContext.java | 145 --- .../apache/tamaya/spi/PropertyConverter.java| 42 .../org/apache/tamaya/spi/PropertyFilter.java | 49 .../org/apache/tamaya/spi/PropertySource.java | 128 -- .../tamaya/spi/PropertySourceProvider.java | 43 .../org/apache/tamaya/spi/ServiceContext.java | 68 - .../tamaya/spi/ServiceContextManager.java | 109 .../org/apache/tamaya/ConfigurationTest.java| 78 -- .../org/apache/tamaya/TestConfiguration.java| 87 --- .../tamaya/spi/ServiceContextManagerTest.java | 109 .../apache/tamaya/spi/ServiceContextTest.java | 93 --- .../apache/tamaya/spi/TestServiceContext.java | 82 -- .../services/org.apache.tamaya.Configuration| 19 -- .../org.apache.tamaya.spi.ServiceContext| 1 - .../test/resources/ServiceContextWithOrdinal| 25 -- core/pom.xml| 46 .../core/internal/DefaultConfiguration.java | 226 - .../internal/DefaultConfigurationContext.java | 183 -- .../core/internal/DefaultServiceContext.java| 89 --- .../core/internal/PropertiesFileLoader.java | 102 .../core/internal/PropertyConverterManager.java | 247 --- .../core/propertysource/BasePropertySource.java | 78 -- .../core/propertysource/DefaultOrdinal.java | 54 .../EnvironmentPropertySource.java | 47 .../PropertiesFilePropertySource.java | 47 .../PropertiesPropertySource.java | 51 .../propertysource/SystemPropertySource.java| 75 -- .../provider/JavaConfigurationProvider.java | 60 - .../services/org.apache.tamaya.Configuration| 19 -- apache.tamaya.core.resources.ResourceLoader | 19 -- .../org.apache.tamaya.spi.ConfigurationContext | 19 -- .../org.apache.tamaya.spi.ServiceContext| 19 -- .../apache/tamaya/core/ConfigurationTest.java | 58 - .../test/internal/PropetiesFileLoaderTest.java | 76 -- .../propertysource/BasePropertySourceTest.java | 106 .../PropertiesFilePropertySourceTest.java | 71 -- .../SystemPropertySourceTest.java | 102 .../provider/JavaConfigurationProviderTest.java | 53 .../testdata/TestPropertyDefaultSource.java | 51 .../core/testdata/TestPropertyFilter.java | 38 --- .../testdata/TestPropertyFilterRemoving.java| 42 .../testdata/TestPropertySourceProvider.java| 73 -- .../org.apache.tamaya.spi.PropertyFilter| 20 -- .../org.apache.tamaya.spi.PropertySource| 21 -- ...org.apache.tamaya.spi.PropertySourceProvider | 20 -- .../test/resources/javaconfiguration.properties | 22 -- .../test/resources/overrideOrdinal.properties | 25 -- core/src/test/resources/testfile.properties | 22 -- java8/api/pom.xml | 43 .../java/org/apache/tamaya/ConfigException.java | 44 .../java/org/apache/tamaya/Configuration.java | 204 +++ .../apache/tamaya/spi/ConfigurationContext.java | 145 +++ .../apache/tamaya/spi/PropertyConverter.java| 42 .../org/apache/tamaya/spi/PropertyFilter.java | 49 .../org/apache/tamaya/spi/PropertySource.java | 128 ++ .../tamaya/spi/PropertySourceProvider.java | 43 .../org/apache/tamaya/spi/ServiceContext.java | 68 + .../tamaya/spi/ServiceContextManager.java | 109 .../org/apache/tamaya/ConfigurationTest.java| 78 ++ .../org/apache/tamaya/TestConfiguration.java| 87 +++ .../tamaya/spi/ServiceContextManagerTest.java | 109 .../apache/tamaya/spi/ServiceContextTest.java | 93 +++ .../apache/tamaya/spi/TestServiceContext.java | 82 ++ .../services/org.apache.tamaya.Configuration| 19 ++ .../org.apache.tamaya.spi.ServiceContext| 1 + .../test/resources/ServiceContextWithOrdinal| 25 ++ java8/core/pom.xml | 46 .../core/internal
[5/9] incubator-tamaya git commit: TAMAYA-49 move api and core to java8 module
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/328a4ac7/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContext.java -- diff --git a/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContext.java b/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContext.java deleted file mode 100644 index b6acae5..000 --- a/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContext.java +++ /dev/null @@ -1,183 +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.core.internal; - -import org.apache.tamaya.spi.ConfigurationContext; -import org.apache.tamaya.spi.PropertyConverter; -import org.apache.tamaya.spi.PropertyFilter; -import org.apache.tamaya.spi.PropertySource; -import org.apache.tamaya.spi.PropertySourceProvider; -import org.apache.tamaya.spi.ServiceContext; - -import javax.annotation.Priority; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.StampedLock; - -/** - * Default Implementation of a simple ConfigurationContext. - */ -public class DefaultConfigurationContext implements ConfigurationContext { -/** - * Cubcomponent handling {@link org.apache.tamaya.spi.PropertyConverter} instances. - */ -private PropertyConverterManager propertyConverterManager = new PropertyConverterManager(); - -/** - * The current unmodifiable list of loaded {@link org.apache.tamaya.spi.PropertySource} instances. - */ -private List immutablePropertySources; - -/** - * The current unmodifiable list of loaded {@link org.apache.tamaya.spi.PropertyFilter} instances. - */ -private List immutablePropertyFilters; - -/** - * Lock for internal synchronization. - */ -private StampedLock propertySourceLock = new StampedLock(); - - -/** - * The first time the Configuration system gets invoked we do initialize - * all our {@link org.apache.tamaya.spi.PropertySource}s and - * {@link org.apache.tamaya.spi.PropertyFilter}s which are known at startup. - */ -public DefaultConfigurationContext() { -List propertySources = new ArrayList<>(); - -// first we load all PropertySources which got registered via java.util.ServiceLoader - propertySources.addAll(ServiceContext.getInstance().getServices(PropertySource.class)); - -// after that we add all PropertySources which get dynamically registered via their PropertySourceProviders -propertySources.addAll(evaluatePropertySourcesFromProviders()); - -// now sort them according to their ordinal values -Collections.sort(propertySources, this::comparePropertySources); - -immutablePropertySources = Collections.unmodifiableList(propertySources); - -// as next step we pick up the PropertyFilters pretty much the same way -List propertyFilters = new ArrayList<>(); - propertyFilters.addAll(ServiceContext.getInstance().getServices(PropertyFilter.class)); -Collections.sort(propertyFilters, this::comparePropertyFilters); - -immutablePropertyFilters = Collections.unmodifiableList(propertyFilters); -} - -/** - * Pick up all {@link org.apache.tamaya.spi.PropertySourceProvider}s and return all the - * {@link org.apache.tamaya.spi.PropertySource}s they like to register. - */ -private Collection evaluatePropertySourcesFromProviders() { -List propertySources = new ArrayList<>(); -List propertySourceProviders = ServiceContext.getInstance().getServices(PropertySourceProvider.class); -for (PropertySourceProvider propertySourceProvider : propertySourceProviders) { - propertySources.addAll(propertySourceProvider.getPropertySources()); -} - -return propertySources; -} - -@Override -public void addPropertySources(PropertySource... propertySourcesToAdd) { -Lock writeLock = propertySourceLock
[7/9] incubator-tamaya git commit: TAMAYA-49 ipmlement java7 api as well
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67855faa/modules/json/src/main/java/org/apache/tamaya/modules/json/JSONPropertySource.java -- diff --git a/modules/json/src/main/java/org/apache/tamaya/modules/json/JSONPropertySource.java b/modules/json/src/main/java/org/apache/tamaya/modules/json/JSONPropertySource.java index bff8004..6a1a11b 100644 --- a/modules/json/src/main/java/org/apache/tamaya/modules/json/JSONPropertySource.java +++ b/modules/json/src/main/java/org/apache/tamaya/modules/json/JSONPropertySource.java @@ -31,7 +31,6 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Objects; -import java.util.Optional; import static java.lang.String.format; @@ -74,10 +73,10 @@ public class JSONPropertySource } @Override -public Optional get(String key) { +public String get(String key) { Objects.requireNonNull(key, "Key must not be null"); -return Optional.ofNullable(getProperties().get(key)); +return getProperties().get(key); } @Override http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67855faa/modules/resolver/src/test/java/org/apache/tamaya/resolver/MyTestPropertySource.java -- diff --git a/modules/resolver/src/test/java/org/apache/tamaya/resolver/MyTestPropertySource.java b/modules/resolver/src/test/java/org/apache/tamaya/resolver/MyTestPropertySource.java index d19c05f..750ca8d 100644 --- a/modules/resolver/src/test/java/org/apache/tamaya/resolver/MyTestPropertySource.java +++ b/modules/resolver/src/test/java/org/apache/tamaya/resolver/MyTestPropertySource.java @@ -22,7 +22,6 @@ import org.apache.tamaya.spi.PropertySource; import java.util.HashMap; import java.util.Map; -import java.util.Optional; /** * Created by Anatole on 04.01.2015. @@ -52,8 +51,8 @@ public class MyTestPropertySource implements PropertySource{ } @Override -public Optional get(String key) { -return Optional.ofNullable(properties.get(key)); +public String get(String key) { +return properties.get(key); } @Override http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67855faa/pom.xml -- diff --git a/pom.xml b/pom.xml index 07b22f3..6cb1699 100644 --- a/pom.xml +++ b/pom.xml @@ -189,6 +189,7 @@ under the License. +java7 java8 modules http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67855faa/toolchains.xml -- diff --git a/toolchains.xml b/toolchains.xml new file mode 100644 index 000..98617b2 --- /dev/null +++ b/toolchains.xml @@ -0,0 +1,27 @@ +http://maven.apache.org/TOOLCHAINS/1.1.0"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; + xsi:schemaLocation="http://maven.apache.org/TOOLCHAINS/1.1.0 http://maven.apache.org/xsd/toolchains-1.1.0.xsd";> + + + +jdk + + 1.7 + Oracle + + + /path/to/jdk/1.7 + + + + + +jdk + + 1.8 + Oracle + + + /path/to/jdk/1.8 + + +
[1/9] incubator-tamaya git commit: TAMAYA-49 make getOptional default interfaces
Repository: incubator-tamaya Updated Branches: refs/heads/master 7985c039c -> 585167aa8 TAMAYA-49 make getOptional default interfaces Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/3d6456d2 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/3d6456d2 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/3d6456d2 Branch: refs/heads/master Commit: 3d6456d255eb741936d027afcd81b356c2b11168 Parents: b4bde92 Author: Mark Struberg Authored: Tue Jan 6 23:34:54 2015 +0100 Committer: Mark Struberg Committed: Wed Jan 7 23:17:58 2015 +0100 -- .../java/org/apache/tamaya/Configuration.java | 16 ++--- .../org/apache/tamaya/TestConfiguration.java| 25 ++-- .../core/internal/DefaultConfiguration.java | 11 + 3 files changed, 26 insertions(+), 26 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3d6456d2/java8/api/src/main/java/org/apache/tamaya/Configuration.java -- diff --git a/java8/api/src/main/java/org/apache/tamaya/Configuration.java b/java8/api/src/main/java/org/apache/tamaya/Configuration.java index d5bd4f7..b86c94f 100644 --- a/java8/api/src/main/java/org/apache/tamaya/Configuration.java +++ b/java8/api/src/main/java/org/apache/tamaya/Configuration.java @@ -50,9 +50,7 @@ public interface Configuration { * @param key the property's key, not null. * @return the property's value or {@code null}. */ -default String get(String key) { -return getOptional(key).orElse(null); -} +String get(String key); /** * Get the property keys as type T. This will implicitly require a corresponding {@link @@ -65,9 +63,7 @@ public interface Configuration { * @return the property value, never null.. * @throws ConfigException if the keys could not be converted to the required target type. */ -default T get(String key, Class type) { -return getOptional(key, type).orElse(null); -} + T get(String key, Class type); /** * Access a property. @@ -75,7 +71,9 @@ public interface Configuration { * @param key the property's key, not null. * @return the property's keys. */ -Optional getOptional(String key); +default Optional getOptional(String key) { +return Optional.ofNullable(get(key)); +} /** * Get the property keys as type T. This will implicitly require a corresponding {@link @@ -88,7 +86,9 @@ public interface Configuration { * @return the property value, never null.. * @throws ConfigException if the keys could not be converted to the required target type. */ - Optional getOptional(String key, Class type); +default Optional getOptional(String key, Class type) { +return Optional.ofNullable(get(key, type)); +} /** * Access all current known Configuration properties as a full {@code Map}. http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3d6456d2/java8/api/src/test/java/org/apache/tamaya/TestConfiguration.java -- diff --git a/java8/api/src/test/java/org/apache/tamaya/TestConfiguration.java b/java8/api/src/test/java/org/apache/tamaya/TestConfiguration.java index 459cb9f..ac3b646 100644 --- a/java8/api/src/test/java/org/apache/tamaya/TestConfiguration.java +++ b/java8/api/src/test/java/org/apache/tamaya/TestConfiguration.java @@ -20,7 +20,6 @@ package org.apache.tamaya; import java.util.HashMap; import java.util.Map; -import java.util.Optional; /** * Test Configuration class, that is used to testdata the default methods provided by the API. @@ -42,40 +41,40 @@ public class TestConfiguration implements Configuration { } @Override -public Optional getOptional(String key) { -return Optional.ofNullable(VALUES.get(key)); +public String get(String key) { +return VALUES.get(key); } @Override -public Optional getOptional(String key, Class type) { +public T get(String key, Class type) { if(type.equals(Long.class)){ -return Optional.class.cast(Optional.ofNullable(Long.MAX_VALUE)); +return (T)(Object)Long.MAX_VALUE; } else if(type.equals(Integer.class)){ -return Optional.class.cast(Optional.ofNullable(Integer.MAX_VALUE)); +return (T)(Object) Integer.MAX_VALUE; } else if(type.equals(Double.class)){ -return Optional.class.cast(Optional.ofNullable(Double.MAX_VALUE)); +return (T)(Object) Double.MAX_VALUE; } else if(type.equals(Float.class
[8/9] incubator-tamaya git commit: TAMAYA-49 ipmlement java7 api as well
TAMAYA-49 ipmlement java7 api as well Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/67855faa Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/67855faa Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/67855faa Branch: refs/heads/master Commit: 67855faa5e8f18bcccf11cb05f0d055949598208 Parents: 328a4ac Author: Mark Struberg Authored: Tue Jan 6 22:19:11 2015 +0100 Committer: Mark Struberg Committed: Wed Jan 7 23:17:58 2015 +0100 -- README.md | 15 ++ java7/api/pom.xml | 43 ++ .../java/org/apache/tamaya/ConfigException.java | 44 ++ .../java/org/apache/tamaya/Configuration.java | 72 ++ .../apache/tamaya/ConfigurationProvider.java| 32 + .../apache/tamaya/spi/ConfigurationContext.java | 140 +++ .../apache/tamaya/spi/PropertyConverter.java| 41 ++ .../org/apache/tamaya/spi/PropertyFilter.java | 49 +++ .../org/apache/tamaya/spi/PropertySource.java | 125 + .../tamaya/spi/PropertySourceProvider.java | 43 ++ .../org/apache/tamaya/spi/ServiceContext.java | 57 .../tamaya/spi/ServiceContextManager.java | 109 +++ .../org/apache/tamaya/ConfigurationTest.java| 64 + .../org/apache/tamaya/TestConfiguration.java| 86 .../apache/tamaya/spi/ServiceContextTest.java | 95 + .../apache/tamaya/spi/TestServiceContext.java | 89 .../services/org.apache.tamaya.Configuration| 19 +++ .../org.apache.tamaya.spi.ServiceContext| 1 + java7/pom.xml | 68 + .../java/org/apache/tamaya/Configuration.java | 54 +-- .../apache/tamaya/ConfigurationProvider.java| 34 + .../org/apache/tamaya/spi/PropertyFilter.java | 2 +- .../org/apache/tamaya/spi/PropertySource.java | 5 +- .../tamaya/spi/ServiceContextManager.java | 2 +- .../org/apache/tamaya/TestConfiguration.java| 6 +- .../core/internal/DefaultConfiguration.java | 14 +- .../core/propertysource/BasePropertySource.java | 13 +- .../apache/tamaya/core/ConfigurationTest.java | 22 +-- .../propertysource/BasePropertySourceTest.java | 7 +- .../PropertiesFilePropertySourceTest.java | 8 +- .../SystemPropertySourceTest.java | 7 +- .../provider/JavaConfigurationProviderTest.java | 4 +- .../testdata/TestPropertyFilterRemoving.java| 3 +- .../apache/tamaya/format/PropertiesFormat.java | 5 +- .../tamaya/format/PropertiesXmlFormat.java | 5 +- .../tamaya/modules/json/JSONPropertySource.java | 5 +- .../tamaya/resolver/MyTestPropertySource.java | 5 +- pom.xml | 1 + toolchains.xml | 27 39 files changed, 1345 insertions(+), 76 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67855faa/README.md -- diff --git a/README.md b/README.md new file mode 100644 index 000..d23963e --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +Building Apache Tamaya (incubating) + + + +The Apache Tamaya project contains classes which are intended to be built with Java7 and others +which are for Java8. This means you need to have both JDK-1.7 and JDK-1.8 installed on your computer. + +To tell maven which JDK it should use for each of the projects we do leverage the +maven-toolchains-plugin and Mavens toolchains support. + +See the following links for more information +http://maven.apache.org/ref/3.2.5/maven-core/toolchains.html +http://maven.apache.org/guides/mini/guide-using-toolchains.html + +Please copy the provided toolchains.xml sample to ~.m2/toolchains.xml \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67855faa/java7/api/pom.xml -- diff --git a/java7/api/pom.xml b/java7/api/pom.xml new file mode 100644 index 000..3dbfa4c --- /dev/null +++ b/java7/api/pom.xml @@ -0,0 +1,43 @@ + +http://maven.apache.org/POM/4.0.0"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd";> +4.0.0 + + +org.apache.tamaya +tamaya-java7 +0.2-SNAPSHOT +../pom.xml + + +tamaya-java7-api + +The API defines a complete Java7 based API for reading of configuration data. + + + + +junit +junit +test + + + + http://git
[3/9] incubator-tamaya git commit: TAMAYA-49 move api and core to java8 module
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/328a4ac7/java8/core/src/main/java/org/apache/tamaya/core/internal/PropertiesFileLoader.java -- diff --git a/java8/core/src/main/java/org/apache/tamaya/core/internal/PropertiesFileLoader.java b/java8/core/src/main/java/org/apache/tamaya/core/internal/PropertiesFileLoader.java new file mode 100644 index 000..b79a756 --- /dev/null +++ b/java8/core/src/main/java/org/apache/tamaya/core/internal/PropertiesFileLoader.java @@ -0,0 +1,102 @@ +/* + * 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.core.internal; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.Enumeration; +import java.util.HashSet; +import java.util.Objects; +import java.util.Properties; +import java.util.Set; + +public final class PropertiesFileLoader { + + +private PropertiesFileLoader() { +// no instantiation +} + + +/** + * loads all properties-files with the given name. + * If the name do not end with {@code .properties} it will be appended + * + * @param name of the properties file + * + * @return URLs of properties-files or + * an empty {@link Set} if no files has been found + * + * @throws IOException in case of problems loading the properties-files + */ +public static Set resolvePropertiesFiles(String name) throws IOException { +Objects.requireNonNull(name); + +if (!name.endsWith(".properties")) { +name = name + ".properties"; +} + +Set urls = new HashSet<>(); + +Enumeration files = Thread.currentThread().getContextClassLoader().getResources(name); +while (files.hasMoreElements()) { +urls.add(files.nextElement()); +} + +return urls; +} + + +/** + * loads the Properties from the given URL + * + * @param propertiesFile {@link URL} to load Properties from + * + * @return loaded {@link Properties} + * + * @throws IllegalStateException in case of an error while reading properties-file + */ +public static Properties load(URL propertiesFile) { + +Properties properties = new Properties(); + +InputStream stream = null; +try { +stream = propertiesFile.openStream(); + +if (stream != null) { +properties.load(stream); +} +} catch (IOException e) { +throw new IllegalStateException("Error loading Properties " + propertiesFile, e); +} finally { +if (stream != null) { +try { +stream.close(); +} catch (IOException e) { +// bad luck -> stream is already closed +} +} +} + +return properties; +} + +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/328a4ac7/java8/core/src/main/java/org/apache/tamaya/core/internal/PropertyConverterManager.java -- diff --git a/java8/core/src/main/java/org/apache/tamaya/core/internal/PropertyConverterManager.java b/java8/core/src/main/java/org/apache/tamaya/core/internal/PropertyConverterManager.java new file mode 100644 index 000..5c7ae02 --- /dev/null +++ b/java8/core/src/main/java/org/apache/tamaya/core/internal/PropertyConverterManager.java @@ -0,0 +1,247 @@ +/* + * 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 e
[2/9] incubator-tamaya git commit: TAMAYA-49 remove Optional from ConfigSource
TAMAYA-49 remove Optional from ConfigSource Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/b4bde92b Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/b4bde92b Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/b4bde92b Branch: refs/heads/master Commit: b4bde92b5b6342d4062189a1b7248b05df9fa381 Parents: 67855fa Author: Mark Struberg Authored: Tue Jan 6 22:38:50 2015 +0100 Committer: Mark Struberg Committed: Wed Jan 7 23:17:58 2015 +0100 -- .../modules/json/JSONPropertySourceTest.java| 65 ++-- 1 file changed, 33 insertions(+), 32 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b4bde92b/modules/json/src/test/java/org/apache/tamaya/modules/json/JSONPropertySourceTest.java -- diff --git a/modules/json/src/test/java/org/apache/tamaya/modules/json/JSONPropertySourceTest.java b/modules/json/src/test/java/org/apache/tamaya/modules/json/JSONPropertySourceTest.java index 87a9ff2..8935857 100644 --- a/modules/json/src/test/java/org/apache/tamaya/modules/json/JSONPropertySourceTest.java +++ b/modules/json/src/test/java/org/apache/tamaya/modules/json/JSONPropertySourceTest.java @@ -22,15 +22,16 @@ import org.apache.tamaya.ConfigException; import org.apache.tamaya.core.propertysource.DefaultOrdinal; import org.apache.tamaya.spi.PropertySource; import org.hamcrest.CoreMatchers; +import org.hamcrest.Matchers; import org.junit.Test; import java.io.File; import java.net.URISyntaxException; import java.net.URL; -import java.util.Optional; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.hasSize; import static org.junit.Assert.fail; @@ -75,16 +76,16 @@ public class JSONPropertySourceTest { assertThat(source.getProperties().keySet(), hasSize(3)); -Optional keyA = source.get("a"); -Optional keyB = source.get("b"); -Optional keyC = source.get("c"); +String keyA = source.get("a"); +String keyB = source.get("b"); +String keyC = source.get("c"); -assertThat(keyA.isPresent(), is(true)); -assertThat(keyA.get(), equalTo("A")); -assertThat(keyB.isPresent(), is(true)); -assertThat(keyB.get(), is("B")); -assertThat(keyC.isPresent(), is(true)); -assertThat(keyC.get(), is("C")); +assertThat(keyA, notNullValue()); +assertThat(keyA, equalTo("A")); +assertThat(keyB, notNullValue()); +assertThat(keyB, is("B")); +assertThat(keyC, notNullValue()); +assertThat(keyC, is("C")); } @Test @@ -99,16 +100,16 @@ public class JSONPropertySourceTest { assertThat(source.getProperties().keySet(), hasSize(5)); -Optional keyb = source.get("b"); -Optional keyDO = source.get("d.o"); -Optional keyDP = source.get("d.p"); +String keyb = source.get("b"); +String keyDO = source.get("d.o"); +String keyDP = source.get("d.p"); -assertThat(keyb.isPresent(), is(true)); -assertThat(keyb.get(), equalTo("B")); -assertThat(keyDO.isPresent(), is(true)); -assertThat(keyDO.get(), equalTo("O")); -assertThat(keyDP.isPresent(), is(true)); -assertThat(keyDP.get(), is("P")); +assertThat(keyb, notNullValue()); +assertThat(keyb, equalTo("B")); +assertThat(keyDO, notNullValue()); +assertThat(keyDO, equalTo("O")); +assertThat(keyDP, Matchers.notNullValue()); +assertThat(keyDP, is("P")); } @Test @@ -124,19 +125,19 @@ public class JSONPropertySourceTest { assertThat(source.getProperties().keySet(), hasSize(4)); -Optional keyA = source.get("a"); -Optional keyDO = source.get("b.o"); -Optional keyDP = source.get("b.p"); -Optional keyC = source.get("c"); - -assertThat(keyA.isPresent(), is(true)); -assertThat(keyA.get(), is("A")); -assertThat(keyC.isPresent(), is(true)); -assertThat(keyC.get(), equalTo("C")); -assertThat(keyDO.isPresent(), is(true)); -assertThat(keyDO.get(), equalTo("O")); -assertThat(keyDP.isPresent(), is(true)); -assertTha
[9/9] incubator-tamaya git commit: TAMAYA-49 fix test which I broke
TAMAYA-49 fix test which I broke Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/585167aa Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/585167aa Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/585167aa Branch: refs/heads/master Commit: 585167aa8dbcf695399977e889b5681e49e82f1d Parents: 3d6456d Author: Mark Struberg Authored: Wed Jan 7 23:19:34 2015 +0100 Committer: Mark Struberg Committed: Wed Jan 7 23:19:34 2015 +0100 -- .../org/apache/tamaya/modules/json/JSONPropertySourceTest.java| 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/585167aa/modules/json/src/test/java/org/apache/tamaya/modules/json/JSONPropertySourceTest.java -- diff --git a/modules/json/src/test/java/org/apache/tamaya/modules/json/JSONPropertySourceTest.java b/modules/json/src/test/java/org/apache/tamaya/modules/json/JSONPropertySourceTest.java index 8935857..0c48534 100644 --- a/modules/json/src/test/java/org/apache/tamaya/modules/json/JSONPropertySourceTest.java +++ b/modules/json/src/test/java/org/apache/tamaya/modules/json/JSONPropertySourceTest.java @@ -32,6 +32,7 @@ import java.net.URL; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.notNullValue; +import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.hasSize; import static org.junit.Assert.fail; @@ -150,7 +151,7 @@ public class JSONPropertySourceTest { JSONPropertySource source = new JSONPropertySource(configFile, 10); -assertThat(source.get(PropertySource.TAMAYA_ORDINAL).isPresent(), is(false)); +assertThat(source.get(PropertySource.TAMAYA_ORDINAL), nullValue()); } @Test
[1/2] incubator-tamaya git commit: TAMAYA-51 also upgrade inactive modules to 'incubating'
Repository: incubator-tamaya Updated Branches: refs/heads/master e4754bb06 -> a1f85650f TAMAYA-51 also upgrade inactive modules to 'incubating' Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/a1f85650 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/a1f85650 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/a1f85650 Branch: refs/heads/master Commit: a1f85650f9eeba54026c2a8dc40f68ba37f71a93 Parents: 7241a92 Author: Mark Struberg Authored: Wed Jan 7 00:00:09 2015 +0100 Committer: Mark Struberg Committed: Wed Jan 7 00:01:01 2015 +0100 -- modules/injection/pom.xml | 2 +- modules/management/pom.xml | 2 +- modules/metamodels/environment/pom.xml | 2 +- modules/metamodels/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a1f85650/modules/injection/pom.xml -- diff --git a/modules/injection/pom.xml b/modules/injection/pom.xml index c0970cd..0627d50 100644 --- a/modules/injection/pom.xml +++ b/modules/injection/pom.xml @@ -23,7 +23,7 @@ under the License. org.apache.tamaya.ext tamaya-extensions -0.2-SNAPSHOT +0.2-incubating-SNAPSHOT .. tamaya-injection http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a1f85650/modules/management/pom.xml -- diff --git a/modules/management/pom.xml b/modules/management/pom.xml index 6d6e441..31d632a 100644 --- a/modules/management/pom.xml +++ b/modules/management/pom.xml @@ -23,7 +23,7 @@ under the License. org.apache.tamaya.ext tamaya-extensions -0.2-SNAPSHOT +0.2-incubating-SNAPSHOT .. tamaya-management http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a1f85650/modules/metamodels/environment/pom.xml -- diff --git a/modules/metamodels/environment/pom.xml b/modules/metamodels/environment/pom.xml index 85a45ee..38370d8 100644 --- a/modules/metamodels/environment/pom.xml +++ b/modules/metamodels/environment/pom.xml @@ -23,7 +23,7 @@ under the License. org.apache.tamaya.ext.metamodels tamaya-metamodels -0.2-SNAPSHOT +0.2-incubating-SNAPSHOT .. tamaya-metamodel-environment http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a1f85650/modules/metamodels/pom.xml -- diff --git a/modules/metamodels/pom.xml b/modules/metamodels/pom.xml index 2631d94..4eecdc4 100644 --- a/modules/metamodels/pom.xml +++ b/modules/metamodels/pom.xml @@ -23,7 +23,7 @@ under the License. org.apache.tamaya.ext tamaya-extensions -0.2-SNAPSHOT +0.2-incubating-SNAPSHOT .. org.apache.tamaya.ext.metamodels
[2/2] incubator-tamaya git commit: TAMAYA-51 changed version to 0.2-incubating-SNAPSHOT
TAMAYA-51 changed version to 0.2-incubating-SNAPSHOT Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/7241a923 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/7241a923 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/7241a923 Branch: refs/heads/master Commit: 7241a923c57dc1173c8eca43803f8c30b9fd6f86 Parents: e4754bb Author: Reinhard Sandtner Authored: Tue Jan 6 23:40:53 2015 +0100 Committer: Mark Struberg Committed: Wed Jan 7 00:01:01 2015 +0100 -- api/pom.xml | 2 +- core/pom.xml | 2 +- docs/pom.xml | 2 +- modules/formats/pom.xml | 2 +- modules/json/pom.xml | 2 +- modules/pom.xml | 2 +- modules/resolver/pom.xml | 2 +- modules/resources/pom.xml | 2 +- pom.xml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7241a923/api/pom.xml -- diff --git a/api/pom.xml b/api/pom.xml index 83842e7..6cea5b6 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -23,7 +23,7 @@ under the License. org.apache.tamaya tamaya-all -0.2-SNAPSHOT +0.2-incubating-SNAPSHOT ../pom.xml http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7241a923/core/pom.xml -- diff --git a/core/pom.xml b/core/pom.xml index 917f2e2..8f53980 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -23,7 +23,7 @@ under the License. org.apache.tamaya tamaya-all -0.2-SNAPSHOT +0.2-incubating-SNAPSHOT ../pom.xml http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7241a923/docs/pom.xml -- diff --git a/docs/pom.xml b/docs/pom.xml index 787f1ef..d3646fd 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -23,7 +23,7 @@ under the License. org.apache.tamaya tamaya-all -0.2-SNAPSHOT +0.2-incubating-SNAPSHOT .. http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7241a923/modules/formats/pom.xml -- diff --git a/modules/formats/pom.xml b/modules/formats/pom.xml index 15d554c..40fd059 100644 --- a/modules/formats/pom.xml +++ b/modules/formats/pom.xml @@ -23,7 +23,7 @@ under the License. org.apache.tamaya.ext tamaya-extensions -0.2-SNAPSHOT +0.2-incubating-SNAPSHOT .. tamaya-formats http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7241a923/modules/json/pom.xml -- diff --git a/modules/json/pom.xml b/modules/json/pom.xml index f40fcb5..28abec9 100644 --- a/modules/json/pom.xml +++ b/modules/json/pom.xml @@ -25,7 +25,7 @@ under the License. tamaya-extensions org.apache.tamaya.ext -0.2-SNAPSHOT +0.2-incubating-SNAPSHOT json http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7241a923/modules/pom.xml -- diff --git a/modules/pom.xml b/modules/pom.xml index 0f19d8b..c5671d2 100644 --- a/modules/pom.xml +++ b/modules/pom.xml @@ -23,7 +23,7 @@ under the License. org.apache.tamaya tamaya-all -0.2-SNAPSHOT +0.2-incubating-SNAPSHOT .. tamaya-extensions http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7241a923/modules/resolver/pom.xml -- diff --git a/modules/resolver/pom.xml b/modules/resolver/pom.xml index 301ba9a..65029b7 100644 --- a/modules/resolver/pom.xml +++ b/modules/resolver/pom.xml @@ -23,7 +23,7 @@ under the License. org.apache.tamaya.ext tamaya-extensions -0.2-SNAPSHOT +0.2-incubating-SNAPSHOT .. tamaya-resolver http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7241a923/modules/resources/pom.xml -- diff --git a/modules/resources/pom.xml b/modules/resources/pom.xml index c7e1e32..652556a 100644 --- a/modules/resources/pom.xml +++ b/modules/resources/pom.xml @@ -23,7 +23,7 @@ under the License. org.apache.tamaya.ext tamaya-extensions -0.2-SNAPSHOT +0.2-incubating-SNAPSHOT .. tamaya-resources http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/7241a923/pom.xml
incubator-tamaya git commit: TAMAYA-50 added ServiceContextManagerTest
Repository: incubator-tamaya Updated Branches: refs/heads/master 7b2a9afe0 -> d615825da TAMAYA-50 added ServiceContextManagerTest to verify the one with the highest ordinal is taken Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/d615825d Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/d615825d Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/d615825d Branch: refs/heads/master Commit: d615825da1fa11dffafb18101decfd39ae312789 Parents: 7b2a9af Author: Reinhard Sandtner Authored: Tue Jan 6 22:46:00 2015 +0100 Committer: Reinhard Sandtner Committed: Tue Jan 6 22:46:00 2015 +0100 -- .../tamaya/spi/ServiceContextManagerTest.java | 109 +++ .../test/resources/ServiceContextWithOrdinal| 25 + 2 files changed, 134 insertions(+) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d615825d/api/src/test/java/org/apache/tamaya/spi/ServiceContextManagerTest.java -- diff --git a/api/src/test/java/org/apache/tamaya/spi/ServiceContextManagerTest.java b/api/src/test/java/org/apache/tamaya/spi/ServiceContextManagerTest.java new file mode 100644 index 000..0309c6c --- /dev/null +++ b/api/src/test/java/org/apache/tamaya/spi/ServiceContextManagerTest.java @@ -0,0 +1,109 @@ +/* + * 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.spi; + +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.io.IOException; +import java.lang.reflect.Field; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.Enumeration; +import java.util.List; +import java.util.Optional; + +public class ServiceContextManagerTest { + +private static URLClassLoader classLoader; +private static Field delegateField; + +@BeforeClass +public static void init() throws Exception { + +// setup the environment for our ugly hacks + +// replace classloader with our own +classLoader = (URLClassLoader) Thread.currentThread().getContextClassLoader(); +Thread.currentThread().setContextClassLoader(new UglyHackClassLoader(classLoader)); + +// clear the caching field +delegateField = ServiceContextManager.class.getDeclaredField("serviceContextProviderDelegate"); +delegateField.setAccessible(true); + +delegateField.set(null, null); +} + +@AfterClass +public static void clean() throws Exception { + +// clean our hacks + +delegateField.set(null, null); +Thread.currentThread().setContextClassLoader(classLoader); +} + +@Test +public void testGetServiceContext() { + +ServiceContext context = ServiceContextManager.getServiceContext(); +Assert.assertEquals(100, context.ordinal()); + +} + + +// has to be public because ServiceLoader won't find it otherwise +public static class ServiceContextWithOrdinal implements ServiceContext { + +@Override +public int ordinal() { +return 100; +} + +@Override +public Optional getService(Class serviceType) { +return null; +} + +@Override +public List getServices(Class serviceType) { +return null; +} +} + +// to override the getResources method to use our own 'ServiceLoader'-file we have to this ugly hack +private static class UglyHackClassLoader extends URLClassLoader { + +private UglyHackClassLoader(URLClassLoader urlClassLoader) { +super(urlClassLoader.getURLs()); +} + + +@Override +public Enumeration getResources(String name) throws IOException { +if ("META-INF/services/org.apache.tamaya.spi.ServiceContext".equals(name)) { +return super.getResources("ServiceContextWithOrdinal"); +} + +return super.getResources(name); +}
incubator-tamaya git commit: Even more clarifications for PropertySource#isScannable()
Repository: incubator-tamaya Updated Branches: refs/heads/master 37be11acb -> 70c9ae457 Even more clarifications for PropertySource#isScannable() Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/70c9ae45 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/70c9ae45 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/70c9ae45 Branch: refs/heads/master Commit: 70c9ae4571275bf7d83d72bdda3ec2a1891cbb4b Parents: 37be11a Author: Mark Struberg Authored: Tue Jan 6 18:50:43 2015 +0100 Committer: Mark Struberg Committed: Tue Jan 6 18:50:43 2015 +0100 -- api/src/main/java/org/apache/tamaya/spi/PropertySource.java | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/70c9ae45/api/src/main/java/org/apache/tamaya/spi/PropertySource.java -- diff --git a/api/src/main/java/org/apache/tamaya/spi/PropertySource.java b/api/src/main/java/org/apache/tamaya/spi/PropertySource.java index bfa0252..ae80159 100644 --- a/api/src/main/java/org/apache/tamaya/spi/PropertySource.java +++ b/api/src/main/java/org/apache/tamaya/spi/PropertySource.java @@ -112,7 +112,11 @@ public interface PropertySource { /** * Determines if this config source could be scanned for its list of properties. * - * Generally, slow PropertySources should return {@code false} here. + * + * PropertySources which are not scannable might not be able to find all the + * configured values to provide via {@link #getProperties()}. This can e.g. happen + * if the underlying storage doesn't support listing. + * * * @return {@code true} if this PropertySource could be scanned for its list of properties, * {@code false} if it should not be scanned.
incubator-tamaya git commit: fixed unused imports which broke the build
Repository: incubator-tamaya Updated Branches: refs/heads/master 1bdd4b719 -> 6d5514a08 fixed unused imports which broke the build please all do a mvn clean install before committing anything! Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/6d5514a0 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/6d5514a0 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/6d5514a0 Branch: refs/heads/master Commit: 6d5514a08c4be6f45cc3287600772e5c6c7d7e48 Parents: 1bdd4b7 Author: Mark Struberg Authored: Tue Jan 6 18:41:41 2015 +0100 Committer: Mark Struberg Committed: Tue Jan 6 18:41:41 2015 +0100 -- api/src/main/java/org/apache/tamaya/spi/PropertyFilter.java| 2 -- .../tamaya/resolver/internal/ExpressionResolutionFilter.java | 1 - .../java/org/apache/tamaya/resolver/spi/ExpressionEvaluator.java | 1 - .../java/org/apache/tamaya/resolver/spi/ExpressionResolver.java| 1 - 4 files changed, 5 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/6d5514a0/api/src/main/java/org/apache/tamaya/spi/PropertyFilter.java -- diff --git a/api/src/main/java/org/apache/tamaya/spi/PropertyFilter.java b/api/src/main/java/org/apache/tamaya/spi/PropertyFilter.java index a19188c..50a03dd 100644 --- a/api/src/main/java/org/apache/tamaya/spi/PropertyFilter.java +++ b/api/src/main/java/org/apache/tamaya/spi/PropertyFilter.java @@ -19,8 +19,6 @@ package org.apache.tamaya.spi; -import java.util.function.Function; - /** * Interface for filtering the current map of properties during the evaluation of the chain of PropertySources. * Filters can be registered using the {@link org.apache.tamaya.spi.ServiceContext}. The ordinal http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/6d5514a0/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/ExpressionResolutionFilter.java -- diff --git a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/ExpressionResolutionFilter.java b/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/ExpressionResolutionFilter.java index 231d729..fb4c122 100644 --- a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/ExpressionResolutionFilter.java +++ b/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/ExpressionResolutionFilter.java @@ -23,7 +23,6 @@ import org.apache.tamaya.spi.PropertyFilter; import org.apache.tamaya.spi.ServiceContext; import javax.annotation.Priority; -import java.util.function.Function; import java.util.logging.Logger; /** http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/6d5514a0/modules/resolver/src/main/java/org/apache/tamaya/resolver/spi/ExpressionEvaluator.java -- diff --git a/modules/resolver/src/main/java/org/apache/tamaya/resolver/spi/ExpressionEvaluator.java b/modules/resolver/src/main/java/org/apache/tamaya/resolver/spi/ExpressionEvaluator.java index 62f535c..8f95410 100644 --- a/modules/resolver/src/main/java/org/apache/tamaya/resolver/spi/ExpressionEvaluator.java +++ b/modules/resolver/src/main/java/org/apache/tamaya/resolver/spi/ExpressionEvaluator.java @@ -18,7 +18,6 @@ */ package org.apache.tamaya.resolver.spi; -import java.util.function.Function; /** * Created by Anatole on 05.01.2015. http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/6d5514a0/modules/resolver/src/main/java/org/apache/tamaya/resolver/spi/ExpressionResolver.java -- diff --git a/modules/resolver/src/main/java/org/apache/tamaya/resolver/spi/ExpressionResolver.java b/modules/resolver/src/main/java/org/apache/tamaya/resolver/spi/ExpressionResolver.java index 768bcce..4691f29 100644 --- a/modules/resolver/src/main/java/org/apache/tamaya/resolver/spi/ExpressionResolver.java +++ b/modules/resolver/src/main/java/org/apache/tamaya/resolver/spi/ExpressionResolver.java @@ -18,7 +18,6 @@ */ package org.apache.tamaya.resolver.spi; -import java.util.function.Function; /** * This interfaces provides a model for expression evaluation. This enables transparently plugin expression languages
Re: [4/4] incubator-tamaya git commit: Merge remote-tracking branch 'origin/master'
Hi Anatole! Please always do a $> git pull --rebase otherwise we will have all those nasty merge noise in the log. Isn't exactly helping when tracking changes... LieGrue, strub > On Tuesday, 6 January 2015, 17:23, "anat...@apache.org" > wrote: > > Merge remote-tracking branch 'origin/master' > > > Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo > Commit: > http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/1bdd4b71 > Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/1bdd4b71 > Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/1bdd4b71 > > Branch: refs/heads/master > Commit: 1bdd4b7195b6882713d0be2b6acf32686751edd6 > Parents: e53022e a2a36f1 > Author: anatole > Authored: Tue Jan 6 17:22:53 2015 +0100 > > Committer: anatole > Committed: Tue Jan 6 17:22:53 2015 +0100 > > -- > .../apache/tamaya/spi/ConfigurationContext.java | 2 +- > .../core/internal/DefaultConfiguration.java | 2 +- > .../internal/DefaultConfigurationContext.java | 3 - > .../core/internal/PropertiesFileLoader.java | 102 ++ > .../core/internal/PropertyConverterManager.java | 21 ++-- > .../core/propertysource/DefaultOrdinal.java | 7 +- > .../PropertiesFilePropertySource.java | 47 + > .../PropertiesPropertySource.java | 51 + > .../propertysource/SystemPropertySource.java| 15 ++- > .../provider/JavaConfigurationProvider.java | 60 +++ > .../test/internal/PropetiesFileLoaderTest.java | 76 ++ > .../PropertiesFilePropertySourceTest.java | 71 + > .../provider/JavaConfigurationProviderTest.java | 53 ++ > ...org.apache.tamaya.spi.PropertySourceProvider | 3 +- > .../test/resources/javaconfiguration.properties | 22 > .../test/resources/overrideOrdinal.properties | 25 + > core/src/test/resources/testfile.properties | 22 > extras/json/pom.xml | 63 +++ > .../tamaya/extras/json/FileBasedResource.java | 50 + > .../tamaya/extras/json/InputResource.java | 27 + > .../tamaya/extras/json/JSONPropertySource.java | 104 +++ > .../apache/tamaya/extras/json/JSONVisitor.java | 76 ++ > .../resources/configs/valid/simple-config.json | 5 + > extras/pom.xml | 41 > pom.xml | 8 ++ > 25 files changed, 930 insertions(+), 26 deletions(-) > -- > > > http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/1bdd4b71/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfiguration.java > > -- >
[1/2] incubator-tamaya git commit: TAMAYA-42 avoid NPE and add TODOs
Repository: incubator-tamaya Updated Branches: refs/heads/master 37725cd05 -> ea651771f TAMAYA-42 avoid NPE and add TODOs Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/022b15e7 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/022b15e7 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/022b15e7 Branch: refs/heads/master Commit: 022b15e76079b3a65232eeab3d013c5c1b2bab87 Parents: 37725cd Author: Mark Struberg Authored: Mon Jan 5 21:09:50 2015 +0100 Committer: Mark Struberg Committed: Mon Jan 5 21:10:27 2015 +0100 -- .../core/internal/PropertyConverterManager.java | 16 .../core/propertysource/SystemPropertySource.java | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/022b15e7/core/src/main/java/org/apache/tamaya/core/internal/PropertyConverterManager.java -- diff --git a/core/src/main/java/org/apache/tamaya/core/internal/PropertyConverterManager.java b/core/src/main/java/org/apache/tamaya/core/internal/PropertyConverterManager.java index 359dff7..86c8ebe 100644 --- a/core/src/main/java/org/apache/tamaya/core/internal/PropertyConverterManager.java +++ b/core/src/main/java/org/apache/tamaya/core/internal/PropertyConverterManager.java @@ -65,25 +65,25 @@ public class PropertyConverterManager { */ protected void initDefaultConverters() { // Add default converters -register(char.class, (s) -> s.charAt(0)); +register(char.class, (s) -> s != null ? s.charAt(0) : null); register(byte.class, Byte::parseByte); register(short.class, Short::parseShort); register(int.class, Integer::parseInt); register(long.class, Long::parseLong); register(boolean.class, Boolean::parseBoolean); -register(float.class, Float::parseFloat); -register(double.class, Double::parseDouble); +register(float.class, Float::parseFloat); //X TODO not good enough as this is Locale dependent! +register(double.class, Double::parseDouble); //X TODO not good enough as this is Locale dependent! -register(Character.class, (s) -> s.charAt(0)); +register(Character.class, (s) -> s != null ? s.charAt(0) : null ); register(Byte.class, Byte::valueOf); register(Short.class, Short::valueOf); register(Integer.class, Integer::valueOf); register(Long.class, Long::valueOf); register(Boolean.class, Boolean::valueOf); -register(Float.class, Float::valueOf); -register(Double.class, Double::valueOf); -register(BigDecimal.class, BigDecimal::new); -register(BigInteger.class, BigInteger::new); +register(Float.class, Float::valueOf); //X TODO not good enough as this is Locale dependent! +register(Double.class, Double::valueOf); //X TODO not good enough as this is Locale dependent! +register(BigDecimal.class, BigDecimal::new); //X TODO not good enough as this is Locale dependent! +register(BigInteger.class, BigInteger::new); //X TODO not good enough as this is Locale dependent! register(Currency.class, Currency::getInstance); http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/022b15e7/core/src/main/java/org/apache/tamaya/core/propertysource/SystemPropertySource.java -- diff --git a/core/src/main/java/org/apache/tamaya/core/propertysource/SystemPropertySource.java b/core/src/main/java/org/apache/tamaya/core/propertysource/SystemPropertySource.java index e06e185..4ead5ab 100644 --- a/core/src/main/java/org/apache/tamaya/core/propertysource/SystemPropertySource.java +++ b/core/src/main/java/org/apache/tamaya/core/propertysource/SystemPropertySource.java @@ -29,7 +29,7 @@ import java.util.Properties; public class SystemPropertySource extends BasePropertySource { /** - * cashed System.getProperties() filled in our Map + * cached System.getProperties() filled in our Map */ private Map properties;
[2/2] incubator-tamaya git commit: TAMAYA-42 make ConfigurationContext final again
TAMAYA-42 make ConfigurationContext final again Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/ea651771 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/ea651771 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/ea651771 Branch: refs/heads/master Commit: ea651771f7448afd7dc8a8e9bea965ab9784a40b Parents: 022b15e Author: Mark Struberg Authored: Mon Jan 5 21:13:37 2015 +0100 Committer: Mark Struberg Committed: Mon Jan 5 21:13:37 2015 +0100 -- .../java/org/apache/tamaya/core/internal/DefaultConfiguration.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/ea651771/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfiguration.java -- diff --git a/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfiguration.java b/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfiguration.java index 2efff12..bec3996 100644 --- a/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfiguration.java +++ b/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfiguration.java @@ -55,7 +55,7 @@ public class DefaultConfiguration implements Configuration { /** * The current {@link org.apache.tamaya.spi.ConfigurationContext} of the current instance. */ -private ConfigurationContext configurationContext = ServiceContext.getInstance().getService(ConfigurationContext.class).get(); +private final ConfigurationContext configurationContext = ServiceContext.getInstance().getService(ConfigurationContext.class).get(); /** * This method evaluates the given configuration key. Hereby if goes down the chain or PropertySource instances
incubator-tamaya git commit: TAMAYA-42 pickup PropertySources at startup
Repository: incubator-tamaya Updated Branches: refs/heads/master 3368db2e1 -> 853047a72 TAMAYA-42 pickup PropertySources at startup * no need to store the PropertySourceProviders as we just evaluate them once * store PropertySources and Filter in an unmodifiable list Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/853047a7 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/853047a7 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/853047a7 Branch: refs/heads/master Commit: 853047a72815b878eb149ce98b5aa05fa9413eab Parents: 3368db2 Author: Mark Struberg Authored: Mon Jan 5 16:27:11 2015 +0100 Committer: Mark Struberg Committed: Mon Jan 5 16:27:11 2015 +0100 -- .../internal/DefaultConfigurationContext.java | 100 ++- 1 file changed, 54 insertions(+), 46 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/853047a7/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContext.java -- diff --git a/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContext.java b/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContext.java index c225e59..a2705ef 100644 --- a/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContext.java +++ b/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContext.java @@ -28,56 +28,92 @@ import org.apache.tamaya.spi.ServiceContext; import javax.annotation.Priority; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.StampedLock; -import java.util.logging.Level; import java.util.logging.Logger; /** * Default Implementation of a simple ConfigurationContext. */ public class DefaultConfigurationContext implements ConfigurationContext { -/** The logger. */ + private static final Logger LOG = Logger.getLogger(DefaultConfigurationContext.class.getName()); /** * Cubcomponent handling {@link org.apache.tamaya.spi.PropertyConverter} instances. */ private PropertyConverterManager propertyConverterManager = new PropertyConverterManager(); + /** - * The current list of loaded {@link org.apache.tamaya.spi.PropertySource} instances. - */ -private List propertySources = new ArrayList<>(); -/** - * The current list of loaded {@link org.apache.tamaya.spi.PropertySourceProvider} instances. + * The current unmodifiable list of loaded {@link org.apache.tamaya.spi.PropertySource} instances. */ -private List propertySourceProviders = new ArrayList<>(); +private List immutablePropertySources; + /** - * The current list of loaded {@link org.apache.tamaya.spi.PropertyFilter} instances. + * The current unmodifiable list of loaded {@link org.apache.tamaya.spi.PropertyFilter} instances. */ -private List propertyFilters = new ArrayList<>(); +private List immutablePropertyFilters; + /** * Lock for internal synchronization. */ private StampedLock propertySourceLock = new StampedLock(); + + +/** + * The first time the Configuration system gets invoked we do initialize + * all our {@link org.apache.tamaya.spi.PropertySource}s and + * {@link org.apache.tamaya.spi.PropertyFilter}s which are known at startup. + */ +public DefaultConfigurationContext() { +List propertySources = new ArrayList<>(); + +// first we load all PropertySources which got registered via java.util.ServiceLoader + propertySources.addAll(ServiceContext.getInstance().getServices(PropertySource.class)); + +// after that we add all PropertySources which get dynamically registered via their PropertySourceProviders +propertySources.addAll(evaluatePropertySourcesFromProviders()); + +// now sort them according to their ordinal values +Collections.sort(propertySources, this::comparePropertySources); + +immutablePropertySources = Collections.unmodifiableList(propertySources); + +// as next step we pick up the PropertyFilters pretty much the same way +List propertyFilters = new ArrayList<>(); + propertyFilters.addAll(ServiceContext.getInstance().getServices(PropertyFilter.class)); +Collections.sort(propertyFilters, this::comparePropertyFilters); + +immutablePropertyFilters = Collections.unmodifiableList(propertyFilters); +} + /** - * Loaded flag. - * TODO replace flag with check o
incubator-tamaya git commit: TAMAYA-42 only resolve the ConfigurationContext once
Repository: incubator-tamaya Updated Branches: refs/heads/master 909ec1616 -> 3368db2e1 TAMAYA-42 only resolve the ConfigurationContext once The Configuration and ConfigurationConstance impls belong together 1:1. We not only don't need to proxy them internally but also shall not do this otherwise we would trash the performance. Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/3368db2e Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/3368db2e Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/3368db2e Branch: refs/heads/master Commit: 3368db2e1a8eb5b54fdc8c5320acbfbdb2cfa245 Parents: 909ec16 Author: Mark Struberg Authored: Mon Jan 5 14:55:56 2015 +0100 Committer: Mark Struberg Committed: Mon Jan 5 14:55:56 2015 +0100 -- .../tamaya/core/internal/DefaultConfiguration.java | 16 1 file changed, 8 insertions(+), 8 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3368db2e/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfiguration.java -- diff --git a/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfiguration.java b/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfiguration.java index 3769e27..651398b 100644 --- a/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfiguration.java +++ b/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfiguration.java @@ -45,6 +45,9 @@ public class DefaultConfiguration implements Configuration { private static final Logger LOG = Logger.getLogger(DefaultConfiguration.class.getName()); +private final ConfigurationContext configurationContext = ServiceContext.getInstance().getService(ConfigurationContext.class).get(); + + /** * This method evaluates the given configuration key. Hereby if goes down the chain or PropertySource instances * provided by the current {@link org.apache.tamaya.spi.ConfigurationContext}. The first non-null-value returned @@ -57,7 +60,7 @@ public class DefaultConfiguration implements Configuration { */ @Override public Optional get(String key) { -List propertySources = ServiceContext.getInstance().getService(ConfigurationContext.class).get().getPropertySources(); +List propertySources = configurationContext.getPropertySources(); String unfilteredValue = null; for (PropertySource propertySource : propertySources) { Optional value = propertySource.get(key); @@ -67,8 +70,7 @@ public class DefaultConfiguration implements Configuration { } } // Apply filters to values, prevent values filtered to null! -for(PropertyFilter filter: - ServiceContext.getInstance().getService(ConfigurationContext.class).get().getPropertyFilters()){ +for(PropertyFilter filter: configurationContext.getPropertyFilters()){ unfilteredValue = filter.filterProperty(key, unfilteredValue, (String k) -> key.equals(k)?null:get(k).orElse(null)); } @@ -77,8 +79,7 @@ public class DefaultConfiguration implements Configuration { @Override public Map getProperties() { -List propertySources = new ArrayList<>( - ServiceContext.getInstance().getService(ConfigurationContext.class).get().getPropertySources()); +List propertySources = new ArrayList<>(configurationContext.getPropertySources()); Collections.reverse(propertySources); Map result = new HashMap<>(); for (PropertySource propertySource : propertySources) { @@ -95,7 +96,7 @@ public class DefaultConfiguration implements Configuration { } // Apply filters to values, prevent values filtered to null! for(PropertyFilter filter: - ServiceContext.getInstance().getService(ConfigurationContext.class).get().getPropertyFilters()){ +configurationContext.getPropertyFilters()){ result.replaceAll((k,v) -> filter.filterProperty(k, v, (String k2) -> k2.equals(k)?null:get(k2).orElse(null))); } @@ -119,8 +120,7 @@ public class DefaultConfiguration implements Configuration { public Optional get(String key, Class type) { Optional value = get(key); if (value.isPresent()) { -List> converters = ServiceContext.getInstance().getService(ConfigurationContext.class) -.get().getPropertyConverters(type); +List> converters = configurationContext.getPropertyConverters(type); for (PropertyConverter converter : converters) {
[2/3] incubator-tamaya git commit: remove spring Notice as we removed the spring classes
remove spring Notice as we removed the spring classes Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/4caf602e Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/4caf602e Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/4caf602e Branch: refs/heads/master Commit: 4caf602eb8a2a7897b3007f38cc636011dfc9b1b Parents: b70ed55 Author: Mark Struberg Authored: Sat Jan 3 23:49:03 2015 +0100 Committer: Mark Struberg Committed: Sat Jan 3 23:49:03 2015 +0100 -- NOTICE | 1 - 1 file changed, 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/4caf602e/NOTICE -- diff --git a/NOTICE b/NOTICE index 6010bed..3bd2e43 100644 --- a/NOTICE +++ b/NOTICE @@ -10,4 +10,3 @@ Initial Contributors: This product includes software developed at - Anatole Tresch (http://github.com/atsticks) - The Apache Software Foundation (http://www.apache.org/). -- The Spring Framework (http://spring.io/projects).
[3/3] incubator-tamaya git commit: remove unused imports
remove unused imports Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/59a9e211 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/59a9e211 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/59a9e211 Branch: refs/heads/master Commit: 59a9e21103aaa877d2a2d09babdec289363f800d Parents: 4caf602 Author: Mark Struberg Authored: Sat Jan 3 23:50:52 2015 +0100 Committer: Mark Struberg Committed: Sat Jan 3 23:50:52 2015 +0100 -- api/src/test/java/org/apache/tamaya/spi/ServiceContextTest.java| 1 - api/src/test/java/org/apache/tamaya/spi/TestServiceContext.java| 1 - .../tamaya/core/test/propertysource/BasePropertySourceTest.java| 1 - .../tamaya/core/test/propertysource/SystemPropertySourceTest.java | 1 - .../java/org/apache/tamaya/core/testdata/TestPropertySource.java | 2 -- 5 files changed, 6 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/59a9e211/api/src/test/java/org/apache/tamaya/spi/ServiceContextTest.java -- diff --git a/api/src/test/java/org/apache/tamaya/spi/ServiceContextTest.java b/api/src/test/java/org/apache/tamaya/spi/ServiceContextTest.java index 066bdc5..5ebfc19 100644 --- a/api/src/test/java/org/apache/tamaya/spi/ServiceContextTest.java +++ b/api/src/test/java/org/apache/tamaya/spi/ServiceContextTest.java @@ -25,7 +25,6 @@ import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Optional; -import java.util.function.Supplier; import static org.junit.Assert.*; import static org.junit.Assert.assertEquals; http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/59a9e211/api/src/test/java/org/apache/tamaya/spi/TestServiceContext.java -- diff --git a/api/src/test/java/org/apache/tamaya/spi/TestServiceContext.java b/api/src/test/java/org/apache/tamaya/spi/TestServiceContext.java index 288726c..665c99f 100644 --- a/api/src/test/java/org/apache/tamaya/spi/TestServiceContext.java +++ b/api/src/test/java/org/apache/tamaya/spi/TestServiceContext.java @@ -25,7 +25,6 @@ import java.util.Map; import java.util.Optional; import java.util.ServiceLoader; import java.util.concurrent.ConcurrentHashMap; -import java.util.function.Supplier; import java.util.logging.Level; import java.util.logging.Logger; http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/59a9e211/core/src/test/java/org/apache/tamaya/core/test/propertysource/BasePropertySourceTest.java -- diff --git a/core/src/test/java/org/apache/tamaya/core/test/propertysource/BasePropertySourceTest.java b/core/src/test/java/org/apache/tamaya/core/test/propertysource/BasePropertySourceTest.java index 7b92910..357a262 100644 --- a/core/src/test/java/org/apache/tamaya/core/test/propertysource/BasePropertySourceTest.java +++ b/core/src/test/java/org/apache/tamaya/core/test/propertysource/BasePropertySourceTest.java @@ -28,7 +28,6 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Optional; -import java.util.Properties; public class BasePropertySourceTest { http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/59a9e211/core/src/test/java/org/apache/tamaya/core/test/propertysource/SystemPropertySourceTest.java -- diff --git a/core/src/test/java/org/apache/tamaya/core/test/propertysource/SystemPropertySourceTest.java b/core/src/test/java/org/apache/tamaya/core/test/propertysource/SystemPropertySourceTest.java index 5789346..a7712db 100644 --- a/core/src/test/java/org/apache/tamaya/core/test/propertysource/SystemPropertySourceTest.java +++ b/core/src/test/java/org/apache/tamaya/core/test/propertysource/SystemPropertySourceTest.java @@ -27,7 +27,6 @@ import org.junit.Test; import java.util.Map; import java.util.Optional; import java.util.Properties; -import java.util.Set; public class SystemPropertySourceTest { http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/59a9e211/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertySource.java -- diff --git a/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertySource.java b/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertySource.java index d03b43b..d1314aa 100644 --- a/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertySource.java +++ b/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertySource.java @@ -21,9 +21,7 @@ package org.apache.tamaya.core.testdata; import
[1/3] incubator-tamaya git commit: remove unused serviceloader file
Repository: incubator-tamaya Updated Branches: refs/heads/master 0734e210e -> 59a9e2110 remove unused serviceloader file Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/b70ed55b Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/b70ed55b Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/b70ed55b Branch: refs/heads/master Commit: b70ed55be0350aadc1b1da219b73bb0ac24799ab Parents: 0734e21 Author: Mark Struberg Authored: Sat Jan 3 23:48:39 2015 +0100 Committer: Mark Struberg Committed: Sat Jan 3 23:48:39 2015 +0100 -- ...g.apache.tamaya.core.resources.ResourceLoader | 19 --- 1 file changed, 19 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b70ed55b/core/src/main/resources/META-INF/services/org.apache.tamaya.core.resources.ResourceLoader -- diff --git a/core/src/main/resources/META-INF/services/org.apache.tamaya.core.resources.ResourceLoader b/core/src/main/resources/META-INF/services/org.apache.tamaya.core.resources.ResourceLoader deleted file mode 100644 index 08c9577..000 --- a/core/src/main/resources/META-INF/services/org.apache.tamaya.core.resources.ResourceLoader +++ /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.core.internal.resource.DefaultResourceLoader \ No newline at end of file
[5/9] incubator-tamaya git commit: remove files we don't have the full copyright!
remove files we don't have the full copyright! We shall not use code which we did not write ourself! Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/3e1a7a51 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/3e1a7a51 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/3e1a7a51 Branch: refs/heads/master Commit: 3e1a7a51540b6f43a0548fb9b9f23dc69a4324ad Parents: 4af87fc Author: Mark Struberg Authored: Sat Jan 3 18:11:56 2015 +0100 Committer: Mark Struberg Committed: Sat Jan 3 18:11:56 2015 +0100 -- .../org/apache/tamaya/core/util/ClassUtils.java | 1102 -- .../apache/tamaya/core/util/StringUtils.java| 473 2 files changed, 1575 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3e1a7a51/core/src/main/java/org/apache/tamaya/core/util/ClassUtils.java -- diff --git a/core/src/main/java/org/apache/tamaya/core/util/ClassUtils.java b/core/src/main/java/org/apache/tamaya/core/util/ClassUtils.java deleted file mode 100644 index 9e7e6d9..000 --- a/core/src/main/java/org/apache/tamaya/core/util/ClassUtils.java +++ /dev/null @@ -1,1102 +0,0 @@ -/* -* Copyright 2002-2014 the original author or authors. -* -* Licensed 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.core.util; - -import org.apache.tamaya.core.internal.resource.ReflectionUtils; - -import java.lang.reflect.Array; -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.lang.reflect.Proxy; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Objects; -import java.util.Set; - -/** - * Miscellaneous class utility methods. - * Mainly for internal use within the framework. - * - * @author Juergen Hoeller - * @author Keith Donald - * @author Rob Harrop - * @author Sam Brannen - * @since 1.1 - */ -public final class ClassUtils { - -/** - * Suffix for array class names: "[]" - */ -public static final String ARRAY_SUFFIX = "[]"; - -/** - * Prefix for internal array class names: "[" - */ -private static final String INTERNAL_ARRAY_PREFIX = "["; - -/** - * Prefix for internal non-primitive array class names: "[L" - */ -private static final String NON_PRIMITIVE_ARRAY_PREFIX = "[L"; - -/** - * The package separator character '.' - */ -private static final char PACKAGE_SEPARATOR = '.'; - -/** - * The path separator character '/' - */ -private static final char PATH_SEPARATOR = '/'; - -/** - * The inner class separator character '$' - */ -private static final char INNER_CLASS_SEPARATOR = '$'; - -/** - * Map with primitive wrapper type as key and corresponding primitive - * type as keys, for example: Integer.class -> int.class. - */ -private static final Map, Class> PRIMITIVE_WRAPPER_TYPE_MAP = new HashMap<>(8); - -/** - * Map with primitive type as key and corresponding wrapper - * type as keys, for example: int.class -> Integer.class. - */ -private static final Map, Class> PRIMITIVE_TYPE_TO_WRAPPER_MAP = new HashMap<>(8); - -/** - * Map with primitive type name as key and corresponding primitive - * type as keys, for example: "int" -> "int.class". - */ -private static final Map> PRIMITIVE_TYPE_NAME_MAP = new HashMap<>(32); - - -static { -PRIMITIVE_WRAPPER_TYPE_MAP.put(Boolean.class, boolean.class); -PRIMITIVE_WRAPPER_TYPE_MAP.put(Byte.class, byte.class); -PRIMITIVE_WRAPPER_TYPE_MAP.put(Character.class, char.class); -PRIMITIVE_WRAPPER_TYPE_MAP.put(Double.class, double.class); -PRIMITIVE_WRAPPER_TYPE_MAP.put(Float.class, float.class); -PRIMITIVE_WRAPPER_TYPE_MAP.put(Integer.class, int.class); -
[2/9] incubator-tamaya git commit: Merge remote-tracking branch 'rsandtner/TAMAYA-38' into TAMAYA-38
Merge remote-tracking branch 'rsandtner/TAMAYA-38' into TAMAYA-38 Conflicts: core/pom.xml Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/78732d44 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/78732d44 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/78732d44 Branch: refs/heads/master Commit: 78732d44cfbf18a300ac071276a03204407b7d83 Parents: ced3463 51960ef Author: Mark Struberg Authored: Sat Jan 3 14:43:02 2015 +0100 Committer: Mark Struberg Committed: Sat Jan 3 14:43:02 2015 +0100 -- .../org/apache/tamaya/spi/PropertySource.java | 7 ++ core/pom.xml| 33 +- .../core/propertysource/BasePropertySource.java | 76 + .../core/propertysource/DefaultOrdinal.java | 46 .../EnvironmentPropertySource.java | 47 .../propertysource/SystemPropertySource.java| 82 ++ .../propertysource/BasePropertySourceTest.java | 107 +++ .../EnvironmentPropertySourceTest.java | 70 .../SystemPropertySourceTest.java | 103 ++ 9 files changed, 539 insertions(+), 32 deletions(-) --
[9/9] incubator-tamaya git commit: remove sources which are not from this very project and don'd have (c) Apache.
remove sources which are not from this very project and don'd have (c) Apache. Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/0734e210 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/0734e210 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/0734e210 Branch: refs/heads/master Commit: 0734e210e8029557cbc2affbb7a67305de713aeb Parents: 364139f Author: Mark Struberg Authored: Sat Jan 3 19:06:52 2015 +0100 Committer: Mark Struberg Committed: Sat Jan 3 19:06:52 2015 +0100 -- .../core/PathBasedPropertySourceProvider.java | 89 --- .../core/ResourcePropertySourceProvider.java| 87 --- .../core/formats/ConfigurationFormat.java | 47 -- .../tamaya/core/formats/PropertiesFormat.java | 117 --- .../core/formats/PropertiesXmlFormat.java | 118 --- .../resource/AbstractFileResolvingResource.java | 224 -- .../core/internal/resource/AntPathMatcher.java | 775 --- .../internal/resource/ClassPathResource.java| 258 -- .../resource/DefaultResourceLoader.java | 105 --- .../internal/resource/FileSystemResource.java | 232 -- .../internal/resource/InputStreamResource.java | 124 --- .../PathMatchingDefaultResourceLoader.java | 142 .../PathMatchingResourcePatternResolver.java| 725 - .../core/internal/resource/ReflectionUtils.java | 201 - .../core/internal/resource/ResourceUtils.java | 288 --- .../core/internal/resource/UrlResource.java | 279 --- .../core/internal/resource/VfsResource.java | 131 .../tamaya/core/internal/resource/VfsUtils.java | 206 - .../core/resources/InputStreamSource.java | 47 -- .../apache/tamaya/core/resources/Resource.java | 185 - .../tamaya/core/resources/ResourceLoader.java | 87 --- .../apache/tamaya/core/ConfigurationTest.java | 6 - .../TestPropertyDefaultSourceProvider.java | 32 - .../core/testdata/TestPropertySource.java | 57 ++ .../testdata/TestPropertySourceProvider.java| 32 - .../org.apache.tamaya.spi.PropertySource| 19 + ...org.apache.tamaya.spi.PropertySourceProvider | 20 - 27 files changed, 76 insertions(+), 4557 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0734e210/core/src/main/java/org/apache/tamaya/core/PathBasedPropertySourceProvider.java -- diff --git a/core/src/main/java/org/apache/tamaya/core/PathBasedPropertySourceProvider.java b/core/src/main/java/org/apache/tamaya/core/PathBasedPropertySourceProvider.java deleted file mode 100644 index fc04c3b..000 --- a/core/src/main/java/org/apache/tamaya/core/PathBasedPropertySourceProvider.java +++ /dev/null @@ -1,89 +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.core; - -import org.apache.tamaya.core.formats.ConfigurationFormat; -import org.apache.tamaya.core.resources.Resource; -import org.apache.tamaya.core.resources.ResourceLoader; -import org.apache.tamaya.spi.PropertySource; -import org.apache.tamaya.spi.PropertySourceProvider; -import org.apache.tamaya.spi.ServiceContext; - -import java.util.*; -import java.util.ArrayList; -import java.util.Objects; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * Implementation of a {@link PropertySourceProvider} that reads configuration from some given resource paths - * and using the given formats. - */ -public class PathBasedPropertySourceProvider implements PropertySourceProvider { -/** The lohgger. */ -private static final Logger LOG = Logger.getLogger(PathBasedPropertySourceProvider.class.getName()); - -private String baseName; -/** The config formats tried. */ -private List configFormats = new ArrayList<>(); -/** The paths tpo be evaluated. */ -private List paths = new ArrayList<>(); - -/** - * Creates a new instance. - *
[7/9] incubator-tamaya git commit: remove sources which are not from this very project and don'd have (c) Apache.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0734e210/core/src/main/java/org/apache/tamaya/core/resources/InputStreamSource.java -- diff --git a/core/src/main/java/org/apache/tamaya/core/resources/InputStreamSource.java b/core/src/main/java/org/apache/tamaya/core/resources/InputStreamSource.java deleted file mode 100644 index 3d95269..000 --- a/core/src/main/java/org/apache/tamaya/core/resources/InputStreamSource.java +++ /dev/null @@ -1,47 +0,0 @@ -/* -* Copyright 2002-2012 the original author or authors. -* -* Licensed 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.core.resources; - -import java.io.IOException; -import java.io.InputStream; - -/** - * Simple interface for objects that are sources for an {@link InputStream}. - * - * This is the base interface for the more extensive {@link Resource} interface. - * - * @author Juergen Hoeller - * @see java.io.InputStream - * @see Resource - * @since 20.01.2004 - */ -@FunctionalInterface -public interface InputStreamSource { - -/** - * Return an {@link InputStream}. - * It is expected that each call creates a fresh stream. - * This requirement is particularly important when you consider an API such - * as JavaMail, which needs to be able to read the stream multiple times when - * creating mail attachments. For such a use case, it is required - * that each {@code getInputStreamSupplier()} call returns a fresh stream. - * - * @return the input stream for the underlying resource (must not be {@code null}) - * @throws IOException if the stream could not be opened - */ -InputStream getInputStream() throws IOException; - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0734e210/core/src/main/java/org/apache/tamaya/core/resources/Resource.java -- diff --git a/core/src/main/java/org/apache/tamaya/core/resources/Resource.java b/core/src/main/java/org/apache/tamaya/core/resources/Resource.java deleted file mode 100644 index 14966e9..000 --- a/core/src/main/java/org/apache/tamaya/core/resources/Resource.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright 2002-2012 the original author or authors. - * - * Licensed 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.core.resources; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.util.Objects; - -/** - * Interface for a resource descriptor that abstracts from the actual - * type current underlying resource, such as a file or class path resource. - * - * An InputStream can be opened for every resource if it exists in - * physical form, but a URL or File handle can just be returned for - * certain resources. The actual behavior is implementation-specific. - * - * @author Juergen Hoeller - * @see #getInputStream() - * @see #toURL() - * @see #getURI() - * @see #toFile() - * @since 28.12.2003 - */ -public interface Resource extends InputStreamSource { - -/** - * Return whether this resource actually exists in physical form. - * This method performs a definitive existence check, whereas the - * existence current a {@code Resource} handle only guarantees a - * valid descriptor handle. - */ -default boolean exists() { -// Try file existence: can we find the file in the file system? -try { -return toFile().exists(); -} catch (IOException ex) { -// Fall back to stream existence: can we open the stream? -try { -InputStream is = getInputStream(); -is.close(); -return true; -} catch (Throwable isEx) { -return fa
[8/9] incubator-tamaya git commit: remove sources which are not from this very project and don'd have (c) Apache.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0734e210/core/src/main/java/org/apache/tamaya/core/internal/resource/InputStreamResource.java -- diff --git a/core/src/main/java/org/apache/tamaya/core/internal/resource/InputStreamResource.java b/core/src/main/java/org/apache/tamaya/core/internal/resource/InputStreamResource.java deleted file mode 100644 index 11dc8ee..000 --- a/core/src/main/java/org/apache/tamaya/core/internal/resource/InputStreamResource.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2002-2012 the original author or authors. - * - * Licensed 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.core.internal.resource; - -import org.apache.tamaya.core.resources.Resource; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Objects; - -/** - * {@link Resource} implementation for a given InputStream. Should only - * be used if no specific Resource implementation is applicable. - * In particular, prefer {@code ByteArrayResource} or any current the - * file-based Resource implementations where possible. - * - * In contrast to other Resource implementations, this is a descriptor - * for an already opened resource - therefore returning "true" from - * {@code isOpen()}. Do not use it if you need to keep the resource - * descriptor somewhere, or if you need to read a stream multiple times. - * - * @author Juergen Hoeller - * @since 28.12.2003 - */ -public class InputStreamResource implements Resource { - -private final InputStream inputStream; - -private final String description; - -private boolean read = false; - - -/** - * Create a new InputStreamResource. - * - * @param inputStream the InputStream to use - */ -public InputStreamResource(InputStream inputStream) { -this(inputStream, "resource loaded through InputStream"); -} - -/** - * Create a new InputStreamResource. - * - * @param inputStream the InputStream to use - * @param description where the InputStream comes from - */ -public InputStreamResource(InputStream inputStream, String description) { -this.inputStream = Objects.requireNonNull(inputStream); -this.description = (description != null ? description : ""); -} - - -/** - * This implementation always returns {@code true}. - */ -@Override -public boolean exists() { -return true; -} - -/** - * This implementation always returns {@code true}. - */ -@Override -public boolean isOpen() { -return true; -} - -/** - * This implementation throws IllegalStateException if attempting to - * read the underlying stream multiple times. - */ -@Override -public InputStream getInputStream() throws IOException { -if (this.read) { -throw new IllegalStateException("InputStream has already been read - " + -"do not use InputStreamResource if a stream needs to be read multiple times"); -} -this.read = true; -return this.inputStream; -} - -/** - * This implementation returns the passed-in description, if any. - */ -public String toString() { -return this.description != null ? this.description : super.toString(); -} - - -/** - * This implementation compares the underlying InputStream. - */ -@Override -public boolean equals(Object obj) { -return (obj == this || -(obj instanceof InputStreamResource && ((InputStreamResource) obj).inputStream.equals(this.inputStream))); -} - -/** - * This implementation returns the hash code current the underlying InputStream. - */ -@Override -public int hashCode() { -return this.inputStream.hashCode(); -} - -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0734e210/core/src/main/java/org/apache/tamaya/core/internal/resource/PathMatchingDefaultResourceLoader.java -- diff --git a/core/src/main/java/org/apache/tamaya/core/internal/resource/PathMatchingDefaultResourceLoader.java b/core/src/main/java/org/apache/tamaya/core/internal/resource/PathMatchingDefaultResourceLoader.java deleted file mode 100644 index cf16762..000 --- a/core/src/main/java/org/apache/tamaya/core/internal/resource/PathMatch
[3/9] incubator-tamaya git commit: Merge branch 'TAMAYA-38'
Merge branch 'TAMAYA-38' contributed by rsandtner Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/a6c0800d Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/a6c0800d Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/a6c0800d Branch: refs/heads/master Commit: a6c0800df04e8997e5722d12e8dc28a43acd2d4e Parents: 5743322 78732d4 Author: Mark Struberg Authored: Sat Jan 3 17:53:22 2015 +0100 Committer: Mark Struberg Committed: Sat Jan 3 17:53:22 2015 +0100 -- .../org/apache/tamaya/spi/PropertySource.java | 7 ++ core/pom.xml| 33 +- .../core/propertysource/BasePropertySource.java | 76 + .../core/propertysource/DefaultOrdinal.java | 46 .../EnvironmentPropertySource.java | 47 .../propertysource/SystemPropertySource.java| 82 ++ .../propertysource/BasePropertySourceTest.java | 107 +++ .../EnvironmentPropertySourceTest.java | 70 .../SystemPropertySourceTest.java | 103 ++ 9 files changed, 539 insertions(+), 32 deletions(-) --
[4/9] incubator-tamaya git commit: remove logger abstraction
remove logger abstraction this should not be part of our project but part of the container integration if any. Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/4af87fcc Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/4af87fcc Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/4af87fcc Branch: refs/heads/master Commit: 4af87fcce3ef77679e87d3cd024a937516922b69 Parents: a6c0800 Author: Mark Struberg Authored: Sat Jan 3 18:11:05 2015 +0100 Committer: Mark Struberg Committed: Sat Jan 3 18:11:05 2015 +0100 -- .../logging/AbstractDelegatingLogger.java | 415 --- .../core/internal/logging/Log4j2Logger.java | 97 - .../core/internal/logging/Log4jLogger.java | 200 - .../core/internal/logging/Slf4jLogger.java | 181 4 files changed, 893 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/4af87fcc/core/src/main/java/org/apache/tamaya/core/internal/logging/AbstractDelegatingLogger.java -- diff --git a/core/src/main/java/org/apache/tamaya/core/internal/logging/AbstractDelegatingLogger.java b/core/src/main/java/org/apache/tamaya/core/internal/logging/AbstractDelegatingLogger.java deleted file mode 100644 index 30c2d2e..000 --- a/core/src/main/java/org/apache/tamaya/core/internal/logging/AbstractDelegatingLogger.java +++ /dev/null @@ -1,415 +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.core.internal.logging; - -import java.text.MessageFormat; -import java.util.Locale; -import java.util.MissingResourceException; -import java.util.ResourceBundle; -import java.util.logging.Filter; -import java.util.logging.Handler; -import java.util.logging.Level; -import java.util.logging.LogRecord; -import java.util.logging.Logger; - -/** - * java.util.logging.Logger implementation delegating to another framework. - * All methods can be used except: - * setLevel - * addHandler / getHandlers - * setParent / getParent - * setUseParentHandlers / getUseParentHandlers - * - * @author gnodet - */ -public abstract class AbstractDelegatingLogger extends Logger { - -protected AbstractDelegatingLogger(final String name, final String resourceBundleName) { -super(name, resourceBundleName); -} - -public void log(final LogRecord record) { -if (isLoggable(record.getLevel())) { -doLog(record); -} -} - -public void log(final Level level, final String msg) { -if (isLoggable(level)) { -final LogRecord lr = new LogRecord(level, msg); -doLog(lr); -} -} - -public void log(final Level level, final String msg, final Object param1) { -if (isLoggable(level)) { -final LogRecord lr = new LogRecord(level, msg); -final Object[] params = {param1}; -lr.setParameters(params); -doLog(lr); -} -} - -public void log(final Level level, final String msg, final Object[] params) { -if (isLoggable(level)) { -final LogRecord lr = new LogRecord(level, msg); -lr.setParameters(params); -doLog(lr); -} -} - -public void log(final Level level, final String msg, final Throwable thrown) { -if (isLoggable(level)) { -final LogRecord lr = new LogRecord(level, msg); -lr.setThrown(thrown); -doLog(lr); -} -} - -public void logp(final Level level, final String sourceClass, final String sourceMethod, final String msg) { -if (isLoggable(level)) { -final LogRecord lr = new LogRecord(level, msg); -lr.setSourceClassName(sourceClass); -lr.setSourceMethodName(sourceMethod); -doLog(lr); -} -} - -public void logp(final Level level, final String sourceClass, final String sourceMethod, final Stri
[6/9] incubator-tamaya git commit: fix TestConfiguration - did not even compile ...
fix TestConfiguration - did not even compile ... Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/364139f5 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/364139f5 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/364139f5 Branch: refs/heads/master Commit: 364139f5bc8abe05a87e0899e79a32926e77b153 Parents: 3e1a7a5 Author: Mark Struberg Authored: Sat Jan 3 18:26:57 2015 +0100 Committer: Mark Struberg Committed: Sat Jan 3 18:26:57 2015 +0100 -- .../org/apache/tamaya/TestConfiguration.java| 49 +--- 1 file changed, 21 insertions(+), 28 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/364139f5/api/src/test/java/org/apache/tamaya/TestConfiguration.java -- diff --git a/api/src/test/java/org/apache/tamaya/TestConfiguration.java b/api/src/test/java/org/apache/tamaya/TestConfiguration.java index 122d671..cdcb0e9 100644 --- a/api/src/test/java/org/apache/tamaya/TestConfiguration.java +++ b/api/src/test/java/org/apache/tamaya/TestConfiguration.java @@ -18,6 +18,8 @@ */ package org.apache.tamaya; +import java.util.HashMap; +import java.util.Map; import java.util.Optional; /** @@ -25,36 +27,23 @@ import java.util.Optional; */ public class TestConfiguration implements Configuration{ +private static final Map VALUES; +static { +VALUES = new HashMap(); +VALUES.put("long", String.valueOf(Long.MAX_VALUE)); +VALUES.put("int", String.valueOf(Integer.MAX_VALUE)); +VALUES.put("double", String.valueOf(Double.MAX_VALUE)); +VALUES.put("float", String.valueOf(Float.MAX_VALUE)); +VALUES.put("short", String.valueOf(Short.MAX_VALUE)); +VALUES.put("byte", String.valueOf(Byte.MAX_VALUE)); +VALUES.put("booleanTrue", "true"); +VALUES.put("booleanFalse", "false"); +VALUES.put("String", "aStringValue"); +} + @Override public Optional get(String key) { -if("long".equals(key)){ -return Optional.ofNullable(String.valueOf(Long.MAX_VALUE)); -} -else if("int".equals(key)){ -return Optional.ofNullable(String.valueOf(Integer.MAX_VALUE)); -} -else if("double".equals(key)){ -return Optional.ofNullable(String.valueOf(Double.MAX_VALUE)); -} -else if("float".equals(key)){ -return Optional.ofNullable(String.valueOf(Float.MAX_VALUE)); -} -else if("short".equals(key)){ -return Optional.ofNullable(String.valueOf(Short.MAX_VALUE)); -} -else if("byte".equals(key)){ -return Optional.ofNullable(String.valueOf(Byte.MAX_VALUE)); -} -else if("booleanTrue".equals(key)){ -return Optional.ofNullable("true"); -} -else if("booleanFalse".equals(key)){ -return Optional.ofNullable("false"); -} -else if("String".equals(key)){ -return Optional.ofNullable("aStringValue"); -} -return Optional.ofNullable("noValue"); +return Optional.ofNullable(VALUES.get(key)); } @Override @@ -91,4 +80,8 @@ public class TestConfiguration implements Configuration{ throw new ConfigException("No such property: " + key); } +@Override +public Map getProperties() { +return null; +} }
[1/9] incubator-tamaya git commit: TAMAYA-38 implemented standard System- and EnvironmentPropertySource
Repository: incubator-tamaya Updated Branches: refs/heads/master 574332226 -> 0734e210e TAMAYA-38 implemented standard System- and EnvironmentPropertySource Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/51960ef0 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/51960ef0 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/51960ef0 Branch: refs/heads/master Commit: 51960ef0f1fe507cb894228b1097d35e4d7d077a Parents: 0791e87 Author: Reinhard Sandtner Authored: Fri Jan 2 19:40:19 2015 +0100 Committer: Reinhard Sandtner Committed: Sat Jan 3 13:18:49 2015 +0100 -- .../org/apache/tamaya/spi/PropertySource.java | 7 ++ core/pom.xml| 5 + .../core/propertysource/BasePropertySource.java | 76 + .../core/propertysource/DefaultOrdinal.java | 46 .../EnvironmentPropertySource.java | 47 .../propertysource/SystemPropertySource.java| 82 ++ .../propertysource/BasePropertySourceTest.java | 107 +++ .../EnvironmentPropertySourceTest.java | 70 .../SystemPropertySourceTest.java | 103 ++ 9 files changed, 543 insertions(+) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/51960ef0/api/src/main/java/org/apache/tamaya/spi/PropertySource.java -- diff --git a/api/src/main/java/org/apache/tamaya/spi/PropertySource.java b/api/src/main/java/org/apache/tamaya/spi/PropertySource.java index 711b84b..eb11358 100644 --- a/api/src/main/java/org/apache/tamaya/spi/PropertySource.java +++ b/api/src/main/java/org/apache/tamaya/spi/PropertySource.java @@ -48,6 +48,12 @@ import java.util.Optional; public interface PropertySource { /** + * property name to override default tamaya ordinals + */ +static final String TAMAYA_ORDINAL = "tamaya.ordinal"; + + +/** * Lookup order: * TODO rethink whole default PropertySources and ordering: * TODO introduce default values or constants for ordinals @@ -88,6 +94,7 @@ public interface PropertySource { /** * Access a property. * + * //X TODO discuss if the key can be null * @param key the property's key, not null. * @return the property's keys. */ http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/51960ef0/core/pom.xml -- diff --git a/core/pom.xml b/core/pom.xml index 26ccce0..917f2e2 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -36,6 +36,11 @@ under the License. tamaya-api ${project.version} + + +junit +junit + http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/51960ef0/core/src/main/java/org/apache/tamaya/core/propertysource/BasePropertySource.java -- diff --git a/core/src/main/java/org/apache/tamaya/core/propertysource/BasePropertySource.java b/core/src/main/java/org/apache/tamaya/core/propertysource/BasePropertySource.java new file mode 100644 index 000..2a0107c --- /dev/null +++ b/core/src/main/java/org/apache/tamaya/core/propertysource/BasePropertySource.java @@ -0,0 +1,76 @@ +/* + * 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.core.propertysource; + +import org.apache.tamaya.spi.PropertySource; + +import java.util.Objects; +import java.util.Optional; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Base class for {@link PropertySource}s + */ +public abstract class BasePropertySource implements PropertySource { + +private static final Logger LOG = Logger.getLogger(BasePropertySource.class.getName()); + + +private int ordinal = DefaultOrdinal.PROPERTY_SOURCE; + + +@Override +public int getOrdinal() { +return ordi
[1/2] incubator-tamaya git commit: add a way to register and lookup Converters
Repository: incubator-tamaya Updated Branches: refs/heads/master 4c95c9b9c -> 2d508f3db add a way to register and lookup Converters Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/251432b4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/251432b4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/251432b4 Branch: refs/heads/master Commit: 251432b469d6b6d44749c161ba050e1f4e20fc59 Parents: 4c95c9b Author: Mark Struberg Authored: Tue Dec 30 11:47:13 2014 +0100 Committer: Mark Struberg Committed: Tue Dec 30 11:47:13 2014 +0100 -- .../apache/tamaya/spi/ConfigurationContext.java | 42 1 file changed, 42 insertions(+) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/251432b4/api/src/main/java/org/apache/tamaya/spi/ConfigurationContext.java -- diff --git a/api/src/main/java/org/apache/tamaya/spi/ConfigurationContext.java b/api/src/main/java/org/apache/tamaya/spi/ConfigurationContext.java index 932c21b..7cfadc7 100644 --- a/api/src/main/java/org/apache/tamaya/spi/ConfigurationContext.java +++ b/api/src/main/java/org/apache/tamaya/spi/ConfigurationContext.java @@ -20,6 +20,7 @@ package org.apache.tamaya.spi; import java.util.List; +import java.util.Map; /** * Central SPI for programmatically dealing with the setup of the configuration system. @@ -48,4 +49,45 @@ public interface ConfigurationContext { */ List getPropertySources(); + +/** + * This method can be used for programmatically adding {@link PropertyConverter}s. + * It is not needed for normal 'usage' by end users, but only for Extension Developers! + * + * @param typeToConvert the type which the converter is for + * @param propertyConverter the PropertyConverters to add for this type + */ + void addPropertyConverter(Class typeToConvert, PropertyConverter propertyConverter); + +/** + * + * This method returns the Map of registered PropertyConverters + * per type. + * The List for each type is ordered via their {@link javax.annotation.Priority}. + * + * + * + * PropertyConverters with a lower Priority come first. The PropertyConverter with the + * highest Priority comes last. + * If two PropertyConverter have the same ordinal number they will get sorted + * using their class name just to ensure the user at least gets the same ordering + * after a JVM restart. + * + * + * + * The scenario could be like: + * + * { + * Date.class -> {StandardDateConverter, TimezoneDateConverter, MyCustomDateConverter } + * Boolean.class -> {StandardBooleanConverter, FrenchBooleanConverter} + * } + * + * + * + * TODO: we need to define in which order the converters will be used later! + * + * @return map with sorted list of registered PropertySources per type. + */ +Map, List>> getPropertyConverters(); + }
[2/2] incubator-tamaya git commit: add TODO for PropertyFilters
add TODO for PropertyFilters Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/2d508f3d Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/2d508f3d Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/2d508f3d Branch: refs/heads/master Commit: 2d508f3dbca93bef97e7670abfde7008210f06e9 Parents: 251432b Author: Mark Struberg Authored: Tue Dec 30 11:48:55 2014 +0100 Committer: Mark Struberg Committed: Tue Dec 30 11:48:55 2014 +0100 -- api/src/main/java/org/apache/tamaya/spi/ConfigurationContext.java | 2 ++ 1 file changed, 2 insertions(+) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/2d508f3d/api/src/main/java/org/apache/tamaya/spi/ConfigurationContext.java -- diff --git a/api/src/main/java/org/apache/tamaya/spi/ConfigurationContext.java b/api/src/main/java/org/apache/tamaya/spi/ConfigurationContext.java index 7cfadc7..370683d 100644 --- a/api/src/main/java/org/apache/tamaya/spi/ConfigurationContext.java +++ b/api/src/main/java/org/apache/tamaya/spi/ConfigurationContext.java @@ -90,4 +90,6 @@ public interface ConfigurationContext { */ Map, List>> getPropertyConverters(); + +//X TODO add a way to manage and use PropertyFilters }
incubator-tamaya git commit: add getPropertySources method
Repository: incubator-tamaya Updated Branches: refs/heads/master 69dd32e44 -> 4c95c9b9c add getPropertySources method Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/4c95c9b9 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/4c95c9b9 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/4c95c9b9 Branch: refs/heads/master Commit: 4c95c9b9cadbca438b8f92f76290ef1976302d78 Parents: 69dd32e Author: Mark Struberg Authored: Tue Dec 30 11:26:43 2014 +0100 Committer: Mark Struberg Committed: Tue Dec 30 11:26:43 2014 +0100 -- .../org/apache/tamaya/spi/ConfigurationContext.java| 13 + 1 file changed, 13 insertions(+) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/4c95c9b9/api/src/main/java/org/apache/tamaya/spi/ConfigurationContext.java -- diff --git a/api/src/main/java/org/apache/tamaya/spi/ConfigurationContext.java b/api/src/main/java/org/apache/tamaya/spi/ConfigurationContext.java index 2bc9fe6..932c21b 100644 --- a/api/src/main/java/org/apache/tamaya/spi/ConfigurationContext.java +++ b/api/src/main/java/org/apache/tamaya/spi/ConfigurationContext.java @@ -19,6 +19,8 @@ package org.apache.tamaya.spi; +import java.util.List; + /** * Central SPI for programmatically dealing with the setup of the configuration system. * This includes adding and enlisting {@link org.apache.tamaya.spi.PropertySource}s, @@ -34,5 +36,16 @@ public interface ConfigurationContext { */ void addPropertySources(PropertySource... propertySourcesToAdd); +/** + * This method returns the list of registered PropertySources ordered via their ordinal. + * PropertySources with a lower ordinal come first. The PropertySource with the + * highest ordinal comes last. + * If two PropertySources have the same ordinal number they will get sorted + * using their class name just to ensure the user at least gets the same ordering + * after a JVM restart. + * + * @return sorted list of registered PropertySources + */ +List getPropertySources(); }
incubator-tamaya git commit: improve PropertyConverter and introduce ConfigurationContext
Repository: incubator-tamaya Updated Branches: refs/heads/master 49efbfe55 -> 69dd32e44 improve PropertyConverter and introduce ConfigurationContext implemented in a joint hacking session with anatole, rsandtner and plexus Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/69dd32e4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/69dd32e4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/69dd32e4 Branch: refs/heads/master Commit: 69dd32e44e71f9868df82d7013d6a999a96fa481 Parents: 49efbfe Author: Mark Struberg Authored: Tue Dec 30 00:21:02 2014 +0100 Committer: Mark Struberg Committed: Tue Dec 30 00:21:02 2014 +0100 -- .../java/org/apache/tamaya/Configuration.java | 14 ++-- .../apache/tamaya/spi/ConfigurationContext.java | 38 +++ .../org/apache/tamaya/spi/PropertyAdapter.java | 38 --- .../apache/tamaya/spi/PropertyConverter.java| 42 .../org/apache/tamaya/spi/ServiceContext.java | 62 ++--- .../org/apache/tamaya/ConfigurationTest.java| 16 ++--- .../apache/tamaya/spi/ServiceContextTest.java | 46 ++--- .../apache/tamaya/spi/TestServiceContext.java | 35 ++ pom.xml | 70 +++- 9 files changed, 151 insertions(+), 210 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/69dd32e4/api/src/main/java/org/apache/tamaya/Configuration.java -- diff --git a/api/src/main/java/org/apache/tamaya/Configuration.java b/api/src/main/java/org/apache/tamaya/Configuration.java index ef9955d..e9d47a5 100644 --- a/api/src/main/java/org/apache/tamaya/Configuration.java +++ b/api/src/main/java/org/apache/tamaya/Configuration.java @@ -18,7 +18,7 @@ */ package org.apache.tamaya; -import org.apache.tamaya.spi.PropertyAdapter; +import org.apache.tamaya.spi.PropertyConverter; import org.apache.tamaya.spi.ServiceContext; import java.util.*; @@ -55,7 +55,7 @@ public interface Configuration { /** * Get the property keys as type T. This will implicitly require a corresponding {@link - * PropertyAdapter} to be available that is capable current providing type T + * org.apache.tamaya.spi.PropertyConverter} to be available that is capable current providing type T * fromMap the given String keys. * * @param key the property's absolute, or relative path, e.g. @code @@ -72,22 +72,22 @@ public interface Configuration { * * If {@code Class} is not one current * {@code Boolean, Short, Integer, Long, Float, Double, BigInteger, - * BigDecimal, String} , an according adapter must be + * BigDecimal, String} , an according converter must be * available to perform the conversion fromMap {@link String} to * {@code Class}. * * @param key the property's absolute, or relative path, e.g. @code *a/b/c/d.myProperty}. - * @param adapter the PropertyAdapter to perform the conversion fromMap + * @param converter the PropertyConverter to perform the conversion fromMap *{@link String} to {@code Class}, not {@code null}. * @return the property's keys. * @throws ConfigException if the keys could not be converted to the required target * type, or no such property exists. */ -default Optional getAdapted(String key, PropertyAdapter adapter) { +default Optional get(String key, PropertyConverter converter) { Optional value = get(key); if (value.isPresent()) { -return Optional.ofNullable(adapter.adapt(value.get())); +return Optional.ofNullable(converter.convert(value.get())); } return Optional.empty(); } @@ -191,7 +191,7 @@ public interface Configuration { * @throws ConfigException if no such configuration is defined. */ public static Configuration current(){ -return ServiceContext.getInstance().getSingleton(Configuration.class); +return ServiceContext.getInstance().getService(Configuration.class).get(); } } http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/69dd32e4/api/src/main/java/org/apache/tamaya/spi/ConfigurationContext.java -- diff --git a/api/src/main/java/org/apache/tamaya/spi/ConfigurationContext.java b/api/src/main/java/org/apache/tamaya/spi/ConfigurationContext.java new file mode 100644 index 000..2bc9fe6 --- /dev/null +++ b/api/src/main/java/org/apache/tamaya/spi/ConfigurationContext.java @@ -0,0 +1,38 @@ +/* + * Licensed to t
[2/2] incubator-tamaya git commit: fix version number of docs pom
fix version number of docs pom Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/0cb955a3 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/0cb955a3 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/0cb955a3 Branch: refs/heads/master Commit: 0cb955a3fe2abe2b14cb2bb2117c400ea00dc999 Parents: 05cca04 Author: Mark Struberg Authored: Mon Dec 29 01:56:03 2014 +0100 Committer: Mark Struberg Committed: Mon Dec 29 01:56:03 2014 +0100 -- docs/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0cb955a3/docs/pom.xml -- diff --git a/docs/pom.xml b/docs/pom.xml index a34503d..787f1ef 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -23,7 +23,7 @@ under the License. org.apache.tamaya tamaya-all -0.1-SNAPSHOT +0.2-SNAPSHOT ..
[1/2] incubator-tamaya git commit: make the ordinal of the ServiceContext a default 1.
Repository: incubator-tamaya Updated Branches: refs/heads/master c4e24709b -> 0cb955a3f make the ordinal of the ServiceContext a default 1. The 'internal' default ServiceContext will be using 0. Thus any other impl will replace the default one. Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/05cca046 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/05cca046 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/05cca046 Branch: refs/heads/master Commit: 05cca0469b01e913a0ce5b312d812c33215acb3f Parents: c4e2470 Author: Mark Struberg Authored: Mon Dec 29 01:53:28 2014 +0100 Committer: Mark Struberg Committed: Mon Dec 29 01:53:28 2014 +0100 -- api/src/main/java/org/apache/tamaya/spi/ServiceContext.java | 4 +++- .../main/java/org/apache/tamaya/spi/ServiceContextManager.java | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/05cca046/api/src/main/java/org/apache/tamaya/spi/ServiceContext.java -- diff --git a/api/src/main/java/org/apache/tamaya/spi/ServiceContext.java b/api/src/main/java/org/apache/tamaya/spi/ServiceContext.java index 2c134c3..a883852 100644 --- a/api/src/main/java/org/apache/tamaya/spi/ServiceContext.java +++ b/api/src/main/java/org/apache/tamaya/spi/ServiceContext.java @@ -33,7 +33,9 @@ public interface ServiceContext { /** * @return ordinal of the ServiceContext. The one with the highest ordinal will be taken. */ -int ordinal(); +default int ordinal() { +return 1; +} /** * Delegate method for {@link ServiceContext#getService(Class)}. http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/05cca046/api/src/main/java/org/apache/tamaya/spi/ServiceContextManager.java -- diff --git a/api/src/main/java/org/apache/tamaya/spi/ServiceContextManager.java b/api/src/main/java/org/apache/tamaya/spi/ServiceContextManager.java index d5cbb93..0d20ad4 100644 --- a/api/src/main/java/org/apache/tamaya/spi/ServiceContextManager.java +++ b/api/src/main/java/org/apache/tamaya/spi/ServiceContextManager.java @@ -18,7 +18,8 @@ */ package org.apache.tamaya.spi; -import java.util.*; +import java.util.Objects; +import java.util.ServiceLoader; import java.util.logging.Level; import java.util.logging.Logger;
incubator-tamaya git commit: move reviewed core APIs and SPIs back in place
Repository: incubator-tamaya Updated Branches: refs/heads/master d9b2cf418 -> c4e24709b move reviewed core APIs and SPIs back in place done together with anatole and rsandtner Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/c4e24709 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/c4e24709 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/c4e24709 Branch: refs/heads/master Commit: c4e24709b13774413bf18d42b0fb41344648b00b Parents: d9b2cf4 Author: Mark Struberg Authored: Mon Dec 29 01:39:28 2014 +0100 Committer: Mark Struberg Committed: Mon Dec 29 01:39:28 2014 +0100 -- .../java/org/apache/tamaya/ConfigException.java | 44 +++ .../java/org/apache/tamaya/Configuration.java | 197 ++ .../org/apache/tamaya/spi/PropertyAdapter.java | 38 ++ .../org/apache/tamaya/spi/PropertySource.java | 117 ++ .../tamaya/spi/PropertySourceProvider.java | 43 +++ .../org/apache/tamaya/spi/ServiceContext.java | 114 ++ .../tamaya/spi/ServiceContextManager.java | 106 ++ .../java/org/apache/tamaya/ConfigException.java | 44 --- .../java/org/apache/tamaya/Configuration.java | 366 --- .../java/org/apache/tamaya/PropertyAdapter.java | 89 - .../java/org/apache/tamaya/PropertySource.java | 129 --- .../org/apache/tamaya/spi/ServiceContext.java | 109 -- .../tamaya/spi/ServiceContextManager.java | 100 - pom.xml | 16 +- 14 files changed, 674 insertions(+), 838 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c4e24709/api/src/main/java/org/apache/tamaya/ConfigException.java -- diff --git a/api/src/main/java/org/apache/tamaya/ConfigException.java b/api/src/main/java/org/apache/tamaya/ConfigException.java new file mode 100644 index 000..bac2ef4 --- /dev/null +++ b/api/src/main/java/org/apache/tamaya/ConfigException.java @@ -0,0 +1,44 @@ +/* + * 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; + +/** + * Exception class (runtime exception) for configuration issues. + */ +public class ConfigException extends RuntimeException{ + +private static final long serialVersionUID = -5886094818057522680L; + +/** + * Creates a new configuration exception. + * @param message the exception message, not null. + */ +public ConfigException(String message){ +super(message); +} + +/** + * Creates a new configuration exception. + * @param message the exception message, not null. + * @param t the throwable. + */ +public ConfigException(String message, Throwable t){ +super(message, t); +} +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c4e24709/api/src/main/java/org/apache/tamaya/Configuration.java -- diff --git a/api/src/main/java/org/apache/tamaya/Configuration.java b/api/src/main/java/org/apache/tamaya/Configuration.java new file mode 100644 index 000..ef9955d --- /dev/null +++ b/api/src/main/java/org/apache/tamaya/Configuration.java @@ -0,0 +1,197 @@ +/* + * 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
[18/34] incubator-tamaya git commit: first step: move all sources to a 'dormant' directory
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9964c64/dormant/api/src/main/java/org/apache/tamaya/PropertyAdapter.java -- diff --git a/dormant/api/src/main/java/org/apache/tamaya/PropertyAdapter.java b/dormant/api/src/main/java/org/apache/tamaya/PropertyAdapter.java new file mode 100644 index 000..5cecd09 --- /dev/null +++ b/dormant/api/src/main/java/org/apache/tamaya/PropertyAdapter.java @@ -0,0 +1,89 @@ +/* + * 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; + + +import org.apache.tamaya.annotation.WithPropertyAdapter; +import org.apache.tamaya.spi.PropertyAdapterSpi; +import org.apache.tamaya.spi.ServiceContext; + +/** + * Interface for an property that converts a configured String into something else. + * This is used for implementing type conversion from a property (String) to a certain target + * type. Hereby the target type can be multivalued (eg eollections), complex or even contain + * full subconfigurations, if needed. + */ +@FunctionalInterface +public interface PropertyAdapter{ + +/** + * Adapt the given configuration keys to the required target type. + * @param value the configuration keys + * @return adapted keys + */ +T adapt(String value); + + +/** + * Registers a new PropertyAdapter for the given target type, hereby replacing any existing adapter for + * this type. + * @param targetType The target class, not null. + * @param adapter The adapter, not null. + * @param The target type + * @return any adapter replaced with the new adapter, or null. + */ +public static PropertyAdapter register(Class targetType, PropertyAdapter adapter){ +return ServiceContext.getInstance().getSingleton(PropertyAdapterSpi.class).register(targetType, adapter); +} + +/** + * Get an adapter converting to the given target type. + * @param targetType the target type class + * @return true, if the given target type is supported. + */ +public static boolean isTargetTypeSupported(Class targetType){ +return ServiceContext.getInstance().getSingleton(PropertyAdapterSpi.class).isTargetTypeSupported(targetType); +} + +/** + * Get an adapter converting to the given target type. + * @param targetType the target type class + * @param the target type + * @return the corresponding adapter, never null. + * @throws org.apache.tamaya.ConfigException if the target type is not supported. + */ +public static PropertyAdapter getInstance(Class targetType){ +return ServiceContext.getInstance().getSingleton(PropertyAdapterSpi.class).getPropertyAdapter(targetType, null); +} + +/** + * Get an adapter converting to the given target type. + * @param targetType the target type class + * @param annotation the {@link org.apache.tamaya.annotation.WithPropertyAdapter} annotation, or null. If the annotation is not null and + * defines an overriding adapter, this instance is created and returned. + * @param the target type + * @return the corresponding adapter, never null. + * @throws org.apache.tamaya.ConfigException if the target type is not supported, or the overriding adapter cannot be + * instantiated. + */ +public static PropertyAdapter getInstance(Class targetType, WithPropertyAdapter annotation){ +return ServiceContext.getInstance().getSingleton(PropertyAdapterSpi.class).getPropertyAdapter(targetType, annotation); +} + +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9964c64/dormant/api/src/main/java/org/apache/tamaya/PropertySource.java -- diff --git a/dormant/api/src/main/java/org/apache/tamaya/PropertySource.java b/dormant/api/src/main/java/org/apache/tamaya/PropertySource.java new file mode 100644 index 000..f4b01ae --- /dev/null +++ b/dormant/api/src/main/java/org/apache/tamaya/PropertySource.java @@ -0,0 +1,129 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the N
[07/34] incubator-tamaya git commit: first step: move all sources to a 'dormant' directory
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9964c64/dormant/modules/integration/managed/pom.xml -- diff --git a/dormant/modules/integration/managed/pom.xml b/dormant/modules/integration/managed/pom.xml new file mode 100644 index 000..3b4f5bc --- /dev/null +++ b/dormant/modules/integration/managed/pom.xml @@ -0,0 +1,71 @@ + +http://maven.apache.org/POM/4.0.0"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd";> +4.0.0 + + +org.apache.tamaya.integration +tamaya-integration-all +0.1-SNAPSHOT +.. + +tamaya-integration-managed +Apache Tamaya Modules Integration - Java Management Extensions +jar + + + + + + + +org.jacoco +jacoco-maven-plugin + + +prepare-agent + +prepare-agent + + + + + + + + + +junit +junit +test + + +${project.groupId} +tamaya-api +${project.version} + + +${project.groupId} +tamaya-core +${project.version} + + + + http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9964c64/dormant/modules/integration/managed/src/main/java/org/apache/tamaya/management/ManagedConfig.java -- diff --git a/dormant/modules/integration/managed/src/main/java/org/apache/tamaya/management/ManagedConfig.java b/dormant/modules/integration/managed/src/main/java/org/apache/tamaya/management/ManagedConfig.java new file mode 100644 index 000..b991690 --- /dev/null +++ b/dormant/modules/integration/managed/src/main/java/org/apache/tamaya/management/ManagedConfig.java @@ -0,0 +1,95 @@ +/* + * 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.se; + +import org.apache.tamaya.ConfigException; +import org.apache.tamaya.AggregationPolicy; + +import java.util.Map; +import java.util.Set; + +/** + * Created by Anatole on 24.11.2014. + */ +public class ManagedConfig implements ManagedConfigMBean{ +@Override +public Set getConfigurationNames() { +return null; +} + +@Override +public String getConfigurationInfo(String configName) { +return null; +} + +@Override +public boolean isConfigurationAvailable(String configName, String envType, String context) { +return false; +} + +@Override +public boolean isConfigurationLoaded(String configName, String envType, String context) { +return false; +} + +@Override +public Map getConfiguration(String configName, String envType, String context) throws ConfigException { +return null; +} + +@Override +public Map getRecursiveConfigValues(String area, String configName, String envType, String context) throws ConfigException { +return null; +} + +@Override +public Map getConfigValues(String area, String configName, String envType, String context) throws ConfigException { +return null; +} + +@Override +public Map updateConfiguration(String configName, String envType, String context, Map values, AggregationPolicy aggregationPolicy) throws ConfigException { +return null; +} + +@Override +public String getConfigurationInfo(String configName, String envType, String context) { +return null; +} + +@Override +public Set getAreas(String configName, String envType, String context) { +return null; +} + +@Override +public Set getTransitiveAreas(String configName, String envType, String context) { +return null; +} + +@Override +public boolean isAreaExisting(String area, String configName, String envType, String context) { +return false; +
[26/34] incubator-tamaya git commit: first step: move all sources to a 'dormant' directory
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9964c64/core/src/main/java/org/apache/tamaya/core/internal/config/DefaultPropertyAdapterSpi.java -- diff --git a/core/src/main/java/org/apache/tamaya/core/internal/config/DefaultPropertyAdapterSpi.java b/core/src/main/java/org/apache/tamaya/core/internal/config/DefaultPropertyAdapterSpi.java deleted file mode 100644 index f1b14e0..000 --- a/core/src/main/java/org/apache/tamaya/core/internal/config/DefaultPropertyAdapterSpi.java +++ /dev/null @@ -1,168 +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.core.internal.config; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.time.ZoneId; -import java.util.Currency; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.apache.tamaya.ConfigException; -import org.apache.tamaya.PropertyAdapter; -import org.apache.tamaya.annotation.WithPropertyAdapter; -import org.apache.tamaya.spi.PropertyAdapterSpi; - -/** - * Default codecs singleton, which provides default codesc for all kind of classes out of the box, which will be - * instantiatable from configuration, if one of the following is given: - * - * static factory methods using a String as simgle argument, called {@code of, valueOf, getInstance, instance, parse} - * have constructors taking a single String - * - */ -@SuppressWarnings({"rawtypes", "unchecked"}) -public class DefaultPropertyAdapterSpi implements PropertyAdapterSpi { - - - private Map adapters = new ConcurrentHashMap<>(); - -public DefaultPropertyAdapterSpi(){ -// Add default adapters -register(char.class, (s) -> s.charAt(0)); -register(byte.class, Byte::parseByte); -register(short.class, Short::parseShort); -register(int.class, Integer::parseInt); -register(long.class, Long::parseLong); -register(boolean.class, Boolean::parseBoolean); -register(float.class, Float::parseFloat); -register(double.class, Double::parseDouble); - -register(Character.class, (s) -> s.charAt(0)); -register(Byte.class, Byte::valueOf); -register(Short.class, Short::valueOf); -register(Integer.class, Integer::valueOf); -register(Long.class, Long::valueOf); -register(Boolean.class, Boolean::valueOf); -register(Float.class, Float::valueOf); -register(Double.class, Double::valueOf); -register(BigDecimal.class, BigDecimal::new); -register(BigInteger.class, BigInteger::new); - -register(Currency.class, Currency::getInstance); - -register(LocalDate.class, LocalDate::parse); -register(LocalTime.class, LocalTime::parse); -register(LocalDateTime.class, LocalDateTime::parse); -register(ZoneId.class, ZoneId::of); -} - - @Override -public PropertyAdapter register(Class targetType, PropertyAdapter adapter){ -return adapters.put(targetType, adapter); -} - -@Override -public PropertyAdapter getPropertyAdapter(Class targetType, WithPropertyAdapter adapterAnnot){ -PropertyAdapter codec = null; -Class configuredCodec = null; -if(adapterAnnot != null){ -configuredCodec = adapterAnnot.value(); -if(!configuredCodec.equals(PropertyAdapter.class)){ -try{ -codec = configuredCodec.newInstance(); -} -catch(Exception e){ -throw new ConfigException("Invalid codec configured.", e); -} -} -} -if(codec == null){ -codec = adapters.get(targetType); -} -if(codec == null){ -codec = getDefaultPropertyAdapter(targetType); -} -if(codec == null){ -throw new ConfigException("No Codec found for " + targetType.getName()); -} -return codec; -} - -private Prop
[10/34] incubator-tamaya git commit: first step: move all sources to a 'dormant' directory
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9964c64/dormant/core/src/main/java/org/apache/tamaya/core/properties/ContextualPropertySource.java -- diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/properties/ContextualPropertySource.java b/dormant/core/src/main/java/org/apache/tamaya/core/properties/ContextualPropertySource.java new file mode 100644 index 000..6290706 --- /dev/null +++ b/dormant/core/src/main/java/org/apache/tamaya/core/properties/ContextualPropertySource.java @@ -0,0 +1,142 @@ +/* + * 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.core.properties; + +import org.apache.tamaya.*; + +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.function.Supplier; + +/** + * Created by Anatole on 12.04.2014. + */ +class ContextualPropertySource implements PropertySource { + +private volatile Map cachedMaps = new ConcurrentHashMap<>(); + +private Supplier mapSupplier; +private Supplier isolationKeySupplier; +private String name; + + +/** + * Creates a new contextual PropertyMap. Contextual maps delegate to different instances current PropertyMap depending + * on the keys returned fromMap the isolationP + * + * @param mapSupplier + * @param isolationKeySupplier + */ +public ContextualPropertySource(String name, Supplier mapSupplier, Supplier isolationKeySupplier){ +this.name = Optional.ofNullable(name).orElse(""); +Objects.requireNonNull(mapSupplier); +Objects.requireNonNull(isolationKeySupplier); +this.mapSupplier = mapSupplier; +this.isolationKeySupplier = isolationKeySupplier; +} + +/** + * This method provides the contextual Map for the current environment. Hereby, ba default, for each different + * key returned by the #isolationKeySupplier a separate PropertyMap instance is acquired fromMap the #mapSupplier. + * If the map supplier returns an instance it is cached in the local #cachedMaps. + * + * @return the current contextual PropertyMap. + */ +protected PropertySource getContextualMap(){ +String environmentKey = this.isolationKeySupplier.get(); +if(environmentKey == null){ +return PropertySource.EMPTY_PROPERTYSOURCE; +} +PropertySource map = this.cachedMaps.get(environmentKey); +if(map == null){ +synchronized(cachedMaps){ +map = this.cachedMaps.get(environmentKey); +if(map == null){ +map = this.mapSupplier.get(); +if(map == null){ +return PropertySource.EMPTY_PROPERTYSOURCE; +} +this.cachedMaps.put(environmentKey, map); +} +} +} +return map; +} + +@Override +public Map getProperties(){ +return getContextualMap().getProperties(); +} + +@Override +public String getName(){ +return this.name; +} + +@Override +public Optional get(String key){ +return getContextualMap().get(key); +} + +/** + * Access a cached PropertyMap. + * + * @param key the target environment key as returned by the environment key supplier, not null. + * @return the corresponding PropertyMap, or null. + */ +public PropertySource getCachedMap(String key){ +return this.cachedMaps.get(key); +} + +/** + * Access the set current currently loaded/cached maps. + * + * @return the set current cached map keys, never null. + */ +public Set getCachedMapKeys(){ +return this.cachedMaps.keySet(); +} + +/** + * Access the supplier for environment key, determining map isolation. + * + * @return the environment key supplier instance, not null. + */ +public Supplier getIsolationKeySupplier(){ +return this.isolationKeySupplier; +} + +/** + * Access the supplier for new PropertyMap instances. + * + * @return the PropertyMap supplier instance, not null. + */ +public Su
[22/34] incubator-tamaya git commit: first step: move all sources to a 'dormant' directory
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9964c64/core/src/main/java/org/apache/tamaya/core/internal/resources/io/StringUtils.java -- diff --git a/core/src/main/java/org/apache/tamaya/core/internal/resources/io/StringUtils.java b/core/src/main/java/org/apache/tamaya/core/internal/resources/io/StringUtils.java deleted file mode 100644 index 1dfb189..000 --- a/core/src/main/java/org/apache/tamaya/core/internal/resources/io/StringUtils.java +++ /dev/null @@ -1,1165 +0,0 @@ -/* - * Copyright 2002-2014 the original author or authors. - * - * Licensed 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.core.internal.resources.io; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.StringTokenizer; - -/** -* Miscellaneous {@link String} utility methods. -* -* Mainly for internal use within the framework; consider -* http://jakarta.apache.org/commons/lang/";>Jakarta's Commons Lang -* for a more comprehensive suite current String utilities. -* -* This class delivers some simple functionality that should really -* be provided by the core Java {@code String} and {@link StringBuilder} -* classes, such as the ability to {@code replace} all occurrences current a given -* substring in a target string. It also provides easy-to-use methods to convert -* between delimited strings, such as CSV strings, and collections and arrays. -* -* @author Rod Johnson -* @author Juergen Hoeller -* @author Keith Donald -* @author Rob Harrop -* @author Rick Evans -* @author Arjen Poutsma -* @since 16 April 2001 -*/ -class StringUtils { - - private static final String FOLDER_SEPARATOR = "/"; - - private static final String WINDOWS_FOLDER_SEPARATOR = "\\"; - - private static final String TOP_PATH = ".."; - - private static final String CURRENT_PATH = "."; - -// private static final char EXTENSION_SEPARATOR = '.'; -// - -private StringUtils(){} - -// //- -// // General convenience methods for working with Strings -// //- -// -// /** -// * Check whether the given String is empty. -// * This method accepts any Object as an argument, comparing it to -// * {@code null} and the empty String. As a consequence, this method -// * will never return {@code true} for a non-null non-String object. -// * The Object signature is useful for general attribute handling code -// * that commonly deals with Strings but generally has to iterate over -// * Objects since attributes may e.g. be primitive keys objects as well. -// * @param str the candidate String -// * @since 3.2.1 -// */ -// public static boolean isEmpty(Object str) { -// return (str == null || "".equals(str)); -// } - - /** -* Check that the given CharSequence is neither {@code null} nor current length 0. -* Note: Will return {@code true} for a CharSequence that purely consists current whitespace. -* -* StringUtils.hasLength(null) = false -* StringUtils.hasLength("") = false -* StringUtils.hasLength(" ") = true -* StringUtils.hasLength("Hello") = true -* -* @param str the CharSequence to check (may be {@code null}) -* @return {@code true} if the CharSequence is not null and has length -*/ - public static boolean hasLength(CharSequence str) { - return (str != null && str.length() > 0); - } - -// /** -// * Check that the given String is neither {@code null} nor current length 0. -// * Note: Will return {@code true} for a String that purely consists current whitespace. -// * @param str the String to check (may be {@code null}) -// * @return {@code true} if the String is not null and has length -// * @see #hasLength(CharSequence) -// */ -// public static boolean hasLength(String str) { -// return hasLength((CharSequence) str); -// } - - /** -* Check whether the given CharSequence has actual text. -* More specifically, returns {@code true} if the string not {@code null}, -* its length is greater than 0, and it contains a
[19/34] incubator-tamaya git commit: first step: move all sources to a 'dormant' directory
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9964c64/core/src/test/java/org/apache/tamaya/simple/SimplePropertiesAndCLISample.java -- diff --git a/core/src/test/java/org/apache/tamaya/simple/SimplePropertiesAndCLISample.java b/core/src/test/java/org/apache/tamaya/simple/SimplePropertiesAndCLISample.java deleted file mode 100644 index e0351b2..000 --- a/core/src/test/java/org/apache/tamaya/simple/SimplePropertiesAndCLISample.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.simple; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.tamaya.Configuration; -import org.apache.tamaya.core.ConfigurationFunctions; -import org.apache.tamaya.core.properties.PropertySourceBuilder; -import org.junit.Test; - -/** - * Created by Anatole on 24.02.14. - */ -public class SimplePropertiesAndCLISample { - -@Test -public void testSystemPropertyResolution() { -System.out.println(Configuration.evaluateValue("${sys:java.version}")); -} - -@Test -public void testProgrammatixPropertySet() { -System.out.println(PropertySourceBuilder.of("test").addPaths("test", "classpath:test.properties").build()); -} - -@Test -public void testProgrammaticConfig() { -//ConfigurationFormat format = ConfigurationFormats.getPropertiesFormat(); -Map cfgMap = new HashMap<>(); -cfgMap.put("param1", "value1"); -cfgMap.put("a", "Adrian"); // overrides Anatole -Configuration config = Configuration.from(PropertySourceBuilder.of("myTestConfig").addPaths( -"classpath:test.properties").addPaths("classpath:cfg/test.xml") -.addArgs(new String[]{"-arg1", "--fullarg", "fullValue", "-myflag"}).addMap(cfgMap) -.build()); -System.out.println(config.query(ConfigurationFunctions.getAreas())); -System.out.println("---"); -System.out.println(config.query(ConfigurationFunctions.getAreas(s -> s.startsWith("another"; -System.out.println("---"); - System.out.println(config.query(ConfigurationFunctions.getTransitiveAreas())); -System.out.println("---"); - System.out.println(config.query(ConfigurationFunctions.getTransitiveAreas(s -> s.startsWith("another"; -System.out.println("---"); -System.out.println(config); -System.out.print("--- b="); -System.out.println(config.get("b")); -//System.out.println("--- only a,b,c)"); -//System.out.println(PropertySourceBuilder.of(config).filter((f) -> f.equals("a") || f.equals("b") || f.equals("c")).build()); -} - -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9964c64/core/src/test/java/org/apache/tamaya/ucs/UC1ReadProperties.java -- diff --git a/core/src/test/java/org/apache/tamaya/ucs/UC1ReadProperties.java b/core/src/test/java/org/apache/tamaya/ucs/UC1ReadProperties.java deleted file mode 100644 index e7f2049..000 --- a/core/src/test/java/org/apache/tamaya/ucs/UC1ReadProperties.java +++ /dev/null @@ -1,220 +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. - */ -package org.apache.tamaya.ucs; - -import static junit.framework.TestCase.assertTrue; -import static org.junit.Assert.assertEquals;
[25/34] incubator-tamaya git commit: first step: move all sources to a 'dormant' directory
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9964c64/core/src/main/java/org/apache/tamaya/core/internal/inject/InjectionUtils.java -- diff --git a/core/src/main/java/org/apache/tamaya/core/internal/inject/InjectionUtils.java b/core/src/main/java/org/apache/tamaya/core/internal/inject/InjectionUtils.java deleted file mode 100644 index d80ee80..000 --- a/core/src/main/java/org/apache/tamaya/core/internal/inject/InjectionUtils.java +++ /dev/null @@ -1,221 +0,0 @@ -package org.apache.tamaya.core.internal.inject; - -import java.lang.reflect.AnnotatedElement; -import java.lang.reflect.Field; -import java.lang.reflect.Member; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.ListIterator; - -import org.apache.tamaya.ConfigException; -import org.apache.tamaya.Configuration; -import org.apache.tamaya.PropertyAdapter; -import org.apache.tamaya.annotation.*; -import org.apache.tamaya.annotation.WithPropertyAdapter; -import org.apache.tamaya.core.internal.Utils; -import org.apache.tamaya.spi.PropertyAdapterSpi; - -/** - * Created by Anatole on 19.12.2014. - */ -@SuppressWarnings("unchecked") -final class InjectionUtils { - -private InjectionUtils(){} - -/** - * This method evaluates the {@link org.apache.tamaya.Configuration} that currently is valid for the given target field/method. - * - * @return the {@link org.apache.tamaya.Configuration} instance to be used, never null. - */ -public static Configuration getConfiguration(ConfiguredProperty prop, Configuration... configuration) { -String name = prop.config(); -if (name != null && !name.trim().isEmpty()) { -return Configuration.current(name.trim()); -} -return Configuration.current(); -} - -/** - * Evaluates all absolute configuration key based on the annotations found on a class. - * - * @param areasAnnot the (optional) annotation definining areas to be looked up. - * @param propertyAnnotation the annotation on field/method level that may defined one or - *several keys to be looked up (in absolute or relative form). - * @return the list current keys in order how they should be processed/looked up. - */ -public static List evaluateKeys(Member member, DefaultAreas areasAnnot, ConfiguredProperty propertyAnnotation) { -List keys = new ArrayList<>(Arrays.asList(propertyAnnotation.keys())); -if (keys.isEmpty()) //noinspection UnusedAssignment -keys.add(member.getName()); -ListIterator iterator = keys.listIterator(); -while (iterator.hasNext()) { -String next = iterator.next(); -if (next.startsWith("[") && next.endsWith("]")) { -// absolute key, strip away brackets, take key as is -iterator.set(next.substring(1, next.length() - 1)); -} else { -if (areasAnnot != null) { -// Remove original entry, since it will be replaced with prefixed entries -iterator.remove(); -// Add prefixed entries, including absolute (root) entry for "" area keys. -for (String area : areasAnnot.value()) { -iterator.add(area.isEmpty() ? next : area + '.' + next); -} -} -} -} -return keys; -} - -/** - * Evaluates all absolute configuration key based on the member name found. - * - * @param areasAnnot the (optional) annotation definining areas to be looked up. - * @return the list current keys in order how they should be processed/looked up. - */ -public static List evaluateKeys(Member member, DefaultAreas areasAnnot) { -List keys = new ArrayList<>(); -String name = member.getName(); -String mainKey; -if(name.startsWith("get") || name.startsWith("set")){ -mainKey = Character.toLowerCase(name.charAt(3)) + name.substring(4); -} -else{ -mainKey = Character.toLowerCase(name.charAt(0)) + name.substring(1); -} -keys.add(mainKey); -if (areasAnnot != null) { -// Add prefixed entries, including absolute (root) entry for "" area keys. -for (String area : areasAnnot.value()) { -if(!area.isEmpty()) { -keys.add(area + '.' + mainKey); -} -} -} -else{ // add package name -keys.add(member.getDeclaringClass().getName()+'.'+mainKey); -} -return keys; -} - -/** - * Internally evaluated the current valid configuration keys based on the given annotations present. - * - * @return the
[12/34] incubator-tamaya git commit: first step: move all sources to a 'dormant' directory
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9964c64/dormant/core/src/main/java/org/apache/tamaya/core/internal/resources/io/PathMatchingResourcePatternResolver.java -- diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/internal/resources/io/PathMatchingResourcePatternResolver.java b/dormant/core/src/main/java/org/apache/tamaya/core/internal/resources/io/PathMatchingResourcePatternResolver.java new file mode 100644 index 000..900a53f --- /dev/null +++ b/dormant/core/src/main/java/org/apache/tamaya/core/internal/resources/io/PathMatchingResourcePatternResolver.java @@ -0,0 +1,729 @@ +/* + * Copyright 2002-2008 the original author or authors. + * + * Licensed 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.core.internal.resources.io; + +import org.apache.tamaya.core.resource.Resource; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Method; +import java.net.JarURLConnection; +import java.net.URL; +import java.net.URLConnection; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; + +import java.lang.reflect.InvocationHandler; +import java.net.MalformedURLException; +import java.net.URISyntaxException; +import java.net.URLClassLoader; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.stream.Collectors; + + +/** + * A {@code ResourcePatternResolver} implementation that is able to resolve a + * specified resource location path into one or more matching Resources. + * The source path may be a simple path which has a one-to-one annotation to a + * target {@code org.springframework.core.io.Resource}, or alternatively + * may contain the special "{@code classpath*:}" prefix and/or + * internal Ant-style regular expressions (matched using Spring's + * {@code org.springframework.util.AntPathMatcher} utility). + * Both current the latter are effectively wildcards. + * + * No Wildcards: + * + * In the simple case, if the specified location path does not start with the + * {@code "classpath*:}" prefix, and does not contain a PathMatcher pattern, + * this resolver will simply return a single resource via a + * {@code getResource()} call on the underlying {@code ResourceLoader}. + * Examples are real URLs such as "{@code file:C:/context.xml}", pseudo-URLs + * such as "{@code classpath:/context.xml}", and simple unprefixed paths + * such as "{@code /WEB-INF/context.xml}". The latter will resolve in a + * fashion specific to the underlying {@code ResourceLoader} (e.g. + * {@code ServletContextResource} for a {@code WebApplicationContext}). + * + * Ant-style Patterns: + * + * When the path location contains an Ant-style pattern, e.g.: + * + * /WEB-INF/*-context.xml + * com/mycompany/**/applicationContext.xml + * file:C:/some/path/*-context.xml + * classpath:com/mycompany/**/applicationContext.xml + * the resolver follows a more complex but defined procedure to try to resolve + * the wildcard. It produces a {@code Resource} for the path up to the last + * non-wildcard segment and obtains a {@code URL} from it. If this URL is + * not a "{@code jar:}" URL or container-specific variant (e.g. + * "{@code zip:}" in WebLogic, "{@code wsjar}" in WebSphere", etc.), + * then a {@code java.io.File} is obtained from it, and used to resolve the + * wildcard by walking the filesystem. In the case current a jar URL, the resolver + * either gets a {@code java.net.JarURLConnection} from it, or manually parses + * the jar URL, and then traverses the contents current the jar file, to resolve the + * wildcards. + * + * Implications on portability: + * + * If the specified path is already a file URL (either explicitly, or + * implicitly because the base {@code ResourceLoader} is a filesystem one, + * then wildcarding is guaranteed to work in a completely portable fashion. + * + * If the specified path is a classpath location, then the resolver must + * obtain the last non-wildcard path segment URL via a + * {@code Classloader.getResource()} call. Since this is just a + * node current the path (not the file at the end) it is actually undefined + * (in the ClassLoader Javadocs) exactly what sort current a URL is returned in + * this case. In practice, it is usually a {@code java.io.File} representing + * the directory, where the classpath resource resolves to a filesystem
[05/34] incubator-tamaya git commit: first step: move all sources to a 'dormant' directory
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9964c64/modules/metamodels/environment/src/main/java/org/apache/tamaya/metamodel/environment/BuildableEnvironment.java -- diff --git a/modules/metamodels/environment/src/main/java/org/apache/tamaya/metamodel/environment/BuildableEnvironment.java b/modules/metamodels/environment/src/main/java/org/apache/tamaya/metamodel/environment/BuildableEnvironment.java deleted file mode 100644 index 3633c97..000 --- a/modules/metamodels/environment/src/main/java/org/apache/tamaya/metamodel/environment/BuildableEnvironment.java +++ /dev/null @@ -1,109 +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.environment; - -import java.util.*; - -/** - * Environment class that is used by the {@link org.apache.tamaya.metamodel.environment.EnvironmentBuilder}. - */ -class BuildableEnvironment implements Environment { - -/** The environment data. */ -private Map context = new TreeMap<>(); - -/** - * Constructor. - * @param builder the builder, not null. - */ -BuildableEnvironment(EnvironmentBuilder builder){ -Objects.requireNonNull(builder); -context.putAll(builder.contextData); -} - -@Override -public Map toMap() { -return context; -} - -@Override -public Optional get(String key){ -return Optional.ofNullable(context.get(key)); -} - -@Override -public boolean containsKey(String key){ -return context.containsKey(key); -} - -@Override -public Set keySet() { -return context.keySet(); -} - -@Override -public boolean equals(Object o) { -if (this == o) return true; -if (o == null || getClass() != o.getClass()) return false; - -BuildableEnvironment that = (BuildableEnvironment) o; -return context.equals(that.context); -} - -@Override -public int hashCode() { -return context.hashCode(); -} - -/* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ -@Override -public String toString(){ -return "Environment: " + getData(); -} - -/** - * Get the delta. - * @return - */ -private String getData() { -StringBuilder b = new StringBuilder(); -for(Map.Entry en: this.context.entrySet()){ -b.append(" ").append(en.getKey()).append('=').append(escape(en.getValue())).append('\n'); -} -if(b.length()>0) -b.setLength(b.length()-1); -return b.toString(); -} - -/** - * Escapes several characters. - * @param value - * @return - */ -private String escape(String value){ -if(value==null) -return null; -return value.replaceAll("\n", "n").replaceAll("\r", "r").replaceAll("\t", "t") -.replaceAll("=", "="); -} -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9964c64/modules/metamodels/environment/src/main/java/org/apache/tamaya/metamodel/environment/Environment.java -- diff --git a/modules/metamodels/environment/src/main/java/org/apache/tamaya/metamodel/environment/Environment.java b/modules/metamodels/environment/src/main/java/org/apache/tamaya/metamodel/environment/Environment.java deleted file mode 100644 index 8a8b157..000 --- a/modules/metamodels/environment/src/main/java/org/apache/tamaya/metamodel/environment/Environment.java +++ /dev/null @@ -1,86 +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 writi
[27/34] incubator-tamaya git commit: first step: move all sources to a 'dormant' directory
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9964c64/core/src/main/asciidoc/design.adoc -- diff --git a/core/src/main/asciidoc/design.adoc b/core/src/main/asciidoc/design.adoc deleted file mode 100644 index 61750e3..000 --- a/core/src/main/asciidoc/design.adoc +++ /dev/null @@ -1,1077 +0,0 @@ -Configuration User Guide - -Anatole Tresch -:Author Initials: ATR -:source-highlighter: coderay -:toc: -:icons: -:numbered: -:website: http://tamaya.incubator.apache.org/ - - -<<< -:numbered!: -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. - -:numbered: - -'Apache Tamaya Core' is an implementation of the 'Apache Tamaya Config API'. The API is separated -so also other can provide their own implementations. This document will discuss topics -from both areas, API and this implementation, using a more general view. - -.This document -** -This is an overview document that describes all relevant aspects of -this Java configuration implementation. - -For a shorter introduction you may check out the quick start guide -(tbd). -** - - -== Introduction to Java Configuration - -[NOTE] -You may also checkout the introductory blog http://javaeeconfig.blogspot.ch/[here]. - -=== General Aspects - -Basically one might ask, what configuration is at all. When looking at the a computation model, where some input is -converted to some output, configuration can be seen as some kind of control flow, which affects the transformation. -Nevertheless configuration is not equal to the program converting input to output. Configuration is more like a -constraint recipe that tells the program in place, what to do, but only within the boundaries of the program allows to -be configured. Obviously, if the configuration is so powerful, that it is capable of performing any task, it is -questionable, if this should be called 'configuration' (it may be called more a 'script' or 'recipe'). - -So summarizing configuration should be - -* constrained and limited for purpose. -* must be interpreted by some algorithmic logic - -== Configuration is an API - -Configuration is not there just for fun. With configuration your program logic defines an API, which clients interacts -with. If you change it, you will break the contract. If you replace configuration, you must deprecated it. But things -get worse. With code you have a compiler that flags out deprecations and will fail if pieces do not fit together -anymore. With configuration you do not have any such tools. - -As a consequence, like with APIs, you must think on what should be configurable. In general, similar as when designing -programmatic APIs, reduce your API footprint to an absolute minimum. Frankly speaking, if something is not really -meant to be configured or very complex to configure, or even very rarely used, consider to make it non configurable -at all. Instead of ensure the component is well encapsulated as a Java artifact, so customers still can replace it -with their own version if needed. - -Configuration Types -~~~ -When thinking on configuration types there are a couple of things that are commonly used to 'configure' a program: - -* command line arguments -* environment properties -* system properties -* files and classpath resources, using different formats; including standardized deployment descriptors as well as -vendor specific formats -* databases -* remote configuration services -* ... - -This is list is for sure far from being complete. Nevertheless there are some similarities in most cases you will find: - -* a configuration entry is *identified by some literal key*. -* configuration values most of the times are *literal values*. -* configuration most of the time is *single valued*, but sometimes also *multi valued* (e.g. collections). -* often keys use a *naming scheme* similar to package and class names (though property names are typically in lower -case), e.g. +a.b.
[06/34] incubator-tamaya git commit: first step: move all sources to a 'dormant' directory
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9964c64/dormant/modules/metamodels/environment/src/test/java/org/apache/tamaya/metamodel/environment/EnvironmentManagerTest.java -- diff --git a/dormant/modules/metamodels/environment/src/test/java/org/apache/tamaya/metamodel/environment/EnvironmentManagerTest.java b/dormant/modules/metamodels/environment/src/test/java/org/apache/tamaya/metamodel/environment/EnvironmentManagerTest.java new file mode 100644 index 000..5abdd8e --- /dev/null +++ b/dormant/modules/metamodels/environment/src/test/java/org/apache/tamaya/metamodel/environment/EnvironmentManagerTest.java @@ -0,0 +1,66 @@ +/* + * 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.environment; + +import org.apache.tamaya.Environment; +import org.junit.Test; + + +import static org.junit.Assert.*; + +/** + * Tests for basic {@link org.apache.tamaya.EnvironmentManager} functionality. + * Created by Anatole on 17.10.2014. + */ +public class EnvironmentManagerTest { + +@Test +public void testGetEnvironment(){ +Environment env = Environment.current(); +assertNotNull(env); +Environment env2 = Environment.current(); +assertNotNull(env2); +assertFalse("Current Environments requested in same context are not the same!", env==env2); +} + +@Test +public void testGetRootEnvironment(){ +Environment env = Environment.root(); +assertNotNull(env); +Environment env2 = Environment.root(); +assertNotNull(env2); +assertTrue("Root Environments requested in same context are not the same!", env==env2); +} + +@Test +public void testRootIsNotCurrentEnvironment(){ +Environment env1 = Environment.root(); +Environment env2 = Environment.current(); +assertNotNull(env1); +assertNotNull(env2); +// within this test environment these are always the same +assertEquals(env1, env2); +} + +@Test +public void testEnvironmentOverride(){ + assertEquals(Environment.root().get("user.country").get(),System.getProperty("user.country")); +assertEquals(Environment.current().get("user.country").get(), System.getProperty("user.country")); +} +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9964c64/dormant/modules/metamodels/environment/src/test/java/org/apache/tamaya/metamodel/environment/TestEnvironmentManagerSingleton.java -- diff --git a/dormant/modules/metamodels/environment/src/test/java/org/apache/tamaya/metamodel/environment/TestEnvironmentManagerSingleton.java b/dormant/modules/metamodels/environment/src/test/java/org/apache/tamaya/metamodel/environment/TestEnvironmentManagerSingleton.java new file mode 100644 index 000..83a6056 --- /dev/null +++ b/dormant/modules/metamodels/environment/src/test/java/org/apache/tamaya/metamodel/environment/TestEnvironmentManagerSingleton.java @@ -0,0 +1,37 @@ +/* + * 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.environment; + +import org.apache.tamaya.metamodel.environment.spi.EnvironmentSpi; + +/** + * Created by Anatole on 12.09.2014. + */ +public class TestEnvironmentManagerSingleton implements EnvironmentSpi { +@Override +public Environment getC
[23/34] incubator-tamaya git commit: first step: move all sources to a 'dormant' directory
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9964c64/core/src/main/java/org/apache/tamaya/core/internal/resources/io/DefaultResourceLoader.java -- diff --git a/core/src/main/java/org/apache/tamaya/core/internal/resources/io/DefaultResourceLoader.java b/core/src/main/java/org/apache/tamaya/core/internal/resources/io/DefaultResourceLoader.java deleted file mode 100644 index d8fa274..000 --- a/core/src/main/java/org/apache/tamaya/core/internal/resources/io/DefaultResourceLoader.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright 2002-2014 the original author or authors. - * - * Licensed 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.core.internal.resources.io; - -import org.apache.tamaya.core.resource.Resource; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Objects; - -/** - * Will return a {@code UrlResource} if the location keys is a URL, - * and a {@code ClassPathResource} if it is a non-URL path or a - * "classpath:" pseudo-URL. - * - * @author Juergen Hoeller - * @since 10.03.2004 - */ -class DefaultResourceLoader { - -/** Pseudo URL prefix for loading from the class path: "classpath:" */ -public static final String CLASSPATH_URL_PREFIX = "classpath:"; - - private ClassLoader classLoader; - - - /** -* Create a new DefaultResourceLoader. -* ClassLoader access will happen using the thread context class loader -* at the time current this ResourceLoader's initialization. -* @see java.lang.Thread#getContextClassLoader() -*/ - public DefaultResourceLoader() { - this.classLoader = ClassUtils.getDefaultClassLoader(); - } - - /** -* Create a new DefaultResourceLoader. -* @param classLoader the ClassLoader to load class path resources with, or {@code null} -* for using the thread context class loader at the time current actual resource access -*/ - public DefaultResourceLoader(ClassLoader classLoader) { - this.classLoader = classLoader; - } - - - /** -* Specify the ClassLoader to load class path resources with, or {@code null} -* for using the thread context class loader at the time current actual resource access. -* The default is that ClassLoader access will happen using the thread context -* class loader at the time current this ResourceLoader's initialization. -*/ - void setClassLoader(ClassLoader classLoader) { - this.classLoader = classLoader; - } - - /** -* Return the ClassLoader to load class path resources with. -* Will get passed to ClassPathResource's constructor for all -* ClassPathResource objects created by this resource loader. -* @see ClassPathResource -*/ - public ClassLoader getClassLoader() { - return (this.classLoader != null ? this.classLoader : ClassUtils.getDefaultClassLoader()); - } - - - public Resource getResource(String location) { - Objects.requireNonNull(location, "Location must not be null"); - if (location.startsWith("/")) { - return getResourceByPath(location); - } - else if (location.startsWith(CLASSPATH_URL_PREFIX)) { - return new ClassPathResource(location.substring(CLASSPATH_URL_PREFIX.length()), getClassLoader()); - } - else { - try { - // Try to parse the location as a URL... - URL url = new URL(location); - return new UrlResource(url); - } - catch (MalformedURLException ex) { - // No URL -> resolve as resource path. - return getResourceByPath(location); - } - } - } - - /** -* Return a Resource handle for the resource at the given path. -* The default implementation supports class path locations. This should -* be appropriate for standalone implementations but can be overridden, -* e.g. for implementations targeted at a Servlet container. -* @param path the path to the resource -*
[17/34] incubator-tamaya git commit: first step: move all sources to a 'dormant' directory
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9964c64/dormant/core/src/main/asciidoc/design.adoc -- diff --git a/dormant/core/src/main/asciidoc/design.adoc b/dormant/core/src/main/asciidoc/design.adoc new file mode 100644 index 000..61750e3 --- /dev/null +++ b/dormant/core/src/main/asciidoc/design.adoc @@ -0,0 +1,1077 @@ +Configuration User Guide + +Anatole Tresch +:Author Initials: ATR +:source-highlighter: coderay +:toc: +:icons: +:numbered: +:website: http://tamaya.incubator.apache.org/ + + +<<< +:numbered!: +--- +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. +--- + +:numbered: + +'Apache Tamaya Core' is an implementation of the 'Apache Tamaya Config API'. The API is separated +so also other can provide their own implementations. This document will discuss topics +from both areas, API and this implementation, using a more general view. + +.This document +** +This is an overview document that describes all relevant aspects of +this Java configuration implementation. + +For a shorter introduction you may check out the quick start guide +(tbd). +** + + +== Introduction to Java Configuration + +[NOTE] +You may also checkout the introductory blog http://javaeeconfig.blogspot.ch/[here]. + +=== General Aspects + +Basically one might ask, what configuration is at all. When looking at the a computation model, where some input is +converted to some output, configuration can be seen as some kind of control flow, which affects the transformation. +Nevertheless configuration is not equal to the program converting input to output. Configuration is more like a +constraint recipe that tells the program in place, what to do, but only within the boundaries of the program allows to +be configured. Obviously, if the configuration is so powerful, that it is capable of performing any task, it is +questionable, if this should be called 'configuration' (it may be called more a 'script' or 'recipe'). + +So summarizing configuration should be + +* constrained and limited for purpose. +* must be interpreted by some algorithmic logic + +== Configuration is an API + +Configuration is not there just for fun. With configuration your program logic defines an API, which clients interacts +with. If you change it, you will break the contract. If you replace configuration, you must deprecated it. But things +get worse. With code you have a compiler that flags out deprecations and will fail if pieces do not fit together +anymore. With configuration you do not have any such tools. + +As a consequence, like with APIs, you must think on what should be configurable. In general, similar as when designing +programmatic APIs, reduce your API footprint to an absolute minimum. Frankly speaking, if something is not really +meant to be configured or very complex to configure, or even very rarely used, consider to make it non configurable +at all. Instead of ensure the component is well encapsulated as a Java artifact, so customers still can replace it +with their own version if needed. + +Configuration Types +~~~ +When thinking on configuration types there are a couple of things that are commonly used to 'configure' a program: + +* command line arguments +* environment properties +* system properties +* files and classpath resources, using different formats; including standardized deployment descriptors as well as +vendor specific formats +* databases +* remote configuration services +* ... + +This is list is for sure far from being complete. Nevertheless there are some similarities in most cases you will find: + +* a configuration entry is *identified by some literal key*. +* configuration values most of the times are *literal values*. +* configuration most of the time is *single valued*, but sometimes also *multi valued* (e.g. collections). +* often keys use a *naming scheme* similar to package and class names (though property names are typically
[04/34] incubator-tamaya git commit: add checkstyle and basic pom structure
add checkstyle and basic pom structure Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/fbd13875 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/fbd13875 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/fbd13875 Branch: refs/heads/master Commit: fbd13875d8857831c20eca39bb74209584e8f778 Parents: d9964c6 Author: Mark Struberg Authored: Sat Dec 27 10:16:02 2014 +0100 Committer: Mark Struberg Committed: Sat Dec 27 11:10:11 2014 +0100 -- api/pom.xml | 35 ++ core/pom.xml | 41 +++ dormant/api/pom.xml | 85 - dormant/core/pom.xml | 114 -- pom.xml | 298 +- 5 files changed, 291 insertions(+), 282 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/fbd13875/api/pom.xml -- diff --git a/api/pom.xml b/api/pom.xml new file mode 100644 index 000..03c4ab7 --- /dev/null +++ b/api/pom.xml @@ -0,0 +1,35 @@ + +http://maven.apache.org/POM/4.0.0"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd";> +4.0.0 + + +org.apache.tamaya +tamaya-all +0.2-SNAPSHOT +../pom.xml + + +tamaya-api + +The API defines a complete SE based API for reading of configuration data. + + + http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/fbd13875/core/pom.xml -- diff --git a/core/pom.xml b/core/pom.xml new file mode 100644 index 000..26ccce0 --- /dev/null +++ b/core/pom.xml @@ -0,0 +1,41 @@ + +http://maven.apache.org/POM/4.0.0"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd";> +4.0.0 + + +org.apache.tamaya +tamaya-all +0.2-SNAPSHOT +../pom.xml + + +tamaya-core + + + + +org.apache.tamaya +tamaya-api +${project.version} + + + + http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/fbd13875/dormant/api/pom.xml -- diff --git a/dormant/api/pom.xml b/dormant/api/pom.xml deleted file mode 100644 index 78925f5..000 --- a/dormant/api/pom.xml +++ /dev/null @@ -1,85 +0,0 @@ - -http://maven.apache.org/POM/4.0.0"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd";> -4.0.0 - - -org.apache.tamaya -tamaya-all -0.1-SNAPSHOT -.. - - -tamaya-api -Apache Tamaya - API -The API defines a complete SE based API for reading, creating an dmanaging of configuration and -environment data. - -jar - - - - - - - -org.apache.maven.plugins -maven-javadoc-plugin - - -attach-javadocs - -jar - - - - --Xdoclint:none -false -true -false -false -false - - - -org.jacoco -jacoco-maven-plugin - - -prepare-agent - -prepare-agent - - - - - - - - - -junit -junit -test - - - - http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/fbd13875/dormant/core/pom.xml -- diff --git a/dormant/core/pom.xml b/dormant/core/pom.xml deleted file mode 100644 index 85ef679..000 --- a/dormant/core/pom.xml +++ /dev/null @@ -1,114 +0,0 @@ - -http://maven.apache.org/POM/4.0.0"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd";> -4.0.0 - - -org.apache.tamaya -tamaya-all -
[29/34] incubator-tamaya git commit: first step: move all sources to a 'dormant' directory
first step: move all sources to a 'dormant' directory later we gonna move back all the things we really need. Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/d9964c64 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/d9964c64 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/d9964c64 Branch: refs/heads/master Commit: d9964c64fc1e39a0fd22b4df23ae8005b231677e Parents: 784884c Author: Mark Struberg Authored: Sat Dec 27 00:15:33 2014 +0100 Committer: Mark Struberg Committed: Sat Dec 27 11:10:11 2014 +0100 -- api/.gitignore | 18 - api/pom.xml | 85 -- .../java/org/apache/tamaya/ConfigException.java | 44 - .../java/org/apache/tamaya/Configuration.java | 366 -- .../java/org/apache/tamaya/PropertyAdapter.java | 89 -- .../java/org/apache/tamaya/PropertySource.java | 129 -- .../tamaya/annotation/ConfiguredProperties.java | 41 - .../tamaya/annotation/ConfiguredProperty.java | 87 -- .../apache/tamaya/annotation/DefaultAreas.java | 43 - .../apache/tamaya/annotation/DefaultValue.java | 41 - .../apache/tamaya/annotation/LoadPolicy.java| 48 - .../org/apache/tamaya/annotation/NoConfig.java | 32 - .../tamaya/annotation/ObservesConfigChange.java | 38 - .../tamaya/annotation/WithConfigOperator.java | 45 - .../tamaya/annotation/WithLoadPolicy.java | 40 - .../tamaya/annotation/WithPropertyAdapter.java | 45 - .../org/apache/tamaya/spi/ConfigurationSpi.java | 98 -- .../spi/DefaultServiceContextProvider.java | 101 -- .../apache/tamaya/spi/PropertyAdapterSpi.java | 72 - .../org/apache/tamaya/spi/ServiceContext.java | 109 -- .../tamaya/spi/ServiceContextManager.java | 100 -- .../test/java/annottext/AnnotatedConfig.java| 51 - .../java/annottext/AnnotatedFullConfig.java | 52 - .../tamaya/TestConfigServiceSingletonSpi.java | 90 -- .../TestPropertyAdaptersSingletonSpi.java | 99 -- api/src/test/resources/META-INF/beans.xml | 25 - .../org.apache.tamaya.spi.ConfigurationSpi | 19 - .../org.apache.tamaya.spi.PropertyAdapterSpi| 19 - buildtools/pom.xml | 35 - .../src/main/resources/findbugs-exclude.xml | 22 - core/.gitignore | 16 - core/pom.xml| 114 -- core/src/main/asciidoc/design.adoc | 1077 --- .../tamaya/core/config/ConfigChangeSet.java | 169 --- .../core/config/ConfigChangeSetBuilder.java | 359 - .../apache/tamaya/core/internal/MetaConfig.java | 68 - .../org/apache/tamaya/core/internal/Utils.java | 126 -- .../config/DefaultConfigurationSpi.java | 116 -- .../config/DefaultPropertyAdapterSpi.java | 168 --- .../config/EnvPropertiesConfigProvider.java | 54 - .../config/FallbackSimpleConfigProvider.java| 60 - .../internal/config/FileChangeListener.java | 137 -- .../internal/config/FileChangeObserver.java | 13 - .../core/internal/config/FileConfiguration.java | 68 - .../tamaya/core/internal/config/FileReader.java | 80 -- .../config/FilesPropertiesConfigProvider.java | 97 -- .../config/SystemPropertiesConfigProvider.java | 54 - .../internal/el/DefaultExpressionEvaluator.java | 144 -- .../el/EnvironmentPropertyResolver.java | 44 - .../internal/el/SystemPropertyResolver.java | 44 - .../format/DefaultConfigurationFormatSpi.java | 78 -- .../tamaya/core/internal/format/IniFormat.java | 98 -- .../core/internal/format/PropertiesFormat.java | 61 - .../internal/format/PropertiesXmlFormat.java| 62 - .../inject/ConfigChangeCallbackMethod.java | 67 - .../inject/ConfigTemplateInvocationHandler.java | 76 -- .../internal/inject/ConfigurationInjector.java | 61 - .../core/internal/inject/ConfiguredField.java | 126 -- .../internal/inject/ConfiguredSetterMethod.java | 136 -- .../core/internal/inject/ConfiguredType.java| 222 .../core/internal/inject/InjectionUtils.java| 221 .../inject/WeakConfigListenerManager.java | 117 -- .../logging/AbstractDelegatingLogger.java | 411 -- .../core/internal/logging/Log4j2Logger.java | 97 -- .../core/internal/logging/Log4jLogger.java | 200 --- .../core/internal/logging/Slf4jLogger.java | 181 --- .../resources/AntPathClasspathResolver.java | 60 - .../internal/resources/AntPathFileResolver.java | 61 - .../resources/DefaultResourceLoader.java| 81 -- .../io/AbstractFileResolvingResource.java | 221 .../internal/resources/io/AbstractResource.java | 217 --- .../internal/resources/io/AntPathMatcher.java | 777 --- .../re
[24/34] incubator-tamaya git commit: first step: move all sources to a 'dormant' directory
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9964c64/core/src/main/java/org/apache/tamaya/core/internal/resources/io/AntPathMatcher.java -- diff --git a/core/src/main/java/org/apache/tamaya/core/internal/resources/io/AntPathMatcher.java b/core/src/main/java/org/apache/tamaya/core/internal/resources/io/AntPathMatcher.java deleted file mode 100644 index 43d2a20..000 --- a/core/src/main/java/org/apache/tamaya/core/internal/resources/io/AntPathMatcher.java +++ /dev/null @@ -1,777 +0,0 @@ -/* - * Copyright 2002-2014 the original author or authors. - * - * Licensed 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.core.internal.resources.io; - -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * PathMatcher implementation for Ant-style path patterns. Examples are provided below. - * - * Part current this annotation code has been kindly borrowed from http://ant.apache.org";>Apache Ant. - * - * The annotation matches URLs using the following rules: ? matches one character * matches zero - * or more characters ** matches zero or more 'directories' in a path - * - * Some examples: {@code com/t?st.jsp} - matches {@code com/test.jsp} but also - * {@code com/tast.jsp} or {@code com/txst.jsp} {@code com/*.jsp} - matches all - * {@code .jsp} files in the {@code com} directory {@code com/**/test.jsp} - matches all - * {@code test.jsp} files underneath the {@code com} path {@code org/springframework/**/*.jsp} - * - matches all {@code .jsp} files underneath the {@code org/springframework} path - * {@code org/**/servlet/bla.jsp} - matches {@code org/springframework/servlet/bla.jsp} but also - * {@code org/springframework/testing/servlet/bla.jsp} and {@code org/servlet/bla.jsp} - * - * @author Alef Arendsen - * @author Juergen Hoeller - * @author Rob Harrop - * @author Arjen Poutsma - * @author Rossen Stoyanchev - * @since 16.07.2003 - */ -class AntPathMatcher { - - /** Default path separator: "/" */ - public static final String DEFAULT_PATH_SEPARATOR = "/"; - - private static final int CACHE_TURNOFF_THRESHOLD = 65536; - - private static final Pattern VARIABLE_PATTERN = Pattern.compile("\\{[^/]+?\\}"); - - - private String pathSeparator; - - private PathSeparatorPatternCache pathSeparatorPatternCache; - - private boolean trimTokens = true; - - private volatile Boolean cachePatterns; - - private final Map tokenizedPatternCache = new ConcurrentHashMap<>(256); - - final Map stringMatcherCache = new ConcurrentHashMap<>(256); - - - /** -* Create a new instance with the {@link #DEFAULT_PATH_SEPARATOR}. -*/ - public AntPathMatcher() { - this.pathSeparator = DEFAULT_PATH_SEPARATOR; - this.pathSeparatorPatternCache = new PathSeparatorPatternCache(DEFAULT_PATH_SEPARATOR); - } - - /** -* A convenience alternative constructor to use with a custom path separator. -* @param pathSeparator the path separator to use, must not be {@code null}. -* @since 4.1 -*/ - public AntPathMatcher(String pathSeparator) { - Objects.requireNonNull(pathSeparator, "'pathSeparator' is required"); - this.pathSeparator = pathSeparator; - this.pathSeparatorPatternCache = new PathSeparatorPatternCache(pathSeparator); - } - - - /** -* Set the path separator to use for pattern parsing. -* Default is "/", as in Ant. -*/ - public void setPathSeparator(String pathSeparator) { - this.pathSeparator = (pathSeparator != null ? pathSeparator : DEFAULT_PATH_SEPARATOR); - this.pathSeparatorPatternCache = new PathSeparatorPatternCache(this.pathSeparator); - } - - /** -* Specify whether to trim tokenized paths and patterns. -* Default is {@code true}. -*/ - public void setTrimTokens(boolean trimTokens) { - this.trimTokens = trimTokens; - } - - /** -* Specify whether to cache parsed pattern metadata for patterns passed -* into this matcher's {@link #match} method. A keys current {@code true} -* activates an unlimited pattern cache; a keys current {@code false} turns -* the pa
[13/34] incubator-tamaya git commit: first step: move all sources to a 'dormant' directory
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9964c64/dormant/core/src/main/java/org/apache/tamaya/core/internal/resources/io/ClassUtils.java -- diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/internal/resources/io/ClassUtils.java b/dormant/core/src/main/java/org/apache/tamaya/core/internal/resources/io/ClassUtils.java new file mode 100644 index 000..7b6efec --- /dev/null +++ b/dormant/core/src/main/java/org/apache/tamaya/core/internal/resources/io/ClassUtils.java @@ -0,0 +1,1232 @@ +/* +* Copyright 2002-2014 the original author or authors. +* +* Licensed 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.core.internal.resources.io; + +import java.lang.reflect.Array; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** +* Miscellaneous class utility methods. +* Mainly for internal use within the framework. +* +* @author Juergen Hoeller +* @author Keith Donald +* @author Rob Harrop +* @author Sam Brannen +* @since 1.1 +*/ +public class ClassUtils { + + /** Suffix for array class names: "[]" */ + public static final String ARRAY_SUFFIX = "[]"; + + /** Prefix for internal array class names: "[" */ + private static final String INTERNAL_ARRAY_PREFIX = "["; + + /** Prefix for internal non-primitive array class names: "[L" */ + private static final String NON_PRIMITIVE_ARRAY_PREFIX = "[L"; + + /** The package separator character '.' */ + private static final char PACKAGE_SEPARATOR = '.'; + + /** The path separator character '/' */ + private static final char PATH_SEPARATOR = '/'; + + /** The inner class separator character '$' */ + private static final char INNER_CLASS_SEPARATOR = '$'; +// +// /** The CGLIB class separator character "$$" */ +// public static final String CGLIB_CLASS_SEPARATOR = "$$"; +// +// /** The ".class" file suffix */ +// public static final String CLASS_FILE_SUFFIX = ".class"; +// + + /** +* Map with primitive wrapper type as key and corresponding primitive +* type as keys, for example: Integer.class -> int.class. +*/ + private static final Map, Class> primitiveWrapperTypeMap = new HashMap<>(8); + + /** +* Map with primitive type as key and corresponding wrapper +* type as keys, for example: int.class -> Integer.class. +*/ + private static final Map, Class> primitiveTypeToWrapperMap = new HashMap<>(8); + + /** +* Map with primitive type name as key and corresponding primitive +* type as keys, for example: "int" -> "int.class". +*/ + private static final Map> primitiveTypeNameMap = new HashMap<>(32); +// +// /** +// * Map with common "java.lang" class name as key and corresponding Class as keys. +// * Primarily for efficient deserialization current remote invocations. +// */ +// private static final Map> commonClassCache = new HashMap>(32); +// +// + static { + primitiveWrapperTypeMap.put(Boolean.class, boolean.class); + primitiveWrapperTypeMap.put(Byte.class, byte.class); + primitiveWrapperTypeMap.put(Character.class, char.class); + primitiveWrapperTypeMap.put(Double.class, double.class); + primitiveWrapperTypeMap.put(Float.class, float.class); + primitiveWrapperTypeMap.put(Integer.class, int.class); + primitiveWrapperTypeMap.put(Long.class, long.class); + primitiveWrapperTypeMap.put(Short.class, short.class); + + for (Map.Entry, Class> entry : primitiveWrapperTypeMap.entrySet()) { + primitiveTypeToWrapperMap.put(entry.getValue(), entry.getKey()); +// registerCommonClasses(entry.getKey()); + } + + Set> primitiveTypes = new HashSet<>(32); + primitiveTypes.addAll(primitiveWrapperTypeMap.values()); + primitiveTypes.addAll(Arrays.asList(new Class[] { + boolean[].class, byte[].class, char[].class, double[].class, + float[].class, int[].class, long[].class, short[].class})); + primitiveTypes.add(void.class); + for (Class primitiveType
[31/34] incubator-tamaya git commit: move intermediately changed stuff to dormant as well
move intermediately changed stuff to dormant as well Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/278a6c68 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/278a6c68 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/278a6c68 Branch: refs/heads/master Commit: 278a6c681b2cfd52ac375b84e2e90aa2b579e12e Parents: 30bdbb9 Author: Mark Struberg Authored: Sat Dec 27 11:09:17 2014 +0100 Committer: Mark Struberg Committed: Sat Dec 27 11:10:12 2014 +0100 -- .../tamaya/core/ConfigurationFunctions.java | 213 .../core/properties/ConfigurationFormat.java| 111 -- .../core/properties/FrozenPropertySource.java | 80 - .../core/properties/MappedPropertySource.java | 53 --- .../core/properties/PropertyChangeSet.java | 169 - .../properties/PropertyChangeSetBuilder.java| 347 --- .../properties/PropertySourceFunctions.java | 65 ...e.tamaya.core.properties.ConfigurationFormat | 21 -- .../tamaya/core/ConfigurationFunctions.java | 213 .../core/properties/ConfigurationFormat.java| 111 ++ .../core/properties/FrozenPropertySource.java | 80 + .../core/properties/MappedPropertySource.java | 53 +++ .../core/properties/PropertyChangeSet.java | 169 + .../properties/PropertyChangeSetBuilder.java| 347 +++ .../properties/PropertySourceFunctions.java | 65 ...e.tamaya.core.properties.ConfigurationFormat | 21 ++ 16 files changed, 1059 insertions(+), 1059 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/278a6c68/core/src/main/java/org/apache/tamaya/core/ConfigurationFunctions.java -- diff --git a/core/src/main/java/org/apache/tamaya/core/ConfigurationFunctions.java b/core/src/main/java/org/apache/tamaya/core/ConfigurationFunctions.java deleted file mode 100644 index b1c2522..000 --- a/core/src/main/java/org/apache/tamaya/core/ConfigurationFunctions.java +++ /dev/null @@ -1,213 +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.core; - -import org.apache.tamaya.Configuration; -import org.apache.tamaya.core.properties.PropertySourceBuilder; - -import java.util.*; -import java.util.function.Function; -import java.util.function.Predicate; -import java.util.function.UnaryOperator; -import java.util.stream.Collectors; - -/** - * Accessor that provides useful functions along with configuration. - */ -public final class ConfigurationFunctions { -/** - * Private singleton constructor. - */ -private ConfigurationFunctions() { -} - -/** - * Creates a ConfigOperator that creates a Configuration containing only keys - * that are contained in the given area (non recursive). Hereby - * the area key is stripped away fromMap the resulting key. - * - * @param areaKey the area key, not null - * @return the area configuration, with the areaKey stripped away. - */ -public static UnaryOperator selectArea(String areaKey) { -return selectArea(areaKey, true); -} - -/** - * Creates a ConfigOperator that creates a Configuration containing only keys - * that are contained in the given area (non recursive). - * - * @param areaKey the area key, not null - * @param stripKeys if set to true, the area key is stripped away fromMap the resulting key. - * @return the area configuration, with the areaKey stripped away. - */ -public static UnaryOperator selectArea(String areaKey, boolean stripKeys) { -return config -> { -Map area = new HashMap<>(); -area.putAll( -config.getProperties().entrySet().stream() -.filter(e -> isKeyInArea(e.getKey(), areaKey)) -.collect(Collectors.toMap( -
[15/34] incubator-tamaya git commit: first step: move all sources to a 'dormant' directory
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9964c64/dormant/core/src/main/java/org/apache/tamaya/core/internal/format/PropertiesFormat.java -- diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/internal/format/PropertiesFormat.java b/dormant/core/src/main/java/org/apache/tamaya/core/internal/format/PropertiesFormat.java new file mode 100644 index 000..10355ef --- /dev/null +++ b/dormant/core/src/main/java/org/apache/tamaya/core/internal/format/PropertiesFormat.java @@ -0,0 +1,61 @@ +/* + * 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.core.internal.format; + +import java.io.InputStream; +import java.util.Collections; +import java.util.Map; +import java.util.Properties; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.apache.tamaya.core.resource.Resource; +import org.apache.tamaya.core.properties.ConfigurationFormat; + +public class PropertiesFormat implements ConfigurationFormat{ + +private final static Logger LOG = Logger.getLogger(PropertiesFormat.class.getName()); + +@Override +public String getFormatName(){ +return "properties"; +} + +@Override + public boolean isAccepted(Resource resource) { + String path = resource.getFilename(); + return path != null && path.endsWith(".properties"); + } + + @SuppressWarnings("unchecked") + @Override + public Map readConfiguration(Resource resource) { + if (isAccepted(resource) && resource.exists()) { + try (InputStream is = resource.getInputStream()) { + Properties p = new Properties(); + p.load(is); + return Map.class.cast(p); + } catch (Exception e) { +LOG.log(Level.FINEST, e, () -> "Failed to read config from resource: " + resource); + } + } + return Collections.emptyMap(); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9964c64/dormant/core/src/main/java/org/apache/tamaya/core/internal/format/PropertiesXmlFormat.java -- diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/internal/format/PropertiesXmlFormat.java b/dormant/core/src/main/java/org/apache/tamaya/core/internal/format/PropertiesXmlFormat.java new file mode 100644 index 000..660c092 --- /dev/null +++ b/dormant/core/src/main/java/org/apache/tamaya/core/internal/format/PropertiesXmlFormat.java @@ -0,0 +1,62 @@ +/* + * 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.core.internal.format; + +import org.apache.tamaya.core.resource.Resource; +import org.apache.tamaya.core.properties.ConfigurationFormat; + +import java.io.InputStream; +import java.util.Collections; +import java.util.Map; +import java.util.Properties; +import java.util.logging.Level; +import java.util.logging.Logger; + + +public class PropertiesXmlFormat implements ConfigurationFormat{ + +private final static Logger LOG = Logger.getLogger(PropertiesXmlFormat.class.getName()); + +@Override +public String getFormatName(){ +return "xml-properties"; +} + +@Override +public boolean isAccepted(Resource reso
[32/34] incubator-tamaya git commit: TAMAYA-19: Separated config from property source.
TAMAYA-19: Separated config from property source. Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/30bdbb90 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/30bdbb90 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/30bdbb90 Branch: refs/heads/master Commit: 30bdbb9046272f8bde0eaf8f27c2c6d2f6fe7361 Parents: 158a0f1 Author: anatole Authored: Sat Dec 27 02:10:31 2014 +0100 Committer: Mark Struberg Committed: Sat Dec 27 11:10:12 2014 +0100 -- .../java/org/apache/tamaya/DynamicValue.java| 153 ++- .../org/apache/tamaya/PropertyMapSupplier.java | 37 + .../tamaya/spi/ConfigurationFactorySpi.java | 60 3 files changed, 211 insertions(+), 39 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/30bdbb90/dormant/api/src/main/java/org/apache/tamaya/DynamicValue.java -- diff --git a/dormant/api/src/main/java/org/apache/tamaya/DynamicValue.java b/dormant/api/src/main/java/org/apache/tamaya/DynamicValue.java index 150586f..b8e0cf5 100644 --- a/dormant/api/src/main/java/org/apache/tamaya/DynamicValue.java +++ b/dormant/api/src/main/java/org/apache/tamaya/DynamicValue.java @@ -32,13 +32,14 @@ import java.util.function.Supplier; import java.util.logging.Logger; /** - * A accessor for a single configured value. This can be used to support values that may be reinjected, reconfigured or - * final. - * Implementation Requirements - * Instances of this class must be + * A accessor for a single configured value. This can be used to support values that may change during runtime, reconfigured or + * final. Hereby external code (could be Tamaya configuration listners or client code), can set a new value. Depending on the + * {@link org.apache.tamaya.DynamicValue.UpdatePolicy} the new value is immedeately active or it requires an active commit + * by client code. Similarly an instance also can ignore all later changes to the value. + * Implementation Details + * This class is * - * Serializable - * Immutable + * Serializable, when also the item stored is serializable * Thread safe * */ @@ -50,8 +51,8 @@ public final class DynamicValue implements Serializable{ enum UpdatePolicy{ /** New values are applied immedately and registered listeners are informed about the change. */ IMMEDIATE, -/** New values or not applied, but stored in the newValue property. Explcit call to #update - of #updateAndGet are required to accept the change and inform the listeners about the change. +/** New values or not applied, but stored in the newValue property. Explcit call to #commit + of #commitAndGet are required to accept the change and inform the listeners about the change. */ EXPLCIT, /** @@ -65,17 +66,19 @@ public final class DynamicValue implements Serializable{ } +/** The property name of the entry. */ +private String propertyName; /** - * Converts this value to an {@link java.util.Optional} instance. - * @return an {@link java.util.Optional} instance, never null. + * Policy that defines how new values are applied, be default it is applied initially once, but never updated anymore. */ private UpdatePolicy updatePolicy = UpdatePolicy.NEVER; +/** The current value, never null. */ private transient Optional value; -private transient PropertyChangeEvent newValue; +/** The new value, or null. */ +private transient Optional newValue; +/** List of listeners that listen for changes. */ private transient WeakList> listeners; -public static final DynamicValue EMPTY = new DynamicValue(null); - /** * Returns an empty {@code Optional} instance. No value is present for this * Optional. @@ -88,25 +91,45 @@ public final class DynamicValue implements Serializable{ * @param Type of the non-existent value * @return an empty {@code Optional} */ -public static DynamicValue empty() { -DynamicValue v = (DynamicValue) EMPTY; +public static DynamicValue empty(String propertyName) { +DynamicValue v = new DynamicValue(propertyName, null); return v; } -private DynamicValue(Optional item){ +/** + * Constructor. + * @param propertyName the name of the value in the format {@code :}. + * @param item the initial value. + */ +private DynamicValue(String propertyName, Optional item){ +this.propertyName = Objects.requireNonNull(propertyName); this.value = item; } -public static DynamicValue of(T instance){ -return new DynamicVa
[28/34] incubator-tamaya git commit: first step: move all sources to a 'dormant' directory
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9964c64/api/src/main/java/org/apache/tamaya/spi/DefaultServiceContextProvider.java -- diff --git a/api/src/main/java/org/apache/tamaya/spi/DefaultServiceContextProvider.java b/api/src/main/java/org/apache/tamaya/spi/DefaultServiceContextProvider.java deleted file mode 100644 index e1d1740..000 --- a/api/src/main/java/org/apache/tamaya/spi/DefaultServiceContextProvider.java +++ /dev/null @@ -1,101 +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.spi; - -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * This class implements the (default) {@link ServiceContext} interface and hereby uses the JDK - * {@link java.util.ServiceLoader} to load the services required. - */ -@SuppressWarnings({"rawtypes", "unchecked"}) -class DefaultServiceContextProvider implements ServiceContext { -/** List current services loaded, per class. */ - private final ConcurrentHashMap> servicesLoaded = new ConcurrentHashMap<>(); -/** Singletons. */ -private final ConcurrentHashMap> singletons = new ConcurrentHashMap<>(); - -@Override -public Optional getService(Class serviceType) { - Optional cached = (Optional)singletons.get(serviceType); -if(cached==null) { -List services = getServices(serviceType, Collections.emptyList()); -if (services.isEmpty()) { -cached = Optional.empty(); -} -else{ -cached = Optional.of(services.get(0)); -} -singletons.put(serviceType, cached); -} -return cached; -} - -/** - * Loads and registers services. - * - * @param serviceType - *The service type. - * @param - *the concrete type. - * @param defaultList - *the list current items returned, if no services were found. - * @return the items found, never {@code null}. - */ -@Override -public List getServices(final Class serviceType, final List defaultList) { -List found = (List) servicesLoaded.get(serviceType); -if (found != null) { -return found; -} -return loadServices(serviceType, defaultList); -} - -/** - * Loads and registers services. - * - * @param serviceType The service type. - * @param the concrete type. - * @param defaultList the list current items returned, if no services were found. - * - * @return the items found, never {@code null}. - */ -private List loadServices(final Class serviceType, final List defaultList) { -try { -List services = new ArrayList<>(); -for (T t : ServiceLoader.load(serviceType)) { -services.add(t); -} -if(services.isEmpty()){ -services.addAll(defaultList); -} -services = Collections.unmodifiableList(services); -final List previousServices = (List) servicesLoaded.putIfAbsent(serviceType, (List)services); -return previousServices != null ? previousServices : services; -} catch (Exception e) { - Logger.getLogger(DefaultServiceContextProvider.class.getName()).log(Level.WARNING, - "Error loading services current type " + serviceType, e); -return defaultList; -} -} - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9964c64/api/src/main/java/org/apache/tamaya/spi/PropertyAdapterSpi.java -- diff --git a/api/src/main/java/org/apache/tamaya/spi/PropertyAdapterSpi.java b/api/src/main/java/org/apache/tamaya/spi/PropertyAdapterSpi.java deleted file mode 100644 index a1222a4..000 --- a/api/src/main/java/org/apache/tamaya/spi/PropertyAdapterSpi.java +++ /dev/null @@ -1,72 +0,0 @@ -/
[11/34] incubator-tamaya git commit: first step: move all sources to a 'dormant' directory
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9964c64/dormant/core/src/main/java/org/apache/tamaya/core/internal/resources/io/StringUtils.java -- diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/internal/resources/io/StringUtils.java b/dormant/core/src/main/java/org/apache/tamaya/core/internal/resources/io/StringUtils.java new file mode 100644 index 000..1dfb189 --- /dev/null +++ b/dormant/core/src/main/java/org/apache/tamaya/core/internal/resources/io/StringUtils.java @@ -0,0 +1,1165 @@ +/* + * Copyright 2002-2014 the original author or authors. + * + * Licensed 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.core.internal.resources.io; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.StringTokenizer; + +/** +* Miscellaneous {@link String} utility methods. +* +* Mainly for internal use within the framework; consider +* http://jakarta.apache.org/commons/lang/";>Jakarta's Commons Lang +* for a more comprehensive suite current String utilities. +* +* This class delivers some simple functionality that should really +* be provided by the core Java {@code String} and {@link StringBuilder} +* classes, such as the ability to {@code replace} all occurrences current a given +* substring in a target string. It also provides easy-to-use methods to convert +* between delimited strings, such as CSV strings, and collections and arrays. +* +* @author Rod Johnson +* @author Juergen Hoeller +* @author Keith Donald +* @author Rob Harrop +* @author Rick Evans +* @author Arjen Poutsma +* @since 16 April 2001 +*/ +class StringUtils { + + private static final String FOLDER_SEPARATOR = "/"; + + private static final String WINDOWS_FOLDER_SEPARATOR = "\\"; + + private static final String TOP_PATH = ".."; + + private static final String CURRENT_PATH = "."; + +// private static final char EXTENSION_SEPARATOR = '.'; +// + +private StringUtils(){} + +// //- +// // General convenience methods for working with Strings +// //- +// +// /** +// * Check whether the given String is empty. +// * This method accepts any Object as an argument, comparing it to +// * {@code null} and the empty String. As a consequence, this method +// * will never return {@code true} for a non-null non-String object. +// * The Object signature is useful for general attribute handling code +// * that commonly deals with Strings but generally has to iterate over +// * Objects since attributes may e.g. be primitive keys objects as well. +// * @param str the candidate String +// * @since 3.2.1 +// */ +// public static boolean isEmpty(Object str) { +// return (str == null || "".equals(str)); +// } + + /** +* Check that the given CharSequence is neither {@code null} nor current length 0. +* Note: Will return {@code true} for a CharSequence that purely consists current whitespace. +* +* StringUtils.hasLength(null) = false +* StringUtils.hasLength("") = false +* StringUtils.hasLength(" ") = true +* StringUtils.hasLength("Hello") = true +* +* @param str the CharSequence to check (may be {@code null}) +* @return {@code true} if the CharSequence is not null and has length +*/ + public static boolean hasLength(CharSequence str) { + return (str != null && str.length() > 0); + } + +// /** +// * Check that the given String is neither {@code null} nor current length 0. +// * Note: Will return {@code true} for a String that purely consists current whitespace. +// * @param str the String to check (may be {@code null}) +// * @return {@code true} if the String is not null and has length +// * @see #hasLength(CharSequence) +// */ +// public static boolean hasLength(String str) { +// return hasLength((CharSequence) str); +// } + + /** +* Check whether the given CharSequence has actual text. +* More specifically, returns {@code true} if the string not {@code null}, +* its length is great
[02/34] incubator-tamaya git commit: add various other committers
add various other committers Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/e13cb283 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/e13cb283 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/e13cb283 Branch: refs/heads/master Commit: e13cb28348bfee13e2bf8da7a55d979e0fffd286 Parents: 574d5bd Author: Mark Struberg Authored: Sat Dec 27 10:19:27 2014 +0100 Committer: Mark Struberg Committed: Sat Dec 27 11:10:11 2014 +0100 -- pom.xml | 34 ++ 1 file changed, 34 insertions(+) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/e13cb283/pom.xml -- diff --git a/pom.xml b/pom.xml index 8c24c74..64b6a49 100644 --- a/pom.xml +++ b/pom.xml @@ -150,6 +150,40 @@ under the License. + + +struberg +Mark Struberg +struberg at apache.org + +PMC + ++1 + + + +gpetracek +Gerhard Petracek +gpetracek at apache.org +IRIAN.at, Austria +http://www.irian.at/ + +PMC + ++1 + + + +johndament +John D. Ament +johndament at apache.org + +PMC + +-5 + + +
[08/34] incubator-tamaya git commit: first step: move all sources to a 'dormant' directory
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9964c64/dormant/core/src/test/java/org/apache/tamaya/samples/annotations/ConfiguredTest.java -- diff --git a/dormant/core/src/test/java/org/apache/tamaya/samples/annotations/ConfiguredTest.java b/dormant/core/src/test/java/org/apache/tamaya/samples/annotations/ConfiguredTest.java new file mode 100644 index 000..112f479 --- /dev/null +++ b/dormant/core/src/test/java/org/apache/tamaya/samples/annotations/ConfiguredTest.java @@ -0,0 +1,65 @@ +/* + * 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.samples.annotations; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assume.assumeTrue; + +import org.apache.tamaya.Configuration; +import org.junit.Test; + +/** + * Created by Anatole on 08.09.2014. + */ +public class ConfiguredTest { +private static final String OS = System.getProperty("os.name").toLowerCase(); + +@Test +public void testTemplateOnAllSystems(){ +ConfigTemplate template = Configuration.createTemplate(ConfigTemplate.class); +assertNotNull(template); +assertEquals(2233, template.int2()); +assertEquals(Integer.valueOf(5), template.int1()); +assertNotNull(System.getProperty("java.version"), template.javaVersion2()); +} + +@Test +public void testTemplateWithEnvironmentVariableOnWindows(){ +assumeTrue(OS.contains("win")); +ConfigTemplate template = Configuration.createTemplate(ConfigTemplate.class); +assertNotNull(template.computerName()); +} + +@Test +public void testTemplateWithEnvironmentVariableOnMac(){ +assumeTrue(OS.contains("mac")); +ConfigTemplate template = Configuration.createTemplate(ConfigTemplate.class); +assertNotNull(template.homeDir()); +} + +@Test +public void testTemplateWithEnvironmentVariableOnUnixoidSystem(){ +assumeTrue(OS.contains("nix") || OS.contains("nux") || OS.indexOf("aix") > 0); + +ConfigTemplate template = Configuration.createTemplate(ConfigTemplate.class); +assertNotNull(template.homeDir()); +} + +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9964c64/dormant/core/src/test/java/org/apache/tamaya/samples/devops/DeploymentProvider.java -- diff --git a/dormant/core/src/test/java/org/apache/tamaya/samples/devops/DeploymentProvider.java b/dormant/core/src/test/java/org/apache/tamaya/samples/devops/DeploymentProvider.java new file mode 100644 index 000..18e6705 --- /dev/null +++ b/dormant/core/src/test/java/org/apache/tamaya/samples/devops/DeploymentProvider.java @@ -0,0 +1,43 @@ +/* + * 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.samples.devops; + + +public class DeploymentProvider { + + public static void main(String[] args) { + // ConfigurationServiceSpi service = JavaConfig.getConfigService(); + // // Main configuration done by ServiceLoader based services and + // // custom implemented system or environment properties, mechanisms + // System.out.println(service.getCurrentContext()); + // // Access default configuration for current environment + // Defa
[14/34] incubator-tamaya git commit: first step: move all sources to a 'dormant' directory
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9964c64/dormant/core/src/main/java/org/apache/tamaya/core/internal/resources/AntPathFileResolver.java -- diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/internal/resources/AntPathFileResolver.java b/dormant/core/src/main/java/org/apache/tamaya/core/internal/resources/AntPathFileResolver.java new file mode 100644 index 000..0645d70 --- /dev/null +++ b/dormant/core/src/main/java/org/apache/tamaya/core/internal/resources/AntPathFileResolver.java @@ -0,0 +1,61 @@ +/* + * 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.core.internal.resources; + +import org.apache.tamaya.core.internal.resources.io.PathMatchingResourcePatternResolver; +import org.apache.tamaya.core.spi.PathResolver; +import org.apache.tamaya.core.resource.Resource; + +import java.io.IOException; +import java.util.*; +import java.util.logging.Level; +import java.util.logging.Logger; + + +public class AntPathFileResolver implements PathResolver { + +private static final Logger LOG = Logger.getLogger(AntPathFileResolver.class.getName()); + +@Override +public String getResolverId(){ +return "file"; +} + +@Override +public Collection resolve(ClassLoader classLoader, Collection expressions){ +PathMatchingResourcePatternResolver resolver = PathMatchingResourcePatternResolver.of(classLoader); +List result = new ArrayList<>(); +expressions.forEach((expression) -> { +try { +Resource[] resources = resolver.getResources(expression); +for (Resource res : resources) { +try { +result.add(res); +} catch (Exception e) { +LOG.log(Level.FINE, "URI could not be extracted from Resource: " + res.toString(), e); +} +} +} +catch(IOException e){ +LOG.log(Level.FINE, "Failed to load resource expression: " + expression, e); +} +}); +return result; +} +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9964c64/dormant/core/src/main/java/org/apache/tamaya/core/internal/resources/DefaultResourceLoader.java -- diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/internal/resources/DefaultResourceLoader.java b/dormant/core/src/main/java/org/apache/tamaya/core/internal/resources/DefaultResourceLoader.java new file mode 100644 index 000..9f2a8cb --- /dev/null +++ b/dormant/core/src/main/java/org/apache/tamaya/core/internal/resources/DefaultResourceLoader.java @@ -0,0 +1,81 @@ +/* + * 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.core.internal.resources; + +import org.apache.tamaya.core.spi.PathResolver; +import org.apache.tamaya.core.resource.Resource; +import org.apache.tamaya.core.resource.ResourceLoader; + +import org.apache.tamaya.spi.ServiceContext; + +import java.util.*; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.stream.Collectors; + +/** + * Singleton accessor to access registered reader mechanism. + */ +public class DefaultResourceLoader implements ResourceLoader{ + +private static final Logger LOG = Logger.getLogge
[34/34] incubator-tamaya git commit: remove stuff already got moved to dormant
remove stuff already got moved to dormant Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/d9b2cf41 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/d9b2cf41 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/d9b2cf41 Branch: refs/heads/master Commit: d9b2cf4187a8e688060e128c937f2bd72a840ca3 Parents: 278a6c6 Author: Mark Struberg Authored: Sat Dec 27 11:10:54 2014 +0100 Committer: Mark Struberg Committed: Sat Dec 27 11:10:54 2014 +0100 -- .../java/org/apache/tamaya/DynamicValue.java| 500 --- .../org/apache/tamaya/PropertyMapSupplier.java | 37 -- .../tamaya/spi/ConfigurationFactorySpi.java | 60 --- 3 files changed, 597 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9b2cf41/api/src/main/java/org/apache/tamaya/DynamicValue.java -- diff --git a/api/src/main/java/org/apache/tamaya/DynamicValue.java b/api/src/main/java/org/apache/tamaya/DynamicValue.java deleted file mode 100644 index b8e0cf5..000 --- a/api/src/main/java/org/apache/tamaya/DynamicValue.java +++ /dev/null @@ -1,500 +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; - -import java.beans.PropertyChangeEvent; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; -import java.lang.ref.WeakReference; -import java.util.*; -import java.util.function.Consumer; -import java.util.function.Function; -import java.util.function.Predicate; -import java.util.function.Supplier; -import java.util.logging.Logger; - -/** - * A accessor for a single configured value. This can be used to support values that may change during runtime, reconfigured or - * final. Hereby external code (could be Tamaya configuration listners or client code), can set a new value. Depending on the - * {@link org.apache.tamaya.DynamicValue.UpdatePolicy} the new value is immedeately active or it requires an active commit - * by client code. Similarly an instance also can ignore all later changes to the value. - * Implementation Details - * This class is - * - * Serializable, when also the item stored is serializable - * Thread safe - * - */ -public final class DynamicValue implements Serializable{ - -/** - * Policy to control how new values are applied to this instance. - */ -enum UpdatePolicy{ -/** New values are applied immedately and registered listeners are informed about the change. */ -IMMEDIATE, -/** New values or not applied, but stored in the newValue property. Explcit call to #commit - of #commitAndGet are required to accept the change and inform the listeners about the change. - */ -EXPLCIT, -/** - * New values are always immedately discarded. - */ -NEVER, -/** - * Changes are logged before the are discarded. - */ -LOG_AND_DISCARD -} - - -/** The property name of the entry. */ -private String propertyName; -/** - * Policy that defines how new values are applied, be default it is applied initially once, but never updated anymore. - */ -private UpdatePolicy updatePolicy = UpdatePolicy.NEVER; -/** The current value, never null. */ -private transient Optional value; -/** The new value, or null. */ -private transient Optional newValue; -/** List of listeners that listen for changes. */ -private transient WeakList> listeners; - -/** - * Returns an empty {@code Optional} instance. No value is present for this - * Optional. - * - * @apiNote Though it may be tempting to do so, avoid testing if an object - * is empty by comparing with {@code ==} against instances returned by - * {@code Option.empty()}. There is no guarantee that it is a singleton. - * Instead
[20/34] incubator-tamaya git commit: first step: move all sources to a 'dormant' directory
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9964c64/core/src/main/java/org/apache/tamaya/core/spi/ConfigurationProviderSpi.java -- diff --git a/core/src/main/java/org/apache/tamaya/core/spi/ConfigurationProviderSpi.java b/core/src/main/java/org/apache/tamaya/core/spi/ConfigurationProviderSpi.java deleted file mode 100644 index e60a53d..000 --- a/core/src/main/java/org/apache/tamaya/core/spi/ConfigurationProviderSpi.java +++ /dev/null @@ -1,46 +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.core.spi; - -import org.apache.tamaya.Configuration; - -/** -* This configuration provider SPI allows to register the effective factory logic to of and manage a configuration -* instance. Hereby the qualifiers determine the type current configuration. By default -*/ -public interface ConfigurationProviderSpi{ - -/** - * Returns the name current the configuration provided. - * @return the name current the configuration provided, not empty. - */ -String getConfigName(); - -/** - * Get the {@link Configuration}, if available. - * @return according configuration, or null, if none is available for the given environment. - */ -Configuration getConfiguration(); - -/** - * Reloads the provider for the current context. - */ -void reload(); - -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9964c64/core/src/main/java/org/apache/tamaya/core/spi/DefaultServiceComparator.java -- diff --git a/core/src/main/java/org/apache/tamaya/core/spi/DefaultServiceComparator.java b/core/src/main/java/org/apache/tamaya/core/spi/DefaultServiceComparator.java deleted file mode 100644 index 2fb719c..000 --- a/core/src/main/java/org/apache/tamaya/core/spi/DefaultServiceComparator.java +++ /dev/null @@ -1,85 +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.core.spi; - -import java.util.*; - -/** - * Simple comparator based on a Collection of {@link OrdinalProvider} instances. - */ -final class DefaultServiceComparator implements Comparator{ - -/** - * List of ordinal providers loaded. - */ -private List ordinalProviders = new ArrayList<>(); - -DefaultServiceComparator(Collection providers){ -ordinalProviders.addAll(Objects.requireNonNull(providers)); -ordinalProviders.sort(this::compare); -} - -private int compare(OrdinalProvider provider1, OrdinalProvider provider2){ -int o1 = getOrdinal(provider1); -int o2 = getOrdinal(provider2); -int order = o1-o2; -if(order < 0){ -return -1; -} -else if(order > 0){ -return 1; -} -return 0; -} - -private int getOrdinal(OrdinalProvider provider){ -if(provider instanceof Orderable){ -return ((Orderable)provider).order(); -} -return 0; -} - -public int getOrdinal(Object service){ -for(OrdinalProvider provider: ordinalProviders){ -OptionalInt ord = provider.getOrdinal(service.getClass()); -if(ord.isPresent()){ -return ord.getAsInt(); -} -} -if(service instanceof Orderable){ -return ((Orderable)service).order(); -
[16/34] incubator-tamaya git commit: first step: move all sources to a 'dormant' directory
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9964c64/dormant/core/src/main/java/org/apache/tamaya/core/config/ConfigurationBuilder.java -- diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/config/ConfigurationBuilder.java b/dormant/core/src/main/java/org/apache/tamaya/core/config/ConfigurationBuilder.java new file mode 100644 index 000..f8b1c95 --- /dev/null +++ b/dormant/core/src/main/java/org/apache/tamaya/core/config/ConfigurationBuilder.java @@ -0,0 +1,374 @@ +/* +* 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.core.config; + +import java.net.URL; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.function.BiFunction; +import java.util.function.Predicate; +import java.util.function.Supplier; + +import org.apache.tamaya.Configuration; +import org.apache.tamaya.PropertySource; +import org.apache.tamaya.core.properties.AggregationPolicy; +import org.apache.tamaya.core.properties.PropertySourceBuilder; + +/** +* Builder for assembling non trivial {@link org.apache.tamaya.Configuration} instances. +*/ +public final class ConfigurationBuilder { + +/** + * The final meta info to be used, or null, if a default should be generated. + */ +private PropertySourceBuilder builderDelegate; + +/** + * Private singleton constructor. + */ +private ConfigurationBuilder(String name) { +this.builderDelegate = PropertySourceBuilder.of(name); +} + +/** + * Private singleton constructor. + */ +private ConfigurationBuilder(String name, PropertySource source) { +this.builderDelegate = PropertySourceBuilder.of(name, source); +} + +/** + * Private singleton constructor. + */ +private ConfigurationBuilder(PropertySource source) { +this.builderDelegate = PropertySourceBuilder.of(source); +} + + +/** + * Creates a new builder instance. + * + * @param provider the base provider to be used, not null. + * @return a new builder instance, never null. + */ +public static ConfigurationBuilder of(PropertySource provider) { +return new ConfigurationBuilder(provider); +} + +/** + * Creates a new builder instance. + * + * @param name the provider name, not null. + * @return a new builder instance, never null. + */ +public static ConfigurationBuilder of(String name) { +return new ConfigurationBuilder(Objects.requireNonNull(name)); +} + +/** + * Creates a new builder instance. + * + * @return a new builder instance, never null. + */ +public static ConfigurationBuilder of() { +return new ConfigurationBuilder(""); +} + + + + +/** + * Sets the aggregation policy to be used, when adding additional property sets. The policy will + * be active a slong as the builder is used or it is reset to another keys. + * + * @param aggregationPolicy the aggregation policy, not null. + * @return the builder for chaining. + */ +public ConfigurationBuilder withAggregationPolicy(AggregationPolicy aggregationPolicy) { +this.builderDelegate.withAggregationPolicy(aggregationPolicy); +return this; +} + +/** + * Sets the meta info to be used for the next operation. + * + * @param name the name, not null. + * @return the builder for chaining. + */ +public ConfigurationBuilder withName(String name) { +this.builderDelegate.withName(name); +return this; +} + +/** + * Adds the given providers with the current active {@link AggregationPolicy}. By + * default {@link AggregationPolicy#OVERRIDE} is used. + * @see #withAggregationPolicy(AggregationPolicy) + * @param providers providers to be added, not null. + * @return the builder for chaining. + */ +public ConfigurationBuilder addProviders(PropertySource... providers) { +this.builderDelegate.addProviders(providers); +return this; +} + +/** + * Adds the given providers with the current active {@link AggregationPolicy}. By + * default {@link
[21/34] incubator-tamaya git commit: first step: move all sources to a 'dormant' directory
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9964c64/core/src/main/java/org/apache/tamaya/core/properties/ContextualPropertySource.java -- diff --git a/core/src/main/java/org/apache/tamaya/core/properties/ContextualPropertySource.java b/core/src/main/java/org/apache/tamaya/core/properties/ContextualPropertySource.java deleted file mode 100644 index 6290706..000 --- a/core/src/main/java/org/apache/tamaya/core/properties/ContextualPropertySource.java +++ /dev/null @@ -1,142 +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.core.properties; - -import org.apache.tamaya.*; - -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; -import java.util.function.Supplier; - -/** - * Created by Anatole on 12.04.2014. - */ -class ContextualPropertySource implements PropertySource { - -private volatile Map cachedMaps = new ConcurrentHashMap<>(); - -private Supplier mapSupplier; -private Supplier isolationKeySupplier; -private String name; - - -/** - * Creates a new contextual PropertyMap. Contextual maps delegate to different instances current PropertyMap depending - * on the keys returned fromMap the isolationP - * - * @param mapSupplier - * @param isolationKeySupplier - */ -public ContextualPropertySource(String name, Supplier mapSupplier, Supplier isolationKeySupplier){ -this.name = Optional.ofNullable(name).orElse(""); -Objects.requireNonNull(mapSupplier); -Objects.requireNonNull(isolationKeySupplier); -this.mapSupplier = mapSupplier; -this.isolationKeySupplier = isolationKeySupplier; -} - -/** - * This method provides the contextual Map for the current environment. Hereby, ba default, for each different - * key returned by the #isolationKeySupplier a separate PropertyMap instance is acquired fromMap the #mapSupplier. - * If the map supplier returns an instance it is cached in the local #cachedMaps. - * - * @return the current contextual PropertyMap. - */ -protected PropertySource getContextualMap(){ -String environmentKey = this.isolationKeySupplier.get(); -if(environmentKey == null){ -return PropertySource.EMPTY_PROPERTYSOURCE; -} -PropertySource map = this.cachedMaps.get(environmentKey); -if(map == null){ -synchronized(cachedMaps){ -map = this.cachedMaps.get(environmentKey); -if(map == null){ -map = this.mapSupplier.get(); -if(map == null){ -return PropertySource.EMPTY_PROPERTYSOURCE; -} -this.cachedMaps.put(environmentKey, map); -} -} -} -return map; -} - -@Override -public Map getProperties(){ -return getContextualMap().getProperties(); -} - -@Override -public String getName(){ -return this.name; -} - -@Override -public Optional get(String key){ -return getContextualMap().get(key); -} - -/** - * Access a cached PropertyMap. - * - * @param key the target environment key as returned by the environment key supplier, not null. - * @return the corresponding PropertyMap, or null. - */ -public PropertySource getCachedMap(String key){ -return this.cachedMaps.get(key); -} - -/** - * Access the set current currently loaded/cached maps. - * - * @return the set current cached map keys, never null. - */ -public Set getCachedMapKeys(){ -return this.cachedMaps.keySet(); -} - -/** - * Access the supplier for environment key, determining map isolation. - * - * @return the environment key supplier instance, not null. - */ -public Supplier getIsolationKeySupplier(){ -return this.isolationKeySupplier; -} - -/** - * Access the supplier for new PropertyMap instances. - * - * @return the PropertyMap supplier instance, not null. - */ -public Supplier getMapSupplier(){ -
[09/34] incubator-tamaya git commit: first step: move all sources to a 'dormant' directory
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9964c64/dormant/core/src/main/java/org/apache/tamaya/core/spi/ConfigurationFormatSpi.java -- diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/spi/ConfigurationFormatSpi.java b/dormant/core/src/main/java/org/apache/tamaya/core/spi/ConfigurationFormatSpi.java new file mode 100644 index 000..1c41820 --- /dev/null +++ b/dormant/core/src/main/java/org/apache/tamaya/core/spi/ConfigurationFormatSpi.java @@ -0,0 +1,61 @@ +/* + * 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.core.spi; + +import org.apache.tamaya.core.properties.ConfigurationFormat; +import org.apache.tamaya.core.resource.Resource; + +import java.util.Collection; + +/** + * Created by Anatole on 17.09.2014. + */ +public interface ConfigurationFormatSpi { +/** + * Access a {@link org.apache.tamaya.core.properties.ConfigurationFormat}. + * + * @param formatName the format name + * @return the corresponding {@link org.apache.tamaya.core.properties.ConfigurationFormat}, or {@code null}, if + * not available for the given environment. + */ +ConfigurationFormat getFormat(String formatName); + +/** + * Get a collection current the keys current the registered {@link org.apache.tamaya.core.properties.ConfigurationFormat} instances. + * + * @return a collection current the keys current the registered {@link ConfigurationFormat} instances. + */ +Collection getFormatNames(); + +/** + * Evaluate the matching format for a given resource. + * + * @param resource The resource + * @return a matching configuration format, or {@code null} if no matching format could be determined. + */ +ConfigurationFormat getFormat(Resource resource); + +default ConfigurationFormat getPropertiesFormat(){ +return getFormat("properties"); +} + +default ConfigurationFormat getXmlPropertiesFormat(){ +return getFormat("xml-properties"); +} +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/d9964c64/dormant/core/src/main/java/org/apache/tamaya/core/spi/ConfigurationProviderSpi.java -- diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/spi/ConfigurationProviderSpi.java b/dormant/core/src/main/java/org/apache/tamaya/core/spi/ConfigurationProviderSpi.java new file mode 100644 index 000..e60a53d --- /dev/null +++ b/dormant/core/src/main/java/org/apache/tamaya/core/spi/ConfigurationProviderSpi.java @@ -0,0 +1,46 @@ +/* + * 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.core.spi; + +import org.apache.tamaya.Configuration; + +/** +* This configuration provider SPI allows to register the effective factory logic to of and manage a configuration +* instance. Hereby the qualifiers determine the type current configuration. By default +*/ +public interface ConfigurationProviderSpi{ + +/** + * Returns the name current the configuration provided. + * @return the name current the configuration provided, not empty. + */ +String getConfigName(); + +/** + * Get the {@link Configuration}, if available. + * @return according configuration, or null, if none is available for the given environment. + */ +Configuration getConfiguration();
[01/34] incubator-tamaya git commit: fix gitignore
Repository: incubator-tamaya Updated Branches: refs/heads/master 784884c79 -> d9b2cf418 fix gitignore Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/64f7cfb0 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/64f7cfb0 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/64f7cfb0 Branch: refs/heads/master Commit: 64f7cfb0f631c36445cf3d8e043473025a8456b3 Parents: e13cb28 Author: Mark Struberg Authored: Sat Dec 27 10:21:13 2014 +0100 Committer: Mark Struberg Committed: Sat Dec 27 11:10:11 2014 +0100 -- .gitignore | 15 +++ 1 file changed, 3 insertions(+), 12 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/64f7cfb0/.gitignore -- diff --git a/.gitignore b/.gitignore index 40a779f..b97b7b5 100644 --- a/.gitignore +++ b/.gitignore @@ -9,15 +9,6 @@ release.properties *.log *~ .DS_Store -modules/.project -modules/.settings/ -modules/integration/.project -modules/integration/.settings/ -modules/integration/cdi/.classpath -modules/integration/cdi/.project -modules/integration/cdi/.settings/ -modules/metamodels/.project -modules/metamodels/.settings/ -modules/metamodels/simple/.classpath -modules/metamodels/simple/.project -modules/metamodels/simple/.settings/ +.project +.settings +.classpath
[30/34] incubator-tamaya git commit: move intermediately changed stuff to dormant as well
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/278a6c68/dormant/core/src/main/java/org/apache/tamaya/core/properties/PropertySourceFunctions.java -- diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/properties/PropertySourceFunctions.java b/dormant/core/src/main/java/org/apache/tamaya/core/properties/PropertySourceFunctions.java new file mode 100644 index 000..5fcf895 --- /dev/null +++ b/dormant/core/src/main/java/org/apache/tamaya/core/properties/PropertySourceFunctions.java @@ -0,0 +1,65 @@ +/* + * 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.core.properties; + +import org.apache.tamaya.PropertySource; + +import java.util.*; +import java.util.function.Function; +import java.util.function.Predicate; +import java.util.function.UnaryOperator; +import java.util.stream.Collectors; + +/** + * Accessor that provides useful functions along with configuration. + */ +public final class PropertySourceFunctions { +/** + * Private singleton constructor. + */ +private PropertySourceFunctions() { +} + +/** + * Creates a ConfigOperator that creates a Configuration containing only keys + * that are contained in the given area (non recursive). Hereby + * the area key is stripped away fromMap the resulting key. + * + * @param areaKey the area key, not null + * @param mappedAreaKey the target key, not null + * @return the area configuration, with the areaKey stripped away. + */ +public static UnaryOperator mapArea(String areaKey, String mappedAreaKey) { +return mapKeys(key -> key.startsWith(areaKey + '.') ? +mappedAreaKey + key.substring(areaKey.length()) : key); +} + +/** + * Creates a {@link java.util.function.UnaryOperator} that creates a {@link org.apache.tamaya.Configuration} that maps any keys as + * defined by the {@code keyMapper} given. If the {@code keyMapper} returns + * {@code null} for a keys, it is removed from the resulting map. + * + * @param keyMapper the key mapper, not null + * @return the area configuration, with the areaKey stripped away. + */ +public static UnaryOperator mapKeys(UnaryOperator keyMapper) { +return (c) -> new MappedPropertySource(c, keyMapper); +} + +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/278a6c68/dormant/core/src/main/resources/META-INF/services/org.apache.tamaya.core.properties.ConfigurationFormat -- diff --git a/dormant/core/src/main/resources/META-INF/services/org.apache.tamaya.core.properties.ConfigurationFormat b/dormant/core/src/main/resources/META-INF/services/org.apache.tamaya.core.properties.ConfigurationFormat new file mode 100644 index 000..7aa2407 --- /dev/null +++ b/dormant/core/src/main/resources/META-INF/services/org.apache.tamaya.core.properties.ConfigurationFormat @@ -0,0 +1,21 @@ +# +# 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.core.internal.format.PropertiesFormat +org.apache.tamaya.core.internal.format.PropertiesXmlFormat +org.apache.tamaya.core.internal.format.IniFormat \ No newline at end of file
[33/34] incubator-tamaya git commit: Made DynamicValue a class.similar to Optional, but serializable.
Made DynamicValue a class.similar to Optional, but serializable. Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/158a0f1d Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/158a0f1d Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/158a0f1d Branch: refs/heads/master Commit: 158a0f1df8c2a08877323b688b5ae4bfa64b8034 Parents: 64f7cfb Author: anatole Authored: Fri Dec 26 14:10:17 2014 +0100 Committer: Mark Struberg Committed: Sat Dec 27 11:10:12 2014 +0100 -- .../java/org/apache/tamaya/DynamicValue.java| 425 +++ 1 file changed, 425 insertions(+) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/158a0f1d/dormant/api/src/main/java/org/apache/tamaya/DynamicValue.java -- diff --git a/dormant/api/src/main/java/org/apache/tamaya/DynamicValue.java b/dormant/api/src/main/java/org/apache/tamaya/DynamicValue.java new file mode 100644 index 000..150586f --- /dev/null +++ b/dormant/api/src/main/java/org/apache/tamaya/DynamicValue.java @@ -0,0 +1,425 @@ +/* + * 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; + +import java.beans.PropertyChangeEvent; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.lang.ref.WeakReference; +import java.util.*; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Predicate; +import java.util.function.Supplier; +import java.util.logging.Logger; + +/** + * A accessor for a single configured value. This can be used to support values that may be reinjected, reconfigured or + * final. + * Implementation Requirements + * Instances of this class must be + * + * Serializable + * Immutable + * Thread safe + * + */ +public final class DynamicValue implements Serializable{ + +/** + * Policy to control how new values are applied to this instance. + */ +enum UpdatePolicy{ +/** New values are applied immedately and registered listeners are informed about the change. */ +IMMEDIATE, +/** New values or not applied, but stored in the newValue property. Explcit call to #update + of #updateAndGet are required to accept the change and inform the listeners about the change. + */ +EXPLCIT, +/** + * New values are always immedately discarded. + */ +NEVER, +/** + * Changes are logged before the are discarded. + */ +LOG_AND_DISCARD +} + + +/** + * Converts this value to an {@link java.util.Optional} instance. + * @return an {@link java.util.Optional} instance, never null. + */ +private UpdatePolicy updatePolicy = UpdatePolicy.NEVER; +private transient Optional value; +private transient PropertyChangeEvent newValue; +private transient WeakList> listeners; + +public static final DynamicValue EMPTY = new DynamicValue(null); + +/** + * Returns an empty {@code Optional} instance. No value is present for this + * Optional. + * + * @apiNote Though it may be tempting to do so, avoid testing if an object + * is empty by comparing with {@code ==} against instances returned by + * {@code Option.empty()}. There is no guarantee that it is a singleton. + * Instead, use {@link #isPresent()}. + * + * @param Type of the non-existent value + * @return an empty {@code Optional} + */ +public static DynamicValue empty() { +DynamicValue v = (DynamicValue) EMPTY; +return v; +} + +private DynamicValue(Optional item){ +this.value = item; +} + +public static DynamicValue of(T instance){ +return new DynamicValue(Optional.of(instance)); +} + +public static DynamicValue ofNullable(T value){ +return value == nu
[03/34] incubator-tamaya git commit: add my Apache pgp KEY
add my Apache pgp KEY Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/574d5bda Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/574d5bda Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/574d5bda Branch: refs/heads/master Commit: 574d5bdaadc687ca63b8e5d8a05e6f9e23ca6a8a Parents: fbd1387 Author: Mark Struberg Authored: Sat Dec 27 10:16:37 2014 +0100 Committer: Mark Struberg Committed: Sat Dec 27 11:10:11 2014 +0100 -- keys/KEYS | 58 ++ 1 file changed, 58 insertions(+) -- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/574d5bda/keys/KEYS -- diff --git a/keys/KEYS b/keys/KEYS index 7d6f366..f18c334 100644 --- a/keys/KEYS +++ b/keys/KEYS @@ -71,3 +71,61 @@ jScOY1axIZ92b9A2jHq7hjL0fZ6XBDajjOETki7zFv95QSdUBcs5Y6sc2epfUfcY Ig== =bvSZ -END PGP PUBLIC KEY BLOCK- + + +pub 4096R/2FDB81B1 2010-02-01 +uid Mark Struberg (Apache) +sub 4096R/F24C5214 2010-02-01 + +-BEGIN PGP PUBLIC KEY BLOCK- +Version: GnuPG v1.4.9 (GNU/Linux) + +mQINBEtnVXUBEACz2CXck8rFZsqlmtZrwySHkCKdKQ3dO5fyya3ScYRofIS0OVi0 +BwpWyVfzezq2jl4AkjEFGS/ja0shnr4hg6tWU6w3obZ4S8dQMyPm8x5kSTxj28mn +lkNnR1mBr7S13n33ZtA6f5c1cPu4zMqzKEFvsqVoBwD/ru5WOB0buwGi9mG173Vi +tkTi1MtzQ4aaIo8XiJyLsm/StTq1ylU1vfqtyFDZJUzoakdYSiA4NVfVFUL2LMTl +gPq3hpWNZjVm41+YKWuzjIJ/lidH2Y2TmjivgtQToVbHMV3sHn/PtDKw91S6Ls2q +kSLUm/Bs19H4ZGPMhWI1MnQnQiuMMPYvqIddIh2SIog2bSowPZz2FkZxrw04ej/t +tYrSIfiR3sRegmWoeo/FCLYVWZ32mw5L8Tw0npHg3BSi0v5FoNd/GiD1Y6//Usy3 +tQVFUI1zkh/PSWVImAgmgoE3qhcIjzlkVutsFY4NGr6LH2sUpIJBi/ECy0R38rLg +sg5pjUPhs7QexH5M9FxshI+yDsvPOTeUjvpHysvemHhVJyPQSmpOa16ONFmx5xvz +d90FmxKfaJJvmVMvNmGMdhdAzaAJ3XomFEJZDKfyBJoOJSoNvdOQRNBUt7aKEEKb +3BGypY2bzr0C3WxggpywPmlD1xDohurx/b3dLFoK39hmFiTek4db0tin1QARAQAB +tCxNYXJrIFN0cnViZXJnIChBcGFjaGUpIDxzdHJ1YmVyZ0BhcGFjaGUub3JnPokC +NwQTAQoAIQUCS2dVdQIbAwULCQgHAwUVCgkICwUWAgMBAAIeAQIXgAAKCRDpEoeC +L9uBsTzGD/41kZMlyyzg6gsrQgDZPxzxVbsFWGqareqElLZ8MVTo8mEt9cKwS71T +dHaEXO1BBukqPWpRjWp1TepRZ1i4PNscDwtDcGkv2lpaQICwo43MNW9GFFRJaGCr +Ry4Tpov5yYwdbP1cdqNS+Q1TtwZcCTFiEL1xAAnR3nY2BzfdpL/fTXzHggmuLtRD +OeiIPQrp+NaVzhk994t1MQ5wjevoZYGvH6oV6hQ3Nr4t0rA93F5fKb9vJiz3SnJU +a97uPANCYzhYSb6IzNICLfSQCKi5AoK7fjENCTaq2Uqsvkl2hVZWmGYmJLRAZDFE +5RNE2OGU+x7hVCQnD1r/a0rnWpdODqM2EkqDpxkKkH5pJvzPepLeSYv4KmRu3+89 +ljFtBM01pt9TPoBYRE2/sODZUFs+ct+AaxatHjs46U1Ks6g0ah7YmUnolENqsuF+ +grpLtrCwgKrwfY3N4KHIMUnmq4Wmh0ooiL2o/DN0EciA2JDm+3xgK1giAXvzCbDS +oHgJ/SJ6DAUtSb+t74Gd4GRvpDMoo7u82A7tZj/3h5cjmyuwms1uJc40D6v4/Ljp +sbltrrWcJ/E1TokJlFT2QpRBJkMixHO4aaS7olOMJqI6/wrrzq7KjZOUfD3KwhDL +DolhmshiFw1tx1sloa7RlibHAxxLKkcc+DVGVr1MBf4xus38QZT9R7kCDQRLZ1V1 +ARAAstCgZH1oA9RwRaBJ21qKeOzOaB3iOQynBdjeDJGiaKuMQWgv+NpLCh+fqe8t +QSj0j40fphOJq0dTNSqNExLd4P5hEhUXALkFWGmc8vki5InXkeUc8eMvvAILa8qX +jXsR5Y13TES1hZGhAUQ9KPirJubrnIWOexoBndW6gEAS6N1awoQEFsTcB7wrV+Ae +7pBQHH2CrtvFYXePNjiWAHdV63uOTXkM8elozBMa0cIVznv4sgKzs9sdJlg9Q+5E +iU6zLmEL+zsVgtUczAx5x9nIMRZsqgxlysalqj9GQHlnv49JcR4wyjHSLvuxUVgy +YOOsRzpbizjyBZe3w+bo/J4K9covXmLIIHEaNm127Xq/pT/aB79cmRmyzXgD4EQ2 +AhP82+c/UVr5GO8PBqPG8pydwMXpT1jzgTmMOwvEhj2hOtqA/HE5cEIpiwgcJOrB +g2C1irnApXFTmA6xtPGAZjCAaHHouelNepA9T8x2LvzoOdfXIf6dOX218Y99VLRc +Uwj37uyYTaEwbWvyEX7u+nHuKWXN7SaML/IYTv/rGu+TUVAQGlWTg2lJkY6vh/07 +1EUmavR/BBUOP4NqmisNS0Xtx8OHwQ92x8+ayRixO3Kh6OC1nJH5Jylr/lqpVxXw +HgA/hn/jX4/TWFpmv9JTvxXlYfnRr9UccEncK9/28eUz+CcAEQEAAYkCHwQYAQoA +CQUCS2dVdQIbDAAKCRDpEoeCL9uBsRwVD/4ogReEt1w2ODA3SsypnrCettQtnV4J +Vn7zjvDK0v0U+xZ+tB7VvUqkY7dQ4RmzhxETnORUZNgCWLZ6fs5Us2RB/yoOyYSJ +c+SBN3YEpbFBwLBLoGlZTGsJPktYNo+nQ9KEIZ+OHFnhXGJLqBknMn0vu6T+pQv5 +8hJzrfOh98TCtFLmKfZGGwoQfKeDAMEo71T69Yoz1NSSFHr5o39iHff8+mhp1WL1 +hsiJI6MOlaUZAwNI1CRebZPQofvydTH+LWsBna1oAiFrO4KcorBJI/gUfGO1mmBq +l5qjtoxhq5Tr2oBQtFoqbUaXJcwbDVxLSQhk6omNjNlolsRXj6TBy1eTFgd4Ww0Q +B5mYo8cc8Et0wlzZ3UyhD2ix6EnKxWUqj0oFPIVzFfuQ/whmWuqBiMZcAN9RhCGP +aovv1v0jP1i983QWptUwpr0m2UjxblFUz2GiQ9sXPCi1Cko978LKCiVseCKVEmbG +fWdpq/h+sM4GokoYwa6ak5B5Dyu9/JywTAex/DgUvkuGQuBjtipmS84lb+Ah8wkj +lxiWgAoxUUnVFRJb9bpH7sRNc8SXfy6dYcCDWURq73JYzPtmCVAE6stD5lSU+YvQ +f+QZZLa4u84eh0skgAakDgkeL2cbOg4tzkUo4EmbXR5M0VRk/946s78/JtchwdNB +zxrmkygs1IMB6Q== +=8P8F +-END PGP PUBLIC KEY BLOCK-