You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by pl...@apache.org on 2016/09/15 17:26:18 UTC
[01/24] incubator-tamaya git commit: Removed all modules from the
main repository. They will be reborn in separate ASF repository.
Repository: incubator-tamaya
Updated Branches:
refs/heads/master a41d14368 -> 359d3e4a2
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/yaml/src/test/resources/configs/valid/test-with-prio.yaml
----------------------------------------------------------------------
diff --git a/modules/yaml/src/test/resources/configs/valid/test-with-prio.yaml b/modules/yaml/src/test/resources/configs/valid/test-with-prio.yaml
deleted file mode 100644
index 05b5dbf..0000000
--- a/modules/yaml/src/test/resources/configs/valid/test-with-prio.yaml
+++ /dev/null
@@ -1,39 +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.
-#
-version: 1.0
-released: 2012-11-30
-
-# tamaya specifics...
-tamaya:
- ordinal: 16784
-
-# Connection parameters
-connection:
- url: jdbc:mysql://localhost:3306/db
- poolSize: 5
-
-# Protocols
-protocols:
- - http
- - https
-
-# Users
-users:
- tom: passwd
- bob: passwd
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/yaml/src/test/resources/configs/valid/test.yaml
----------------------------------------------------------------------
diff --git a/modules/yaml/src/test/resources/configs/valid/test.yaml b/modules/yaml/src/test/resources/configs/valid/test.yaml
deleted file mode 100644
index 697e9f3..0000000
--- a/modules/yaml/src/test/resources/configs/valid/test.yaml
+++ /dev/null
@@ -1,35 +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.
-#
-version: 1.0
-released: 2012-11-30
-
-# Connection parameters
-connection:
- url: jdbc:mysql://localhost:3306/db
- poolSize: 5
-
-# Protocols
-protocols:
- - http
- - https
-
-# Users
-users:
- tom: passwd
- bob: passwd
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index d29e4b0..5282f70 100644
--- a/pom.xml
+++ b/pom.xml
@@ -214,7 +214,6 @@ under the License.
<modules>
<module>buildconfigurations</module>
<module>code</module>
- <module>modules</module>
<module>docs</module>
<module>examples</module>
<module>distribution</module>
[22/24] incubator-tamaya git commit: Removed all modules from the
main repository. They will be reborn in separate ASF repository.
Posted by pl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/classloader-support/src/main/java/org/apache/tamaya/clsupport/CLAwareConfigurationContext.java
----------------------------------------------------------------------
diff --git a/modules/classloader-support/src/main/java/org/apache/tamaya/clsupport/CLAwareConfigurationContext.java b/modules/classloader-support/src/main/java/org/apache/tamaya/clsupport/CLAwareConfigurationContext.java
deleted file mode 100644
index 94e5fb5..0000000
--- a/modules/classloader-support/src/main/java/org/apache/tamaya/clsupport/CLAwareConfigurationContext.java
+++ /dev/null
@@ -1,105 +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.clsupport;
-
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.spisupport.DefaultConfigurationContext;
-import org.apache.tamaya.spi.ConfigurationContext;
-import org.apache.tamaya.spi.ConfigurationContextBuilder;
-import org.apache.tamaya.spi.PropertyConverter;
-import org.apache.tamaya.spi.PropertyFilter;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValueCombinationPolicy;
-
-import javax.annotation.Priority;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Logger;
-
-/**
- * Default Implementation of a simple ConfigurationContext.
- */
-@Priority(100)
-public class CLAwareConfigurationContext implements ConfigurationContext {
-
- /** The logger used. */
- private final static Logger LOG = Logger.getLogger(CLAwareConfigurationContext.class.getName());
-
- private final ContextManager contextManager = new ContextManager();
-
-
- @Override
- public void addPropertySources(PropertySource... propertySourcesToAdd) {
- contextManager.getItemNoParent(true).addPropertySources(propertySourcesToAdd);
- }
-
- @Override
- public List<PropertySource> getPropertySources() {
- return contextManager.getItemNoParent(true).getPropertySources();
- }
-
- @Override
- public <T> void addPropertyConverter(TypeLiteral<T> typeToConvert, PropertyConverter<T> propertyConverter) {
- contextManager.getItemNoParent(true).addPropertyConverter(typeToConvert, propertyConverter);
- }
-
- @Override
- public Map<TypeLiteral<?>, List<PropertyConverter<?>>> getPropertyConverters() {
- return contextManager.getItemNoParent(true).getPropertyConverters();
- }
-
- @Override
- public <T> List<PropertyConverter<T>> getPropertyConverters(TypeLiteral<T> targetType) {
- return contextManager.getItemNoParent(true).getPropertyConverters(targetType);
- }
-
- @Override
- public List<PropertyFilter> getPropertyFilters() {
- return contextManager.getItemNoParent(true).getPropertyFilters();
- }
-
- @Override
- public PropertyValueCombinationPolicy getPropertyValueCombinationPolicy(){
- return contextManager.getItemNoParent(true).getPropertyValueCombinationPolicy();
- }
-
- @Override
- public ConfigurationContextBuilder toBuilder() {
- return contextManager.getItemNoParent(true).toBuilder();
- }
-
-
- /**
- * Subcomponent managing {@link ConfigurationContext} instances, one per classloader.
- */
- private static final class ContextManager extends AbstractClassloaderAwareItemLoader<ConfigurationContext>{
-
- @Override
- protected ConfigurationContext createItem(ClassLoader classLoader) {
- // Simply create a complete configuration manager for every classloader. Maybe we will optimize this at a
- // later stage in the project but as for now it is the most simple working solution.
- return new DefaultConfigurationContext();
- }
-
- @Override
- protected void updateItem(ConfigurationContext currentItemSet, ClassLoader classLoader) {
- // ignore, currently not supported.
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/classloader-support/src/main/java/org/apache/tamaya/clsupport/CLAwareServiceContext.java
----------------------------------------------------------------------
diff --git a/modules/classloader-support/src/main/java/org/apache/tamaya/clsupport/CLAwareServiceContext.java b/modules/classloader-support/src/main/java/org/apache/tamaya/clsupport/CLAwareServiceContext.java
deleted file mode 100644
index a5d1700..0000000
--- a/modules/classloader-support/src/main/java/org/apache/tamaya/clsupport/CLAwareServiceContext.java
+++ /dev/null
@@ -1,248 +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.clsupport;
-
-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.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-
-/**
- * <p>This class implements a {@link ServiceContext}, which basically provides a similar loading mechanism as used
- * by the {@link java.util.ServiceLoader}. Whereas the {@link java.util.ServiceLoader} only loads configurations
- * and instances from one classloader, this loader manages configs found and the related instances for each
- * classloader along the classloader hierarchies individually. It ensures instances are loaded on the classloader
- * level, where they first are visible. Additionally it ensures the same configuration resource (and its
- * declared services) are loaded multiple times, when going up the classloader hierarchy.</p>
- *
- * <p>Finally classloaders are not stored by reference by this class, to ensure they still can be garbage collected.
- * Refer also the inherited parent class for further details.</p>
- *
- * <p>This class uses an ordinal of {@code 10}, so it overrides any default {@link ServiceContext} implementations
- * provided with the Tamaya core modules.</p>
- */
-@Priority(10)
-public class CLAwareServiceContext extends AbstractClassloaderAwareItemLoader<ServiceContainer>
- implements ServiceContext{
-
- private static final Logger LOG = Logger.getLogger(CLAwareServiceContext.class.getName());
-
- /**
- * Default location for service loader files.
- */
- private static final String PREFIX = "META-INF/services/";
-
- /**
- * Constructor, using the current default classloader as defined by
- * {@link AbstractClassloaderAwareItemLoader#getDefaultClassLoader()}.
- */
- public CLAwareServiceContext(){
- super();
- }
-
- /**
- * Constructor, using the given classloader.
- * @param classLoader the target classloader for initializing of services, not null.
- */
- public CLAwareServiceContext(ClassLoader classLoader) {
- super(classLoader);
- }
-
-
- /**
- * Implementation that creates a {@link ServiceContainer}, which manages all configs and instances loaded
- * for a given classloader.
- * @param classLoader the classloader, not null.
- * @return a new empty, {@link ServiceContainer} instance.
- */
- @Override
- protected ServiceContainer createItem(ClassLoader classLoader) {
- if(LOG.isLoggable(Level.INFO)) {
- LOG.info("Loading services for classloader: " + classLoader);
- }
- return new ServiceContainer(classLoader);
- }
-
- @Override
- protected void updateItem(ServiceContainer currentContainer, ClassLoader classLoader) {
- // nothing to be done here, since we dont have a specific target type.
- }
-
- @Override
- public int ordinal() {
- return 10;
- }
-
- /**
- * This method tries to evaluate the current singleton from the {@link ServiceContainer} attached to the
- * current classloader. If not found the singleton instance is evaluated based on the priorities
- * assigned for all known providers. The resulting instance is then cached and always returned as
- * singleton instance fomr this loader, when the same current classloader instance is active.
- * @param serviceType the service type.
- * @param <T> the type
- * @return the item found, or null.
- */
- @Override
- public <T> T getService(Class<T> serviceType) {
- return getService(serviceType, getDefaultClassLoader());
- }
-
- /**
- * Evaluates the current singleton instance using the given classloader context.
- * @param serviceType the service type.
- * @param classLoader the classloader, not null.
- * @param <T> the type
- * @return the item found, or null.
- */
- public <T> T getService(Class<T> serviceType, ClassLoader classLoader) {
- if(LOG.isLoggable(Level.INFO)) {
- LOG.info("Evaluating services for classloader: " + classLoader);
- }
- ServiceContainer container = getItemNoParent(classLoader, true);
- T singleton = container.getSingleton(serviceType);
- if(singleton!=null){
- if(LOG.isLoggable(Level.FINEST)) {
- LOG.finest("Evaluated singleton of type " + serviceType.getName() + " to " + singleton);
- }
- return singleton;
- }
- Collection<? extends T> services = getServices(serviceType, classLoader);
- if (services.isEmpty()) {
- singleton = null;
- } else {
- singleton = getServiceWithHighestPriority(services, serviceType);
- }
- if(singleton!=null) {
- container.setSingleton(serviceType, singleton);
- }
- if(LOG.isLoggable(Level.FINEST)) {
- LOG.finest("Evaluated singleton of type " + serviceType.getName() + " to " + singleton);
- }
- return singleton;
- }
-
- /**
- * Gets the services visible.
- * @param serviceType
- * the service type.
- * @param <T> the type param
- * @return the services visible for the current classloader.
- */
- @Override
- public <T> List<T> getServices(Class<T> serviceType) {
- return getServices(serviceType, AbstractClassloaderAwareItemLoader.getDefaultClassLoader());
- }
-
- /**
- * Gets the services visible.
- * @param serviceType the service type.
- * @param classLoader the classloader
- * @param <T> the type param
- * @return the services visible for the current classloader.
- */
- public <T> List<T> getServices(Class<T> serviceType, ClassLoader classLoader) {
- List<T> services = new ArrayList<>();
- ClassLoader cl = classLoader;
- List<ServiceContainer> containers = new ArrayList<>();
- while(cl!=null) {
- ServiceContainer container = getItemNoParent(cl, true);
- containers.add(container);
- cl = cl.getParent();
- }
- List<ServiceContainer> prevContainers = new ArrayList<>();
- Collections.reverse(containers);
- for(ServiceContainer container: containers) {
- if (!container.isTypeLoaded(serviceType)) {
- container.loadServices(serviceType, prevContainers);
- }
- services.addAll(container.getServices(serviceType));
- prevContainers.add(container);
- }
- if(LOG.isLoggable(Level.FINEST)) {
- LOG.finest("Evaluated services of type " + serviceType.getName() + " to " + services);
- }
- return services;
- }
-
- /**
- * @param services to scan
- * @param <T> 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> T getServiceWithHighestPriority(Collection<? extends T> services, Class<T> serviceType) {
-
- // we do not need the priority stuff if the list contains only one element
- if (services.size() == 1) {
- return services.iterator().next();
- }
-
- Integer highestPriority = null;
- int highestPriorityServiceCount = 0;
- T highestService = null;
-
- for (T service : services) {
- int prio = getPriority(service);
- 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}: {3}",
- highestPriorityServiceCount,
- serviceType.getName(),
- highestPriority,
- services));
- }
- return highestService;
- }
-
- /**
- * Checks the given instance for a @Priority annotation. If present the annotation's value s evaluated. If no such
- * annotation is present, a default priority is returned (1);
- * @param o the instance, not null.
- * @return a priority, by default 1.
- */
- public static int getPriority(Object o){
- int prio = 0;
- Priority priority = o.getClass().getAnnotation(Priority.class);
- if (priority != null) {
- prio = priority.value();
- }
- if(LOG.isLoggable(Level.FINEST)) {
- LOG.finest("Evaluated priority for " + o.getClass().getName() + " to " + prio);
- }
- return prio;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/classloader-support/src/main/java/org/apache/tamaya/clsupport/ServiceContainer.java
----------------------------------------------------------------------
diff --git a/modules/classloader-support/src/main/java/org/apache/tamaya/clsupport/ServiceContainer.java b/modules/classloader-support/src/main/java/org/apache/tamaya/clsupport/ServiceContainer.java
deleted file mode 100644
index 23e73c0..0000000
--- a/modules/classloader-support/src/main/java/org/apache/tamaya/clsupport/ServiceContainer.java
+++ /dev/null
@@ -1,306 +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.clsupport;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.lang.ref.WeakReference;
-import java.net.URL;
-import java.security.AccessControlContext;
-import java.security.AccessController;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.ServiceConfigurationError;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Classloader managed ServiceContainer.
- */
-class ServiceContainer {
-
- private static final Logger LOG = Logger.getLogger(ServiceContainer.class.getName());
-
- private static final String PREFIX = "META-INF/services/";
-
- // The access control context taken when the ServiceLoader is created
- private final AccessControlContext acc;
-
- private final WeakReference<ClassLoader> classLoaderRef;
-
- /**
- * List current services loaded using this classloader, per class.
- */
- private final Map<Class<?>, Map<String, Object>> servicesLoaded = new ConcurrentHashMap<>();
- /**
- * The cached singletons for the given classloader.
- */
- private final Map<Class, Object> singletons = new ConcurrentHashMap<>();
-
- /**
- * List current services loaded using this classloader, per class.
- */
- private final Map<Class, List<URL>> configsLoaded = new ConcurrentHashMap<>();
-
- ServiceContainer(ClassLoader classLoader) {
- acc = (System.getSecurityManager() != null) ? AccessController.getContext() : null;
- this.classLoaderRef = new WeakReference<>(classLoader);
- }
-
- public ClassLoader getClassLoader() {
- ClassLoader cl = classLoaderRef.get();
- if (cl == null) {
- throw new IllegalStateException("Classloader reference removed, not active anynire.");
- }
- return cl;
- }
-
-
- public <T> void loadServices(Class<?> type,
- Collection<ServiceContainer> preceedingContainers) {
- Map<String, Object> services = this.servicesLoaded.get(type);
- if (services == null) {
- services = new LinkedHashMap<>();
- this.servicesLoaded.put(type, services);
- }
- loop:
- for (URL config : getConfigs(type)) {
- for (ServiceContainer cont : preceedingContainers) {
- if (cont.getConfigs(type).contains(config)) {
- LOG.finer("Ignoring already loaded config: " + config);
- continue loop;
- }
- }
- Collection<String> serviceNames = parse(type, config);
- for (String s : serviceNames) {
- for (ServiceContainer cont : preceedingContainers) {
- if (cont.containsService(type, s)) {
- LOG.finest("Ignoring duplicate service: " + s);
- }
- }
- LOG.info("Loading component: " + s);
- services.put(s, create(type, s));
- }
- }
- }
-
- private Collection<URL> getConfigs(Class<?> type) {
- List<URL> result = this.configsLoaded.get(type);
- if (result == null) {
- ClassLoader cl = this.classLoaderRef.get();
- if (cl == null) {
- throw new IllegalStateException("CLassLoader dereferenced already.");
- }
- result = new ArrayList<>();
- try {
- Enumeration<URL> resources = cl.getResources(PREFIX + type.getName());
- while (resources.hasMoreElements()) {
- result.add(resources.nextElement());
- }
- } catch (Exception e) {
- LOG.log(Level.WARNING, "Failed to read service config for " + type.getName() + " from " + cl, e);
- }
- this.configsLoaded.put(type, result);
- LOG.log(Level.FINE, "Found service config for " + type.getName() + ": " + result);
- }
- return result;
- }
-
- private boolean containsService(Class<?> type, String serviceClassName) {
- Map<String, Object> services = servicesLoaded.get(type);
- return services != null && services.containsKey(serviceClassName);
- }
-
-
- private <S> S create(Class<S> serviceType, String className) {
- Class<?> c = null;
- ClassLoader classLoader = getClassLoader();
- try {
- c = Class.forName(className, false, classLoader);
- } catch (ClassNotFoundException x) {
- fail(serviceType,
- "Provider " + className + " not found");
- }
- if (!serviceType.isAssignableFrom(c)) {
- fail(serviceType,
- "Provider " + className + " not a subtype");
- }
- try {
- return serviceType.cast(c.newInstance());
- } catch (Throwable x) {
- fail(serviceType,
- "Provider " + className + " could not be instantiated",
- x);
- }
- throw new Error(); // This cannot happen
- }
-
- public <T> Collection<T> getServices(Class<T> serviceType) {
- Map<String, Object> services = this.servicesLoaded.get(serviceType);
- if (services != null) {
- return (Collection<T>) services.values();
- }
- return Collections.emptySet();
- }
-
- public boolean isTypeLoaded(Class<?> serviceType) {
- return this.servicesLoaded.containsKey(serviceType);
- }
-
- public Collection<URL> load(Class<?> serviceType) {
- return load(serviceType, Collection.class.cast(Collections.emptySet()));
- }
-
- public Collection<URL> load(Class<?> serviceType, Collection<URL> configsLoaded) {
- List<URL> result = new ArrayList<>();
- try {
- Enumeration<URL> resources = getClassLoader().getResources(PREFIX + serviceType.getName());
- while (resources.hasMoreElements()) {
- URL res = resources.nextElement();
- if (!configsLoaded.contains(res)) {
- result.add(res);
- }
- }
- return result;
- } catch (Exception e) {
- fail(serviceType, "Failed to load service config: " + PREFIX + serviceType.getName(), e);
- }
- return result;
- }
-
-
- // Parse a single line from the given configuration file, adding the name
- // on the line to the names list.
- //
- private int parseLine(Class<?> serviceType, URL u, BufferedReader r, int lc,
- List<String> names)
- throws IOException, ServiceConfigurationError {
- String ln = r.readLine();
- if (ln == null) {
- return -1;
- }
- int ci = ln.indexOf('#');
- if (ci >= 0) {
- ln = ln.substring(0, ci);
- }
- ln = ln.trim();
- int n = ln.length();
- if (n != 0) {
- if ((ln.indexOf(' ') >= 0) || (ln.indexOf('\t') >= 0)) {
- fail(serviceType, u, lc, "Illegal configuration-file syntax");
- }
- int cp = ln.codePointAt(0);
- if (!Character.isJavaIdentifierStart(cp)) {
- fail(serviceType, u, lc, "Illegal provider-class name: " + ln);
- }
- for (int i = Character.charCount(cp); i < n; i += Character.charCount(cp)) {
- cp = ln.codePointAt(i);
- if (!Character.isJavaIdentifierPart(cp) && (cp != '.')) {
- fail(serviceType, u, lc, "Illegal provider-class name: " + ln);
- }
- }
- Map<String, Object> services = this.servicesLoaded.get(serviceType);
- if (services == null || !services.containsKey(ln) && !names.contains(ln)) {
- names.add(ln);
- }
- }
- return lc + 1;
- }
-
-
- // Parse the content of the given URL as a provider-configuration file.
- //
- // @param service
- // The service type for which providers are being sought;
- // used to construct error detail strings
- //
- // @param u
- // The URL naming the configuration file to be parsed
- //
- // @return A (possibly empty) iterator that will yield the provider-class
- // names in the given configuration file that are not yet members
- // of the returned set
- //
- // @throws ServiceConfigurationError
- // If an I/O error occurs while reading from the given URL, or
- // if a configuration-file format error is detected
- //
- private Collection<String> parse(Class<?> service, URL u)
- throws ServiceConfigurationError {
- InputStream in = null;
- BufferedReader r = null;
- ArrayList<String> names = new ArrayList<>();
- try {
- in = u.openStream();
- r = new BufferedReader(new InputStreamReader(in, "utf-8"));
- int lc = 1;
- while ((lc = parseLine(service, u, r, lc, names)) >= 0) {
- // go ahead
- }
- } catch (IOException x) {
- fail(service, "Error reading configuration file", x);
- } finally {
- try {
- if (r != null) {
- r.close();
- }
- if (in != null) {
- in.close();
- }
- } catch (IOException y) {
- fail(service, "Error closing configuration file", y);
- }
- }
- return names;
- }
-
-
- private static void fail(Class<?> service, String msg, Throwable cause)
- throws ServiceConfigurationError {
- LOG.log(Level.SEVERE, "Failed to load: " + service.getName() + ": " + msg, cause);
- }
-
- private static void fail(Class<?> service, String msg)
- throws ServiceConfigurationError {
- LOG.log(Level.SEVERE, "Failed to load: " + service.getName() + ": " + msg);
- }
-
- private static void fail(Class<?> service, URL u, int line, String msg)
- throws ServiceConfigurationError {
- fail(service, u + ":" + line + ": " + msg);
- }
-
- public <T> T getSingleton(Class<T> serviceType) {
- return (T) this.singletons.get(serviceType);
- }
-
- <T> void setSingleton(Class<T> type, T instance) {
- LOG.info("Caching singleton for " + type.getName() + " and classloader: " +
- getClassLoader().toString() + ": " + instance);
- this.singletons.put(type, instance);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/classloader-support/src/main/java/org/apache/tamaya/clsupport/package-info.java
----------------------------------------------------------------------
diff --git a/modules/classloader-support/src/main/java/org/apache/tamaya/clsupport/package-info.java b/modules/classloader-support/src/main/java/org/apache/tamaya/clsupport/package-info.java
deleted file mode 100644
index d8e3953..0000000
--- a/modules/classloader-support/src/main/java/org/apache/tamaya/clsupport/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-/**
- * Programmatic API of the classloader support.
- */
-package org.apache.tamaya.clsupport;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/classloader-support/src/main/resources/META-INF/services/org.apache.tamaya.spi.ServiceContext
----------------------------------------------------------------------
diff --git a/modules/classloader-support/src/main/resources/META-INF/services/org.apache.tamaya.spi.ServiceContext b/modules/classloader-support/src/main/resources/META-INF/services/org.apache.tamaya.spi.ServiceContext
deleted file mode 100644
index 7016afb..0000000
--- a/modules/classloader-support/src/main/resources/META-INF/services/org.apache.tamaya.spi.ServiceContext
+++ /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.clsupport.CLAwareServiceContext
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/classloader-support/src/test/resources/META-INF/services/org.apache.tamaya.environment.spi.ContextProviderSpi
----------------------------------------------------------------------
diff --git a/modules/classloader-support/src/test/resources/META-INF/services/org.apache.tamaya.environment.spi.ContextProviderSpi b/modules/classloader-support/src/test/resources/META-INF/services/org.apache.tamaya.environment.spi.ContextProviderSpi
deleted file mode 100644
index 7f71c15..0000000
--- a/modules/classloader-support/src/test/resources/META-INF/services/org.apache.tamaya.environment.spi.ContextProviderSpi
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy 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.environment.internal.ClassLoaderDependentAppEnvironmentProvider
-org.apache.tamaya.environment.internal.ClassLoaderDependentEarEnvironmentProvider
-org.apache.tamaya.environment.internal.InitialEnvironmentProviderSpi
-org.apache.tamaya.environment.internal.SystemClassLoaderEnvironmentProviderSpi
-org.apache.tamaya.metamodel.environment.TestEnvironmentProvider
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/classloader-support/src/test/resources/META-INF/services/org.apache.tamaya.environment.spi.ContextSpi
----------------------------------------------------------------------
diff --git a/modules/classloader-support/src/test/resources/META-INF/services/org.apache.tamaya.environment.spi.ContextSpi b/modules/classloader-support/src/test/resources/META-INF/services/org.apache.tamaya.environment.spi.ContextSpi
deleted file mode 100644
index 166dd67..0000000
--- a/modules/classloader-support/src/test/resources/META-INF/services/org.apache.tamaya.environment.spi.ContextSpi
+++ /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.environment.internal.SingleEnvironmentManager
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/collections/pom.xml
----------------------------------------------------------------------
diff --git a/modules/collections/pom.xml b/modules/collections/pom.xml
deleted file mode 100644
index 44200bd..0000000
--- a/modules/collections/pom.xml
+++ /dev/null
@@ -1,74 +0,0 @@
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy 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.
--->
-<project xmlns="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">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-extensions</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
-
- <artifactId>tamaya-collections</artifactId>
- <name>Apache Tamaya Modules - Collections Support</name>
- <packaging>bundle</packaging>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-core</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Import-Package>
- org.apache.tamaya,
- org.apache.tamaya.spi,
- javax.annotation,
- *
- </Import-Package>
- <Private-Package>
- org.apache.tamaya.collections.internal
- </Private-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/AdaptiveCombinationPolicy.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/AdaptiveCombinationPolicy.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/AdaptiveCombinationPolicy.java
deleted file mode 100644
index c0e9b9a..0000000
--- a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/AdaptiveCombinationPolicy.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.collections.internal;
-
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-import org.apache.tamaya.spi.PropertyValueCombinationPolicy;
-
-import javax.annotation.Priority;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * PropertyValueCombinationPolicy that allows to configure a PropertyValueCombinationPolicy for each key
- * individually, by adding a configured entry of the form
- * {@code _key.combination-policy=collect|override|fqPolicyClassName}.
- */
-@Priority(100)
-public class AdaptiveCombinationPolicy implements PropertyValueCombinationPolicy {
- /** Logger. */
- private static final Logger LOG = Logger.getLogger(AdaptiveCombinationPolicy.class.getName());
-
- /**
- * Collecting combination policy using (optional) {@code item-separator} parameter for determining the sparator
- * to combine multiple config entries found.
- */
- private static final PropertyValueCombinationPolicy COLLECTING_POLICY = new PropertyValueCombinationPolicy(){
- @Override
- public Map<String, String> collect(Map<String, String> currentValue, String key, PropertySource propertySource) {
- // check for default collection combination policies for lists, sets, maps etc.
- final String separator = ConfigurationProvider.getConfiguration().getOrDefault('_' + key+".item-separator", ",");
- PropertyValue newValue = propertySource.get(key);
- if(newValue!=null){
- Map<String,String> newMapValue = new HashMap<>();
- if(currentValue!=null){
- newMapValue.putAll(currentValue);
- }
- String oldVal = newMapValue.get(key);
- newMapValue.putAll(newValue.getConfigEntries());
- if(oldVal!=null){
- newMapValue.put(key,oldVal + separator + newValue.getValue());
- }
- return newMapValue;
- }else{
- if(currentValue!=null){
- return currentValue;
- }
- return Collections.emptyMap();
- }
- }
- };
-
- /** Cache for loaded custom combination policies. */
- private Map<Class, PropertyValueCombinationPolicy> configuredPolicies = new ConcurrentHashMap<>();
-
- @Override
- public Map<String,String> collect(Map<String,String> currentValue, String key, PropertySource propertySource){
- if(key.startsWith("_")){
- PropertyValue newValue = propertySource.get(key);
- if(newValue!=null){
- return newValue.getConfigEntries();
- }
- return currentValue;
- }
- String adaptiveCombinationPolicyClass = ConfigurationProvider.getConfiguration().getOrDefault(
- '_' + key+".combination-policy", "override");
- PropertyValueCombinationPolicy combinationPolicy = null;
- switch(adaptiveCombinationPolicyClass){
- case "collect":
- case "COLLECT":
- if(LOG.isLoggable(Level.FINEST)){
- LOG.finest("Using collecting combination policy for key: " + key + "");
- }
- combinationPolicy = COLLECTING_POLICY;
- break;
- case "override":
- case "OVERRIDE":
- if(LOG.isLoggable(Level.FINEST)){
- LOG.finest("Using default (overriding) combination policy for key: " + key + "");
- }
- combinationPolicy = PropertyValueCombinationPolicy.DEFAULT_OVERRIDING_COLLECTOR;
- break;
- default:
- try{
- Class<PropertyValueCombinationPolicy> clazz = (Class<PropertyValueCombinationPolicy>)
- Class.forName(adaptiveCombinationPolicyClass);
- combinationPolicy = configuredPolicies.get(clazz);
- if(combinationPolicy==null){
- combinationPolicy = clazz.newInstance();
- configuredPolicies.put(clazz, combinationPolicy);
- }
- if(LOG.isLoggable(Level.FINEST)){
- LOG.finest("Using custom combination policy "+adaptiveCombinationPolicyClass+" for " +
- "key: " + key + "");
- }
- } catch(Exception e){
- LOG.log(Level.SEVERE, "Error loading configured PropertyValueCombinationPolicy for " +
- "key: " + key + ", using default (overriding) policy.", e);
- combinationPolicy = PropertyValueCombinationPolicy.DEFAULT_OVERRIDING_COLLECTOR;
- }
- }
- return combinationPolicy.collect(currentValue, key, propertySource);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ArrayListConverter.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ArrayListConverter.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ArrayListConverter.java
deleted file mode 100644
index f337e26..0000000
--- a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ArrayListConverter.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.collections.internal;
-
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * PropertyConverter for gnerating ArrayList representation of a values.
- */
-public class ArrayListConverter implements PropertyConverter<ArrayList> {
-
- private static final Logger LOG = Logger.getLogger(ArrayListConverter.class.getName());
-
- /** The shared instance, used by other collection converters in this package.*/
- private static final ArrayListConverter INSTANCE = new ArrayListConverter();
-
- /**
- * Provide a shared instance, used by other collection converters in this package.
- * @return the shared instance, never null.
- */
- static ArrayListConverter getInstance(){
- return INSTANCE;
- }
-
- @Override
- public ArrayList convert(String value, ConversionContext context) {
- List<String> rawList = ItemTokenizer.split(value, context);
- ArrayList<Object> mlist = new ArrayList<>();
- for(String raw:rawList){
- Object convValue = ItemTokenizer.convertValue(raw, context);
- if (convValue != null) {
- mlist.add(convValue);
- }else{
- LOG.log(Level.SEVERE, "Failed to convert collection value type for '"+raw+"'.");
- }
- }
- return mlist;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/CollectionConverter.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/CollectionConverter.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/CollectionConverter.java
deleted file mode 100644
index 343610a..0000000
--- a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/CollectionConverter.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.collections.internal;
-
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-import java.util.Collection;
-import java.util.Collections;
-
-/**
- * PropertyConverter for gnerating a LIST representation of values.
- */
-public class CollectionConverter implements PropertyConverter<Collection> {
-
- @Override
- public Collection convert(String value, ConversionContext context) {
- String collectionType = context.getConfiguration().getOrDefault('_' + context.getKey()+".collection-type", "List");
- if(collectionType.startsWith("java.util.")){
- collectionType = collectionType.substring("java.util.".length());
- }
- Collection result = null;
- switch(collectionType){
- case "LinkedList":
- result = LinkedListConverter.getInstance().convert(value, context);
- break;
- case "Set":
- case "HashSet":
- result = HashSetConverter.getInstance().convert(value, context);
- break;
- case "SortedSet":
- case "TreeSet":
- result = TreeSetConverter.getInstance().convert(value, context);
- break;
- case "List":
- case "ArrayList":
- default:
- result = ArrayListConverter.getInstance().convert(value, context);
- break;
- }
- if(context.getConfiguration().getOrDefault('_' + context.getKey()+".read-only",
- Boolean.class, Boolean.TRUE)){
- return Collections.unmodifiableCollection(result);
- }
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ConcurrentHashMapConverter.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ConcurrentHashMapConverter.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ConcurrentHashMapConverter.java
deleted file mode 100644
index 7770fcf..0000000
--- a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ConcurrentHashMapConverter.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.collections.internal;
-
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-import java.util.List;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * PropertyConverter for gnerating ConcurrentHashMap representation of a values.
- */
-public class ConcurrentHashMapConverter implements PropertyConverter<ConcurrentHashMap> {
- private static final Logger LOG = Logger.getLogger(ConcurrentHashMapConverter.class.getName());
-
- /** The shared instance, used by other collection converters in this package.*/
- private static final ConcurrentHashMapConverter INSTANCE = new ConcurrentHashMapConverter();
-
- /**
- * Provide a shared instance, used by other collection converters in this package.
- * @return the shared instance, never null.
- */
- static ConcurrentHashMapConverter getInstance(){
- return INSTANCE;
- }
-
- @Override
- public ConcurrentHashMap convert(String value, ConversionContext context) {
- List<String> rawList = ItemTokenizer.split(value, context);
- ConcurrentHashMap result = new ConcurrentHashMap(rawList.size());
- for(String raw:rawList){
- String[] items = ItemTokenizer.splitMapEntry(raw, context);
- Object convValue = ItemTokenizer.convertValue(items[1], context);
- if(convValue!=null){
- result.put(items[0], convValue);
- }else{
- LOG.log(Level.SEVERE, "Failed to convert collection value type for '"+raw+"'.");
- }
- }
- return result;
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/HashMapConverter.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/HashMapConverter.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/HashMapConverter.java
deleted file mode 100644
index 4e405e3..0000000
--- a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/HashMapConverter.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.collections.internal;
-
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * PropertyConverter for gnerating HashMap representation of a values.
- */
-public class HashMapConverter implements PropertyConverter<HashMap> {
- private static final Logger LOG = Logger.getLogger(HashMapConverter.class.getName());
-
- /** The shared instance, used by other collection converters in this package.*/
- private static final HashMapConverter INSTANCE = new HashMapConverter();
-
- /**
- * Provide a shared instance, used by other collection converters in this package.
- * @return the shared instance, never null.
- */
- static HashMapConverter getInstance(){
- return INSTANCE;
- }
-
- @Override
- public HashMap convert(String value, ConversionContext context) {
- List<String> rawList = ItemTokenizer.split(value, context);
- HashMap result = new HashMap(rawList.size());
- for(String raw:rawList){
- String[] items = ItemTokenizer.splitMapEntry(raw, context);
- Object convValue = ItemTokenizer.convertValue(items[1], context);
- if(convValue!=null){
- result.put(items[0], convValue);
- }else{
- LOG.log(Level.SEVERE, "Failed to convert collection value type for '"+raw+"'.");
- }
- }
- return result;
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/HashSetConverter.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/HashSetConverter.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/HashSetConverter.java
deleted file mode 100644
index dab1b82..0000000
--- a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/HashSetConverter.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.collections.internal;
-
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * PropertyConverter for gnerating HashSet representation of a values.
- */
-public class HashSetConverter implements PropertyConverter<HashSet> {
-
- private static final Logger LOG = Logger.getLogger(HashSetConverter.class.getName());
-
- /** The shared instance, used by other collection converters in this package.*/
- private static final HashSetConverter INSTANCE = new HashSetConverter();
-
- /**
- * Provide a shared instance, used by other collection converters in this package.
- * @return the shared instance, never null.
- */
- static HashSetConverter getInstance(){
- return INSTANCE;
- }
-
- @Override
- public HashSet convert(String value, ConversionContext context) {
- List<String> rawList = ItemTokenizer.split(value, context);
- HashSet<Object> result = new HashSet<>();
- for(String raw:rawList){
- String[] items = ItemTokenizer.splitMapEntry(raw, context);
- Object convValue = ItemTokenizer.convertValue(items[1], context);
- if(convValue!=null){
- result.add(convValue);
- }else{
- LOG.log(Level.SEVERE, "Failed to convert collection value type for '"+raw+"'.");
- }
- }
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ItemTokenizer.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ItemTokenizer.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ItemTokenizer.java
deleted file mode 100644
index 658131f..0000000
--- a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ItemTokenizer.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.collections.internal;
-
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Helper class that implements the tokenizing of the entries of a configuration value.
- */
-final class ItemTokenizer {
-
- private static final Logger LOG = Logger.getLogger(ItemTokenizer.class.getName());
-
- /**
- * Private singleton.
- */
- private ItemTokenizer(){}
-
- /**
- * Splits the given value using the given separator. Matcjhing is done by traversing the String value using
- * {@code indexOf} calls, one by one. The last unresolvable item (without any next separator token)
- * is added at the end of the list.
- * @param value the value, not null.
- * @param context the conversion context.
- * @return the tokenized value as list, in order of occurrence.
- */
- public static List<String> split(String value, ConversionContext context){
- return split(value, ConfigurationProvider.getConfiguration().getOrDefault(
- '_' + context.getKey()+ "" +
- "item-separator", ","));
- }
-
- /**
- * Splits the given value using the given separator. Matcjhing is done by traversing the String value using
- * {@code indexOf} calls, one by one. The last unresolvable item (without any next separator token)
- * is added at the end of the list.
- * @param value the value, not null.
- * @param separator the separator to be used.
- * @return the tokenized value as list, in order of occurrence.
- */
- public static List<String> split(String value, final String separator) {
- ArrayList<String> result = new ArrayList<>();
- int start = 0;
- int end = value.indexOf(separator,start);
- while(end>0) {
- if (value.charAt(end - 1) != '\\') {
- result.add(value.substring(start, end));
- start = end + separator.length();
- end = value.indexOf(separator,start);
- }else{
- end = value.indexOf(separator,end + separator.length());
- }
- end = value.indexOf(separator,start);
- }
- if(start < value.length()){
- result.add(value.substring(start));
- }
- return result;
- }
-
- /**
- * plits the given String value as a map entry, splitting it into key and value part with the given separator.
- * If the value cannot be split then {@code key = value = mapEntry} is used for further processing. key or value
- * parts are normally trimmed, unless they are enmcosed with brackets {@code []}.
- * @param mapEntry the entry, not null.
- * @param context the conversion context.
- * @return an array of length 2, with the trimmed and parsed key/value pair.
- */
- public static String[] splitMapEntry(String mapEntry, ConversionContext context){
- return splitMapEntry(mapEntry, ConfigurationProvider.getConfiguration().getOrDefault(
- '_' + context.getKey()+".map-entry-separator", "::"));
- }
-
- /**
- * Splits the given String value as a map entry, splitting it into key and value part with the given separator.
- * If the value cannot be split then {@code key = value = mapEntry} is used for further processing. key or value
- * parts are normally trimmed, unless they are enmcosed with brackets {@code []}.
- * @param mapEntry the entry, not null.
- * @param separator the separator, not null.
- * @return an array of length 2, with the trimmed and parsed key/value pair.
- */
- public static String[] splitMapEntry(final String mapEntry, final String separator) {
- int index = mapEntry.indexOf(separator);
- String[] items;
- if(index<0) {
- items = new String[]{mapEntry, mapEntry};
- }else {
- items = new String[]{mapEntry.substring(0,index),
- mapEntry.substring(index+separator.length())};
- }
- if(items[0].trim().startsWith("[")){
- items[0]= items[0].trim();
- items[0] = items[0].substring(1);
- }else{
- items[0]= items[0].trim();
- }
- if(items[1].trim().endsWith("]")){
- items[1] = items[1].substring(0,items[1].length()-1);
- }else{
- items[1]= items[1].trim();
- }
- return items;
- }
-
- /**
- * Parses the given value into the required collection target type, defined by the context.
- * @param value the raw String value.
- * @param context the context
- * @return the parsed value, or null.
- */
- public static Object convertValue(String value, ConversionContext context) {
- String converterClass = context.getConfiguration().get('_' + context.getKey() + ".item-converter");
- List<PropertyConverter<Object>> valueConverters = new ArrayList<>(1);
- if (converterClass != null) {
- try {
- valueConverters.add((PropertyConverter<Object>) Class.forName(converterClass).newInstance());
- } catch (Exception e) {
- LOG.log(Level.SEVERE, "Error convertion config to ArrayList type.", e);
- }
- }
- if (TypeLiteral.getTypeParameters(context.getTargetType().getType()).length>0) {
- valueConverters.addAll(context.getConfigurationContext().getPropertyConverters(
- TypeLiteral.of(TypeLiteral.getTypeParameters(context.getTargetType().getType())[0])));
- }
- ConversionContext ctx = new ConversionContext.Builder(context.getConfiguration(),
- context.getConfigurationContext(), context.getKey(),
- TypeLiteral.of(context.getTargetType().getType())).build();
- Object result = null;
- if (valueConverters.isEmpty()) {
- return value;
- } else {
- for (PropertyConverter<Object> conv : valueConverters) {
- try {
- result = conv.convert(value, ctx);
- if (result != null) {
- return result;
- }
- } catch (Exception e) {
- LOG.log(Level.SEVERE, "Error convertion config to ArrayList type.", e);
- }
- }
- }
- LOG.log(Level.SEVERE, "Failed to convert collection value type for '" + value + "'.");
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/LinkedListConverter.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/LinkedListConverter.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/LinkedListConverter.java
deleted file mode 100644
index 2d35644..0000000
--- a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/LinkedListConverter.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.collections.internal;
-
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * PropertyConverter for gnerating LinkedList representation of a values.
- */
-public class LinkedListConverter implements PropertyConverter<LinkedList> {
- private static final Logger LOG = Logger.getLogger(LinkedListConverter.class.getName());
-
- /** The shared instance, used by other collection converters in this package.*/
- private static final LinkedListConverter INSTANCE = new LinkedListConverter();
-
- /**
- * Provide a shared instance, used by other collection converters in this package.
- * @return the shared instance, never null.
- */
- static LinkedListConverter getInstance(){
- return INSTANCE;
- }
-
- @Override
- public LinkedList convert(String value, ConversionContext context) {
- List<String> rawList = ItemTokenizer.split(value, context);
- LinkedList<Object> result = new LinkedList<>();
- for(String raw:rawList){
- String[] items = ItemTokenizer.splitMapEntry(raw, context);
- Object convValue = ItemTokenizer.convertValue(items[1], context);
- if(convValue!=null){
- result.add(convValue);
- continue;
- }else{
- LOG.log(Level.SEVERE, "Failed to convert collection value type for '"+raw+"'.");
- }
- }
- return result;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ListConverter.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ListConverter.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ListConverter.java
deleted file mode 100644
index 64917f2..0000000
--- a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ListConverter.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.collections.internal;
-
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-import java.util.Collections;
-import java.util.List;
-
-/**
- * PropertyConverter for gnerating a LIST representation of values.
- */
-public class ListConverter implements PropertyConverter<List> {
-
- @Override
- public List convert(String value, ConversionContext context) {
- String collectionType = context.getConfiguration().getOrDefault('_' + context.getKey()+".collection-type", "List");
- if(collectionType.startsWith("java.util.")){
- collectionType = collectionType.substring("java.util.".length());
- }
- List result = null;
- switch(collectionType){
- case "LinkedList":
- result = LinkedListConverter.getInstance().convert(value, context);
- break;
- case "List":
- case "ArrayList":
- default:
- result = ArrayListConverter.getInstance().convert(value, context);
- break;
- }
- if(context.getConfiguration().getOrDefault('_' + context.getKey()+".read-only",
- Boolean.class, Boolean.TRUE)){
- return Collections.unmodifiableList(result);
- }
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/MapConverter.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/MapConverter.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/MapConverter.java
deleted file mode 100644
index 8b9287e..0000000
--- a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/MapConverter.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.collections.internal;
-
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-import java.util.Collections;
-import java.util.Map;
-
-/**
- * PropertyConverter for gnerating HashMap representation of a values.
- */
-public class MapConverter implements PropertyConverter<Map> {
-
- @Override
- public Map convert(String value, ConversionContext context) {
- String collectionType = context.getConfiguration().getOrDefault('_' + context.getKey()+".collection-type", "Map");
- if(collectionType.startsWith("java.util.")){
- collectionType = collectionType.substring("java.util.".length());
- }
- Map result = null;
- switch(collectionType){
- case "TreeMap":
- result = TreeMapConverter.getInstance().convert(value, context);
- break;
- case "ConcurrentHashMap":
- result = ConcurrentHashMapConverter.getInstance().convert(value, context);
- break;
- case "Map":
- case "HashMap":
- default:
- result = HashMapConverter.getInstance().convert(value, context);
- break;
- }
- if(context.getConfiguration().getOrDefault('_' + context.getKey()+".read-only",
- Boolean.class, Boolean.TRUE)){
- return Collections.unmodifiableMap(result);
- }
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/SetConverter.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/SetConverter.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/SetConverter.java
deleted file mode 100644
index d4fe1c6..0000000
--- a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/SetConverter.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.collections.internal;
-
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-import java.util.Collections;
-import java.util.Set;
-
-/**
- * PropertyConverter for gnerating a LIST representation of values.
- */
-public class SetConverter implements PropertyConverter<Set> {
-
- @Override
- public Set convert(String value, ConversionContext context) {
- String collectionType = context.getConfiguration().getOrDefault('_' + context.getKey()+".collection-type", "Set");
- if(collectionType.startsWith("java.util.")){
- collectionType = collectionType.substring("java.util.".length());
- }
- Set result = null;
- switch(collectionType){
- case "TreeSet":
- result = TreeSetConverter.getInstance().convert(value, context);
- break;
- case "Set":
- case "HashSet":
- default:
- result = HashSetConverter.getInstance().convert(value, context);
- break;
- }
- if(context.getConfiguration().getOrDefault('_' + context.getKey()+".read-only",
- Boolean.class, Boolean.TRUE)){
- return Collections.unmodifiableSet(result);
- }
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/SortedMapConverter.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/SortedMapConverter.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/SortedMapConverter.java
deleted file mode 100644
index c87006d..0000000
--- a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/SortedMapConverter.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.collections.internal;
-
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-import java.util.Collections;
-import java.util.SortedMap;
-
-/**
- * PropertyConverter for gnerating a LIST representation of values.
- */
-public class SortedMapConverter implements PropertyConverter<SortedMap> {
-
- @Override
- public SortedMap convert(String value, ConversionContext context) {
- return Collections.unmodifiableSortedMap(TreeMapConverter.getInstance().convert(value, context));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/SortedSetConverter.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/SortedSetConverter.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/SortedSetConverter.java
deleted file mode 100644
index c0b8065..0000000
--- a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/SortedSetConverter.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.collections.internal;
-
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-import java.util.Collections;
-import java.util.SortedSet;
-
-/**
- * PropertyConverter for gnerating a LIST representation of values.
- */
-public class SortedSetConverter implements PropertyConverter<SortedSet> {
-
- @Override
- public SortedSet convert(String value, ConversionContext context) {
- return Collections.unmodifiableSortedSet(TreeSetConverter.getInstance().convert(value, context));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/TreeMapConverter.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/TreeMapConverter.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/TreeMapConverter.java
deleted file mode 100644
index c8a7c3a..0000000
--- a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/TreeMapConverter.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.collections.internal;
-
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-import java.util.List;
-import java.util.TreeMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * PropertyConverter for gnerating HashMap representation of a values.
- */
-public class TreeMapConverter implements PropertyConverter<TreeMap> {
- /** Logger used. */
- private static final Logger LOG = Logger.getLogger(HashMapConverter.class.getName());
-
- /** The shared instance, used by other collection converters in this package.*/
- private static final TreeMapConverter INSTANCE = new TreeMapConverter();
-
- /**
- * Provide a shared instance, used by other collection converters in this package.
- * @return the shared instance, never null.
- */
- static TreeMapConverter getInstance(){
- return INSTANCE;
- }
-
- @Override
- public TreeMap convert(String value, ConversionContext context) {
- List<String> rawList = ItemTokenizer.split(value, context);
- TreeMap result = new TreeMap();
- for(String raw:rawList){
- String[] items = ItemTokenizer.splitMapEntry(raw, context);
- Object convValue = ItemTokenizer.convertValue(items[1], context);
- if(convValue!=null){
- result.put(items[0], convValue);
- }else{
- LOG.log(Level.SEVERE, "Failed to convert collection value type for '"+raw+"'.");
- }
- }
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/TreeSetConverter.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/TreeSetConverter.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/TreeSetConverter.java
deleted file mode 100644
index 399a07b..0000000
--- a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/TreeSetConverter.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.collections.internal;
-
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-import java.util.List;
-import java.util.TreeSet;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * PropertyConverter for gnerating HashSet representation of a values.
- */
-public class TreeSetConverter implements PropertyConverter<TreeSet> {
-
- private static final Logger LOG = Logger.getLogger(TreeSetConverter.class.getName());
-
- /** The shared instance, used by other collection converters in this package.*/
- private static final TreeSetConverter INSTANCE = new TreeSetConverter();
-
- /**
- * Provide a shared instance, used by other collection converters in this package.
- * @return the shared instance, never null.
- */
- static TreeSetConverter getInstance(){
- return INSTANCE;
- }
-
- @Override
- public TreeSet convert(String value, ConversionContext context) {
- List<String> rawList = ItemTokenizer.split(value, context);
- TreeSet<Object> result = new TreeSet<>();
- for(String raw:rawList){
- String[] items = ItemTokenizer.splitMapEntry(raw, context);
- Object convValue = ItemTokenizer.convertValue(items[1], context);
- if(convValue!=null){
- result.add(convValue);
- continue;
- }else{
- LOG.log(Level.SEVERE, "Failed to convert collection value type for '"+raw+"'.");
- }
- }
- return result;
- }
-}
[24/24] incubator-tamaya git commit: Removed all modules from the
main repository. They will be reborn in separate ASF repository.
Posted by pl...@apache.org.
Removed all modules from the main repository. They will be reborn in separate ASF repository.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/359d3e4a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/359d3e4a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/359d3e4a
Branch: refs/heads/master
Commit: 359d3e4a20bbbcfc8b016325bef7fe2056c267cd
Parents: a41d143
Author: Oliver B. Fischer <pl...@apache.org>
Authored: Thu Sep 15 19:26:04 2016 +0200
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Thu Sep 15 19:26:04 2016 +0200
----------------------------------------------------------------------
modules/builder/pom.xml | 104 ---
.../tamaya/builder/ConfigurationBuilder.java | 605 -------------
.../ProgrammaticConfigurationContext.java | 388 --------
.../tamaya/builder/PropertySourceBuilder.java | 118 ---
.../tamaya/builder/SimplePropertySource.java | 86 --
.../org/apache/tamaya/builder/package-info.java | 28 -
.../builder/ConfigurationBuilderTest.java | 907 -------------------
.../builder/TestANonSPIPropertyFilter.java | 35 -
.../builder/TestBNonSPIPropertyFilter.java | 35 -
.../tamaya/builder/TestPropertyFilter.java | 35 -
.../tamaya/builder/TestPropertySource.java | 59 --
.../builder/TestPropertySourceProvider.java | 91 --
.../builder/TestPropertySourceProviderB.java | 91 --
.../builder/util/mockito/NotMockedAnswer.java | 57 --
.../tamaya/builder/util/types/CustomTypeA.java | 34 -
.../tamaya/builder/util/types/CustomTypeB.java | 39 -
.../tamaya/builder/util/types/CustomTypeC.java | 36 -
.../types/CustomTypeCPropertyConverter.java | 29 -
.../org.apache.tamaya.spi.PropertyConverter | 19 -
.../org.apache.tamaya.spi.PropertyFilter | 19 -
.../org.apache.tamaya.spi.PropertySource | 19 -
...org.apache.tamaya.spi.PropertySourceProvider | 19 -
.../test/resources/configfiles/json/first.json | 4 -
.../test/resources/configfiles/json/second.json | 4 -
.../test/resources/configfiles/json/simple.json | 4 -
.../test/resources/configfiles/json/third.json | 4 -
.../test/resources/configfiles/other/simple.oml | 19 -
modules/classloader-support/pom.xml | 74 --
.../AbstractClassloaderAwareItemLoader.java | 268 ------
.../clsupport/CLAwareConfigurationContext.java | 105 ---
.../tamaya/clsupport/CLAwareServiceContext.java | 248 -----
.../tamaya/clsupport/ServiceContainer.java | 306 -------
.../apache/tamaya/clsupport/package-info.java | 22 -
.../org.apache.tamaya.spi.ServiceContext | 19 -
...he.tamaya.environment.spi.ContextProviderSpi | 23 -
...org.apache.tamaya.environment.spi.ContextSpi | 19 -
modules/collections/pom.xml | 74 --
.../internal/AdaptiveCombinationPolicy.java | 125 ---
.../internal/ArrayListConverter.java | 62 --
.../internal/CollectionConverter.java | 63 --
.../internal/ConcurrentHashMapConverter.java | 63 --
.../collections/internal/HashMapConverter.java | 63 --
.../collections/internal/HashSetConverter.java | 62 --
.../collections/internal/ItemTokenizer.java | 171 ----
.../internal/LinkedListConverter.java | 63 --
.../collections/internal/ListConverter.java | 55 --
.../collections/internal/MapConverter.java | 58 --
.../collections/internal/SetConverter.java | 55 --
.../internal/SortedMapConverter.java | 36 -
.../internal/SortedSetConverter.java | 36 -
.../collections/internal/TreeMapConverter.java | 62 --
.../collections/internal/TreeSetConverter.java | 63 --
.../org.apache.tamaya.spi.PropertyConverter | 31 -
...he.tamaya.spi.PropertyValueCombinationPolicy | 19 -
.../collections/CollectionAdvancedTests.java | 117 ---
.../collections/CollectionsBaseTests.java | 227 -----
.../CollectionsTypedReadOnlyTests.java | 173 ----
.../collections/CollectionsTypedTests.java | 208 -----
.../collections/MyUpperCaseConverter.java | 33 -
.../META-INF/javaconfiguration.properties | 73 --
modules/events/pom.xml | 99 --
.../org/apache/tamaya/events/ChangeType.java | 31 -
.../org/apache/tamaya/events/ConfigEvent.java | 55 --
.../tamaya/events/ConfigEventListener.java | 31 -
.../tamaya/events/ConfigEventManager.java | 186 ----
.../tamaya/events/ConfigurationChange.java | 218 -----
.../events/ConfigurationChangeBuilder.java | 274 ------
.../events/ConfigurationContextChange.java | 210 -----
.../ConfigurationContextChangeBuilder.java | 174 ----
.../tamaya/events/FrozenConfiguration.java | 194 ----
.../tamaya/events/FrozenPropertySource.java | 126 ---
.../tamaya/events/PropertySourceChange.java | 242 -----
.../events/PropertySourceChangeBuilder.java | 263 ------
.../tamaya/events/delta/package-info.java | 23 -
.../folderobserver/FileChangeListener.java | 144 ---
.../folderobserver/FileChangeObserver.java | 33 -
.../ObservingPropertySourceProvider.java | 209 -----
.../events/folderobserver/package-info.java | 24 -
.../internal/DefaultConfigChangeObserver.java | 111 ---
.../internal/DefaultConfigEventManagerSpi.java | 202 -----
...faultConfigurationContextChangeListener.java | 74 --
.../events/internal/LoggingConfigListener.java | 40 -
.../tamaya/events/internal/package-info.java | 22 -
.../org/apache/tamaya/events/package-info.java | 24 -
.../tamaya/events/spi/BaseConfigEvent.java | 69 --
.../events/spi/ConfigEventManagerSpi.java | 128 ---
.../apache/tamaya/events/spi/package-info.java | 23 -
...org.apache.tamaya.events.ConfigEventListener | 19 -
...ache.tamaya.events.spi.ConfigEventManagerSpi | 19 -
.../events/ChangeableGlobalPropertySource.java | 62 --
.../ChangeableThreadLocalPropertySource.java | 57 --
.../tamaya/events/ConfigEventManagerTest.java | 66 --
.../tamaya/events/FrozenPropertySourceTest.java | 106 ---
.../tamaya/events/ObservedConfigTest.java | 69 --
.../tamaya/events/RandomPropertySource.java | 66 --
.../org/apache/tamaya/events/SimpleEvent.java | 32 -
.../apache/tamaya/events/TestConfigView.java | 156 ----
.../tamaya/events/TestObservingProvider.java | 92 --
.../events/delta/ConfigurationChangeTest.java | 163 ----
.../delta/ConfigurationContextChangeTest.java | 138 ---
.../events/delta/PropertySourceChangeTest.java | 209 -----
.../DefaultConfigEventManagerSpiTest.java | 66 --
...org.apache.tamaya.events.ConfigEventListener | 19 -
.../org.apache.tamaya.spi.PropertySource | 19 -
...org.apache.tamaya.spi.PropertySourceProvider | 19 -
.../src/test/resources/data/test1.properties | 20 -
.../src/test/resources/data/test1b.properties | 20 -
.../src/test/resources/data/test2.properties | 20 -
.../src/test/resources/data/test3.properties | 20 -
.../events/src/test/resources/test.properties | 21 -
modules/filter/pom.xml | 81 --
.../tamaya/filter/ConfigurationFilter.java | 121 ---
.../tamaya/filter/ProgrammableFilter.java | 118 ---
.../tamaya/filter/RegexPropertyFilter.java | 56 --
.../filter/internal/DefaultMetadataFilter.java | 43 -
.../org.apache.tamaya.spi.PropertyFilter | 19 -
.../tamaya/filter/ConfigurationFilterTest.java | 122 ---
.../tamaya/filter/ProgrammableFilterTest.java | 141 ---
.../tamaya/filter/RegexPropertyFilterTest.java | 55 --
modules/formats/pom.xml | 86 --
.../BaseFormatPropertySourceProvider.java | 154 ----
.../apache/tamaya/format/ConfigurationData.java | 206 -----
.../tamaya/format/ConfigurationDataBuilder.java | 219 -----
.../tamaya/format/ConfigurationFormat.java | 103 ---
.../tamaya/format/ConfigurationFormats.java | 187 ----
.../format/FlattenedDefaultPropertySource.java | 118 ---
.../tamaya/format/InputStreamFactory.java | 89 --
.../format/formats/IniConfigurationFormat.java | 95 --
.../tamaya/format/formats/PropertiesFormat.java | 71 --
.../format/formats/PropertiesXmlFormat.java | 69 --
.../tamaya/format/formats/package-info.java | 23 -
.../org/apache/tamaya/format/package-info.java | 28 -
...org.apache.tamaya.format.ConfigurationFormat | 21 -
.../tamaya/format/ConfigurationFormatsTest.java | 68 --
.../FlattenedDefaultPropertySourceTest.java | 98 --
.../tamaya/format/InputStreamFactoryTest.java | 145 ---
modules/formats/src/test/resources/Test.ini | 26 -
.../formats/src/test/resources/Test.properties | 21 -
modules/functions/pom.xml | 79 --
.../tamaya/functions/CombinedConfiguration.java | 146 ---
.../functions/ConfigWrappingPropertySource.java | 80 --
.../functions/ConfigurationFunctions.java | 662 --------------
.../tamaya/functions/EnrichedConfiguration.java | 159 ----
.../functions/EnrichedPropertySource.java | 97 --
.../tamaya/functions/FilteredConfiguration.java | 126 ---
.../functions/FilteredPropertySource.java | 84 --
.../org/apache/tamaya/functions/KeyMapper.java | 37 -
.../tamaya/functions/MappedConfiguration.java | 132 ---
.../tamaya/functions/MappedPropertySource.java | 88 --
.../org/apache/tamaya/functions/Predicate.java | 42 -
.../apache/tamaya/functions/PropertyMapper.java | 36 -
.../tamaya/functions/PropertyMatcher.java | 38 -
.../functions/PropertySourceFunctions.java | 348 -------
.../functions/ValueMappedPropertySource.java | 85 --
.../apache/tamaya/functions/package-info.java | 22 -
.../functions/ConfigurationFunctionsTest.java | 143 ---
.../functions/PropertySourceFunctionsTest.java | 106 ---
modules/injection-api/pom.xml | 79 --
.../tamaya/inject/api/BaseDynamicValue.java | 125 ---
.../org/apache/tamaya/inject/api/Config.java | 93 --
.../tamaya/inject/api/ConfigAutoInject.java | 36 -
.../inject/api/ConfigDefaultSections.java | 44 -
.../inject/api/ConfiguredItemSupplier.java | 41 -
.../apache/tamaya/inject/api/DynamicValue.java | 161 ----
.../tamaya/inject/api/InjectionUtils.java | 127 ---
.../apache/tamaya/inject/api/LoadPolicy.java | 42 -
.../org/apache/tamaya/inject/api/NoConfig.java | 36 -
.../apache/tamaya/inject/api/UpdatePolicy.java | 40 -
.../tamaya/inject/api/WithConfigOperator.java | 45 -
.../inject/api/WithPropertyConverter.java | 46 -
.../apache/tamaya/inject/api/package-info.java | 22 -
.../tamaya/inject/spi/ConfiguredField.java | 68 --
.../tamaya/inject/spi/ConfiguredMethod.java | 70 --
.../tamaya/inject/spi/ConfiguredType.java | 63 --
modules/injection/pom.xml | 102 ---
.../tamaya/inject/ConfigurationInjection.java | 42 -
.../tamaya/inject/ConfigurationInjector.java | 94 --
.../ConfigTemplateInvocationHandler.java | 73 --
.../inject/internal/ConfiguredFieldImpl.java | 170 ----
.../inject/internal/ConfiguredSetterMethod.java | 139 ---
.../inject/internal/ConfiguredTypeImpl.java | 237 -----
.../internal/DefaultConfigurationInjector.java | 179 ----
.../inject/internal/DefaultDynamicValue.java | 498 ----------
.../tamaya/inject/internal/InjectionHelper.java | 244 -----
.../apache/tamaya/inject/internal/Utils.java | 128 ---
.../tamaya/inject/internal/package-info.java | 22 -
.../org/apache/tamaya/inject/package-info.java | 22 -
...g.apache.tamaya.inject.ConfigurationInjector | 19 -
.../java/annottext/AnnotatedConfigBean.java | 78 --
.../java/annottext/AnnotatedConfigTemplate.java | 47 -
.../java/annottext/NonAnnotatedConfigBean.java | 45 -
.../tamaya/inject/TamayaInjectionTest.java | 87 --
.../tamaya/inject/TestPropertySource.java | 68 --
.../internal/DefaultDynamicValueTest.java | 315 -------
.../org.apache.tamaya.spi.PropertySource | 19 -
modules/integration/camel/pom.xml | 100 --
.../camel/TamayaPropertiesComponent.java | 78 --
.../camel/TamayaPropertyResolver.java | 53 --
.../camel/TamayaPropertyResolverTest.java | 116 ---
.../test/resources/META-INF/camelcontext.xml | 52 --
.../META-INF/javaconfiguration.properties | 19 -
.../src/test/resources/META-INF/routes.xml | 39 -
modules/integration/cdi-se/pom.xml | 210 -----
.../integration/cdi/CDIAwareServiceContext.java | 169 ----
.../cdi/DefaultConfigurationContext.java | 286 ------
.../cdi/DefaultConfigurationContextBuilder.java | 152 ----
.../tamaya/integration/cdi/EnumConverter.java | 71 --
.../cdi/PropertyConverterManager.java | 427 ---------
.../integration/cdi/SEInjectorCDIExtension.java | 112 ---
.../cdi/ServiceLoaderServiceContext.java | 151 ---
.../integration/cdi/TamayaCDIIntegration.java | 52 --
.../integration/cdi/TamayaConfigProvider.java | 54 --
.../cdi/config/ConfiguredVetoExtension.java | 42 -
.../src/main/resources/META-INF/beans.xml | 24 -
.../javax.enterprise.inject.spi.Extension | 20 -
.../org.apache.tamaya.spi.ServiceContext | 19 -
.../tamaya/integration/cdi/ConfiguredClass.java | 112 ---
.../tamaya/integration/cdi/ConfiguredTest.java | 83 --
.../tamaya/integration/cdi/InjectedClass.java | 62 --
.../cdi/cfg/ProvidedPropertySource.java | 67 --
.../integration/cdi/cfg/TestConfigProvider.java | 45 -
.../integration/cdi/cfg/TestPropertySource.java | 79 --
.../src/test/resources/META-INF/beans.xml | 24 -
.../META-INF/javaconfiguration.properties | 20 -
modules/integration/cdi/pom.xml | 224 -----
.../integration/cdi/CDIConfiguredField.java | 77 --
.../integration/cdi/CDIConfiguredMethod.java | 77 --
.../integration/cdi/CDIConfiguredType.java | 94 --
.../integration/cdi/ConfigurationExtension.java | 287 ------
.../integration/cdi/ConfigurationProducer.java | 146 ---
.../integration/cdi/DefaultDynamicValue.java | 499 ----------
.../cdi/src/main/resources/META-INF/beans.xml | 19 -
.../javax.enterprise.inject.spi.Extension | 19 -
...onfigurationProducerFailedInjectionTest.java | 33 -
.../cdi/ConfigurationProducerTest.java | 168 ----
.../cdi/ConfigurationResolverTest.java | 112 ---
.../integration/cdi/EnvironmentsTest.java | 83 --
.../integration/cdi/InterpolationTest.java | 62 --
.../integration/cdi/NotFoundNoDefault.java | 78 --
.../cdi/src/test/resources/META-INF/beans.xml | 19 -
.../META-INF/javaconfiguration.properties | 32 -
.../cdi/src/test/resources/base.properties | 32 -
.../cdi/src/test/resources/cert.properties | 20 -
.../cdi/src/test/resources/dev.properties | 19 -
.../cdi/src/test/resources/prod.properties | 20 -
.../cdi/src/test/resources/qa.properties | 20 -
.../cdi/src/test/resources/test.properties | 20 -
modules/integration/consul/pom.xml | 112 ---
.../apache/tamaya/consul/ConsulBackends.java | 59 --
.../tamaya/consul/ConsulPropertySource.java | 198 ----
.../org.apache.tamaya.spi.PropertySource | 19 -
.../tamaya/etcd/ConsulPropertySourceTest.java | 75 --
.../org/apache/tamaya/etcd/ConsulWriteTest.java | 80 --
modules/integration/etcd/pom.xml | 110 ---
.../org/apache/tamaya/etcd/EtcdAccessor.java | 520 -----------
.../org/apache/tamaya/etcd/EtcdBackends.java | 65 --
.../apache/tamaya/etcd/EtcdPropertySource.java | 209 -----
.../org.apache.tamaya.spi.PropertySource | 19 -
.../apache/tamaya/etcd/EtcdAccessorTest.java | 116 ---
.../tamaya/etcd/EtcdPropertySourceTest.java | 74 --
modules/integration/osgi/pom.xml | 102 ---
.../tamaya/integration/osgi/Activator.java | 134 ---
.../integration/osgi/OSGIConfigRootMapper.java | 36 -
.../osgi/OSGIEnhancedConfiguration.java | 117 ---
.../integration/osgi/TamayaConfigAdminImpl.java | 196 ----
.../osgi/TamayaConfigurationImpl.java | 127 ---
.../META-INF/javaconfiguration.properties | 18 -
.../osgi/src/test/resources/arquillian.xml | 27 -
.../osgi/src/test/resources/felix.properties | 23 -
modules/integration/pom.xml | 43 -
modules/integration/spring/pom.xml | 116 ---
.../SpringConfigInjectionPostProcessor.java | 42 -
.../integration/spring/TamayaEnvironment.java | 33 -
.../integration/spring/TamayaSpringConfig.java | 56 --
.../spring/TamayaSpringPropertySource.java | 39 -
.../spring/src/main/resources/spring-config.xml | 32 -
.../spring/ConfiguredSpringBean.java | 62 --
.../integration/spring/SpringConfigTest.java | 61 --
.../integration/spring/SpringConfigTest2.java | 47 -
.../META-INF/javaconfiguration.properties | 20 -
.../test/resources/spring-config-scanOnly.xml | 35 -
.../spring/src/test/resources/spring-config.xml | 31 -
modules/json/pom.xml | 147 ---
.../java/org/apache/tamaya/json/JSONFormat.java | 85 --
.../apache/tamaya/json/JSONPropertySource.java | 149 ---
.../org/apache/tamaya/json/JSONVisitor.java | 119 ---
...org.apache.tamaya.format.ConfigurationFormat | 19 -
.../json/CommonJSONTestCaseCollection.java | 190 ----
.../org/apache/tamaya/json/JSONFormatIT.java | 48 -
.../org/apache/tamaya/json/JSONFormatTest.java | 75 --
.../tamaya/json/JSONPropertySourceTest.java | 56 --
modules/json/src/test/resources/arquillian.xml | 30 -
.../test/resources/configs/invalid/array.json | 21 -
.../resources/configs/invalid/empty-file.json | 18 -
.../configs/invalid/only-opening-bracket.json | 19 -
.../resources/configs/invalid/with-array.json | 27 -
.../test/resources/configs/valid/cyrillic.json | 22 -
.../configs/valid/empty-object-config.json | 20 -
.../valid/simple-flat-string-only-config.json | 23 -
.../simple-nested-string-only-config-1.json | 27 -
.../simple-nested-string-only-config-2.json | 26 -
.../configs/valid/with-explicit-priority.json | 25 -
modules/management/pom.xml | 81 --
.../management/ConfigManagementSupport.java | 128 ---
.../apache/tamaya/management/ManagedConfig.java | 110 ---
.../tamaya/management/ManagedConfigMBean.java | 119 ---
.../src/main/resources/META-INF/beans.xml | 24 -
.../META-INF/javaconfiguration.properties | 19 -
....apache.tamaya.management.ManagedConfigMBean | 19 -
.../management/internal/ManagedConfigTest.java | 118 ---
.../src/test/resources/META-INF/beans.xml | 24 -
modules/model/pom.xml | 120 ---
.../org/apache/tamaya/model/ConfigModel.java | 78 --
.../apache/tamaya/model/ConfigModelManager.java | 289 ------
.../apache/tamaya/model/ConfigUsageStats.java | 129 ---
.../org/apache/tamaya/model/ModelTarget.java | 37 -
.../java/org/apache/tamaya/model/Usage.java | 312 -------
.../org/apache/tamaya/model/Validation.java | 203 -----
.../apache/tamaya/model/ValidationResult.java | 59 --
.../model/internal/ConfigDocumentationBean.java | 197 ----
.../ConfiguredInlineModelProviderSpi.java | 69 --
.../ConfiguredPropertiesModelProviderSpi.java | 154 ----
.../ConfiguredResourcesModelProviderSpi.java | 160 ----
.../ConfiguredTypeEventsModelPopulator.java | 90 --
.../ConfiguredTypeEventsModelProvider.java | 51 --
.../model/internal/DefaultConfigUsageStats.java | 176 ----
.../model/internal/UsageTrackerFilter.java | 46 -
.../tamaya/model/spi/AbstractConfigModel.java | 88 --
.../model/spi/ConfigDocumentationMBean.java | 53 --
.../tamaya/model/spi/ConfigModelReader.java | 144 ---
.../tamaya/model/spi/ConfigUsageStatsSpi.java | 101 ---
.../org/apache/tamaya/model/spi/GroupModel.java | 110 ---
.../tamaya/model/spi/ModelProviderSpi.java | 39 -
.../apache/tamaya/model/spi/ParameterModel.java | 242 -----
.../apache/tamaya/model/spi/SectionModel.java | 202 -----
.../resources/META-INF/configmodel.properties | 35 -
...org.apache.tamaya.events.ConfigEventListener | 19 -
...he.tamaya.model.spi.ConfigDocumentationMBean | 19 -
....apache.tamaya.model.spi.ConfigUsageStatsSpi | 19 -
...org.apache.tamaya.model.spi.ModelProviderSpi | 22 -
.../org.apache.tamaya.spi.PropertyFilter | 19 -
.../tamaya/model/ConfigModelProviderTest.java | 68 --
.../tamaya/model/ConfigUsageStatsTest.java | 114 ---
.../apache/tamaya/model/ValidationTests.java | 52 --
.../internal/ConfigDocumentationBeanTest.java | 108 ---
.../java/test/model/TestConfigAccessor.java | 45 -
.../resources/META-INF/configmodel.properties | 96 --
.../META-INF/javaconfiguration.properties | 22 -
...org.apache.tamaya.model.spi.ModelProviderSpi | 19 -
.../src/test/resources/examples/configmodel.ini | 76 --
.../test/resources/examples/configmodel.json | 108 ---
.../resources/examples/configmodel.properties | 96 --
.../src/test/resources/examples/configmodel.xml | 97 --
.../test/resources/examples/configmodel.yaml | 106 ---
modules/mutable-config/pom.xml | 83 --
.../mutableconfig/ChangePropagationPolicy.java | 53 --
.../mutableconfig/MutableConfiguration.java | 126 ---
.../MutableConfigurationProvider.java | 239 -----
.../internal/DefaultMutableConfiguration.java | 170 ----
.../DefaultMutableConfigurationSpi.java | 38 -
.../MutablePropertiesPropertySource.java | 196 ----
.../MutableXmlPropertiesPropertySource.java | 198 ----
.../mutableconfig/spi/ConfigChangeRequest.java | 176 ----
.../spi/MutableConfigurationProviderSpi.java | 42 -
.../spi/MutablePropertySource.java | 47 -
...leconfig.spi.MutableConfigurationProviderSpi | 19 -
.../mutableconfig/MutableConfigurationTest.java | 187 ----
.../PropertiesFileConfigBackendTest.java | 29 -
.../internal/WritablePropertiesSource.java | 49 -
.../internal/WritableXmlPropertiesSource.java | 49 -
.../org.apache.tamaya.spi.PropertySource | 20 -
modules/optional/pom.xml | 81 --
.../tamaya/optional/EvaluationPolicy.java | 33 -
.../tamaya/optional/OptionalConfiguration.java | 214 -----
.../apache/tamaya/optional/ValueProvider.java | 40 -
.../optional/OptionalConfigurationTest.java | 101 ---
modules/pom.xml | 119 ---
modules/resolver/pom.xml | 85 --
.../org/apache/tamaya/resolver/Resolver.java | 77 --
.../resolver/internal/ConfigResolver.java | 43 -
.../internal/DefaultExpressionEvaluator.java | 260 ------
.../internal/EnvironmentPropertyResolver.java | 42 -
.../internal/ExpressionResolutionFilter.java | 86 --
.../tamaya/resolver/internal/FileResolver.java | 120 ---
.../resolver/internal/ResourceResolver.java | 151 ---
.../internal/SystemPropertyResolver.java | 42 -
.../tamaya/resolver/internal/URLResolver.java | 66 --
.../tamaya/resolver/internal/package-info.java | 23 -
.../apache/tamaya/resolver/package-info.java | 22 -
.../resolver/spi/ExpressionEvaluator.java | 66 --
.../tamaya/resolver/spi/ExpressionResolver.java | 48 -
.../tamaya/resolver/spi/package-info.java | 23 -
...ache.tamaya.resolver.spi.ExpressionEvaluator | 19 -
...pache.tamaya.resolver.spi.ExpressionResolver | 24 -
.../org.apache.tamaya.spi.PropertyFilter | 19 -
.../tamaya/resolver/ConfigResolutionTest.java | 121 ---
.../tamaya/resolver/MyTestPropertySource.java | 102 ---
.../apache/tamaya/resolver/ResolverTest.java | 41 -
.../org.apache.tamaya.spi.PropertySource | 19 -
.../src/test/resources/Testresource.txt | 19 -
.../src/test/resources/Testresource2.txt | 19 -
modules/resources/README.md | 26 -
modules/resources/pom.xml | 77 --
.../AbstractPathPropertySourceProvider.java | 193 ----
.../tamaya/resource/BaseResourceResolver.java | 111 ---
.../apache/tamaya/resource/ConfigResources.java | 51 --
.../apache/tamaya/resource/ResourceLocator.java | 37 -
.../tamaya/resource/ResourceResolver.java | 101 ---
.../internal/ClassPathResourceLocator.java | 69 --
.../resource/internal/ClasspathCollector.java | 381 --------
.../internal/DefaultResourceResolver.java | 60 --
.../tamaya/resource/internal/FileCollector.java | 178 ----
.../resource/internal/FileResourceLocator.java | 69 --
.../tamaya/resource/internal/Locator.java | 155 ----
.../resource/internal/PathResourceLocator.java | 65 --
.../resource/internal/URLResourceLocator.java | 66 --
.../tamaya/resource/internal/VfsSupport.java | 252 ------
.../tamaya/resource/internal/package-info.java | 23 -
.../apache/tamaya/resource/package-info.java | 22 -
.../org.apache.tamaya.resource.ResourceLocator | 22 -
.../org.apache.tamaya.resource.ResourceResolver | 19 -
.../AbstractPathPropertySourceProviderTest.java | 133 ---
.../internal/ClasspathCollectorTest.java | 89 --
.../internal/DefaultResourceResolverTest.java | 59 --
.../resource/internal/FileCollectorTest.java | 72 --
.../PathBasedPropertySourceProvider.java | 97 --
.../resources/resources_testroot/aa_a/a1_1.file | 18 -
.../resources/resources_testroot/aa_a/a1_2.file | 18 -
.../resources/resources_testroot/aa_a/a2.file | 18 -
.../resources/resources_testroot/aa_a/a3.file | 18 -
.../resources/resources_testroot/aa_a/z3.file | 18 -
.../resources_testroot/bb/b1/b2/b12.file | 18 -
.../resources_testroot/bb/b2/b2_1.file | 18 -
.../resources_testroot/bb/b2/b2_2.datei | 18 -
.../resources/resources_testroot/bb/b2/b3.foo | 18 -
.../src/test/resources/test.properties | 18 -
modules/server/pom.xml | 203 -----
.../apache/tamaya/server/ConfigServiceApp.java | 77 --
.../tamaya/server/ConfigurationResource.java | 310 -------
.../apache/tamaya/server/VersionProperties.java | 68 --
.../apache/tamaya/server/spi/ScopeManager.java | 84 --
.../apache/tamaya/server/spi/ScopeProvider.java | 40 -
.../META-INF/tamaya-server-version.properties | 22 -
modules/server/src/main/resources/banner.txt | 14 -
.../server/src/main/resources/config-server.yml | 31 -
.../tamaya/server/ConfigServiceAppTest.java | 32 -
.../org/apache/tamaya/server/EtcdAccessor.java | 519 -----------
.../tamaya/server/VersionPropertiesTest.java | 46 -
modules/spi-support/pom.xml | 75 --
.../tamaya/spisupport/BasePropertySource.java | 86 --
.../tamaya/spisupport/DefaultConfiguration.java | 228 -----
.../spisupport/DefaultConfigurationContext.java | 256 ------
.../apache/tamaya/spisupport/EnumConverter.java | 68 --
.../tamaya/spisupport/MapPropertySource.java | 147 ---
.../spisupport/PriorityServiceComparator.java | 59 --
.../PropertiesResourcePropertySource.java | 78 --
.../spisupport/PropertyConverterManager.java | 437 ---------
.../tamaya/spisupport/PropertyFiltering.java | 131 ---
.../spisupport/PropertySourceComparator.java | 54 --
modules/yaml/pom.xml | 117 ---
.../java/org/apache/tamaya/json/YAMLFormat.java | 156 ----
.../apache/tamaya/json/YAMLPropertySource.java | 100 --
...org.apache.tamaya.format.ConfigurationFormat | 19 -
.../org/apache/tamaya/json/YAMLFormatTest.java | 73 --
.../tamaya/json/YAMLPropertySourceTest.java | 54 --
.../test/resources/configs/valid/contact.yaml | 46 -
.../resources/configs/valid/test-with-prio.yaml | 39 -
.../src/test/resources/configs/valid/test.yaml | 35 -
pom.xml | 1 -
469 files changed, 43716 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/builder/pom.xml
----------------------------------------------------------------------
diff --git a/modules/builder/pom.xml b/modules/builder/pom.xml
deleted file mode 100644
index 96f6244..0000000
--- a/modules/builder/pom.xml
+++ /dev/null
@@ -1,104 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-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.
--->
-<project xmlns="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">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-extensions</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
- </parent>
-
- <artifactId>tamaya-builder</artifactId>
- <name>Apache Tamaya Modules - Builder</name>
- <packaging>jar</packaging> <!-- bundle -->
-
- <inceptionYear>2015</inceptionYear>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-api</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-formats</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-core</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-spisupport</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-json</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>java-hamcrest</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
-
-
- </dependencies>
-
- <!--build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.tamaya.builder
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build -->
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/builder/src/main/java/org/apache/tamaya/builder/ConfigurationBuilder.java
----------------------------------------------------------------------
diff --git a/modules/builder/src/main/java/org/apache/tamaya/builder/ConfigurationBuilder.java b/modules/builder/src/main/java/org/apache/tamaya/builder/ConfigurationBuilder.java
deleted file mode 100644
index afdc121..0000000
--- a/modules/builder/src/main/java/org/apache/tamaya/builder/ConfigurationBuilder.java
+++ /dev/null
@@ -1,605 +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.builder;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.spi.PropertyConverter;
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.format.ConfigurationData;
-import org.apache.tamaya.format.ConfigurationFormats;
-import org.apache.tamaya.format.FlattenedDefaultPropertySource;
-import org.apache.tamaya.spi.ConfigurationContext;
-import org.apache.tamaya.spi.PropertyFilter;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertySourceProvider;
-import org.apache.tamaya.spi.PropertyValueCombinationPolicy;
-import org.apache.tamaya.spisupport.DefaultConfiguration;
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Collection;
-import java.util.Objects;
-
-import static java.lang.String.format;
-
-/**
- * <p>Builder class used for building a configuration manually without relying
- * only on the Service Provider Interface API.</p>
- *
- * <p><strong>Features of the builder</strong></p>
- *
- * <ol>
- * <li>Adding of property converters manually</li>
- * <li>Adding of property sources directly</li>
- * <li>Adding of property sources via URL</li>
- * <li>Adding of property source providers directly</li>
- * <li>Enabling and disabling of via SPI mechanism provided resources as converters,
- * property sources, etc.</li>
- * </ol>
- *
- * <p><strong>Example</strong></p>
- *
- * <pre>{@code ConfigurationBuilder builder = new ConfigurationBuilder();
- * builder.disableProvidedPropertySources() // Do not load provided property
- * .disableProvidedPropertySourceProviders() // sources and providers automatically
- * .addPropertySource("file:/etc/conf.properties"); // Load properties from conf.properties
- *
- * Configuration config = builder.build();
- * }</pre>
- *
- * <p><strong>Support for configuration formats</strong></p>
- *
- * The configuration builder allows you to put property resources
- * via a URL, as shown in the code example above, without implementing
- * a {@link org.apache.tamaya.spi.PropertySource PropertySource} or providing an
- * instance of a {@link org.apache.tamaya.spi.PropertySource PropertySource}.
- * If a property resource in
- * a specific format can be added to configuration builder or not depends
- * on the available implementations of
- * {@link org.apache.tamaya.format.ConfigurationFormat} in the classpath.
- * Which formats are available can be checked via
- * {@link org.apache.tamaya.format.ConfigurationFormats#getFormats()}.
- */
-public class ConfigurationBuilder {
- /** Builder used to create new ConfigurationContext instances. */
- private final ProgrammaticConfigurationContext.Builder contextBuilder = new ProgrammaticConfigurationContext.Builder();
-
- /**
- * Flag if the config has already been built.
- * Configuration can be built only once
- */
- private boolean built;
-
- /**
- * Flag if all existing property converter service providers
- * should be loaded if the configuration is build.
- */
- private boolean loadProvidedPropertyConverters = true;
-
- /**
- * Flag if all existing property source service providers
- * will be loaded if the configuration is build.
- */
- private boolean loadProvidedPropertySources = false;
- private boolean loadProvidedPropertySourceProviders = false;
-
- private boolean isLoadProvidedPropertyFilters = false;
-
- /**
- * Creates a new builder instance.
- */
- public ConfigurationBuilder() {
- }
-
- /**
- * Allows to set configuration context during unit tests.
- */
- ConfigurationBuilder setConfigurationContext(ConfigurationContext configurationContext) {
- //noinspection deprecation
- contextBuilder.setConfigurationContext(configurationContext);
- return this;
- }
-
- /**
- * Adds one resources with properties in an arbitrary format
- * to the configuration to be build.
- *
- * <p>If a specific format is supported depends on the available
- * {@link org.apache.tamaya.format.ConfigurationFormat} implementations.</p>
- *
- * <pre>{@code URL resource = new URL("file:/etc/service/config.json");
- *
- * builder.addPropertySources(resource);}
- * </pre>
- *
- * @param url resource with properties for the the configuration to be build.
- *
- * @return the builder instance currently used
- *
- * @see org.apache.tamaya.format.ConfigurationFormat
- * @see org.apache.tamaya.format.ConfigurationFormats#getFormats()
- */
- public ConfigurationBuilder addPropertySource(URL url) {
- try {
- ConfigurationData data = getConfigurationDataFromURL(url);
-
- FlattenedDefaultPropertySource propertySource = new FlattenedDefaultPropertySource(data);
- addPropertySources(propertySource);
- } catch (IOException e) {
- throw new ConfigException("Failed to read " + url.toString(), e);
- }
- return this;
- }
-
- protected ConfigurationData getConfigurationDataFromURL(URL url) throws IOException {
- ConfigurationData data = ConfigurationFormats.readConfigurationData(url);
-
- if (null == data) {
- String mesg = format("No configuration format found which is able " +
- "to read properties from %s.", url.toString());
-
- throw new ConfigException(mesg);
- }
-
- return data;
- }
-
- /**
- * Adds one or more resources with properties in an arbitrary format
- * to the configuration to be build.
- *
- * <p>If a specific format is supported depends on the available
- * {@link org.apache.tamaya.format.ConfigurationFormat} implementations.</p>
- *
- *<pre>{@code URL first = new URL("file:/etc/service/config.json");
- * URL second = new URL("file:/etc/defaults/values.properties");
- *
- * builder.addPropertySources(first, second);}
- *</pre>
- *
- * @param urls list of resources with properties for the configuration to be
- * build.
- *
- * @return the builder instance currently used
- *
- * @see org.apache.tamaya.format.ConfigurationFormat
- * @see org.apache.tamaya.format.ConfigurationFormats#getFormats()
- */
- public ConfigurationBuilder addPropertySources(URL... urls) {
- for(URL url:urls){
- if(url!=null){
- addPropertySource(url);
- }
- }
- return this;
- }
-
- /**
- * Adds one or more resources with properties in an arbitrary format
- * to the configuration to be build.
- *
- * <p>If a specific format is supported depends on the available
- * {@link org.apache.tamaya.format.ConfigurationFormat} implementations.</p>
- *
- *<pre>{@code URL first = new URL("file:/etc/service/config.json");
- * URL second = new URL("file:/etc/defaults/values.properties");
- *
- * builder.addPropertySources(first, second);}
- *</pre>
- *
- * @param urls list of resources with properties for the configuration to be
- * build.
- *
- * @return the builder instance currently used
- *
- * @see org.apache.tamaya.format.ConfigurationFormat
- * @see org.apache.tamaya.format.ConfigurationFormats#getFormats()
- */
- public ConfigurationBuilder addPropertySources(Collection<URL> urls) {
- for(URL url:urls) {
- if (url != null) {
- addPropertySource(url);
- }
- }
- return this;
- }
-
-
- /**
- * Adds one or more resources with properties in an arbitrary format
- * to the configuration to be build.
- *
- * <p>If a specific format is supported depends on the available
- * {@link org.apache.tamaya.format.ConfigurationFormat} implementations.</p>
- *
- *<pre>{@code builder.addPropertySources("file:/etc/service/config.json",
- * "file:/etc/defaults/values.properties");}
- *</pre>
- *
- * @param urls list of resources with properties for the configuration to be
- * build.
- *
- * @return the builder instance currently used
- *
- * @see org.apache.tamaya.format.ConfigurationFormat
- * @see org.apache.tamaya.format.ConfigurationFormats#getFormats()
- */
- public ConfigurationBuilder addPropertySources(String... urls) {
- for(String url:urls) {
- if (url != null) {
- try{
- addPropertySource(new URL(url));
- } catch(Exception e){
- throw new ConfigException("Invalid URL: " + url);
- }
- }
- }
- return this;
- }
-
- /**
- * Adds one or more property source instances to the configuration to be build.
- *
- *<pre>{@code PropertySource first = new CustomPropertySource();
- * PropertySource second = new YetAnotherPropertySource();
- *
- * builder.addPropertySources(first, second)};
- *</pre>
- *
- * @param sources list of property source instances with properties for the
- * configuration to be build.
- *
- * @return the builder instance currently used
- *
- * @see org.apache.tamaya.spi.PropertySource
- */
- public ConfigurationBuilder addPropertySources(PropertySource... sources){
- checkBuilderState();
-
- contextBuilder.addPropertySources(Objects.requireNonNull(sources));
- return this;
- }
-
- private void checkBuilderState() {
- if (built) {
- throw new IllegalStateException("Configuration has already been build.");
- }
- }
-
- /**
- * Adds one or more property source provider instances to the configuration to be build.
- *
- * <pre>{@code PropertySourceProvider jc = new JavaConfigurationProvider();
- *
- * builder.addPropertySources(jc)};
- * </pre>
- *
- * @param providers list of property source provider instances each providing a set
- * of property source instances for the configuration to be build.
- *
- * @return the builder instance currently used
- *
- * @see org.apache.tamaya.spi.PropertySourceProvider
- */
- public ConfigurationBuilder addPropertySourceProviders(PropertySourceProvider... providers){
- contextBuilder.addPropertySourceProviders(providers);
- return this;
- }
-
- /**
- * Adds one or more property filter instances to the configuration to be build.
- *
- * <pre>{@code PropertyFilter quoteReplacingFilter = new QuoteFilter();
- * PropertyFilter commaRemovingFilter = new CommaFilter();
- *
- * builder.addPropertyFilters(commaRemovingFilter, quoteReplacingFilter)};
- * </pre>
- *
- * @param filters list of property filter instances which should be applied
- * to the properties of the configuration to be build.
- *
- * @return the builder instance currently used
- *
- * @see org.apache.tamaya.spi.PropertyFilter
- * @see #disableProvidedPropertyFilters()
- * @see #enabledProvidedPropertyFilters()
- */
- public ConfigurationBuilder addPropertyFilters(PropertyFilter... filters){
- Objects.requireNonNull(filters);
-
- contextBuilder.addPropertyFilters(filters);
- return this;
- }
-
-
- /**
- * @param propertyValueCombinationPolicy combination policy to use for this builder.
- * @return the builder instance currently in use.
- */
- public ConfigurationBuilder setPropertyValueCombinationPolicy(PropertyValueCombinationPolicy propertyValueCombinationPolicy){
- contextBuilder.setPropertyValueCombinationPolicy(propertyValueCombinationPolicy);
- return this;
- }
-
- /**
- * Adds a property converter for the a given type to the configuration to
- * be build.
- *
- * <pre>{@code PropertyConverter<MyType> converter = value -> new MyType(value, 42);
- *
- * builder.addPropertyConverter(MyType.class, converter}
- * </pre>
- *
- * @param <T> the type of the configuration
- * @param type the required target type the converter should be applied to
- * @param converter the converter to be used to convert the string property
- * to the given target type.
- *
- * @return the builder instance currently used
- *
- * @see org.apache.tamaya.spi.PropertyConverter
- * @see #enableProvidedPropertyConverters()
- * @see #disableProvidedPropertyConverters()
- */
- public <T> ConfigurationBuilder addPropertyConverter(Class<T> type, PropertyConverter<T> converter) {
- Objects.requireNonNull(type);
- Objects.requireNonNull(converter);
- return addPropertyConverter(TypeLiteral.of(type), (PropertyConverter<Object>)converter);
- }
-
- /**
- * Adds a propertyConverter of a given type.
- *
- * @param <T> the type of the configuration
- * @param type type literal of this converter.
- * @param propertyConverter property converter.
- * @return the builder instance currently used
- */
- public <T> ConfigurationBuilder addPropertyConverter(TypeLiteral<T> type, PropertyConverter<T> propertyConverter){
- Objects.requireNonNull(type);
- Objects.requireNonNull(propertyConverter);
- contextBuilder.addPropertyConverter(type, propertyConverter);
- return this;
- }
-
- /**
- * Checks if the automatic loading of all {@link org.apache.tamaya.spi.PropertyConverter
- * PropertyConverter} service providers is enabled or disabled.
- *
- * @return {@code true} if the automatic loading is enabled,
- * otherwise {@code false}.
- *
- * @see #enableProvidedPropertyConverters()
- * @see #disableProvidedPropertyConverters()
- * @see #addPropertyConverter(Class, org.apache.tamaya.spi.PropertyConverter)
- * @see #addPropertyConverter(org.apache.tamaya.TypeLiteral, org.apache.tamaya.spi.PropertyConverter)
- */
- public boolean isPropertyConverterLoadingEnabled() {
- return loadProvidedPropertyConverters;
- }
-
- /**
- * Enables the loading of all {@link org.apache.tamaya.spi.PropertyConverter}
- * service providers.
- *
- * @return the builder instance currently used
- *
- * @see org.apache.tamaya.spi.PropertyConverter
- * @see #disableProvidedPropertyConverters()
- * @see #enableProvidedPropertyConverters()
- */
- public ConfigurationBuilder enableProvidedPropertyConverters() {
- checkBuilderState();
-
- loadProvidedPropertyConverters = true;
-
- return this;
- }
-
- /**
- * Disables the automatic loading of all {@link org.apache.tamaya.spi.PropertyConverter}
- * service providers.
- *
- * @return the builder instance currently used
- *
- * @see org.apache.tamaya.spi.PropertyConverter
- * @see #enableProvidedPropertyConverters()
- * @see #addPropertyConverter(Class, org.apache.tamaya.spi.PropertyConverter)
- */
- public ConfigurationBuilder disableProvidedPropertyConverters() {
- checkBuilderState();
-
- loadProvidedPropertyConverters = false;
-
- return this;
- }
-
-
- /**
- * Enables the automatic loading of all {@link org.apache.tamaya.spi.PropertySource}
- * service providers.
- *
- * @return the builder instance currently used
- *
- * @see org.apache.tamaya.spi.PropertySource
- * @see #disableProvidedPropertySources()
- */
- public ConfigurationBuilder enableProvidedPropertySources() {
- checkBuilderState();
-
- loadProvidedPropertySources = true;
-
- return this;
- }
-
- /**
- * Checks if the automatic loading of all {@link org.apache.tamaya.spi.PropertySource
- * PropertySource} service providers is enabled or disabled.
- *
- * @return {@code true} if the automatic loading is enabled,
- * otherwise {@code false}.
- */
- public boolean isPropertySourcesLoadingEnabled() {
- return loadProvidedPropertySources;
- }
-
-
- /**
- * Checks if the automatic loading of all {@link org.apache.tamaya.spi.PropertyFilter
- * PropertyFilter} service providers is enabled or disabled.
- *
- * @return {@code true} if the automatic loading is enabled,
- * otherwise {@code false}.
- */
- public boolean isPropertyFilterLoadingEnabled() {
- return isLoadProvidedPropertyFilters;
- }
-
- /**
- * Enables the automatic loading of all {@link org.apache.tamaya.spi.PropertyFilter}
- * service providers.
- *
- * @return the builder instance currently used
- *
- * @see org.apache.tamaya.spi.PropertyFilter
- * @see #disableProvidedPropertyFilters()
- * @see #addPropertyFilters(org.apache.tamaya.spi.PropertyFilter...)
- */
- public ConfigurationBuilder enabledProvidedPropertyFilters() {
- checkBuilderState();
-
- isLoadProvidedPropertyFilters = true;
-
- return this;
- }
-
- /**
- * Disables the automatic loading of all {@link org.apache.tamaya.spi.PropertyFilter}
- * service providers.
- *
- * @see org.apache.tamaya.spi.PropertyFilter
- * @see #enabledProvidedPropertyFilters()
- * @see #addPropertyFilters(org.apache.tamaya.spi.PropertyFilter...)
- *
- * @return the builder instance currently used
- */
- public ConfigurationBuilder disableProvidedPropertyFilters() {
- checkBuilderState();
-
- isLoadProvidedPropertyFilters = false;
-
- return this;
- }
-
- /**
- * Disables the automatic loading of all {@link org.apache.tamaya.spi.PropertySource}
- * service providers.
- *
- * @return the builder instance currently used
- *
- * @see org.apache.tamaya.spi.PropertySource
- * @see #enableProvidedPropertySources()
- */
- public ConfigurationBuilder disableProvidedPropertySources() {
- checkBuilderState();
-
- loadProvidedPropertySources = false;
-
- return this;
- }
-
- /**
- * Enables the automatic loading of {@link org.apache.tamaya.spi.PropertySourceProvider
- * property source providers} provided via the SPI API.
- *
- * @return the builder instance currently used
- *
- * @see org.apache.tamaya.spi.PropertySourceProvider
- */
- public ConfigurationBuilder enableProvidedPropertySourceProviders() {
- checkBuilderState();
-
- loadProvidedPropertySourceProviders = true;
-
- return this;
- }
-
- /**
- * Disables the automatic loading of {@link org.apache.tamaya.spi.PropertySourceProvider
- * property source providers} provided via the SPI API.
- *
- * @return the builder instance currently used
- */
- public ConfigurationBuilder disableProvidedPropertySourceProviders() {
- checkBuilderState();
-
- loadProvidedPropertySourceProviders = false;
-
- return this;
- }
-
- /**
- * Checks if the automatic loading of {@link org.apache.tamaya.spi.PropertySourceProvider
- * PropertySourceProviders} is enabled or disabled.
- *
- * @return {@code true} if the automatic loading is enabled,
- * otherwise {@code false}.
- */
- public boolean isPropertySourceProvidersLoadingEnabled() {
- return loadProvidedPropertySourceProviders;
- }
-
- //X TODO think on a functionality/API for using the default PropertyConverters and use the configured ones here
- //X TODO as overrides used first.
-
-
- /**
- * Builds a new configuration based on the configuration of this builder instance.
- *
- * @return a new {@link org.apache.tamaya.Configuration configuration instance},
- * never {@code null}.
- */
- public Configuration build() {
- checkBuilderState();
-
- built = true;
-
- contextBuilder.loadProvidedPropertyConverters(isPropertyConverterLoadingEnabled());
- contextBuilder.loadProvidedPropertySources(isPropertySourcesLoadingEnabled());
- contextBuilder.loadProvidedPropertySourceProviders(isPropertySourceProvidersLoadingEnabled());
- contextBuilder.loadProvidedPropertyFilters(isLoadProvidedPropertyFilters);
-
- return new DefaultConfiguration(contextBuilder.build());
- }
-
- /**
- * Mapper to map a URL given as string to an URL instance.
- */
- private static class StringToURLMapper {
- public URL apply(String u) {
- try {
- return new URL(u);
- } catch (MalformedURLException e) {
- throw new ConfigException(u + " is not a valid URL", e);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/builder/src/main/java/org/apache/tamaya/builder/ProgrammaticConfigurationContext.java
----------------------------------------------------------------------
diff --git a/modules/builder/src/main/java/org/apache/tamaya/builder/ProgrammaticConfigurationContext.java b/modules/builder/src/main/java/org/apache/tamaya/builder/ProgrammaticConfigurationContext.java
deleted file mode 100644
index 68e770d..0000000
--- a/modules/builder/src/main/java/org/apache/tamaya/builder/ProgrammaticConfigurationContext.java
+++ /dev/null
@@ -1,388 +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.builder;
-
-
-import org.apache.tamaya.spi.PropertyConverter;
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.spi.ConfigurationContext;
-import org.apache.tamaya.spi.ConfigurationContextBuilder;
-import org.apache.tamaya.spi.PropertyFilter;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertySourceProvider;
-import org.apache.tamaya.spi.PropertyValueCombinationPolicy;
-import org.apache.tamaya.spi.ServiceContextManager;
-import org.apache.tamaya.spisupport.PriorityServiceComparator;
-import org.apache.tamaya.spisupport.PropertyConverterManager;
-import org.apache.tamaya.spisupport.PropertySourceComparator;
-
-import javax.annotation.Priority;
-import java.util.*;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-import java.util.logging.Logger;
-
-/**
- * Implementation of the {@link org.apache.tamaya.spi.ConfigurationContext}
- * used by the {@link org.apache.tamaya.builder.ConfigurationBuilder}
- * internally.
- */
-class ProgrammaticConfigurationContext implements ConfigurationContext {
-
- private static final Comparator<PropertySource> PS_COMPARATOR = new PropertySourceComparator();
- private static final Comparator<Object> COMP_COMPARATOR = new PriorityServiceComparator();
- /**
- * The logger used.
- */
- private final static Logger LOG = Logger.getLogger(ProgrammaticConfigurationContext.class.getName());
- /**
- * 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<PropertySource> immutablePropertySources = new ArrayList<>();
-
- /**
- * The current unmodifiable list of loaded {@link org.apache.tamaya.spi.PropertyFilter} instances.
- */
- private List<PropertyFilter> immutablePropertyFilters = new ArrayList<>();
-
- /**
- * The overriding policy used when combining PropertySources registered to evalute the final configuration
- * values.
- */
- private PropertyValueCombinationPolicy propertyValueCombinationPolicy;
-
- /**
- * Lock for internal synchronization.
- */
- private final ReadWriteLock propertySourceLock = new ReentrantReadWriteLock();
-
-
- /**
- * 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.
- */
- @SuppressWarnings("unchecked")
- public ProgrammaticConfigurationContext(Builder builder) {
- propertyConverterManager = new PropertyConverterManager(builder.loadProvidedPropertyConverters);
-
- List<PropertySource> sources = getAllPropertySources(builder);
- Collections.sort(sources, PS_COMPARATOR);
- immutablePropertySources = Collections.unmodifiableList(sources);
-
-
- List<PropertyFilter> filters = getPropertyFilters(builder);
- Collections.sort(filters, COMP_COMPARATOR);
- immutablePropertyFilters = Collections.unmodifiableList(filters);
-
-
- propertyValueCombinationPolicy = builder.propertyValueCombinationPolicy;
- for(Map.Entry<TypeLiteral<?>, List<PropertyConverter<?>>> en: builder.propertyConverters.entrySet()){
- if(en!=null){
- for(PropertyConverter pv:en.getValue()) {
- propertyConverterManager.register(en.getKey(), pv);
- }
- }
- }
-
- LOG.info("Using " + immutablePropertySources.size() + " property sources: " + immutablePropertySources);
- LOG.info("Using " + immutablePropertyFilters.size() + " property filters: " + immutablePropertyFilters);
- LOG.info("Using PropertyValueCombinationPolicy: " + propertyValueCombinationPolicy);
- }
-
- private List<PropertyFilter> getPropertyFilters(Builder builder) {
- List<PropertyFilter> provided = new ArrayList<>();
- if(builder.loadProvidedPropertyFilters) {
- provided.addAll(ServiceContextManager.getServiceContext().getServices(PropertyFilter.class));
- }
- for(PropertyFilter pf:builder.propertyFilters) {
- if (pf != null) {
- provided.add(pf);
- }
- }
- return provided;
- }
-
- private List<PropertySource> getAllPropertySources(Builder builder) {
- List<PropertySource> provided = new ArrayList<>();
- if(builder.loadProvidedPropertySources) {
- provided.addAll(ServiceContextManager.getServiceContext().getServices(PropertySource.class));
- }
- for(PropertySource ps:builder.propertySources){
- if(ps!=null){
- provided.add(ps);
- }
- }
- if (builder.loadProvidedPropertySourceProviders) {
- List<PropertySourceProvider> providers = ServiceContextManager.getServiceContext()
- .getServices(PropertySourceProvider.class);
- for (PropertySourceProvider provider : providers) {
- for(PropertySource ps:provider.getPropertySources()) {
- if(ps!=null) {
- provided.addAll(provider.getPropertySources());
- }
- }
- }
- }
- return provided;
- }
-
- public void addPropertySources(PropertySource... propertySourcesToAdd) {
- Lock writeLock = propertySourceLock.writeLock();
- try {
- writeLock.lock();
- List<PropertySource> provided = new ArrayList<>();
- for(PropertySource ps:propertySourcesToAdd){
- if(ps!=null){
- provided.add(ps);
- }
- }
- this.immutablePropertySources = Collections.unmodifiableList(provided);
- } finally {
- writeLock.unlock();
- }
- }
-
- /**
- * Order property source reversely, the most important come first.
- *
- * @param source1 the first PropertySource
- * @param source2 the second PropertySource
- * @return the comparison result.
- */
- private int comparePropertySources(PropertySource source1, PropertySource source2) {
-
- //X TODO this method duplicates org.apache.tamaya.core.internal.DefaultConfigurationContext.PropertySourceComparator.comparePropertySources()
- //X maybe we should extract the Comperator in an own class for real code-reuse (copy paste == bad code reuse)
-
- if (source1.getOrdinal() < source2.getOrdinal()) {
- return -1;
- } else if (source1.getOrdinal() > source2.getOrdinal()) {
- return 1;
- } else {
- return source1.getClass().getName().compareTo(source2.getClass().getName());
- }
- }
-
- /**
- * Compare 2 filters for ordering the filter chain.
- *
- * @param filter1 the first filter
- * @param filter2 the second filter
- * @return the comparison result
- */
- private int comparePropertyFilters(PropertyFilter filter1, PropertyFilter filter2) {
-
- //X TODO this method duplicates org.apache.tamaya.core.internal.DefaultConfigurationContext.PropertySourceComparator.comparePropertyFilters()
- //X maybe we should extract the Comperator in an own class for real code-reuse (copy paste == bad code reuse)
-
- Priority prio1 = filter1.getClass().getAnnotation(Priority.class);
- Priority prio2 = filter2.getClass().getAnnotation(Priority.class);
- int ord1 = prio1 != null ? prio1.value() : 0;
- int ord2 = prio2 != null ? prio2.value() : 0;
-
- if (ord1 < ord2) {
- return -1;
- } else if (ord1 > ord2) {
- return 1;
- } else {
- return filter1.getClass().getName().compareTo(filter2.getClass().getName());
- }
- }
-
- @Override
- public List<PropertySource> getPropertySources() {
- return immutablePropertySources;
- }
-
- public <T> void addPropertyConverter(TypeLiteral<T> typeToConvert, PropertyConverter<T> propertyConverter) {
- propertyConverterManager.register(typeToConvert, propertyConverter);
- LOG.info("Added PropertyConverter: " + propertyConverter.getClass().getName());
- }
-
- @Override
- public Map<TypeLiteral<?>, List<PropertyConverter<?>>> getPropertyConverters() {
- return propertyConverterManager.getPropertyConverters();
- }
-
- @Override
- public <T> List<PropertyConverter<T>> getPropertyConverters(TypeLiteral<T> targetType) {
- return propertyConverterManager.getPropertyConverters(targetType);
- }
-
- @Override
- public List<PropertyFilter> getPropertyFilters() {
- return immutablePropertyFilters;
- }
-
- @Override
- public PropertyValueCombinationPolicy getPropertyValueCombinationPolicy() {
- return propertyValueCombinationPolicy;
- }
-
-
- @Override
- public ConfigurationContextBuilder toBuilder() {
- // @todo Check if it could be useful to support this method, Oliver B. Fischer
- throw new RuntimeException("This method is currently not supported.");
- }
-
- /**
- * The Builder for {@link ProgrammaticConfigurationContext}
- */
- public final static class Builder {
- /**
- * The current unmodifiable list of loaded {@link org.apache.tamaya.spi.PropertySource} instances.
- */
- private final List<PropertySource> propertySources = new ArrayList<>();
-
- /**
- * The current unmodifiable list of loaded {@link org.apache.tamaya.spi.PropertyFilter} instances.
- */
- private final List<PropertyFilter> propertyFilters = new ArrayList<>();
-
- private final Map<TypeLiteral<?>, List<PropertyConverter<?>>> propertyConverters = new HashMap<>();
-
- /**
- * The overriding policy used when combining PropertySources registered to evalute the final configuration
- * values.
- */
- private PropertyValueCombinationPolicy propertyValueCombinationPolicy =
- PropertyValueCombinationPolicy.DEFAULT_OVERRIDING_COLLECTOR;
-
- private boolean loadProvidedPropertyConverters;
- private boolean loadProvidedPropertySources;
- private boolean loadProvidedPropertySourceProviders;
- private boolean loadProvidedPropertyFilters;
-
- public Builder setPropertyValueCombinationPolicy(PropertyValueCombinationPolicy policy) {
- this.propertyValueCombinationPolicy = Objects.requireNonNull(policy);
- return this;
- }
-
- public Builder addPropertySources(PropertySource... propertySources) {
- for (PropertySource ps : propertySources) {
- if (ps != null) {
- this.propertySources.add(ps);
- }
- }
- return this;
- }
-
- public Builder addPropertySources(Collection<PropertySource> propertySources) {
- for (PropertySource ps : propertySources) {
- if (ps != null) {
- this.propertySources.add(ps);
- }
- }
- return this;
- }
-
- public Builder addPropertySourceProviders(PropertySourceProvider... propertySourceProviders) {
- for (PropertySourceProvider ps : propertySourceProviders) {
- if (ps != null) {
- this.propertySources.addAll(ps.getPropertySources());
- }
- }
- return this;
- }
-
- public Builder addPropertySourceProviders(Collection<PropertySourceProvider> propertySourceProviders) {
- for (PropertySourceProvider ps : propertySourceProviders) {
- if (ps != null) {
- this.propertySources.addAll(ps.getPropertySources());
- }
- }
- return this;
- }
-
- public Builder addPropertyFilters(PropertyFilter... propertyFIlter) {
- for (PropertyFilter pf : propertyFIlter) {
- if (pf != null) {
- this.propertyFilters.add(pf);
- }
- }
- return this;
- }
-
- public Builder addPropertyFilters(Collection<PropertyFilter> propertyFIlter) {
- for (PropertyFilter pf : propertyFIlter) {
- if (pf != null) {
- this.propertyFilters.add(pf);
- }
- }
- return this;
- }
-
- /**
- * Should be never used.
- */
- @Deprecated
- public Builder setConfigurationContext(ConfigurationContext configurationContext) {
- this.addPropertySources(configurationContext.getPropertySources());
- this.addPropertyFilters(configurationContext.getPropertyFilters());
- this.propertyValueCombinationPolicy = Objects.requireNonNull(
- configurationContext.getPropertyValueCombinationPolicy());
- return this;
- }
-
- //X TODO think on a functonality/API for using the default PropertyConverters and use the configured ones here
- //X TODO as overrides used first.
-
- public <T> Builder addPropertyConverter(TypeLiteral<T> type, PropertyConverter<T> propertyConverter) {
- if(!propertyConverters.containsKey(type)){
- List<PropertyConverter<?>> convList = new ArrayList<>();
- convList.add(propertyConverter);
- propertyConverters.put(type, convList);
- }
- return this;
- }
-
- public ConfigurationContext build() {
- return new ProgrammaticConfigurationContext(this);
- }
-
-
- public void loadProvidedPropertyConverters(boolean state) {
- loadProvidedPropertyConverters = state;
- }
-
- public void loadProvidedPropertySources(boolean state) {
- loadProvidedPropertySources = state;
- }
-
- public void loadProvidedPropertySourceProviders(boolean state) {
- loadProvidedPropertySourceProviders = state;
- }
-
- public void loadProvidedPropertyFilters(boolean state) {
- loadProvidedPropertyFilters = state;
- }
-
- }
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/builder/src/main/java/org/apache/tamaya/builder/PropertySourceBuilder.java
----------------------------------------------------------------------
diff --git a/modules/builder/src/main/java/org/apache/tamaya/builder/PropertySourceBuilder.java b/modules/builder/src/main/java/org/apache/tamaya/builder/PropertySourceBuilder.java
deleted file mode 100644
index 481a80c..0000000
--- a/modules/builder/src/main/java/org/apache/tamaya/builder/PropertySourceBuilder.java
+++ /dev/null
@@ -1,118 +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.builder;
-
-import org.apache.tamaya.spi.PropertySource;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-
-/**
- * Simple builder for building a {@link org.apache.tamaya.spi.PropertySource}.
- */
-public final class PropertySourceBuilder {
- /** The ordinal to be used. */
- private int ordinal;
- /** The name to be used. */
- private final String name;
- /** The properties. */
- private final Map<String,String> properties = new HashMap<>();
-
- /** private constructor. */
- private PropertySourceBuilder(String name){
- this.name = Objects.requireNonNull(name);
- }
-
- /**
- * Gets a new instance of a builder.
- * @param name The name of the property source, not null.
- * @return a new instance.
- */
- public static PropertySourceBuilder of(String name){
- return new PropertySourceBuilder(name);
- }
-
- /**
- * Gets a new instance of a builder.
- * @param name The name of the property source, not null.
- * @return a new instance.
- */
- public static PropertySourceBuilder from(String name){
- return new PropertySourceBuilder(name);
- }
-
- /**
- * Sets a new property key/value.
- * @param key the property key, not null.
- * @param value the property value, not null.
- * @return the bulder for chaining.
- */
- public PropertySourceBuilder put(String key, String value){
- this.properties.put(key, value);
- return this;
- }
-
- /**
- * Put all the given key, values.
- * @param values the new key/values, not null.
- * @return the bulder for chaining.
- */
- public PropertySourceBuilder putAll(Map<String, String> values){
- this.properties.putAll(values);
- return this;
- }
-
- /**
- * Sets the ordinal to be used explicitly (instead evaluating it using {@code tamaya.ordinal}.
- * @param ordinal the explicit ordinal to be used.
- * @return the bulder for chaining.
- */
- public PropertySourceBuilder withOrdinal(int ordinal){
- this.ordinal = ordinal;
- return this;
- }
-
- /**
- * Puts all values from the given property source.
- * @param propertySource the property source, not null.
- * @return the bulder for chaining.
- */
- public PropertySourceBuilder putAll(PropertySource propertySource){
- this.properties.putAll(propertySource.getProperties());
- return this;
- }
-
- /**
- * Creates a new immutable {@link org.apache.tamaya.spi.PropertySource} instance.
- * @return a new immutable {@link org.apache.tamaya.spi.PropertySource} instance, never null.
- */
- public PropertySource build(){
- return new SimplePropertySource(name, properties);
- }
-
- @Override
- public String toString() {
- return "PropertySourceBuilder{" +
- "ordinal=" + ordinal +
- ", name='" + name + '\'' +
- ", properties=" + properties +
- '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/builder/src/main/java/org/apache/tamaya/builder/SimplePropertySource.java
----------------------------------------------------------------------
diff --git a/modules/builder/src/main/java/org/apache/tamaya/builder/SimplePropertySource.java b/modules/builder/src/main/java/org/apache/tamaya/builder/SimplePropertySource.java
deleted file mode 100644
index 085bd9a..0000000
--- a/modules/builder/src/main/java/org/apache/tamaya/builder/SimplePropertySource.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 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.builder;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
-* Simple property source implementation using a map.
-*/
-public class SimplePropertySource implements PropertySource {
- /** The properties. */
- private final Map<String, String> properties;
- /** The source's name. */
- private final String name;
-
- public SimplePropertySource(String name, Map<String, String> properties){
- this.properties = new HashMap<>(properties);
- this.name = Objects.requireNonNull(name);
- }
-
- @Override
- public int getOrdinal(){
- PropertyValue configuredOrdinal = get(TAMAYA_ORDINAL);
- if(configuredOrdinal!=null){
- try{
- return Integer.parseInt(configuredOrdinal.getValue());
- } catch(Exception e){
- Logger.getLogger(getClass().getName()).log(Level.WARNING,
- "Configured Ordinal is not an int number: " + configuredOrdinal, e);
- }
- }
- return getDefaultOrdinal();
- }
-
- public int getDefaultOrdinal(){
- return 0;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public PropertyValue get(String key) {
- return null;
- }
-
- @Override
- public Map<String, String> getProperties() {
- return this.properties;
- }
-
- @Override
- public boolean isScannable() {
- return false;
- }
-
- @Override
- public String toString(){
- return "SimplePropertySource(name="+name+", numProps="+properties.size()+")";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/builder/src/main/java/org/apache/tamaya/builder/package-info.java
----------------------------------------------------------------------
diff --git a/modules/builder/src/main/java/org/apache/tamaya/builder/package-info.java b/modules/builder/src/main/java/org/apache/tamaya/builder/package-info.java
deleted file mode 100644
index 24c86a9..0000000
--- a/modules/builder/src/main/java/org/apache/tamaya/builder/package-info.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-/**
- * This package provides
- * {@link org.apache.tamaya.builder.ConfigurationBuilder a configuration
- * builder} that allows to build a configuration manually without
- * using exclusively on the Service Provider Interface API of Tamaya.
- *
- * @see org.apache.tamaya.builder.ConfigurationBuilder
- * @see org.apache.tamaya.Configuration
- */
-package org.apache.tamaya.builder;
\ No newline at end of file
[06/24] incubator-tamaya git commit: Removed all modules from the
main repository. They will be reborn in separate ASF repository.
Posted by pl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/internal/DefaultMutableConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/internal/DefaultMutableConfiguration.java b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/internal/DefaultMutableConfiguration.java
deleted file mode 100644
index ad272ef..0000000
--- a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/internal/DefaultMutableConfiguration.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.mutableconfig.internal;
-
-import org.apache.tamaya.ConfigOperator;
-import org.apache.tamaya.ConfigQuery;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.mutableconfig.ChangePropagationPolicy;
-import org.apache.tamaya.mutableconfig.MutableConfiguration;
-import org.apache.tamaya.mutableconfig.spi.ConfigChangeRequest;
-import org.apache.tamaya.mutableconfig.spi.MutablePropertySource;
-import org.apache.tamaya.spi.ConfigurationContext;
-import org.apache.tamaya.spi.PropertySource;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.UUID;
-import java.util.logging.Logger;
-
-
-/**
- * Default implementation of a {@link MutableConfiguration}.
- */
-public class DefaultMutableConfiguration implements MutableConfiguration {
- private static final Logger LOG = Logger.getLogger(DefaultMutableConfiguration.class.getName());
- private ConfigChangeRequest changeRequest = new ConfigChangeRequest(UUID.randomUUID().toString());
- private final Configuration config;
- private ChangePropagationPolicy changePropagationPolicy;
-
- public DefaultMutableConfiguration(Configuration config, ChangePropagationPolicy changePropagationPolicy){
- this.config = Objects.requireNonNull(config);
- this.changePropagationPolicy = Objects.requireNonNull(changePropagationPolicy);
- }
-
- @Override
- public ChangePropagationPolicy getChangePropagationPolicy(){
- return changePropagationPolicy;
- }
-
- @Override
- public ConfigChangeRequest getConfigChangeRequest(){
- return changeRequest;
- }
-
- protected List<MutablePropertySource> getMutablePropertySources() {
- List<MutablePropertySource> result = new ArrayList<>();
- for(PropertySource propertySource:this.config.getContext().getPropertySources()) {
- if(propertySource instanceof MutablePropertySource){
- result.add((MutablePropertySource)propertySource);
- }
- }
- return result;
- }
-
-
- @Override
- public MutableConfiguration put(String key, String value) {
- changeRequest.put(key, value);
- return this;
- }
-
- @Override
- public MutableConfiguration putAll(Map<String, String> properties) {
- changeRequest.putAll(properties);
- return this;
- }
-
- @Override
- public MutableConfiguration remove(String... keys) {
- changeRequest.removeAll(Arrays.asList(keys));
- return this;
- }
-
-
- @Override
- public void store() {
- this.changePropagationPolicy.applyChange(changeRequest, config.getContext().getPropertySources());
- }
-
- @Override
- public MutableConfiguration remove(Collection<String> keys) {
- for(MutablePropertySource target:getMutablePropertySources()) {
- changeRequest.removeAll(keys);
- }
- return this;
- }
-
- @Override
- public String get(String key) {
- return this.config.get(key);
- }
-
- @Override
- public String getOrDefault(String key, String defaultValue) {
- return this.config.getOrDefault(key, defaultValue);
- }
-
- @Override
- public <T> T getOrDefault(String key, Class<T> type, T defaultValue) {
- return this.config.getOrDefault(key, type, defaultValue);
- }
-
- @Override
- public <T> T get(String key, Class<T> type) {
- return this.config.get(key, type);
- }
-
- @Override
- public <T> T get(String key, TypeLiteral<T> type) {
- return this.config.get(key, type);
- }
-
- @Override
- public <T> T getOrDefault(String key, TypeLiteral<T> type, T defaultValue) {
- return this.config.getOrDefault(key, type, defaultValue);
- }
-
- @Override
- public Map<String, String> getProperties() {
- return this.config.getProperties();
- }
-
- @Override
- public Configuration with(ConfigOperator operator) {
- return operator.operate(this);
- }
-
- @Override
- public <T> T query(ConfigQuery<T> query) {
- return query.query(this);
- }
-
- @Override
- public ConfigurationContext getContext() {
- return config.getContext();
- }
-
- private Collection<PropertySource> getPropertySources() {
- return this.config.getContext().getPropertySources();
- }
-
- @Override
- public String toString() {
- return "DefaultMutableConfiguration{" +
- "config=" + config +
- '}';
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/internal/DefaultMutableConfigurationSpi.java
----------------------------------------------------------------------
diff --git a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/internal/DefaultMutableConfigurationSpi.java b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/internal/DefaultMutableConfigurationSpi.java
deleted file mode 100644
index a47cd0e..0000000
--- a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/internal/DefaultMutableConfigurationSpi.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.mutableconfig.internal;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.mutableconfig.ChangePropagationPolicy;
-import org.apache.tamaya.mutableconfig.MutableConfiguration;
-import org.apache.tamaya.mutableconfig.spi.MutableConfigurationProviderSpi;
-
-
-/**
- * SPI implementation that creates instances of {@link DefaultMutableConfiguration}, hereby for
- * each instance of {@link Configuration} a new instance has to be returned.
- */
-public class DefaultMutableConfigurationSpi implements MutableConfigurationProviderSpi {
-
- @Override
- public MutableConfiguration createMutableConfiguration(Configuration configuration,
- ChangePropagationPolicy propagationPolicy){
- return new DefaultMutableConfiguration(configuration, propagationPolicy);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/propertysources/MutablePropertiesPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/propertysources/MutablePropertiesPropertySource.java b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/propertysources/MutablePropertiesPropertySource.java
deleted file mode 100644
index af9bed4..0000000
--- a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/propertysources/MutablePropertiesPropertySource.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.mutableconfig.propertysources;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.mutableconfig.spi.ConfigChangeRequest;
-import org.apache.tamaya.mutableconfig.spi.MutablePropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-import org.apache.tamaya.spi.PropertyValueBuilder;
-import org.apache.tamaya.spisupport.BasePropertySource;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Simple implementation of a mutable {@link org.apache.tamaya.spi.PropertySource} for .properties files.
- */
-public class MutablePropertiesPropertySource extends BasePropertySource
-implements MutablePropertySource{
-
- /**
- * The logger.
- */
- private static final Logger LOG = Logger.getLogger(MutablePropertiesPropertySource.class.getName());
-
- /**
- * Default update interval is 1 minute.
- */
- private static final long DEFAULT_UPDATE_INTERVAL = 60000L;
-
- /**
- * The property source name.
- */
- private String name;
-
- /**
- * The configuration resource's URL.
- */
- private File file;
-
- /**
- * Timestamp of last read.
- */
- private long lastRead;
-
- /**
- * Interval, when the resource should try to update its contents.
- */
- private long updateInterval = DEFAULT_UPDATE_INTERVAL;
- /**
- * The current properties.
- */
- private Map<String, String> properties = new HashMap<>();
-
- /**
- * Creates a new Properties based PropertySource based on the given URL.
- *
- * @param propertiesLocation the URL encoded location, not null.
- * @param defaultOrdinal the default ordinal to be used, when no ordinal is provided with the property
- * source's properties.
- */
- public MutablePropertiesPropertySource(File propertiesLocation, int defaultOrdinal) {
- super(defaultOrdinal);
- this.name = propertiesLocation.toString();
- try {
- this.file = propertiesLocation;
- load();
- } catch (Exception e) {
- LOG.log(Level.SEVERE, "Cannot convert file to URL: " + propertiesLocation, e);
- }
- }
-
- @Override
- public PropertyValue get(String key) {
- Map<String,String> properties = getProperties();
- String val = properties.get(key);
- if(val==null){
- return null;
- }
- PropertyValueBuilder b = new PropertyValueBuilder(key, val, getName());
- String metaKeyStart = "_" + key + ".";
- for(Map.Entry<String,String> en:properties.entrySet()) {
- if(en.getKey().startsWith(metaKeyStart)){
- b.addContextData(en.getKey().substring(metaKeyStart.length()), en.getValue());
- }
- }
- return b.build();
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public Map<String, String> getProperties() {
- checkLoad();
- return Collections.unmodifiableMap(this.properties);
- }
-
-
- private void checkLoad() {
- if(file!=null && (lastRead+updateInterval)<System.currentTimeMillis()){
- load();
- }
- }
-
- /**
- * loads the Properties from the given URL
- *
- * @throws IllegalStateException in case of an error while reading properties-file
- */
- private void load() {
- try (InputStream stream = new FileInputStream(file)) {
- Map<String, String> properties = new HashMap<>();
- Properties props = new Properties();
- props.load(stream);
- for (String key : props.stringPropertyNames()) {
- properties.put(key, props.getProperty(key));
- }
- this.lastRead = System.currentTimeMillis();
- LOG.log(Level.FINEST, "Loaded properties from " + file);
- this.properties = properties;
- } catch (IOException e) {
- LOG.log(Level.FINEST, "Cannot load properties from " + file, e);
- }
- }
-
- @Override
- public void applyChange(ConfigChangeRequest change) {
- if(change.isEmpty()){
- LOG.info("Nothing to commit for transaction: " + change.getTransactionID());
- return;
- }
- if(!file.exists()){
- try {
- if(!file.createNewFile()){
- throw new ConfigException("Failed to create config file " + file);
- }
- } catch (IOException e) {
- throw new ConfigException("Failed to create config file " + file, e);
- }
- }
- for(Map.Entry<String,String> en:change.getAddedProperties().entrySet()){
- int index = en.getKey().indexOf('?');
- if(index>0){
- this.properties.put(en.getKey().substring(0, index), en.getValue());
- }else{
- this.properties.put(en.getKey(), en.getValue());
- }
- }
- for(String rmKey:change.getRemovedProperties()){
- this.properties.remove(rmKey);
- }
- try(BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file))){
- Properties props = new Properties();
- for (Map.Entry<String,String> en : this.properties.entrySet()) {
- props.setProperty(en.getKey(), en.getValue());
- }
- props.store(bos, "Properties written from Tamaya on " + new Date());
- bos.flush();
- }
- catch(Exception e){
- throw new ConfigException("Failed to write config to " + file, e);
- }
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/propertysources/MutableXmlPropertiesPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/propertysources/MutableXmlPropertiesPropertySource.java b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/propertysources/MutableXmlPropertiesPropertySource.java
deleted file mode 100644
index 514ed1d..0000000
--- a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/propertysources/MutableXmlPropertiesPropertySource.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.mutableconfig.propertysources;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.mutableconfig.spi.ConfigChangeRequest;
-import org.apache.tamaya.mutableconfig.spi.MutablePropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-import org.apache.tamaya.spi.PropertyValueBuilder;
-import org.apache.tamaya.spisupport.BasePropertySource;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Simple implementation of a mutable {@link org.apache.tamaya.spi.PropertySource} for .xml properties files.
- */
-public class MutableXmlPropertiesPropertySource extends BasePropertySource
-implements MutablePropertySource{
-
- /**
- * The logger.
- */
- private static final Logger LOG = Logger.getLogger(MutableXmlPropertiesPropertySource.class.getName());
- /**
- * Default update interval is 1 minute.
- */
- private static final long DEFAULT_UPDATE_INTERVAL = 60000L;
-
- /**
- * The property source name.
- */
- private String name;
-
- /**
- * The configuration resource's URL.
- */
- private File file;
-
- /**
- * Timestamp of last read.
- */
- private long lastRead;
-
- /**
- * Interval, when the resource should try to update its contents.
- */
- private long updateInterval = DEFAULT_UPDATE_INTERVAL;
- /**
- * The current properties.
- */
- private Map<String, String> properties = new HashMap<>();
-
- /**
- * Creates a new Properties based PropertySource based on the given URL.
- *
- * @param propertiesLocation the URL encoded location, not null.
- * @param defaultOrdinal the default ordinal to be used, when no ordinal is provided with the property
- * source's properties.
- */
- public MutableXmlPropertiesPropertySource(File propertiesLocation, int defaultOrdinal) {
- super(defaultOrdinal);
- this.name = propertiesLocation.toString();
- try {
- this.file = propertiesLocation;
- load();
- } catch (Exception e) {
- LOG.log(Level.SEVERE, "Cannot convert file to URL: " + propertiesLocation, e);
- }
- }
-
-
-
- @Override
- public PropertyValue get(String key) {
- Map<String,String> properties = getProperties();
- String val = properties.get(key);
- if(val==null){
- return null;
- }
- PropertyValueBuilder b = new PropertyValueBuilder(key, val, getName());
- String metaKeyStart = "_" + key + ".";
- for(Map.Entry<String,String> en:properties.entrySet()) {
- if(en.getKey().startsWith(metaKeyStart)){
- b.addContextData(en.getKey().substring(metaKeyStart.length()), en.getValue());
- }
- }
- return b.build();
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public Map<String, String> getProperties() {
- checkLoad();
- return Collections.unmodifiableMap(this.properties);
- }
-
-
- private void checkLoad() {
- if(file!=null && (lastRead+updateInterval)<System.currentTimeMillis()){
- load();
- }
- }
-
- /**
- * loads the Properties from the given URL
- *
- * @throws IllegalStateException in case of an error while reading properties-file
- */
- private void load() {
- try (InputStream stream = new FileInputStream(file)) {
- Map<String, String> properties = new HashMap<>();
- Properties props = new Properties();
- props.loadFromXML(stream);
- for (String key : props.stringPropertyNames()) {
- properties.put(key, props.getProperty(key));
- }
- this.lastRead = System.currentTimeMillis();
- this.properties = properties;
- LOG.log(Level.FINEST, "Loaded properties from " + file);
- this.properties = properties;
- } catch (IOException e) {
- LOG.log(Level.FINEST, "Cannot load properties from " + file, e);
- }
- }
-
- @Override
- public void applyChange(ConfigChangeRequest configChange) {
- if(configChange.isEmpty()){
- LOG.info("Nothing to commit for transaction: " + configChange.getTransactionID());
- return;
- }
- if(!file.exists()){
- try {
- if(!file.createNewFile()){
- throw new ConfigException("Failed to create config file " + file);
- }
- } catch (IOException e) {
- throw new ConfigException("Failed to create config file " + file, e);
- }
- }
- for(Map.Entry<String,String> en:configChange.getAddedProperties().entrySet()){
- int index = en.getKey().indexOf('?');
- if(index>0){
- this.properties.put(en.getKey().substring(0, index), en.getValue());
- }else{
- this.properties.put(en.getKey(), en.getValue());
- }
- }
- for(String rmKey:configChange.getRemovedProperties()){
- this.properties.remove(rmKey);
- }
- try(BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file))){
- Properties props = new Properties();
- for (Map.Entry<String,String> en : this.properties.entrySet()) {
- props.setProperty(en.getKey(), en.getValue());
- }
- props.storeToXML(bos, "Properties written from Tamaya on " + new Date());
- bos.flush();
- }
- catch(Exception e){
- throw new ConfigException("Failed to write config to " + file, e);
- }
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/spi/ConfigChangeRequest.java
----------------------------------------------------------------------
diff --git a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/spi/ConfigChangeRequest.java b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/spi/ConfigChangeRequest.java
deleted file mode 100644
index 2349ad1..0000000
--- a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/spi/ConfigChangeRequest.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.mutableconfig.spi;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-
-/**
- * Change context used for managing configuration changes within an
- * {@link org.apache.tamaya.mutableconfig.spi.MutablePropertySource}.
- */
-public final class ConfigChangeRequest {
- /**
- * The transaction id.
- */
- private String transactionId;
- /**
- * The starting point.
- */
- private long startedAt = System.currentTimeMillis();
- /**
- * The Properties.
- */
- private final Map<String,String> addedProperties = new HashMap<>();
- /**
- * The Removed.
- */
- private final Set<String> removedProperties = new HashSet<>();
-
- /**
- * Creates a new instance bound to the given transaction.
- * @param transactionID the transaction ID, not null.
- */
- public ConfigChangeRequest(String transactionID){
- this.transactionId = Objects.requireNonNull(transactionID);
- }
-
- /**
- * Sets the started at value. By default {@link #startedAt} is already set on instance creation to
- * {@code System.currentTimeMillis()}.
- * @param startedAt the new UTC POSIX timestamp in millis.
- */
- public void setStartedAt(long startedAt) {
- this.startedAt = startedAt;
- }
-
- /**
- * Get the corresppnding transaction ID of this instance.
- * @return the transaction ID, never null.
- */
- public String getTransactionID(){
- return transactionId;
- }
-
- /**
- * Timestamp in UTC millis, when this transaction (context) was created.
- * @return the timestamp in millis.
- */
- public long getStartedAt(){
- return startedAt;
- }
-
- /**
- * Get an unmodifiable key/value map of properties added or updated.
- * @return an unmodifiable key/value map of properties added or updated, never null.
- */
- public Map<String,String> getAddedProperties(){
- return Collections.unmodifiableMap(addedProperties);
- }
-
- /**
- * Get an unmodifiable key set of properties removed.
- * @return an unmodifiable key set of properties removed, never null.
- */
- public Set<String> getRemovedProperties(){
- return Collections.unmodifiableSet(removedProperties);
- }
-
- /**
- * Adds/updates a new key/value pair.
- * @param key the key, not null.
- * @param value the value, not null.
- */
- public void put(String key, String value) {
- this.addedProperties.put(key, value);
- this.removedProperties.remove(key);
- }
-
- /**
- * Add/updated multiple key/values.
- * @param properties the keys and values to be added/updated, not null.
- */
- public void putAll(Map<String, String> properties) {
- this.addedProperties.putAll(properties);
- this.removedProperties.removeAll(properties.keySet());
- }
-
- /**
- * Remove all the given keys, ir present.
- * @param key the key to be removed, not null.
- */
- public void remove(String key) {
- this.removedProperties.add(key);
- this.addedProperties.remove(key);
- }
-
- /**
- * Remove all the given keys, ir present.
- * @param keys the keys to be removed, not null.
- */
- public void removeAll(Collection<String> keys) {
- this.removedProperties.addAll(keys);
- for(String k:keys) {
- this.addedProperties.remove(k);
- }
- }
-
- /**
- * Allows easily to check if no additions/changes an no removals are present in the current transaction.
- * @return true, if not actions have to be committed.
- */
- public boolean isEmpty() {
- return this.addedProperties.isEmpty() && this.removedProperties.isEmpty();
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof ConfigChangeRequest)) {
- return false;
- }
- ConfigChangeRequest that = (ConfigChangeRequest) o;
- return transactionId.equals(that.transactionId);
-
- }
-
- @Override
- public int hashCode() {
- return transactionId.hashCode();
- }
-
- @Override
- public String toString() {
- return "ConfigChangeRequest{" +
- "transactionId=" + transactionId +
- ", startedAt=" + startedAt +
- ", addedProperties=" + addedProperties +
- ", removedProperties=" + removedProperties +
- '}';
- }
-
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/spi/MutableConfigurationProviderSpi.java
----------------------------------------------------------------------
diff --git a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/spi/MutableConfigurationProviderSpi.java b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/spi/MutableConfigurationProviderSpi.java
deleted file mode 100644
index 4412085..0000000
--- a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/spi/MutableConfigurationProviderSpi.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.mutableconfig.spi;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.mutableconfig.ChangePropagationPolicy;
-import org.apache.tamaya.mutableconfig.MutableConfiguration;
-
-
-/**
- * Provider SPI used by {@link org.apache.tamaya.mutableconfig.MutableConfigurationProvider}. Providers may override
- * other providers registering with a higher {@link javax.annotation.Priority} value annotated.
- */
-public interface MutableConfigurationProviderSpi {
-
- /**
- * Creates a new {@link MutableConfiguration} with {@code autoCommit = false} as default.
- *
- * @param configuration the configuration, not null.
- * @param propagationPolicy policy that defines how changes are published to the property
- * sources.
- * @return a new mutable configuration instance.
- */
- MutableConfiguration createMutableConfiguration(Configuration configuration,
- ChangePropagationPolicy propagationPolicy);
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/spi/MutablePropertySource.java
----------------------------------------------------------------------
diff --git a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/spi/MutablePropertySource.java b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/spi/MutablePropertySource.java
deleted file mode 100644
index b648341..0000000
--- a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/spi/MutablePropertySource.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.mutableconfig.spi;
-
-import org.apache.tamaya.spi.PropertySource;
-
-
-/**
- * This interface models a writable backend for configuration data.
- *
- * As a consequence clients should first check, using the corresponding methods, if entries are to edited or removedProperties
- * actually are eligible for change/creation or removal.
- */
-public interface MutablePropertySource extends PropertySource {
-
- /**
- * Puts all given configuration entries. This method should check that all given properties are
- * basically removable, as defined by #isWritable. If any of the passed keys is not writable during this initial
- * check, the operation should not perform any configuration changes and throw a {@link org.apache.tamaya.ConfigException}. If errors
- * occur afterwards, when the properties are effectively written back to the backends, the errors should be
- * collected and returned as part of the ConfigException payload. Nevertheless the operation should in that case
- * remove all entries as far as possible and abort the writing operation.
- *
- * @param configChange the {@link ConfigChangeRequest}, containing the transactionId used to isolate
- * the change, the properties to be added/overridden and the property keys
- * being removed.
- * @throws org.apache.tamaya.ConfigException if any of the given properties could not be written, or the request is read-only.
- */
- void applyChange(ConfigChangeRequest configChange);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/mutable-config/src/main/resources/META-INF/services/org.apache.tamaya.mutableconfig.spi.MutableConfigurationProviderSpi
----------------------------------------------------------------------
diff --git a/modules/mutable-config/src/main/resources/META-INF/services/org.apache.tamaya.mutableconfig.spi.MutableConfigurationProviderSpi b/modules/mutable-config/src/main/resources/META-INF/services/org.apache.tamaya.mutableconfig.spi.MutableConfigurationProviderSpi
deleted file mode 100644
index eb366fc..0000000
--- a/modules/mutable-config/src/main/resources/META-INF/services/org.apache.tamaya.mutableconfig.spi.MutableConfigurationProviderSpi
+++ /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.mutableconfig.internal.DefaultMutableConfigurationSpi
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/mutable-config/src/test/java/org/apache/tamaya/mutableconfig/MutableConfigurationTest.java
----------------------------------------------------------------------
diff --git a/modules/mutable-config/src/test/java/org/apache/tamaya/mutableconfig/MutableConfigurationTest.java b/modules/mutable-config/src/test/java/org/apache/tamaya/mutableconfig/MutableConfigurationTest.java
deleted file mode 100644
index 814f3ce..0000000
--- a/modules/mutable-config/src/test/java/org/apache/tamaya/mutableconfig/MutableConfigurationTest.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.mutableconfig;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.mutableconfig.internal.WritablePropertiesSource;
-import org.apache.tamaya.mutableconfig.internal.WritableXmlPropertiesSource;
-import org.junit.Test;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-/**
- * Tests for {@link MutableConfiguration}.
- */
-public class MutableConfigurationTest {
-
- /**
- * Test create change request.
- *
- * @throws Exception the exception
- */
- @Test
- public void testCreateMutableConfiguration() throws Exception {
- File f = File.createTempFile("ConfigChangeRequest",".properties");
- MutableConfiguration cfg1 = MutableConfigurationProvider.createMutableConfiguration(
- ConfigurationProvider.getConfiguration(),
- MutableConfigurationProvider.getApplyAllChangePolicy());
- assertNotNull(cfg1);
- assertNotNull(cfg1.getConfigChangeRequest());
- MutableConfiguration cfg2 = MutableConfigurationProvider.createMutableConfiguration(
- ConfigurationProvider.getConfiguration());
- assertNotNull(cfg2);
- assertNotNull(cfg2.getConfigChangeRequest());
- assertTrue(cfg1!=cfg2);
- assertTrue(cfg1.getConfigChangeRequest()!=cfg2.getConfigChangeRequest());
- }
-
- /**
- * Test null create change request.
- *
- * @throws Exception the exception
- */
- @Test(expected=NullPointerException.class)
- public void testNullCreateMutableConfiguration1() throws Exception {
- MutableConfigurationProvider.createMutableConfiguration(
- (Configuration) null);
- }
-
- /**
- * Test null create change request.
- *
- * @throws Exception the exception
- */
- @Test(expected=NullPointerException.class)
- public void testNullCreateMutableConfiguration2() throws Exception {
- MutableConfigurationProvider.createMutableConfiguration(
- (ChangePropagationPolicy) null);
- }
-
- /**
- * Test read write properties with rollback.
- *
- * @throws IOException the io exception
- */
- @Test
- public void testReadWriteProperties_WithCancel() throws IOException {
- WritablePropertiesSource.target.delete();
- MutableConfiguration mutConfig = MutableConfigurationProvider.createMutableConfiguration(
- ConfigurationProvider.getConfiguration()
- );
- mutConfig.put("key1", "value1");
- Map<String,String> cm = new HashMap<>();
- cm.put("key2", "value2");
- cm.put("key3", "value3");
- }
-
- /**
- * Test read write properties with commit.
- *
- * @throws IOException the io exception
- */
- @Test
- public void testReadWriteProperties_WithCommit() throws IOException {
- WritablePropertiesSource.target.delete();
- MutableConfiguration mutConfig = MutableConfigurationProvider.createMutableConfiguration(
- ConfigurationProvider.getConfiguration()
- );
- mutConfig.put("key1", "value1");
- Map<String,String> cm = new HashMap<>();
- cm.put("key2", "value2");
- cm.put("key3", "value3");
- mutConfig.putAll(cm);
- mutConfig.store();
- assertTrue(WritablePropertiesSource.target.exists());
- MutableConfiguration mmutConfig2 = MutableConfigurationProvider.createMutableConfiguration(
- ConfigurationProvider.getConfiguration()
- );
- mmutConfig2.remove("foo");
- mmutConfig2.remove("key3");
- mmutConfig2.put("key1", "value1.2");
- mmutConfig2.put("key4", "value4");
- mmutConfig2.store();
- Properties props = new Properties();
- props.load(WritablePropertiesSource.target.toURL().openStream());
- assertEquals(3, props.size());
- assertEquals("value1.2", props.getProperty("key1"));
- assertEquals("value2", props.getProperty("key2"));
- assertEquals("value4", props.getProperty("key4"));
- }
-
- /**
- * Test read write xml properties with commit.
- *
- * @throws IOException the io exception
- */
- @Test
- public void testReadWriteXmlProperties_WithCommit() throws IOException {
- WritableXmlPropertiesSource.target.delete();
- MutableConfiguration cfg = MutableConfigurationProvider.createMutableConfiguration(
- ConfigurationProvider.getConfiguration(), MutableConfigurationProvider.getApplyAllChangePolicy());
- cfg.put("key1", "value1");
- Map<String,String> cm = new HashMap<>();
- cm.put("key2", "value2");
- cm.put("key3", "value3");
- cfg.putAll(cm);
- cfg.store();
- assertTrue(WritableXmlPropertiesSource.target.exists());
- MutableConfiguration cfg2 = MutableConfigurationProvider.createMutableConfiguration(
- ConfigurationProvider.getConfiguration());
- assertTrue(cfg != cfg2);
- cfg2.remove("foo");
- cfg2.remove("key3");
- cfg2.put("key1", "value1.2");
- cfg2.put("key4", "value4");
- cfg2.store();
- Properties props = new Properties();
- props.loadFromXML( WritableXmlPropertiesSource.target.toURL().openStream());
- assertEquals(3, props.size());
- assertEquals("value1", props.getProperty("key1"));
- assertEquals("value2", props.getProperty("key2"));
- }
-
- /**
- * Test read write xml properties with commit.
- *
- * @throws IOException the io exception
- */
- @Test
- public void testWriteWithNoChangePolicy() throws IOException {
- WritableXmlPropertiesSource.target.delete();
- MutableConfiguration cfg = MutableConfigurationProvider.createMutableConfiguration(
- ConfigurationProvider.getConfiguration(),
- MutableConfigurationProvider.getApplyNonePolicy());
- cfg.put("key1", "value1");
- Map<String,String> cm = new HashMap<>();
- cm.put("key2", "value2");
- cm.put("key3", "value3");
- cfg.putAll(cm);
- cfg.store();
- assertFalse(WritableXmlPropertiesSource.target.exists());
- }
-
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/mutable-config/src/test/java/org/apache/tamaya/mutableconfig/internal/PropertiesFileConfigBackendTest.java
----------------------------------------------------------------------
diff --git a/modules/mutable-config/src/test/java/org/apache/tamaya/mutableconfig/internal/PropertiesFileConfigBackendTest.java b/modules/mutable-config/src/test/java/org/apache/tamaya/mutableconfig/internal/PropertiesFileConfigBackendTest.java
deleted file mode 100644
index e6c79f5..0000000
--- a/modules/mutable-config/src/test/java/org/apache/tamaya/mutableconfig/internal/PropertiesFileConfigBackendTest.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.mutableconfig.internal;
-
-import org.apache.tamaya.mutableconfig.propertysources.MutablePropertiesPropertySource;
-
-
-/**
- * Tests for {@link MutablePropertiesPropertySource}.
- */
-public class PropertiesFileConfigBackendTest {
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/mutable-config/src/test/java/org/apache/tamaya/mutableconfig/internal/WritablePropertiesSource.java
----------------------------------------------------------------------
diff --git a/modules/mutable-config/src/test/java/org/apache/tamaya/mutableconfig/internal/WritablePropertiesSource.java b/modules/mutable-config/src/test/java/org/apache/tamaya/mutableconfig/internal/WritablePropertiesSource.java
deleted file mode 100644
index 5257c8b..0000000
--- a/modules/mutable-config/src/test/java/org/apache/tamaya/mutableconfig/internal/WritablePropertiesSource.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.mutableconfig.internal;
-
-import org.apache.tamaya.mutableconfig.propertysources.MutablePropertiesPropertySource;
-
-import java.io.File;
-import java.io.IOException;
-
-/**
- * Writable test property source based on the {@link MutablePropertiesPropertySource}.
- */
-public class WritablePropertiesSource extends MutablePropertiesPropertySource {
-
- public static File target = createFile();
-
- private static File createFile() {
- try {
- return File.createTempFile("writableProps",".properties");
- } catch (IOException e) {
- e.printStackTrace();
- throw new IllegalStateException("Cannot init test.", e);
- }
- }
-
- /**
- * Creates a new Properties based PropertySource based on the given URL.
- */
- public WritablePropertiesSource() throws IOException {
- super(target, 100);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/mutable-config/src/test/java/org/apache/tamaya/mutableconfig/internal/WritableXmlPropertiesSource.java
----------------------------------------------------------------------
diff --git a/modules/mutable-config/src/test/java/org/apache/tamaya/mutableconfig/internal/WritableXmlPropertiesSource.java b/modules/mutable-config/src/test/java/org/apache/tamaya/mutableconfig/internal/WritableXmlPropertiesSource.java
deleted file mode 100644
index d6aa7ec..0000000
--- a/modules/mutable-config/src/test/java/org/apache/tamaya/mutableconfig/internal/WritableXmlPropertiesSource.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.mutableconfig.internal;
-
-import org.apache.tamaya.mutableconfig.propertysources.MutableXmlPropertiesPropertySource;
-
-import java.io.File;
-import java.io.IOException;
-
-/**
- * Writable test property source based on the {@link MutableXmlPropertiesPropertySource}.
- */
-public class WritableXmlPropertiesSource extends MutableXmlPropertiesPropertySource {
-
- public static File target = createFile();
-
- private static File createFile() {
- try {
- return File.createTempFile("writableProps",".xml");
- } catch (IOException e) {
- e.printStackTrace();
- throw new IllegalStateException("Cannot init test.", e);
- }
- }
-
- /**
- * Creates a new Properties based PropertySource based on the given URL.
- */
- public WritableXmlPropertiesSource() throws IOException {
- super(target, 200);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/mutable-config/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
----------------------------------------------------------------------
diff --git a/modules/mutable-config/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource b/modules/mutable-config/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
deleted file mode 100644
index 609b9fe..0000000
--- a/modules/mutable-config/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
+++ /dev/null
@@ -1,20 +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.mutableconfig.internal.WritablePropertiesSource
-org.apache.tamaya.mutableconfig.internal.WritableXmlPropertiesSource
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/optional/pom.xml
----------------------------------------------------------------------
diff --git a/modules/optional/pom.xml b/modules/optional/pom.xml
deleted file mode 100644
index 622c3f7..0000000
--- a/modules/optional/pom.xml
+++ /dev/null
@@ -1,81 +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.
--->
-<project xmlns="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">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-extensions</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
-
- <artifactId>tamaya-optional</artifactId>
- <name>Apache Tamaya Modules - Optional Configuration Backend</name>
- <description>This module provides a simple class that can be used as a single dependency for evaluating
- configuration. It runs basically without Tamaya being on the classpath, but if available it
- considers/uses Tamaya functionality.</description>
- <packaging>bundle</packaging>
-
- <properties>
- <jdkVersion>1.7</jdkVersion>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-api</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-core</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>java-hamcrest</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.tamaya.optional
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/optional/src/main/java/org/apache/tamaya/optional/EvaluationPolicy.java
----------------------------------------------------------------------
diff --git a/modules/optional/src/main/java/org/apache/tamaya/optional/EvaluationPolicy.java b/modules/optional/src/main/java/org/apache/tamaya/optional/EvaluationPolicy.java
deleted file mode 100644
index 86df274..0000000
--- a/modules/optional/src/main/java/org/apache/tamaya/optional/EvaluationPolicy.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.optional;
-
-/**
- * Evaluation policy that determines if local configuration or Tamaya configuration values override.
- */
-public enum EvaluationPolicy {
- /** Values from Tamaya (if available) always override values from the default provider. */
- TAMAYA_OVERRIDES_OTHER,
- /** Values from value provider always override values from Tamaya (if available). */
- OTHER_OVERRIDES_TAMAYA,
- /** No overrides are allowed. If both the value provider and Tamaya return values not equal a RuntimeException
- * is thrown.
- */
- THROWS_EXCEPTION
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/optional/src/main/java/org/apache/tamaya/optional/OptionalConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/optional/src/main/java/org/apache/tamaya/optional/OptionalConfiguration.java b/modules/optional/src/main/java/org/apache/tamaya/optional/OptionalConfiguration.java
deleted file mode 100644
index 4868bc1..0000000
--- a/modules/optional/src/main/java/org/apache/tamaya/optional/OptionalConfiguration.java
+++ /dev/null
@@ -1,214 +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.optional;
-
-
-import java.util.Objects;
-
-import org.apache.tamaya.ConfigurationProvider;
-
-/**
- * Simplified configuration API, that can be used by code that only wants Tamaya to optionally enhance its configuration
- * mechanism, but by default uses its own configuration by default.
- */
-public final class OptionalConfiguration {
-
- /**
- * Flag only true, if Tamaya is on the classpath.
- */
- private static final boolean TAMAYA_LOADED = initTamayaLoaded();
-
- /**
- * Configuration API to be loaded.
- */
- private static final String TAMAYA_CONFIGURATION = "org.apache.tamaya.Configuration";
-
- /**
- * Tries to load the Tamaya Configuration interface from the classpath.
- *
- * @return true, if the interface is available.
- */
- private static boolean initTamayaLoaded() {
- try {
- Class.forName(TAMAYA_CONFIGURATION);
- return true;
- } catch (final Exception e) {
- return false;
- }
- }
-
- /**
- * Default value provider returning Strings from system properties and the system environment.
- * In all other cases {@code null} is returned.
- */
- public static final ValueProvider DEFAULT_PROVIDER = new ValueProvider() {
- @SuppressWarnings("unchecked")
- @Override
- public <T> T get(String key, Class<T> type) {
- if (String.class == type) {
- String value = System.getProperty(key);
- if (value == null) {
- value = System.getenv(key);
- }
- return (T) value;
- }
- return null;
- }
- };
-
- /**
- * Default value provider that always returns {@code null}.
- */
- public static final ValueProvider NULLPROVIDER = new ValueProvider() {
- @Override
- public <T> T get(String key, Class<T> type) {
- return null;
- }
- };
-
- /**
- * Delegating value getter used to evaluate values, depending on the fallback policy.
- */
- private final ValueProvider provider;
-
- /**
- * Evaluation policy that determines if local configuration or Tamaya configuration values override.
- */
- private final EvaluationPolicy policy;
-
- /**
- * Creates a new instance.
- *
- * @param policy the policy how a value should be evaluated depending if Tamaya is available or not.
- * @param provider the non Tamaya-based provider to be used to evaluate values.
- */
- private OptionalConfiguration(EvaluationPolicy policy, ValueProvider provider) {
- this.provider = Objects.requireNonNull(provider);
- this.policy = Objects.requireNonNull(policy);
- }
-
- /**
- * Returns an instance of OptionalConfiguration, which uses the given provider and policy for evaluating the values.
- *
- * @param policy the policy how a value should be evaluated depending if Tamaya is available or not.
- * @param provider the non Tamaya-based provider to be used to evaluate values.
- * @return a default OptionalConfiguration instance, never null.
- */
- public static OptionalConfiguration of(EvaluationPolicy policy, ValueProvider provider) {
- return new OptionalConfiguration(policy, provider);
- }
-
- /**
- * Returns a default instance, which uses a default provider returning values from system properties and environment
- * only.
- *
- * @param policy the policy how a value should be evaluated depending if Tamaya is available or not.
- * @return a default OptionalConfiguration instance, never null.
- */
- public static OptionalConfiguration of(EvaluationPolicy policy) {
- return new OptionalConfiguration(policy, DEFAULT_PROVIDER);
- }
-
- /**
- * Access a String value.
- *
- * @param key the key, not null.
- * @return the value found, or null.
- */
- public String get(String key) {
- return get(key, String.class);
- }
-
- /**
- * Access a String value.
- *
- * @param key the key, not null.
- * @param defaultValue the default value, returned if no such key is found in the configuration.
- * @return the value found, or null.
- */
- public String getOrDefault(String key, String defaultValue) {
- final String value = get(key, String.class);
- if (value == null) {
- return defaultValue;
- }
- return value;
- }
-
- /**
- * Method that returns the corresponding value, depending on the availability of Tamaya, the
- * registered provider and evaluation policy.
- *
- * @param key the key, not null.
- * @param type the target type, not null.
- * @param <T> the type param.
- * @return the value, or null.
- */
- public <T> T get(String key, Class<T> type) {
- final T value = provider.get(key, type);
- final T tamayaValue = getTamaya(key, type);
- switch (policy) {
- case OTHER_OVERRIDES_TAMAYA:
- return value != null ? value : tamayaValue;
- case TAMAYA_OVERRIDES_OTHER:
- return tamayaValue != null ? tamayaValue : value;
- case THROWS_EXCEPTION:
- if (tamayaValue != value) {
- if ((tamayaValue != null && !tamayaValue.equals(value)) ||
- (value != null && TAMAYA_LOADED && !value.equals(tamayaValue))) {
- throw new IllegalStateException("Incompatible configuration values: key=" + key +
- "=" + value + "(provider)/" + tamayaValue + "(Tamaya");
- }
- }
- default:
- }
- return value;
- }
-
- /**
- * Access a String value.
- *
- * @param key the key, not null.
- * @param type the target type, not null.
- * @param <T> the type param.
- * @param defaultValue the default value, returned if no such key is found in the configuration.
- * @return the value found, or null.
- */
- public <T> T getOrDefault(String key, Class<T> type, T defaultValue) {
- final T value = get(key, type);
- if (value == null) {
- return defaultValue;
- }
- return value;
- }
-
- /**
- * Internal method that evaluates a value from Tamaya, when Tamaya is loaded.
- *
- * @param key the key, not null.
- * @param type the target type, not null.
- * @param <T> The type param
- * @return the corresponding value from Tamaya, or null.
- */
- private <T> T getTamaya(String key, Class<T> type) {
- if (TAMAYA_LOADED) {
- return ConfigurationProvider.getConfiguration().get(key, type);
- }
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/optional/src/main/java/org/apache/tamaya/optional/ValueProvider.java
----------------------------------------------------------------------
diff --git a/modules/optional/src/main/java/org/apache/tamaya/optional/ValueProvider.java b/modules/optional/src/main/java/org/apache/tamaya/optional/ValueProvider.java
deleted file mode 100644
index 4ca88b0..0000000
--- a/modules/optional/src/main/java/org/apache/tamaya/optional/ValueProvider.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.optional;
-
-/**
- * Simple (functional) interface, compatible with Java 7 that models a component that provides values.
- * It is the {@link EvaluationPolicy} that also must be passed, when creating an {@link OptionalConfiguration},
- * which is defining if values from this provider are overriding values from Tamaya (if available) or vice
- * versa. This provider interface must be implemented by the client that wants to optionally enhance its
- * code with optional Tamaya configuration support to create a bridge between his code and the values optionally
- * returned by Tamaya.
- */
-public interface ValueProvider {
-
- /**
- * Access a typed value given a (non empty) key.
- * @param key the key, not null.
- * @param type the type, not null.
- * @param <T> the type
- * @return the value found, or null.
- */
- <T> T get(String key, Class<T> type);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/optional/src/test/java/org/apache/tamaya/optional/OptionalConfigurationTest.java
----------------------------------------------------------------------
diff --git a/modules/optional/src/test/java/org/apache/tamaya/optional/OptionalConfigurationTest.java b/modules/optional/src/test/java/org/apache/tamaya/optional/OptionalConfigurationTest.java
deleted file mode 100644
index d91f260..0000000
--- a/modules/optional/src/test/java/org/apache/tamaya/optional/OptionalConfigurationTest.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.optional;
-
-import static org.junit.Assert.*;
-
-/**
- * Created by Anatole on 07.09.2015.
- */
-public class OptionalConfigurationTest {
-
- @org.junit.Test
- public void testOf_OTHER_OVERRIDES_TAMAYA() throws Exception {
- OptionalConfiguration cfg = OptionalConfiguration.of(EvaluationPolicy.OTHER_OVERRIDES_TAMAYA, new ValueProvider() {
- @Override
- public <T> T get(String key, Class<T> type) {
- return (T)"result";
- }
- });
- assertNotNull(cfg);
- assertEquals(cfg.get("sdkjsdkjsdkjhskjdh"), "result");
- assertEquals(cfg.get("sdkjsdkjsdsdsdkjhskjdh", String.class), "result");
- assertEquals(cfg.get("java.version", String.class), "result");
- }
-
- @org.junit.Test
- public void testOf_TAMAYA_OVERRIDES_OTHER() throws Exception {
- OptionalConfiguration cfg = OptionalConfiguration.of(EvaluationPolicy.TAMAYA_OVERRIDES_OTHER, new ValueProvider() {
- @Override
- public <T> T get(String key, Class<T> type) {
- return (T)"result";
- }
- });
- assertNotNull(cfg);
- assertEquals(cfg.get("sdkjsdkjsdkjhskjdh"), "result");
- assertEquals(cfg.get("sdkjsdkjsdsdsdkjhskjdh", String.class), "result");
- assertEquals(cfg.get("java.version", String.class), System.getProperty("java.version"));
- }
-
- @org.junit.Test(expected = IllegalStateException.class)
- public void testOf_THROWS_EXCEPTION() throws Exception {
- OptionalConfiguration cfg = OptionalConfiguration.of(EvaluationPolicy.THROWS_EXCEPTION, new ValueProvider() {
- @Override
- public <T> T get(String key, Class<T> type) {
- if("java.version".equals(key)){
- return (T)System.getProperty(key);
- }
- return (T)"result";
- }
- });
- assertNotNull(cfg);
- assertEquals(cfg.get("sdkjsdkjsdkjhskjdh"), "result");
- assertEquals(cfg.get("sdkjsdkjsdsdsdkjhskjdh", String.class), "result");
- assertEquals(cfg.get("java.version", String.class), System.getProperty("java.version"));
- assertEquals(cfg.get("java.version", String.class), "dfdf");
- }
-
- @org.junit.Test
- public void testOf_NOPROV_THROWS_EXCEPTION() throws Exception {
- OptionalConfiguration cfg = OptionalConfiguration.of(EvaluationPolicy.THROWS_EXCEPTION);
- assertNotNull(cfg);
- assertNull(cfg.get("sdkjsdkjsdkjhskjdh"));
- assertEquals(cfg.get("java.version"), System.getProperty("java.version"));
- assertEquals(cfg.get("java.version", String.class), System.getProperty("java.version"));
- }
-
- @org.junit.Test
- public void testOf_NOPROV_TAMAYA_OVERRIDES_OTHER() throws Exception {
- OptionalConfiguration cfg = OptionalConfiguration.of(EvaluationPolicy.TAMAYA_OVERRIDES_OTHER);
- assertNotNull(cfg);
- assertNull(cfg.get("sdkjsdkjsdkjhskjdh"));
- assertEquals(cfg.get("java.version"), System.getProperty("java.version"));
- assertEquals(cfg.get("java.version", String.class), System.getProperty("java.version"));
- }
-
- @org.junit.Test
- public void testOf_NOPROV_OTHER_OVERRIDES_TAMAYA() throws Exception {
- OptionalConfiguration cfg = OptionalConfiguration.of(EvaluationPolicy.OTHER_OVERRIDES_TAMAYA);
- assertNotNull(cfg);
- assertNull(cfg.get("sdkjsdkjsdkjhskjdh"));
- assertEquals(cfg.get("java.version"), System.getProperty("java.version"));
- assertEquals(cfg.get("java.version", String.class), System.getProperty("java.version"));
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/pom.xml
----------------------------------------------------------------------
diff --git a/modules/pom.xml b/modules/pom.xml
deleted file mode 100644
index e32b92f..0000000
--- a/modules/pom.xml
+++ /dev/null
@@ -1,119 +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.
--->
-<project xmlns="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">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-all</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
-
- <artifactId>tamaya-extensions</artifactId>
- <groupId>org.apache.tamaya.ext</groupId>
- <name>Apache Tamaya Extension Modules - all</name>
- <description>This project contains the several extensions that can be used with Tamaya.</description>
- <packaging>pom</packaging>
-
- <modules>
- <module>builder</module>
- <module>classloader-support</module>
- <module>collections</module>
- <module>events</module>
- <module>filter</module>
- <module>formats</module>
- <module>functions</module>
- <module>injection</module>
- <module>injection-api</module>
-
- <module>integration</module>
-
- <module>json</module>
- <module>management</module>
- <module>model</module>
- <module>mutable-config</module>
- <module>optional</module>
- <module>resolver</module>
- <module>resources</module>
- <module>server</module>
- <module>spi-support</module>
- <module>yaml</module>
- </modules>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <configuration>
- <logViolationsToConsole>true</logViolationsToConsole>
- <configLocation>checkstyle/style.xml</configLocation>
- </configuration>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>buildconfigurations</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-enforcer-plugin</artifactId>
- <executions>
- <execution>
- <id>enforce-versions</id>
- <goals>
- <goal>enforce</goal>
- </goals>
- <configuration>
- <rules>
- <requireJavaVersion>
- <version>[1.7,)</version>
- </requireJavaVersion>
- </rules>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>findbugs-maven-plugin</artifactId>
- <configuration>
- <failOnError>false</failOnError>
- <excludeFilterFile>findbugs/findbugs-exclude.xml</excludeFilterFile>
- </configuration>
- <dependencies>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>buildconfigurations</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- </plugin>
-
- </plugins>
- </build>
-
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resolver/pom.xml
----------------------------------------------------------------------
diff --git a/modules/resolver/pom.xml b/modules/resolver/pom.xml
deleted file mode 100644
index 596abb7..0000000
--- a/modules/resolver/pom.xml
+++ /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 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.
--->
-<project xmlns="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">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-extensions</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>tamaya-resolver</artifactId>
- <name>Apache Tamaya Modules - Resolver Services</name>
- <packaging>bundle</packaging>
-
- <properties>
- <jdkVersion>1.7</jdkVersion>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-core</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-resources</artifactId>
- <version>${project.version}</version>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>java-hamcrest</artifactId>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.tamaya.resolver,
- org.apache.tamaya.resolver.spi
- </Export-Package>
- <Private-Package>
- org.apache.tamaya.resolver.internal
- </Private-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resolver/src/main/java/org/apache/tamaya/resolver/Resolver.java
----------------------------------------------------------------------
diff --git a/modules/resolver/src/main/java/org/apache/tamaya/resolver/Resolver.java b/modules/resolver/src/main/java/org/apache/tamaya/resolver/Resolver.java
deleted file mode 100644
index eadb547..0000000
--- a/modules/resolver/src/main/java/org/apache/tamaya/resolver/Resolver.java
+++ /dev/null
@@ -1,77 +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.resolver;
-
-import org.apache.tamaya.resolver.spi.ExpressionEvaluator;
-import org.apache.tamaya.resolver.spi.ExpressionResolver;
-import org.apache.tamaya.spi.ServiceContextManager;
-
-import java.util.Collection;
-
-/**
- * Resolver singleton.
- */
-public final class Resolver {
-
- /**
- * Singleton constructor.
- */
- private Resolver(){}
-
- /**
- * Evaluates the current expression.
- * @param key the key, not null.
- * @param value the value to be filtered/evaluated.
- * @return the filtered/evaluated value, including null.
- */
- public static String evaluateExpression(String key, String value){
- return ServiceContextManager.getServiceContext().getService(ExpressionEvaluator.class)
- .evaluateExpression(key, value, true);
- }
-
- /**
- * Evaluates the current expression.
- * @param value the value to be filtered/evaluated.
- * @return the filtered/evaluated value, including null.
- */
- public static String evaluateExpression(String value){
- return evaluateExpression(value, true);
- }
-
- /**
- * Evaluates the current expression.
- * @param value the value to be filtered/evaluated.
- * @param maskNotFound if true, not found expression parts will be replaced vy surrounding with [].
- * Setting to false will replace the value with an empty String.
- * @return the filtered/evaluated value, including null.
- */
- public static String evaluateExpression(String value, boolean maskNotFound){
- return ServiceContextManager.getServiceContext().getService(ExpressionEvaluator.class)
- .evaluateExpression(null, value, maskNotFound);
- }
-
- /**
- * Access a collection with the currently registered {@link ExpressionResolver} instances.
- * @return the resolvers currently known, never null.
- */
- public static Collection<ExpressionResolver> getResolvers(){
- return ServiceContextManager.getServiceContext().getService(ExpressionEvaluator.class)
- .getResolvers();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/ConfigResolver.java
----------------------------------------------------------------------
diff --git a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/ConfigResolver.java b/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/ConfigResolver.java
deleted file mode 100644
index 4708a39..0000000
--- a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/ConfigResolver.java
+++ /dev/null
@@ -1,43 +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.resolver.internal;
-
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.resolver.spi.ExpressionResolver;
-
-import javax.annotation.Priority;
-
-/**
- * Property resolver implementation that interprets the resolver expression as a reference to another configuration
- * entry. It can be explicitly addressed by prefixing {@code conf:}, e.g. {@code ${conf:my.other.config.value}}.
- */
-@Priority(200)
-public final class ConfigResolver implements ExpressionResolver{
-
- @Override
- public String getResolverPrefix() {
- return "conf:";
- }
-
- @Override
- public String evaluate(String expression){
- return ConfigurationProvider.getConfiguration().get(expression);
- }
-
-}
[21/24] incubator-tamaya git commit: Removed all modules from the
main repository. They will be reborn in separate ASF repository.
Posted by pl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/collections/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter b/modules/collections/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter
deleted file mode 100644
index 9a93a69..0000000
--- a/modules/collections/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy current the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-org.apache.tamaya.collections.internal.ArrayListConverter
-org.apache.tamaya.collections.internal.CollectionConverter
-org.apache.tamaya.collections.internal.HashMapConverter
-org.apache.tamaya.collections.internal.ConcurrentHashMapConverter
-org.apache.tamaya.collections.internal.HashSetConverter
-org.apache.tamaya.collections.internal.LinkedListConverter
-org.apache.tamaya.collections.internal.ListConverter
-org.apache.tamaya.collections.internal.MapConverter
-org.apache.tamaya.collections.internal.SetConverter
-org.apache.tamaya.collections.internal.SortedSetConverter
-org.apache.tamaya.collections.internal.SortedMapConverter
-org.apache.tamaya.collections.internal.TreeMapConverter
-org.apache.tamaya.collections.internal.TreeSetConverter
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/collections/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyValueCombinationPolicy
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyValueCombinationPolicy b/modules/collections/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyValueCombinationPolicy
deleted file mode 100644
index 6b7a67b..0000000
--- a/modules/collections/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyValueCombinationPolicy
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy current the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-org.apache.tamaya.collections.internal.AdaptiveCombinationPolicy
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/collections/src/test/java/org/apache/tamaya/collections/CollectionAdvancedTests.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/test/java/org/apache/tamaya/collections/CollectionAdvancedTests.java b/modules/collections/src/test/java/org/apache/tamaya/collections/CollectionAdvancedTests.java
deleted file mode 100644
index 43f1f4f..0000000
--- a/modules/collections/src/test/java/org/apache/tamaya/collections/CollectionAdvancedTests.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.collections;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.TypeLiteral;
-import org.junit.Test;
-
-import java.util.Currency;
-import java.util.List;
-import java.util.Map;
-
-import static junit.framework.TestCase.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-
-/**
- * Created by atsticks on 16.02.16.
- */
-public class CollectionAdvancedTests {
-
- /**
- * Tests if a custom separator works, Config is
- * <pre>
- * sep-list=a,b,c|d,e,f|g,h,i
- * _sep-list.collection-type=List
- * _sep-list.collection-separator=|
- * </pre>
- */
- @Test
- public void testCustomSeparator(){
- Configuration config = ConfigurationProvider.getConfiguration();
- List<String> items = config.get("sep-list", new TypeLiteral<List<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(3, items.size());
- assertEquals("a,b,c", items.get(0));
- assertEquals("d,e,f", items.get(1));
- assertEquals("g,h,i", items.get(2));
- }
-
- /**
- * Test typed content.
- * <pre>
- * currency-list=CHF,USD,YEN
- * _currency-list.collection-type=List
- * </pre>
- */
- @Test
- public void testTypedContent(){
- Configuration config = ConfigurationProvider.getConfiguration();
- List<Currency> items = config.get("currency-list", new TypeLiteral<List<Currency>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(3, items.size());
- assertEquals("CHF", items.get(0).getCurrencyCode());
- assertEquals("USD", items.get(1).getCurrencyCode());
- assertEquals("USS", items.get(2).getCurrencyCode());
- }
-
- /**
- * Tests if a custom parser works, Config is
- * <pre>
- * parser-list=a,b,c
- * _parser-list.collection-type=List
- * _parser-list.item-converter=org.apache.tamaya.collections.MyUpperCaseConverter
- * </pre>
- */
- @Test
- public void testCustomParser(){
- Configuration config = ConfigurationProvider.getConfiguration();
- List<String> items = config.get("parser-list", new TypeLiteral<List<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(3, items.size());
- assertEquals("(A)", items.get(0));
- assertEquals("(B)", items.get(1));
- assertEquals("(C)", items.get(2));
- }
-
- /**
- * Redefined map format parsing, Config is as follows:
- * <pre>
- * redefined-map=0==none | 1==single | 2==any
- * _redefined-map.map-entry-separator===
- * _redefined-map.item-separator=|
- * </pre>
- */
- @Test
- public void testCustomMapParser(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Map<String,String> items = config.get("redefined-map", Map.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(3, items.size());
- assertEquals("none", items.get("0"));
- assertEquals("single", items.get("1"));
- assertEquals("any", items.get("2"));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/collections/src/test/java/org/apache/tamaya/collections/CollectionsBaseTests.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/test/java/org/apache/tamaya/collections/CollectionsBaseTests.java b/modules/collections/src/test/java/org/apache/tamaya/collections/CollectionsBaseTests.java
deleted file mode 100644
index 34c82cb..0000000
--- a/modules/collections/src/test/java/org/apache/tamaya/collections/CollectionsBaseTests.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.collections;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.TypeLiteral;
-import org.junit.Test;
-
-import java.util.*;
-
-import static junit.framework.TestCase.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-
-/**
- * Basic tests for Tamaya collection support. Relevant configs for this tests:
- * <pre>base.items=1,2,3,4,5,6,7,8,9,0
- * base.map=1::a, 2::b, 3::c, [4:: ]
- * </pre>
- */
-public class CollectionsBaseTests {
-
- @Test
- public void testList_String(){
- Configuration config = ConfigurationProvider.getConfiguration();
- List<String> items = config.get("base.items", new TypeLiteral<List<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- items = (List<String>) config.get("base.items", List.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- }
-
- @Test
- public void testArrayList_String(){
- Configuration config = ConfigurationProvider.getConfiguration();
- ArrayList<String> items = config.get("base.items", new TypeLiteral<ArrayList<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- items = (ArrayList<String>) config.get("base.items", ArrayList.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- }
-
- @Test
- public void testLinkedList_String(){
- Configuration config = ConfigurationProvider.getConfiguration();
- LinkedList<String> items = config.get("base.items", new TypeLiteral<LinkedList<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- items = (LinkedList<String>) config.get("base.items", LinkedList.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- }
-
- @Test
- public void testSet_String(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Set<String> items = config.get("base.items", new TypeLiteral<Set<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- items = (Set<String>) config.get("base.items", Set.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- }
-
- @Test
- public void testSortedSet_String(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Set<String> items = config.get("base.items", new TypeLiteral<SortedSet<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- items = (SortedSet<String>) config.get("base.items", SortedSet.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- }
-
- @Test
- public void testHashSet_String(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Set<String> items = config.get("base.items", new TypeLiteral<HashSet<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- items = (HashSet<String>) config.get("base.items", HashSet.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- }
-
- @Test
- public void testTreeSet_String(){
- Configuration config = ConfigurationProvider.getConfiguration();
- TreeSet<String> items = config.get("base.items", new TypeLiteral<TreeSet<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- items = (TreeSet<String>) config.get("base.items", TreeSet.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- }
-
- @Test
- public void testMap_String(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Map<String,String> items = config.get("base.map", new TypeLiteral<Map<String,String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(4, items.size());
- assertEquals("a", items.get("1"));
- assertEquals("b", items.get("2"));
- assertEquals("c", items.get("3"));
- assertEquals(" ", items.get("4"));
- items = (Map<String,String>) config.get("base.map", Map.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(4, items.size());
- assertEquals("a", items.get("1"));
- assertEquals("b", items.get("2"));
- assertEquals("c", items.get("3"));
- assertEquals(" ", items.get("4"));
- }
-
- @Test
- public void testHashMap_String(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Map<String,String> items = config.get("base.map", new TypeLiteral<HashMap<String,String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(4, items.size());
- assertEquals("a", items.get("1"));
- assertEquals("b", items.get("2"));
- assertEquals("c", items.get("3"));
- assertEquals(" ", items.get("4"));
- items = (HashMap<String,String>) config.get("base.map", HashMap.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(4, items.size());
- assertEquals("a", items.get("1"));
- assertEquals("b", items.get("2"));
- assertEquals("c", items.get("3"));
- assertEquals(" ", items.get("4"));
- }
-
- @Test
- public void testSortedMap_String(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Map<String,String> items = config.get("base.map", new TypeLiteral<SortedMap<String,String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(4, items.size());
- assertEquals("a", items.get("1"));
- assertEquals("b", items.get("2"));
- assertEquals("c", items.get("3"));
- assertEquals(" ", items.get("4"));
- items = (Map<String,String>) config.get("base.map", SortedMap.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(4, items.size());
- assertEquals("a", items.get("1"));
- assertEquals("b", items.get("2"));
- assertEquals("c", items.get("3"));
- assertEquals(" ", items.get("4"));
- }
-
- @Test
- public void testTreeMap_String(){
- Configuration config = ConfigurationProvider.getConfiguration();
- TreeMap<String,String> items = config.get("base.map", new TypeLiteral<TreeMap<String,String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(4, items.size());
- assertEquals("a", items.get("1"));
- assertEquals("b", items.get("2"));
- assertEquals("c", items.get("3"));
- assertEquals(" ", items.get("4"));
- items = config.get("base.map", TreeMap.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(4, items.size());
- assertEquals("a", items.get("1"));
- assertEquals("b", items.get("2"));
- assertEquals("c", items.get("3"));
- assertEquals(" ", items.get("4"));
- }
-
- @Test
- public void testCollection_String(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Collection<String> items = config.get("base.items", new TypeLiteral<Collection<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- items = (Collection<String>) config.get("base.items", Collection.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/collections/src/test/java/org/apache/tamaya/collections/CollectionsTypedReadOnlyTests.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/test/java/org/apache/tamaya/collections/CollectionsTypedReadOnlyTests.java b/modules/collections/src/test/java/org/apache/tamaya/collections/CollectionsTypedReadOnlyTests.java
deleted file mode 100644
index 7882512..0000000
--- a/modules/collections/src/test/java/org/apache/tamaya/collections/CollectionsTypedReadOnlyTests.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.collections;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.TypeLiteral;
-import org.junit.Test;
-
-import java.util.*;
-
-import static junit.framework.TestCase.assertEquals;
-import static org.junit.Assert.*;
-
-/**
- * Basic tests for Tamaya collection support. Relevant configs for this tests:
- * <pre>base.items=1,2,3,4,5,6,7,8,9,0
- * base.map=1::a, 2::b, 3::c, [4:: ]
- * </pre>
- */
-public class CollectionsTypedReadOnlyTests {
-
- @Test(expected=UnsupportedOperationException.class)
- public void testArrayListList_1(){
- Configuration config = ConfigurationProvider.getConfiguration();
- List<String> items = config.get("typed.arraylist", new TypeLiteral<List<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- items.add("test");
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testArrayListList_2(){
- Configuration config = ConfigurationProvider.getConfiguration();
- List<String> items = (List<String>) config.get("typed.arraylist", List.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- items.add("test");
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testLinkedListList_1(){
- Configuration config = ConfigurationProvider.getConfiguration();
- List<String> items = config.get("typed.linkedlist", new TypeLiteral<List<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- items.add("test");
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testLinkedListList_2(){
- Configuration config = ConfigurationProvider.getConfiguration();
- List<String> items = (List<String>) config.get("typed.linkedlist", List.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- items.add("test");
- }
-
-
- @Test(expected=UnsupportedOperationException.class)
- public void testHashSet_1(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Set<String> items = config.get("typed.hashset", new TypeLiteral<Set<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- items.add("test");
- }
- @Test(expected=UnsupportedOperationException.class)
- public void testHashSet_2(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Set<String> items = (Set<String>) config.get("typed.hashset", Set.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- items.add("test");
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testTreeSet_1(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Set<String> items = config.get("typed.treeset", new TypeLiteral<Set<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- items.add("test");
- }
- @Test(expected=UnsupportedOperationException.class)
- public void testTreeSet_2(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Set<String> items = items = (Set<String>) config.get("typed.treeset", Set.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- items.add("test");
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testHashMap_1(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Map<String,String> items = config.get("typed.hashmap", new TypeLiteral<Map<String,String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(4, items.size());
- assertEquals("a", items.get("1"));
- assertEquals("b", items.get("2"));
- assertEquals("c", items.get("3"));
- assertEquals(" ", items.get("4"));
- items.put("g","hjhhj");
- }
- @Test(expected=UnsupportedOperationException.class)
- public void testHashMap_2(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Map<String,String> items = (Map<String,String>) config.get("typed.hashmap", Map.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(4, items.size());
- assertEquals("a", items.get("1"));
- assertEquals("b", items.get("2"));
- assertEquals("c", items.get("3"));
- assertEquals(" ", items.get("4"));
- items.put("g","hjhhj");
- }
-
-
- @Test(expected=UnsupportedOperationException.class)
- public void testTreeMap_1(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Map<String,String> items = config.get("typed.treemap", new TypeLiteral<Map<String,String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(4, items.size());
- assertEquals("a", items.get("1"));
- assertEquals("b", items.get("2"));
- assertEquals("c", items.get("3"));
- assertEquals(" ", items.get("4"));
- items.put("g","hjhhj");
- }
- @Test(expected=UnsupportedOperationException.class)
- public void testTreeMap_2(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Map<String,String> items = (Map<String,String>) config.get("typed.treemap", Map.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(4, items.size());
- assertEquals("a", items.get("1"));
- assertEquals("b", items.get("2"));
- assertEquals("c", items.get("3"));
- assertEquals(" ", items.get("4"));
- items.put("g","hjhhj");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/collections/src/test/java/org/apache/tamaya/collections/CollectionsTypedTests.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/test/java/org/apache/tamaya/collections/CollectionsTypedTests.java b/modules/collections/src/test/java/org/apache/tamaya/collections/CollectionsTypedTests.java
deleted file mode 100644
index b4e4d52..0000000
--- a/modules/collections/src/test/java/org/apache/tamaya/collections/CollectionsTypedTests.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.collections;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.TypeLiteral;
-import org.junit.Test;
-
-import java.util.*;
-
-import static junit.framework.TestCase.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-/**
- * Basic tests for Tamaya collection support. Relevant configs for this tests:
- * <pre>base.items=1,2,3,4,5,6,7,8,9,0
- * base.map=1::a, 2::b, 3::c, [4:: ]
- * </pre>
- */
-public class CollectionsTypedTests {
-
- @Test
- public void testArrayListList_String(){
- Configuration config = ConfigurationProvider.getConfiguration();
- List<String> items = config.get("typed2.arraylist", new TypeLiteral<List<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- assertTrue(items instanceof ArrayList);
- items = (List<String>) config.get("typed2.arraylist", List.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- assertTrue(items instanceof ArrayList);
- }
-
- @Test
- public void testLinkedListList_String(){
- Configuration config = ConfigurationProvider.getConfiguration();
- List<String> items = config.get("typed2.linkedlist", new TypeLiteral<List<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- assertTrue(items instanceof LinkedList);
- items = (List<String>) config.get("typed2.linkedlist", List.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- assertTrue(items instanceof LinkedList);
- }
-
-
- @Test
- public void testHashSet_String(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Set<String> items = config.get("typed2.hashset", new TypeLiteral<Set<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- assertTrue(items instanceof HashSet);
- items = (Set<String>) config.get("typed2.hashset", Set.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- assertTrue(items instanceof HashSet);
- }
-
- @Test
- public void testTreeSet_String(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Set<String> items = config.get("typed2.treeset", new TypeLiteral<Set<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- assertTrue(items instanceof TreeSet);
- items = (Set<String>) config.get("typed2.treeset", Set.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- assertTrue(items instanceof TreeSet);
- }
-
- @Test
- public void testHashMap_String(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Map<String,String> items = config.get("typed2.hashmap", new TypeLiteral<Map<String,String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(4, items.size());
- assertEquals("a", items.get("1"));
- assertEquals("b", items.get("2"));
- assertEquals("c", items.get("3"));
- assertEquals(" ", items.get("4"));
- assertTrue(items instanceof HashMap);
- items = (Map<String,String>) config.get("typed2.hashmap", Map.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(4, items.size());
- assertEquals("a", items.get("1"));
- assertEquals("b", items.get("2"));
- assertEquals("c", items.get("3"));
- assertEquals(" ", items.get("4"));
- assertTrue(items instanceof HashMap);
- }
-
- @Test
- public void testTreeMap_String(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Map<String,String> items = config.get("typed2.treemap", new TypeLiteral<Map<String,String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(4, items.size());
- assertEquals("a", items.get("1"));
- assertEquals("b", items.get("2"));
- assertEquals("c", items.get("3"));
- assertEquals(" ", items.get("4"));
- assertTrue(items instanceof TreeMap);
- items = (Map<String,String>) config.get("typed2.treemap", Map.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(4, items.size());
- assertEquals("a", items.get("1"));
- assertEquals("b", items.get("2"));
- assertEquals("c", items.get("3"));
- assertEquals(" ", items.get("4"));
- assertTrue(items instanceof TreeMap);
- }
-
- @Test
- public void testCollection_HashSet(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Collection<String> items = config.get("typed2.hashset", new TypeLiteral<Collection<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- assertTrue(items instanceof HashSet);
- items = (Collection<String>) config.get("typed2.hashset", Collection.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- assertTrue(items instanceof HashSet);
- }
-
- @Test
- public void testCollection_TreeSet(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Collection<String> items = config.get("typed2.treeset", new TypeLiteral<Collection<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- assertTrue(items instanceof TreeSet);
- items = (Collection<String>) config.get("typed2.treeset", Collection.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- assertTrue(items instanceof TreeSet);
- }
-
- @Test
- public void testCollection_ArrayList(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Collection<String> items = config.get("typed2.arraylist", new TypeLiteral<Collection<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- assertTrue(items instanceof ArrayList);
- items = (Collection<String>) config.get("typed2.arraylist", Collection.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- assertTrue(items instanceof ArrayList);
- }
-
- @Test
- public void testCollection_LinkedList(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Collection<String> items = config.get("typed2.linkedlist", new TypeLiteral<Collection<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- assertTrue(items instanceof LinkedList);
- items = (Collection<String>) config.get("typed2.linkedlist", Collection.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- assertTrue(items instanceof LinkedList);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/collections/src/test/java/org/apache/tamaya/collections/MyUpperCaseConverter.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/test/java/org/apache/tamaya/collections/MyUpperCaseConverter.java b/modules/collections/src/test/java/org/apache/tamaya/collections/MyUpperCaseConverter.java
deleted file mode 100644
index 1c95261..0000000
--- a/modules/collections/src/test/java/org/apache/tamaya/collections/MyUpperCaseConverter.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.collections;
-
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-/**
- * Example converter that is used for testing the custom parsing functionality. It sorrounds values with () and
- * converts them to uppercase.
- */
-public class MyUpperCaseConverter implements PropertyConverter<String>{
- @Override
- public String convert(String value, ConversionContext context) {
- return "("+value.toUpperCase()+")";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/collections/src/test/resources/META-INF/javaconfiguration.properties
----------------------------------------------------------------------
diff --git a/modules/collections/src/test/resources/META-INF/javaconfiguration.properties b/modules/collections/src/test/resources/META-INF/javaconfiguration.properties
deleted file mode 100644
index e9a234c..0000000
--- a/modules/collections/src/test/resources/META-INF/javaconfiguration.properties
+++ /dev/null
@@ -1,73 +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.
-#
-# Similar to etcd all keys starting with a _ are hidden by default (only directly accessible).
-
-# Config for base tests (no combination policy)
-base.items=1,2,3,4,5,6,7,8,9,0
-base.map=1::a, 2::b, 3::c, [4:: ]
-
-# Config for tests with explcit implementation types
-typed2.arraylist=1,2,3,4,5,6,7,8,9,0
-_typed2.arraylist.collection-type=ArrayList
-_typed2.arraylist.read-only=false
-typed2.linkedlist=1,2,3,4,5,6,7,8,9,0
-_typed2.linkedlist.collection-type=java.util.LinkedList
-_typed2.linkedlist.read-only=false
-typed2.hashset=1,2,3,4,5,6,7,8,9,0
-_typed2.hashset.collection-type=HashSet
-_typed2.hashset.read-only=false
-typed2.treeset=1,2,3,4,5,6,7,8,9,0
-_typed2.treeset.collection-type=TreeSet
-_typed2.treeset.read-only=false
-typed2.hashmap=1::a, 2::b, 3::c, [4:: ]
-_typed2.hashmap.collection-type=java.util.HashMap
-_typed2.hashmap.read-only=false
-typed2.treemap=1::a, 2::b, 3::c, [4:: ]
-_typed2.treemap.collection-type=TreeMap
-_typed2.treemap.read-only=false
-
-# Config for tests with combination policy, writable
-typed.arraylist=1,2,3,4,5,6,7,8,9,0
-_typed.arraylist.collection-type=ArrayList
-typed.linkedlist=1,2,3,4,5,6,7,8,9,0
-_typed.linkedlist.collection-type=java.util.LinkedList
-typed.hashset=1,2,3,4,5,6,7,8,9,0
-_typed.hashset.collection-type=HashSet
-typed.treeset=1,2,3,4,5,6,7,8,9,0
-_typed.treeset.collection-type=TreeSet
-typed.hashmap=1::a, 2::b, 3::c, [4:: ]
-_typed.hashmap.collection-type=java.util.HashMap
-typed.treemap=1::a, 2::b, 3::c, [4:: ]
-_typed.treemap.collection-type=TreeMap
-
-# Config for advanced tests
-sep-list=a,b,c|d,e,f|g,h,i
-_sep-list.collection-type=List
-_sep-list.item-separator=|
-currency-list=CHF,USD,USS
-_currency-list.collection-type=List
-
-parser-list=a,b,c
-_parser-list.collection-type=List
-_parser-list.item-converter=org.apache.tamaya.collections.MyUpperCaseConverter
-
-redefined-map=0==none | 1==single | 2==any
-_redefined-map.map-entry-separator===
-_redefined-map.item-separator=|
-
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/pom.xml
----------------------------------------------------------------------
diff --git a/modules/events/pom.xml b/modules/events/pom.xml
deleted file mode 100644
index fb6c3b3..0000000
--- a/modules/events/pom.xml
+++ /dev/null
@@ -1,99 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-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.
--->
-<project xmlns="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">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-extensions</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
- </parent>
-
- <artifactId>tamaya-events</artifactId>
- <name>Apache Tamaya Modules - Event and dynamic Update Extensions</name>
- <packaging>bundle</packaging>
-
- <properties>
- <jdkVersion>1.7</jdkVersion>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-functions</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-spisupport</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-core</artifactId>
- <version>${project.version}</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>java-hamcrest</artifactId>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.tamaya.events,
- org.apache.tamaya.events.delta,
- org.apache.tamaya.events.folderobserver,
- org.apache.tamaya.events.spi
- </Export-Package>
- <Private-Package>
- org.apache.tamaya.events.internal
- </Private-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/main/java/org/apache/tamaya/events/ChangeType.java
----------------------------------------------------------------------
diff --git a/modules/events/src/main/java/org/apache/tamaya/events/ChangeType.java b/modules/events/src/main/java/org/apache/tamaya/events/ChangeType.java
deleted file mode 100644
index 2059017..0000000
--- a/modules/events/src/main/java/org/apache/tamaya/events/ChangeType.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.events;
-
-/**
- * Enum describing the type of configuration change.
- */
-public enum ChangeType {
- /** Configuration hase been added. */
- NEW,
- /** Configuration hase been removed. */
- DELETED,
- /** Configuration hase been changed. */
- UPDATED,
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/main/java/org/apache/tamaya/events/ConfigEvent.java
----------------------------------------------------------------------
diff --git a/modules/events/src/main/java/org/apache/tamaya/events/ConfigEvent.java b/modules/events/src/main/java/org/apache/tamaya/events/ConfigEvent.java
deleted file mode 100644
index 5a713d7..0000000
--- a/modules/events/src/main/java/org/apache/tamaya/events/ConfigEvent.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.events;
-
-
-/**
- * Event that contains a set current changes that were applied or could be applied.
- * @param <T> the resource type.
- */
-public interface ConfigEvent<T>{
-
- /**
- * Access the type of resource. This allows to easily determine the resource an event wants to observe.
- * @return the resource type.
- */
- Class<T> getResourceType();
-
- /**
- * Get the underlying property provider/configuration.
- * @return the underlying property provider/configuration, never null.
- */
- T getResource();
-
- /**
- * Get the version relative to the observed resource. The version is required to be unique for
- * each change emmitted for a resource. There is no further requirement how this uniqueness is
- * modelled, so returning a UUID is a completely valid strategy.
- * @return the base version.
- */
- String getVersion();
-
- /**
- * Get the timestamp in millis from the current epoch. it is expected that the timestamp and the version are unique to
- * identify a changeset.
- * @return the timestamp, when this changeset was created.
- */
- long getTimestamp();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/main/java/org/apache/tamaya/events/ConfigEventListener.java
----------------------------------------------------------------------
diff --git a/modules/events/src/main/java/org/apache/tamaya/events/ConfigEventListener.java b/modules/events/src/main/java/org/apache/tamaya/events/ConfigEventListener.java
deleted file mode 100644
index 7fb32c8..0000000
--- a/modules/events/src/main/java/org/apache/tamaya/events/ConfigEventListener.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.events;
-
-/**
- * Interface to be implemented for listening on changes on {@link org.apache.tamaya.Configuration} instances.
- */
-public interface ConfigEventListener {
- /**
- * Called if an event occurred.
- * @param event the event, not null.
- */
- void onConfigEvent(ConfigEvent<?> event);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/main/java/org/apache/tamaya/events/ConfigEventManager.java
----------------------------------------------------------------------
diff --git a/modules/events/src/main/java/org/apache/tamaya/events/ConfigEventManager.java b/modules/events/src/main/java/org/apache/tamaya/events/ConfigEventManager.java
deleted file mode 100644
index f6bd3da..0000000
--- a/modules/events/src/main/java/org/apache/tamaya/events/ConfigEventManager.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.events;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.events.spi.ConfigEventManagerSpi;
-import org.apache.tamaya.spi.ServiceContextManager;
-
-import java.util.Collection;
-
-/**
- * Singleton accessor for accessing the event support component that distributes change events of
- * {@link org.apache.tamaya.spi.PropertySource} and {@link org.apache.tamaya.Configuration}.
- */
-public final class ConfigEventManager {
- /**
- * The backing SPI.
- */
- private static final ConfigEventManagerSpi SPI = ServiceContextManager.getServiceContext()
- .getService(ConfigEventManagerSpi.class);
-
- /**
- * Private singleton constructor.
- */
- private ConfigEventManager() {
- }
-
- /**
- * Adds a Config listener that listens to all kind of {@link ConfigEvent}.
- * @param l the listener not null.
- */
- public static void addListener(ConfigEventListener l) {
- if (SPI == null) {
- throw new ConfigException("No SPI registered for " +
- ConfigEventManager.class.getName());
- }
- SPI.addListener(l);
- }
-
- /**
- * Adds a Config listener that listens to all kind of {@link ConfigEvent}.
- * @param <T> the type of the event.
- * @param l the listener not null.
- * @param eventType the event type to which this listener listens to.
- */
- public static <T extends ConfigEvent> void addListener(ConfigEventListener l, Class<T> eventType) {
- if (SPI == null) {
- throw new ConfigException("No SPI registered for " +
- ConfigEventManager.class.getName());
- }
- SPI.addListener(l);
- }
-
- /**
- * Removes a listener registered globally.
- *
- * @param l the listener not null.
- */
- public static void removeListener(ConfigEventListener l) {
- if (SPI == null) {
- throw new ConfigException("No SPI registered for " +
- ConfigEventManager.class.getName());
- }
- SPI.removeListener(l);
- }
-
- /**
- * Removes a listener registered for the given event type.
- *
- * @param <T> the type of the event.
- * @param l the listener, not null.
- * @param eventType the event type to which this listener listens to.
- */
- public static <T extends ConfigEvent> void removeListener(ConfigEventListener l, Class<T> eventType) {
- if (SPI == null) {
- throw new ConfigException("No SPI registered for " +
- ConfigEventManager.class.getName());
- }
- SPI.removeListener(l);
- }
-
- /**
- * Access all registered ConfigEventListeners listening to a given event type.
- * @param type the event type
- * @param <T> type param
- * @return a list with the listeners found, never null.
- */
- public static <T extends ConfigEvent>
- Collection<? extends ConfigEventListener> getListeners(Class<T> type) {
- return SPI.getListeners(type);
- }
-
- /**
- * Access all registered ConfigEventListeners listening to a all kind of event types globally.
- *
- * @param <T> the type of the event.
- * @return a list with the listeners found, never null.
- */
- public static <T extends ConfigEvent>
- Collection<? extends ConfigEventListener> getListeners() {
- return SPI.getListeners();
- }
-
- /**
- * Publishes a {@link ConfigurationChange} synchronously to all interested listeners.
- *
- * @param <T> the type of the event.
- * @param event the event, not null.
- */
- public static <T> void fireEvent(ConfigEvent<?> event) {
- SPI.fireEvent(event);
- }
-
- /**
- * Publishes a {@link ConfigurationChange} asynchronously/multithreaded to all interested listeners.
- *
- * @param <T> the type of the event.
- * @param event the event, not null.
- */
- public static <T> void fireEventAsynch(ConfigEvent<?> event) {
- SPI.fireEventAsynch(event);
- }
-
- /**
- * Start/Stop the change monitoring service, which will observe/reevaluate the current configuration regularly
- * and trigger ConfigurationChange events if something changed. This is quite handy for publishing
- * configuration changes to whatever systems are interested in. Hereby the origin of a configuration change
- * can be on this machine, or also remotely. For handling corresponding {@link ConfigEventListener} have
- * to be registered, e.g. listening on {@link org.apache.tamaya.events.ConfigurationChange} events.
- *
- * @param enable whether to enable or disable the change monitoring.
- *
- * @see #isChangeMonitoring()
- * @see #getChangeMonitoringPeriod()
- */
- public static void enableChangeMonitoring(boolean enable) {
- SPI.enableChangeMonitor(enable);
- }
-
- /**
- * Check if the observer is running currently.
- *
- * @return true, if the change monitoring service is currently running.
- * @see #enableChangeMonitoring(boolean)
- */
- public static boolean isChangeMonitoring() {
- return SPI.isChangeMonitorActive();
- }
-
- /**
- * Get the current check period to check for configuration changes.
- *
- * @return the check period in ms.
- */
- public static long getChangeMonitoringPeriod(){
- return SPI.getChangeMonitoringPeriod();
- }
-
- /**
- * Sets the current monitoring period and restarts the monitor. You still have to enable the monitor if
- * it is currently not enabled.
- * @param millis the monitoring period in ms.
- * @see #enableChangeMonitoring(boolean)
- * @see #isChangeMonitoring()
- */
- public static void setChangeMonitoringPeriod(long millis){
- SPI.setChangeMonitoringPeriod(millis);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/main/java/org/apache/tamaya/events/ConfigurationChange.java
----------------------------------------------------------------------
diff --git a/modules/events/src/main/java/org/apache/tamaya/events/ConfigurationChange.java b/modules/events/src/main/java/org/apache/tamaya/events/ConfigurationChange.java
deleted file mode 100644
index c31cda2..0000000
--- a/modules/events/src/main/java/org/apache/tamaya/events/ConfigurationChange.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.events;
-
-import org.apache.tamaya.Configuration;
-
-import java.beans.PropertyChangeEvent;
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-/**
- * Event that contains a set current changes that were applied or could be applied.
- * This class is immutable and thread-safe. To create instances use
- * {@link PropertySourceChangeBuilder}.
- *
- * Created by Anatole on 22.10.2014.
- */
-public final class ConfigurationChange implements ConfigEvent<Configuration>, Serializable{
-
- private static final long serialVersionUID = 1L;
- /** The base property provider/configuration. */
- private final FrozenConfiguration configuration;
- /** The base version, usable for optimistic locking. */
- private String version = UUID.randomUUID().toString();
- /** The timestamp of the change set in millis from the epoch. */
- private long timestamp = System.currentTimeMillis();
- /** The recorded changes. */
- private final Map<String,PropertyChangeEvent> changes = new HashMap<>();
-
- /**
- * Get an empty change set for the given provider.
- * @param configuration The configuration changed, not null.
- * @return an empty ConfigurationChangeSet instance.
- */
- public static ConfigurationChange emptyChangeSet(Configuration configuration){
- return ConfigurationChangeBuilder.of(configuration).build();
- }
-
- /**
- * Constructor used by {@link PropertySourceChangeBuilder}.
- * @param builder The builder used, not null.
- */
- ConfigurationChange(ConfigurationChangeBuilder builder) {
- this.configuration = FrozenConfiguration.of(builder.source);
- for(PropertyChangeEvent ev:builder.delta.values()){
- this.changes.put(ev.getPropertyName(), ev);
- }
- if(builder.version!=null){
- this.version = builder.version;
- }
- if(builder.timestamp!=null){
- this.timestamp = builder.timestamp;
- }
- }
-
- @Override
- public Class<Configuration> getResourceType() {
- return Configuration.class;
- }
-
- /**
- * Get the underlying property provider/configuration.
- * @return the underlying property provider/configuration, never null.
- */
- @Override
- public Configuration getResource(){
- return this.configuration;
- }
-
- /**
- * Get the base version, usable for optimistic locking.
- * @return the base version.
- */
- @Override
- public String getVersion(){
- return version;
- }
-
- /**
- * Get the timestamp in millis from the current epoch. it is expected that the timestamp and the version are unique to
- * identify a changeset.
- * @return the timestamp, when this changeset was created.
- */
- @Override
- public long getTimestamp(){
- return timestamp;
- }
-
- /**
- * Get the changes recorded.
- * @return the recorded changes, never null.
- */
- public Collection<PropertyChangeEvent> getChanges(){
- return Collections.unmodifiableCollection(this.changes.values());
- }
-
- /**
- * Access the number current removed entries.
- * @return the number current removed entries.
- */
- public int getRemovedSize() {
- int removedCount = 0;
- for(PropertyChangeEvent ev:this.changes.values()){
- if(ev.getNewValue() == null){
- removedCount++;
- }
- }
- return removedCount;
- }
-
- /**
- * Access the number current added entries.
- * @return the number current added entries.
- */
- public int getAddedSize() {
- int addedCount = 0;
- for(PropertyChangeEvent ev:this.changes.values()){
- if(ev.getOldValue() == null &&
- ev.getNewValue() != null){
- addedCount++;
- }
- }
- return addedCount;
- }
-
- /**
- * Access the number current updated entries.
- * @return the number current updated entries.
- */
- public int getUpdatedSize() {
- int updatedCount = 0;
- for(PropertyChangeEvent ev:this.changes.values()){
- if( ev.getOldValue()!=null && ev.getNewValue()!=null){
- updatedCount++;
- }
- }
- return updatedCount;
- }
-
-
- /**
- * Checks if the given key was removed.
- * @param key the target key, not null.
- * @return true, if the given key was removed.
- */
- public boolean isRemoved(String key) {
- PropertyChangeEvent change = this.changes.get(key);
- return change != null && change.getNewValue() == null;
- }
-
- /**
- * Checks if the given key was added.
- * @param key the target key, not null.
- * @return true, if the given key was added.
- */
- public boolean isAdded(String key) {
- PropertyChangeEvent change = this.changes.get(key);
- return change != null && change.getOldValue() == null;
- }
-
- /**
- * Checks if the given key was updated.
- * @param key the target key, not null.
- * @return true, if the given key was updated.
- */
- public boolean isUpdated(String key) {
- PropertyChangeEvent change = this.changes.get(key);
- return change != null && change.getOldValue() != null && change.getNewValue() != null;
- }
-
- /**
- * Checks if the given key is added, or updated AND NOT removed.
- * @param key the target key, not null.
- * @return true, if the given key was added, or updated BUT NOT removed.
- */
- public boolean isKeyAffected(String key) {
- PropertyChangeEvent change = this.changes.get(key);
- return change != null && change.getNewValue() != null;
- }
-
- /**
- * CHecks if the current change set does not contain any changes.
- * @return tru, if the change set is empty.
- */
- public boolean isEmpty(){
- return this.changes.isEmpty();
- }
-
-
- @Override
- public String toString() {
- return "ConfigurationChange{" +
- "configuration=" + configuration +
- ", version='" + version + '\'' +
- ", timestamp=" + timestamp +
- '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/main/java/org/apache/tamaya/events/ConfigurationChangeBuilder.java
----------------------------------------------------------------------
diff --git a/modules/events/src/main/java/org/apache/tamaya/events/ConfigurationChangeBuilder.java b/modules/events/src/main/java/org/apache/tamaya/events/ConfigurationChangeBuilder.java
deleted file mode 100644
index 1fd228a..0000000
--- a/modules/events/src/main/java/org/apache/tamaya/events/ConfigurationChangeBuilder.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.events;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-
-import java.beans.PropertyChangeEvent;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
-/**
- * Models a set current changes applied to a {@link org.apache.tamaya.spi.PropertySource}. Consumers of these events
- * can observing changes to property sources and
- * <ol>
- * <li>Check if their current configuration instance ({@link org.apache.tamaya.spi.ConfigurationContext}
- * contains the changed {@link org.apache.tamaya.spi.PropertySource} (Note: the reference tova property source is never affected by a
- * change, its only the data of the property source).</li>
- * <li>If so corresponding action may be taken, such as reevaluating the configuration values (depending on
- * the update policy) or reevaluating the complete {@link org.apache.tamaya.Configuration} to create a change
- * event on configuration level.
- * </ol>
- */
-public final class ConfigurationChangeBuilder {
- /**
- * The recorded changes.
- */
- final SortedMap<String, PropertyChangeEvent> delta = new TreeMap<>();
- /**
- * The underlying configuration/provider.
- */
- final Configuration source;
- /**
- * The version configured, or null, for generating a default.
- */
- String version;
- /**
- * The optional timestamp in millis of this epoch.
- */
- Long timestamp;
-
- /**
- * Constructor.
- *
- * @param configuration the underlying configuration, not null.
- */
- private ConfigurationChangeBuilder(Configuration configuration) {
- this.source = Objects.requireNonNull(configuration);
- }
-
- /**
- * Creates a new instance current this builder using the current COnfiguration as root resource.
- *
- * @return the builder for chaining.
- */
- public static ConfigurationChangeBuilder of() {
- return new ConfigurationChangeBuilder(ConfigurationProvider.getConfiguration());
- }
-
- /**
- * Creates a new instance current this builder.
- *
- * @param configuration the configuration changed, not null.
- * @return the builder for chaining.
- */
- public static ConfigurationChangeBuilder of(Configuration configuration) {
- return new ConfigurationChangeBuilder(configuration);
- }
-
- /**
- * Compares the two property config/configurations and creates a collection current all changes
- * that must be appied to render {@code map1} into {@code map2}.
- *
- * @param map1 the source map, not null.
- * @param map2 the target map, not null.
- * @return a collection current change events, never null.
- */
- public static Collection<PropertyChangeEvent> compare(Configuration map1, Configuration map2) {
- List<PropertyChangeEvent> changes = new ArrayList<>();
- for (Map.Entry<String, String> en : map1.getProperties().entrySet()) {
- String val = map2.get(en.getKey());
- if (val == null) {
- changes.add(new PropertyChangeEvent(map1, en.getKey(), null, en.getValue()));
- } else if (!val.equals(en.getValue())) {
- changes.add(new PropertyChangeEvent(map1, en.getKey(), val, en.getValue()));
- }
- }
- for (Map.Entry<String, String> en : map2.getProperties().entrySet()) {
- String val = map1.get(en.getKey());
- if (val == null) {
- changes.add(new PropertyChangeEvent(map1, en.getKey(), null, en.getValue()));
- } else if (!val.equals(en.getValue())) {
- changes.add(new PropertyChangeEvent(map1, en.getKey(), val, en.getValue()));
- }
- }
- return changes;
- }
-
- /*
- * Apply a version/UUID to the set being built.
- * @param version the version to apply, or null, to let the system generate a version for you.
- * @return the builder for chaining.
- */
- public ConfigurationChangeBuilder setVersion(String version) {
- this.version = version;
- return this;
- }
-
- /*
- * Apply given timestamp to the set being built.
- * @param version the version to apply, or null, to let the system generate a version for you.
- * @return the builder for chaining.
- */
- public ConfigurationChangeBuilder setTimestamp(long timestamp) {
- this.timestamp = timestamp;
- return this;
- }
-
- /**
- * This method records all changes to be applied to the base property provider/configuration to
- * achieve the given target state.
- *
- * @param newState the new target state, not null.
- * @return the builder for chaining.
- */
- public ConfigurationChangeBuilder addChanges(Configuration newState) {
- for (PropertyChangeEvent c : compare(newState, this.source)) {
- this.delta.put(c.getPropertyName(), c);
- }
- return this;
- }
-
- /**
- * Applies a single key/value change.
- *
- * @param key the changed key
- * @param value the new value.
- * @return this instance for chining.
- */
- public ConfigurationChangeBuilder addChange(String key, String value) {
- this.delta.put(key, new PropertyChangeEvent(this.source, key, this.source.get(key), value));
- return this;
- }
-
- /**
- * Get the current values, also considering any changes recorded within this change set.
- *
- * @param key the key current the entry, not null.
- * @return the keys, or null.
- */
- public String get(String key) {
- PropertyChangeEvent change = this.delta.get(key);
- if (change != null && !(change.getNewValue() == null)) {
- return (String) change.getNewValue();
- }
- return null;
- }
-
- /**
- * Marks the given key(s) fromMap the configuration/properties to be removed.
- *
- * @param key the key current the entry, not null.
- * @param otherKeys additional keys to be removed (convenience), not null.
- * @return the builder for chaining.
- */
- public ConfigurationChangeBuilder removeKey(String key, String... otherKeys) {
- String oldValue = this.source.get(key);
- if (oldValue == null) {
- this.delta.remove(key);
- }
- this.delta.put(key, new PropertyChangeEvent(this.source, key, oldValue, null));
- for (String addKey : otherKeys) {
- oldValue = this.source.get(addKey);
- if (oldValue == null) {
- this.delta.remove(addKey);
- }
- this.delta.put(addKey, new PropertyChangeEvent(this.source, addKey, oldValue, null));
- }
- return this;
- }
-
- /**
- * Apply all the given values to the base configuration/properties.
- * Note that all values passed must be convertible to String, either
- * <ul>
- * <li>the registered codecs provider provides codecs for the corresponding keys, or </li>
- * <li>default codecs are present for the given type, or</li>
- * <li>the value is an instanceof String</li>
- * </ul>
- *
- * @param changes the changes to be applied, not null.
- * @return the builder for chaining.
- */
- public ConfigurationChangeBuilder putAll(Map<String, String> changes) {
- for (Map.Entry<String, String> en : changes.entrySet()) {
- this.delta.put(en.getKey(), new PropertyChangeEvent(this.source, en.getKey(), null, en.getValue()));
- }
- return this;
- }
-
- /**
- * This method will create a change set that clears all entries fromMap the given base configuration/properties.
- *
- * @return the builder for chaining.
- */
- public ConfigurationChangeBuilder removeAllKeys() {
- this.delta.clear();
- for (Map.Entry<String, String> en : this.source.getProperties().entrySet()) {
- this.delta.put(en.getKey(), new PropertyChangeEvent(this.source, en.getKey(), en.getValue(), null));
- }
-// this.source.getProperties().forEach((k, v) ->
-// this.delta.put(k, new PropertyChangeEvent(this.source, k, v, null)));
- return this;
- }
-
- /**
- * Checks if the change set is empty, i.e. does not contain any changes.
- *
- * @return true, if the set is empty.
- */
- public boolean isEmpty() {
- return this.delta.isEmpty();
- }
-
- /**
- * Resets this change set instance. This will clear all changes done to this builder, so the
- * set will be empty.
- */
- public void reset() {
- this.delta.clear();
- }
-
- /**
- * Builds the corresponding change set.
- *
- * @return the new change set, never null.
- */
- public ConfigurationChange build() {
- return new ConfigurationChange(this);
- }
-
- /*
- * (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "ConfigurationChangeSetBuilder [config=" + source + ", " +
- ", delta=" + delta + "]";
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/main/java/org/apache/tamaya/events/ConfigurationContextChange.java
----------------------------------------------------------------------
diff --git a/modules/events/src/main/java/org/apache/tamaya/events/ConfigurationContextChange.java b/modules/events/src/main/java/org/apache/tamaya/events/ConfigurationContextChange.java
deleted file mode 100644
index 4e12d42..0000000
--- a/modules/events/src/main/java/org/apache/tamaya/events/ConfigurationContextChange.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.events;
-
-import org.apache.tamaya.spi.ConfigurationContext;
-import org.apache.tamaya.spi.PropertySource;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.UUID;
-
-/**
- * Event that contains a set of current changes that were applied or can be applied.
- * This class is immutable and thread-safe. To create instances use
- * {@link PropertySourceChangeBuilder}.
- *
- * Created by Anatole on 22.10.2014.
- */
-public final class ConfigurationContextChange implements ConfigEvent<ConfigurationContext>, Serializable{
-
- private static final long serialVersionUID = 1L;
- /** The base property provider/configuration. */
- private final List<PropertySourceChange> changedPropertySources = new ArrayList<>();
- /** The base version, usable for optimistic locking. */
- private String version = UUID.randomUUID().toString();
- /** The timestamp of the change set in millis from the epoch. */
- private long timestamp = System.currentTimeMillis();
- /** The configuration context. */
- private final ConfigurationContext configurationContext;
-
- /**
- * Get an empty change set for the given provider.
- *
- * @param configurationContext context to use for creating changesets.
- * @return an empty ConfigurationContextChange instance.
- */
- public static ConfigurationContextChange emptyChangeSet(ConfigurationContext configurationContext){
- return ConfigurationContextChangeBuilder.of(configurationContext).build();
- }
-
- /**
- * Constructor used by {@link PropertySourceChangeBuilder}.
- * @param builder The builder used, not null.
- */
- ConfigurationContextChange(ConfigurationContextChangeBuilder builder) {
- this.changedPropertySources.addAll(builder.changedPropertySources);
- if(builder.version!=null){
- this.version = builder.version;
- }
- if(builder.timestamp!=null){
- this.timestamp = builder.timestamp;
- }
- this.configurationContext = builder.configurationContext;
- }
-
- @Override
- public Class<ConfigurationContext> getResourceType() {
- return ConfigurationContext.class;
- }
-
- @Override
- public ConfigurationContext getResource() {
- return configurationContext;
- }
-
- /**
- * Get the base version, usable for optimistic locking.
- * @return the base version.
- */
- @Override
- public String getVersion(){
- return version;
- }
-
- /**
- * Get the timestamp in millis from the current epoch. it is expected that the timestamp and the version are unique to
- * identify a changeset.
- * @return the timestamp, when this changeset was created.
- */
- @Override
- public long getTimestamp(){
- return timestamp;
- }
-
- /**
- * Get the changes recorded.
- * @return the recorded changes, never null.
- */
- public Collection<PropertySourceChange> getPropertySourceChanges(){
- return Collections.unmodifiableCollection(this.changedPropertySources);
- }
-
- /**
- * Get the property source updates.
- * @return the recorded changes, never null.
- */
- public Collection<PropertySourceChange> getPropertySourceUpdates(){
- List<PropertySourceChange> result = new ArrayList<>();
- for (PropertySourceChange pc : this.changedPropertySources) {
- if (pc.getChangeType() == ChangeType.UPDATED) {
- result.add(pc);
- }
- }
- return result;
-// return Collections.unmodifiableCollection(this.changedPropertySources).stream()
-// .filter(pc -> pc.getChangeType()==ChangeType.UPDATED).collect(Collectors.toList());
- }
-
- /**
- * Get the property sources to be removed.
- * @return the recorded changes, never null.
- */
- public Collection<PropertySource> getRemovedPropertySources(){
- List<PropertySource> result = new ArrayList<>();
- for (PropertySourceChange pc : this.changedPropertySources) {
- if (pc.getChangeType() == ChangeType.DELETED) {
- result.add(pc.getResource());
- }
- }
- return result;
-// return getPropertySourceChanges().stream().filter(pc -> pc.getChangeType()==ChangeType.DELETED).
-// map(ps -> ps.getPropertySource()).collect(Collectors.toList());
- }
-
- /**
- * Get the property sources to be added.
- * @return the recorded changes, never null.
- */
- public Collection<PropertySource> getAddedPropertySources(){
- List<PropertySource> result = new ArrayList<>();
- for (PropertySourceChange pc : this.changedPropertySources) {
- if (pc.getChangeType() == ChangeType.NEW) {
- result.add(pc.getResource());
- }
- }
- return result;
-// return getPropertySourceChanges().stream().filter(pc -> pc.getChangeType()==ChangeType.NEW).
-// map(ps -> ps.getPropertySource()).collect(Collectors.toList());
- }
-
- /**
- * Get the property sources to be updated.
- * @return the recorded changes, never null.
- */
- public Collection<PropertySource> getUpdatedPropertySources(){
- List<PropertySource> result = new ArrayList<>();
- for (PropertySourceChange pc : this.changedPropertySources) {
- if (pc.getChangeType() == ChangeType.UPDATED) {
- result.add(pc.getResource());
- }
- }
- return result;
-// return getPropertySourceChanges().stream().filter(pc -> pc.getChangeType()==ChangeType.UPDATED).
-// map(ps -> ps.getPropertySource()).collect(Collectors.toList());
- }
-
- /**
- * Checks if the given propertySource is affected (added, changed or removed).
- * @param propertySource the propertySource, not null.
- * @return true, if the given propertySource ia affected.
- */
- public boolean isAffected(PropertySource propertySource) {
- for (PropertySourceChange ps : this.changedPropertySources) {
- if (ps.getResource() == propertySource ||
- ps.getResource().getName().equals(propertySource.getName())) {
- return true;
- }
- }
- return false;
-// return this.changedPropertySources.stream().filter(ps -> ps.getPropertySource()==propertySource ||
-// ps.getPropertySource().getName().equals(propertySource.getName())).findAny().isPresent();
- }
-
- /**
- * CHecks if the current change set does not contain any changes.
- * @return tru, if the change set is empty.
- */
- public boolean isEmpty(){
- return this.changedPropertySources.isEmpty();
- }
-
-
- @Override
- public String toString() {
- return "ConfigurationContextChange{" +
- "changedPropertySources=" + changedPropertySources +
- ", version='" + version + '\'' +
- ", timestamp=" + timestamp +
- '}';
- }
-}
[08/24] incubator-tamaya git commit: Removed all modules from the
main repository. They will be reborn in separate ASF repository.
Posted by pl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/main/java/org/apache/tamaya/model/Validation.java
----------------------------------------------------------------------
diff --git a/modules/model/src/main/java/org/apache/tamaya/model/Validation.java b/modules/model/src/main/java/org/apache/tamaya/model/Validation.java
deleted file mode 100644
index 39b72ed..0000000
--- a/modules/model/src/main/java/org/apache/tamaya/model/Validation.java
+++ /dev/null
@@ -1,203 +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.model;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.model.spi.AbstractConfigModel;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Objects;
-
-/**
- * Models a partial configuration configModel result.
- */
-public final class Validation {
- /**
- * the config section.
- */
- private final ConfigModel configModel;
- /**
- * The configModel result.
- */
- private final ValidationResult result;
- /**
- * The configModel message.
- */
- private final String message;
-
- /**
- * Creates a new ValidationResult.
- *
- * @param configModel the configModel item, not null.
- * @return a new validation result containing valid parts of the given model.
- */
- public static Validation ofValid(ConfigModel configModel) {
- return new Validation(configModel, ValidationResult.VALID, null);
- }
-
- /**
- * Creates a new ValidationResult.
- *
- * @param configModel the configModel item, not null.
- * @return a new validation result containing missing parts of the given model.
- */
- public static Validation ofMissing(ConfigModel configModel) {
- return new Validation(configModel, ValidationResult.MISSING, null);
- }
-
- /**
- * Creates a new ValidationResult.
- *
- * @param configModel the configModel item, not null.
- * @param message Additional message to be shown (optional).
- * @return a new validation result containing missing parts of the given model with a message.
- */
- public static Validation ofMissing(ConfigModel configModel, String message) {
- return new Validation(configModel, ValidationResult.MISSING, message);
- }
-
- /**
- * Creates a new ValidationResult.
- *
- * @param configModel the configModel item, not null.
- * @param error error message to add.
- * @return a new validation result containing erroneous parts of the given model with the given error message.
- */
- public static Validation ofError(ConfigModel configModel, String error) {
- return new Validation(configModel, ValidationResult.ERROR, error);
- }
-
- /**
- * Creates a new ValidationResult.
- *
- * @param configModel the configModel item, not null.
- * @param warning warning message to add.
- * @return a new validation result containing warning parts of the given model with the given warning message.
- */
- public static Validation ofWarning(ConfigModel configModel, String warning) {
- return new Validation(configModel, ValidationResult.WARNING, warning);
- }
-
- /**
- * Creates a new ValidationResult.
- *
- * @param configModel the configModel item, not null.
- * @param alternativeUsage allows setting a message to indicate non-deprecated replacement, maybe null.
- * @return a new validation result containing deprecated parts of the given model with an optional message.
- */
- public static Validation ofDeprecated(ConfigModel configModel, String alternativeUsage) {
- return new Validation(configModel, ValidationResult.DEPRECATED, alternativeUsage != null ? "Use instead: " + alternativeUsage : null);
- }
-
- /**
- * Creates a new ValidationResult.
- *
- * @param configModel the configModel item, not null.
- * @return a new validation result containing deprecated parts of the given model.
- */
- public static Validation ofDeprecated(ConfigModel configModel) {
- return new Validation(configModel, ValidationResult.DEPRECATED, null);
- }
-
- /**
- * Creates a new ValidationResult.
- *
- * @param owner owner
- * @param key the name/model key
- * @param type model type
- * @return a corresponding configModel item
- */
- public static Validation ofUndefined(final String owner, final String key, final ModelTarget type) {
- return new Validation(new AbstractConfigModel(owner, key, false, "Undefined key: " + key) {
-
- @Override
- public ModelTarget getType() {
- return type;
- }
-
- @Override
- public Collection<Validation> validate(Configuration config) {
- return Collections.emptyList();
- }
- }, ValidationResult.UNDEFINED, null);
- }
-
-
- /**
- * Constructor.
- *
- * @param configModel the configModel item, not null.
- * @param result the configModel result, not null.
- * @param message the detail message.
- * @return new validation result.
- */
- public static Validation of(ConfigModel configModel, ValidationResult result, String message) {
- return new Validation(configModel, result, message);
- }
-
-
- /**
- * Constructor.
- *
- * @param configModel the configModel item, not null.
- * @param result the configModel result, not null.
- * @param message the detail message.
- */
- private Validation(ConfigModel configModel, ValidationResult result, String message) {
- this.message = message;
- this.configModel = Objects.requireNonNull(configModel);
- this.result = Objects.requireNonNull(result);
- }
-
- /**
- * Get the configModel section.
- *
- * @return the section, never null.
- */
- public ConfigModel getConfigModel() {
- return configModel;
- }
-
- /**
- * Get the configModel result.
- *
- * @return the result, never null.
- */
- public ValidationResult getResult() {
- return result;
- }
-
- /**
- * Get the detail message.
- *
- * @return the detail message, or null.
- */
- public String getMessage() {
- return message;
- }
-
- @Override
- public String toString() {
- if (message != null) {
- return result + ": " + configModel.getName() + " (" + configModel.getType() + ") -> " + message + '\n';
- }
- return result + ": " + configModel.getName() + " (" + configModel.getType() + ")";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/main/java/org/apache/tamaya/model/ValidationResult.java
----------------------------------------------------------------------
diff --git a/modules/model/src/main/java/org/apache/tamaya/model/ValidationResult.java b/modules/model/src/main/java/org/apache/tamaya/model/ValidationResult.java
deleted file mode 100644
index d719f37..0000000
--- a/modules/model/src/main/java/org/apache/tamaya/model/ValidationResult.java
+++ /dev/null
@@ -1,59 +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.model;
-
-/**
- * Enum type describing the different validation results supported.
- */
-public enum ValidationResult {
- /**
- * The validated item is valid
- */
- VALID,
- /**
- * The validated item is deprecated.
- */
- DEPRECATED,
- /**
- * The validated item is correct, but the value is worth a warning.
- */
- WARNING,
- /**
- * The given section or parameter is not a defined/validated item. It may be still valid, but typically,
- * when validation is fully implemented, such a parameter or section should be removed.
- */
- UNDEFINED,
- /**
- * A required parameter or section is missing.
- */
- MISSING,
- /**
- * The validated item has an invalid value.
- */
- ERROR;
-
- /**
- * Method to quickly evaluate if the current state is an error state.
- *
- * @return true, if the state is not ERROR or MISSING.
- */
- boolean isError() {
- return this.ordinal() == MISSING.ordinal() || this.ordinal() == ERROR.ordinal();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/main/java/org/apache/tamaya/model/internal/ConfigDocumentationBean.java
----------------------------------------------------------------------
diff --git a/modules/model/src/main/java/org/apache/tamaya/model/internal/ConfigDocumentationBean.java b/modules/model/src/main/java/org/apache/tamaya/model/internal/ConfigDocumentationBean.java
deleted file mode 100644
index 3298025..0000000
--- a/modules/model/src/main/java/org/apache/tamaya/model/internal/ConfigDocumentationBean.java
+++ /dev/null
@@ -1,197 +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.model.internal;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.model.ConfigModel;
-import org.apache.tamaya.model.ConfigModelManager;
-import org.apache.tamaya.model.ModelTarget;
-import org.apache.tamaya.model.Validation;
-import org.apache.tamaya.model.spi.ConfigDocumentationMBean;
-
-import javax.json.Json;
-import javax.json.JsonArray;
-import javax.json.JsonArrayBuilder;
-import javax.json.JsonObject;
-import javax.json.JsonObjectBuilder;
-import javax.json.JsonWriter;
-import javax.json.JsonWriterFactory;
-import javax.json.stream.JsonGenerator;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * MBean implementation of {@link ConfigDocumentationMBean}.
- */
-public class ConfigDocumentationBean implements ConfigDocumentationMBean{
-
- private final JsonWriterFactory writerFactory;
-
- private static final Comparator<Validation> COMPARATOR = new Comparator<Validation>() {
- @Override
- public int compare(Validation v1, Validation v2) {
- int compare = VAL_COMPARATOR.compare(v1.getConfigModel(), v2.getConfigModel());
- if(compare==0){
- compare = v1.getResult().compareTo(v2.getResult());
- }
- if(compare==0){
- return v1.getMessage().compareTo(v2.getMessage());
- }
- return compare;
- }
- };
- private static final Comparator<ConfigModel> VAL_COMPARATOR = new Comparator<ConfigModel>() {
- @Override
- public int compare(ConfigModel v1, ConfigModel v2) {
- int compare = v1.getType().compareTo(v2.getType());
- if(compare==0){
- compare = v1.getName().compareTo(v2.getName());
- }
- return compare;
- }
- };
-
- private Configuration config;
-
- /**
- * Default constructor, using the current configuration being available.
- */
- public ConfigDocumentationBean(){
- this(null);
- }
-
-
- /**
- * Creates an mbean bound to the given configuration. This is useful, when multiple mbeans for each
- * context should be used, e.g. one mbean per ear, app deployment.
- * @param config the configuration to be used.
- */
- public ConfigDocumentationBean(Configuration config){
- this.config = config;
- Map<String, Object> writerProperties = new HashMap<>(1);
- writerProperties.put(JsonGenerator.PRETTY_PRINTING, true);
- writerFactory = Json.createWriterFactory(writerProperties);
- }
-
- /**
- * Access the configuration.
- * @return either the configuration bound to this bean, or the current configuration.
- */
- private Configuration getConfig(){
- return config!=null?config: ConfigurationProvider.getConfiguration();
- }
-
- @Override
- public String validate(boolean showUndefined) {
- List<Validation> validations = new ArrayList<>(ConfigModelManager.validate(getConfig(), showUndefined));
- Collections.sort(validations, COMPARATOR);
- JsonArrayBuilder builder = Json.createArrayBuilder();
- for(Validation val:validations){
- builder.add(toJsonObject(val));
- }
- return formatJson(builder.build());
- }
-
-
-
- @Override
- public String getConfigurationModel() {
- List<ConfigModel> configModels = new ArrayList<>(ConfigModelManager.getModels());
- Collections.sort(configModels, VAL_COMPARATOR);
- JsonArrayBuilder result = Json.createArrayBuilder();
- for(ConfigModel val: configModels){
- result.add(toJsonObject(val));
- }
- return formatJson(result.build());
- }
-
- @Override
- public String getConfigurationModel(ModelTarget type) {
- return findValidationModels(".*", type);
- }
-
- @Override
- public String findConfigurationModels(String namePattern) {
- List<ConfigModel> configModels = new ArrayList<>(ConfigModelManager.findModels(namePattern));
- Collections.sort(configModels, VAL_COMPARATOR);
- JsonArrayBuilder result = Json.createArrayBuilder();
- for(ConfigModel val: configModels){
- result.add(toJsonObject(val));
- }
- return formatJson(result.build());
- }
-
- @Override
- public String findValidationModels(String namePattern, ModelTarget... type) {
- List<ConfigModel> configModels = new ArrayList<>(ConfigModelManager.findModels(namePattern, type));
- Collections.sort(configModels, VAL_COMPARATOR);
- JsonArrayBuilder result = Json.createArrayBuilder();
- for(ConfigModel val: configModels){
- result.add(toJsonObject(val));
- }
- return formatJson(result.build());
- }
-
- @Override
- public String toString(){
- return "ConfigDocumentationBean, config: " + (this.config!=null?this.config.toString():"<current>");
- }
-
-
- private JsonObject toJsonObject(ConfigModel val) {
- JsonObjectBuilder valJson = Json.createObjectBuilder().add("target", val.getType().toString())
- .add("name", val.getName());
- if(val.getDescription()!=null) {
- valJson.add("description", val.getDescription());
- }
- if(val.isRequired()){
- valJson.add("required",true);
- }
- return valJson.build();
- }
-
- private JsonObject toJsonObject(Validation val) {
- JsonObjectBuilder valJson = Json.createObjectBuilder().add("target", val.getConfigModel().getType().toString())
- .add("name", val.getConfigModel().getName());
- if(val.getConfigModel().isRequired()){
- valJson.add("required",true);
- }
- if(val.getConfigModel().getDescription() != null){
- valJson.add("description", val.getConfigModel().getDescription());
- }
- valJson.add("result", val.getResult().toString());
- if( val.getMessage() != null) {
- valJson.add("message", val.getMessage());
- }
- return valJson.build();
- }
-
- private String formatJson(JsonArray data) {
- StringWriter writer = new StringWriter();
- JsonWriter gen = writerFactory.createWriter(writer);
- gen.writeArray(data);
- return writer.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/main/java/org/apache/tamaya/model/internal/ConfiguredInlineModelProviderSpi.java
----------------------------------------------------------------------
diff --git a/modules/model/src/main/java/org/apache/tamaya/model/internal/ConfiguredInlineModelProviderSpi.java b/modules/model/src/main/java/org/apache/tamaya/model/internal/ConfiguredInlineModelProviderSpi.java
deleted file mode 100644
index 2e4f379..0000000
--- a/modules/model/src/main/java/org/apache/tamaya/model/internal/ConfiguredInlineModelProviderSpi.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.model.internal;
-
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.model.ConfigModel;
-import org.apache.tamaya.model.spi.ConfigModelReader;
-import org.apache.tamaya.model.spi.ModelProviderSpi;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Logger;
-
-/**
- * ConfigModel provider that reads model metadata from the current {@link org.apache.tamaya.Configuration}.
- */
-public class ConfiguredInlineModelProviderSpi implements ModelProviderSpi {
-
- /** The logger. */
- private static final Logger LOG = Logger.getLogger(ConfiguredInlineModelProviderSpi.class.getName());
- /** parameter to disable this provider. By default the provider is active. */
- private static final String MODEL_EANABLED_PARAM = "org.apache.tamaya.model.integrated.enabled";
-
- /** The configModels read. */
- private List<ConfigModel> configModels = new ArrayList<>();
-
-
- /**
- * Constructor, typically called by the {@link java.util.ServiceLoader}.
- */
- public ConfiguredInlineModelProviderSpi() {
- String enabledVal = ConfigurationProvider.getConfiguration().get(MODEL_EANABLED_PARAM);
- boolean enabled = enabledVal == null || "true".equalsIgnoreCase(enabledVal);
- if (enabled) {
- LOG.info("Reading model configuration from config...");
- Map<String,String> config = ConfigurationProvider.getConfiguration().getProperties();
- String owner = config.get("_model.provider");
- if(owner==null){
- owner = config.toString();
- }
- configModels.addAll(ConfigModelReader.loadValidations(owner, config));
- }
- configModels = Collections.unmodifiableList(configModels);
- }
-
-
- public Collection<ConfigModel> getConfigModels() {
- return configModels;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/main/java/org/apache/tamaya/model/internal/ConfiguredPropertiesModelProviderSpi.java
----------------------------------------------------------------------
diff --git a/modules/model/src/main/java/org/apache/tamaya/model/internal/ConfiguredPropertiesModelProviderSpi.java b/modules/model/src/main/java/org/apache/tamaya/model/internal/ConfiguredPropertiesModelProviderSpi.java
deleted file mode 100644
index 57af99c..0000000
--- a/modules/model/src/main/java/org/apache/tamaya/model/internal/ConfiguredPropertiesModelProviderSpi.java
+++ /dev/null
@@ -1,154 +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.model.internal;
-
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.model.ConfigModel;
-import org.apache.tamaya.model.spi.ConfigModelReader;
-import org.apache.tamaya.model.spi.ModelProviderSpi;
-import org.apache.tamaya.spisupport.MapPropertySource;
-
-import java.io.InputStream;
-import java.net.URL;
-import java.util.*;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * ConfigModel provider that reads model metadata from property files from
- * {@code classpath*:META-INF/configmodel.properties} in the following format:
- * <pre>
- * ###################################################################################
- * # Example of a configuration metamodel expressed via properties.
- * ####################################################################################
- *
- * # Metamodel information
- * [model].provider=ConfigModel Extension
- *
- * ####################################################################################
- * # Description of Configuration Sections (minimal, can be extended by other modules).
- * # By default its interpreted as a section !
- * ####################################################################################
- *
- * # a (section)
- * {model}a.class=Section
- * {model}a.params2.class=Parameter
- * {model}a.params2.type=String
- * {model}a.params2.required=true
- * {model}a.params2.description=a required parameter
- *
- * {model}a.paramInt.class=Parameter
- * {model}a.paramInt.ref=MyNumber
- * {model}a.paramInt.description=an optional parameter (default)
- *
- * {model}a._number.class=Parameter
- * {model}a._number.type=Integer
- * {model}a._number.deprecated=true
- * {model}a._number.mappedTo=a.paramInt
- *
- * # a.b.c (section)
- * {model}a.b.c.class=Section
- * {model}a.b.c.description=Just a test section
- *
- * # a.b.c.aRequiredSection (section)
- * {model}a.b.c.aRequiredSection.class=Section
- * {model}a.b.c.aRequiredSection.required=true
- * {model}a.b.c.aRequiredSection.description=A section containing required parameters is called a required section.\
- * Sections can also explicitly be defined to be required, but without\
- * specifying the paramteres to be contained.,
- *
- * # a.b.c.aRequiredSection.subsection (section)
- * {model}a.b.c.aRequiredSection.subsection.class=Section
- *
- * {model}a.b.c.aRequiredSection.subsection.param0.class=Parameter
- * {model}a.b.c.aRequiredSection.subsection.param0.type=String
- * {model}a.b.c.aRequiredSection.subsection.param0.description=a minmally documented String parameter
- * # A minmal String parameter
- * {model}a.b.c.aRequiredSection.subsection.param00.class=Parameter
- * {model}a.b.c.aRequiredSection.subsection.param00.type=String
- *
- * # a.b.c.aRequiredSection.subsection (section)
- * {model}a.b.c.aRequiredSection.subsection.param1.class=Parameter
- * {model}a.b.c.aRequiredSection.subsection.param1.type = String
- * {model}a.b.c.aRequiredSection.subsection.param1.required = true
- * {model}a.b.c.aRequiredSection.subsection.intParam.class=Parameter
- * {model}a.b.c.aRequiredSection.subsection.intParam.type = Integer
- * {model}a.b.c.aRequiredSection.subsection.intParam.description=an optional parameter (default)
- *
- * # a.b.c.aRequiredSection.nonempty-subsection (section)
- * {model}a.b.c.aRequiredSection.nonempty-subsection.class=Section
- * {model}a.b.c.aRequiredSection.nonempty-subsection.required=true
- *
- * # a.b.c.aRequiredSection.optional-subsection (section)
- * {model}a.b.c.aRequiredSection.optional-subsection.class=Section
- *
- * # a.b.c.aValidatedSection (section)
- * {model}a.b.c.aValidatedSection.class=Section
- * {model}a.b.c.aValidatedSection.description=A validated section.
- * {model}a.b.c.aValidatedSection.configModels=org.apache.tamaya.model.TestValidator
- * </pre>
- */
-public class ConfiguredPropertiesModelProviderSpi implements ModelProviderSpi {
-
- /** The logger. */
- private static final Logger LOG = Logger.getLogger(ConfiguredPropertiesModelProviderSpi.class.getName());
- /** parameter to disable this provider. By default the provider is active. */
- private static final String MODEL_EANABLED_PARAM = "org.apache.tamaya.model.default.enabled";
- /** The configModels read. */
- private List<ConfigModel> configModels = new ArrayList<>();
-
- public ConfiguredPropertiesModelProviderSpi() {
- String enabledVal = ConfigurationProvider.getConfiguration().get(MODEL_EANABLED_PARAM);
- boolean enabled = enabledVal == null || "true".equalsIgnoreCase(enabledVal);
- if(!enabled){
- LOG.info("Reading model data from META-INF/configmodel.properties has been disabled.");
- return;
- }
- try {
- LOG.info("Reading model data from META-INF/configmodel.properties...");
- Enumeration<URL> configs = getClass().getClassLoader().getResources("META-INF/configmodel.properties");
- while (configs.hasMoreElements()) {
- URL config = configs.nextElement();
- try (InputStream is = config.openStream()) {
- Properties props = new Properties();
- props.load(is);
- Map<String,String> data = MapPropertySource.getMap(props);
- String owner = data.get("_model.owner");
- if(owner==null){
- owner = config.toString();
- }
- configModels.addAll(ConfigModelReader.loadValidations(owner,
- data));
- } catch (Exception e) {
- Logger.getLogger(getClass().getName()).log(Level.SEVERE,
- "Error loading config metadata from " + config, e);
- }
- }
- } catch (Exception e) {
- LOG.log(Level.SEVERE,
- "Error loading config metadata from META-INF/configmodel.properties", e);
- }
- configModels = Collections.unmodifiableList(configModels);
- }
-
-
- public Collection<ConfigModel> getConfigModels() {
- return configModels;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/main/java/org/apache/tamaya/model/internal/ConfiguredResourcesModelProviderSpi.java
----------------------------------------------------------------------
diff --git a/modules/model/src/main/java/org/apache/tamaya/model/internal/ConfiguredResourcesModelProviderSpi.java b/modules/model/src/main/java/org/apache/tamaya/model/internal/ConfiguredResourcesModelProviderSpi.java
deleted file mode 100644
index 85f2ac7..0000000
--- a/modules/model/src/main/java/org/apache/tamaya/model/internal/ConfiguredResourcesModelProviderSpi.java
+++ /dev/null
@@ -1,160 +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.model.internal;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.*;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.format.ConfigurationData;
-import org.apache.tamaya.format.ConfigurationFormats;
-import org.apache.tamaya.model.ConfigModel;
-import org.apache.tamaya.model.spi.ConfigModelReader;
-import org.apache.tamaya.model.spi.ModelProviderSpi;
-import org.apache.tamaya.resource.ConfigResources;
-
-/**
- * ConfigModel provider that reads model metadata from property files from
- * {@code classpath*:META-INF/configmodel.json} in the following format:
- * <pre>
- * Example of a configuration metamodel expressed via YAML.
- * Structure is shown through indentation (one or more spaces).
- * Sequence items are denoted by a dash,
- * key value pairs within a map are separated by a colon.
- * </pre>
- */
-public class ConfiguredResourcesModelProviderSpi implements ModelProviderSpi {
-
- /**
- * The logger.
- */
- private static final Logger LOG = Logger.getLogger(ConfiguredResourcesModelProviderSpi.class.getName());
- /**
- * The parameter that can be used to configure the location of the configuration model resources.
- */
- private static final String MODEL_RESOURCE_PARAM = "org.apache.tamaya.model.resources";
- /**
- * The resource class to checked for testing the availability of the resources extension module.
- */
- private static final String CONFIG_RESOURCE_CLASS = "org.apache.tamaya.resource.ConfigResource";
- /**
- * The resource class to checked for testing the availability of the formats extension module.
- */
- private static final String CONFIGURATION_FORMATS_CLASS = "org.apache.tamaya.format.ConfigurationFormats";
- /**
- * Initializes the flag showing if the formats module is present (required).
- */
- private static final boolean AVAILABLE = checkAvailabilityFormats();
- /**
- * Initializes the flag showing if the resources module is present (optional).
- */
- private static final boolean RESOURCES_EXTENSION_AVAILABLE = checkAvailabilityResources();
-
- /**
- * The configModels read.
- */
- private List<ConfigModel> configModels = new ArrayList<>();
-
- /**
- * Initializes the flag showing if the formats module is present (required).
- */
- private static boolean checkAvailabilityFormats() {
- try {
- Class.forName(CONFIGURATION_FORMATS_CLASS);
- return true;
- } catch (final Exception e) {
- return false;
- }
- }
-
- /**
- * Initializes the flag showing if the resources module is present (optional).
- */
- private static boolean checkAvailabilityResources() {
- try {
- Class.forName(CONFIG_RESOURCE_CLASS);
- return true;
- } catch (final Exception e) {
- return false;
- }
- }
-
- /**
- * Constructor, mostly called from {@link java.util.ServiceLoader}
- */
- public ConfiguredResourcesModelProviderSpi() {
- if (!AVAILABLE) {
- LOG.info("tamaya-format extension is required to read model configuration, No extended model support AVAILABLE.");
- } else {
- final String resources = ConfigurationProvider.getConfiguration().get(MODEL_RESOURCE_PARAM);
- if (resources == null || resources.trim().isEmpty()) {
- LOG.info("Mo model resources location configured in " + MODEL_RESOURCE_PARAM + ".");
- return;
- }
- Collection<URL> urls;
- if (RESOURCES_EXTENSION_AVAILABLE) {
- LOG.info("Using tamaya-resources extension to read model configuration from " + resources);
- urls = ConfigResources.getResourceResolver().getResources(resources.split(","));
- } else {
- LOG.info("Using default classloader resource location to read model configuration from " + resources);
- urls = new ArrayList<>();
- for (final String resource : resources.split(",")) {
- if (!resource.trim().isEmpty()) {
- Enumeration<URL> configs;
- try {
- configs = getClass().getClassLoader().getResources(resource);
- while (configs.hasMoreElements()) {
- urls.add(configs.nextElement());
- }
- } catch (final IOException e) {
- Logger.getLogger(getClass().getName()).log(Level.SEVERE,
- "Error evaluating config model locations from " + resource, e);
- }
- }
- }
- }
- // Reading configs
- for (final URL config : urls) {
- try (InputStream is = config.openStream()) {
- final ConfigurationData data = ConfigurationFormats.readConfigurationData(config);
- Map<String,String> props = data.getCombinedProperties();
- String owner = props.get("_model.provider");
- if(owner==null){
- owner = config.toString();
- }
- configModels.addAll(ConfigModelReader.loadValidations(owner, props));
- } catch (final Exception e) {
- Logger.getLogger(getClass().getName()).log(Level.SEVERE,
- "Error loading config model data from " + config, e);
- }
- }
- }
- configModels = Collections.unmodifiableList(configModels);
- }
-
-
- @Override
- public Collection<ConfigModel> getConfigModels() {
- return configModels;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/main/java/org/apache/tamaya/model/internal/ConfiguredTypeEventsModelPopulator.java
----------------------------------------------------------------------
diff --git a/modules/model/src/main/java/org/apache/tamaya/model/internal/ConfiguredTypeEventsModelPopulator.java b/modules/model/src/main/java/org/apache/tamaya/model/internal/ConfiguredTypeEventsModelPopulator.java
deleted file mode 100644
index f6169ad..0000000
--- a/modules/model/src/main/java/org/apache/tamaya/model/internal/ConfiguredTypeEventsModelPopulator.java
+++ /dev/null
@@ -1,90 +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.model.internal;
-
-import org.apache.tamaya.events.ConfigEvent;
-import org.apache.tamaya.events.ConfigEventListener;
-import org.apache.tamaya.inject.spi.ConfiguredField;
-import org.apache.tamaya.inject.spi.ConfiguredMethod;
-import org.apache.tamaya.inject.spi.ConfiguredType;
-import org.apache.tamaya.model.ConfigModelManager;
-import org.apache.tamaya.model.spi.ParameterModel;
-
-import java.util.Collection;
-import java.util.logging.Logger;
-
-/**
- * Internal facade that registers all kind of injected fields as {@link org.apache.tamaya.model.ConfigModel} entries,
- * so all configured injection points are visible as documented configuration hooks.
- */
-public final class ConfiguredTypeEventsModelPopulator implements ConfigEventListener {
-
- /**
- * The logger.
- */
- private static final Logger LOG = Logger.getLogger(ConfiguredTypeEventsModelPopulator.class.getName());
-
- /** System property to be set to deactivate auto documentation of configured classes published thorugh
- * ConfiguredType events.
- */
- private static final String ENABLE_EVENT_DOC = "org.apache.tamaya.model.autoModelEvents";
-
- @Override
- public void onConfigEvent(ConfigEvent event) {
- if(event.getResourceType()!=ConfiguredType.class){
- return;
- }
- String value = System.getProperty(ENABLE_EVENT_DOC);
- if(value == null || Boolean.parseBoolean(value)) {
- ConfiguredType confType = (ConfiguredType)event.getResource();
- for (ConfiguredField field : confType.getConfiguredFields()) {
- Collection<String> keys = field.getConfiguredKeys();
- for (String key : keys) {
- ParameterModel val = ConfigModelManager.getModel(key, ParameterModel.class);
- if (val == null) {
- ConfiguredTypeEventsModelProvider.addConfigModel(
- new ParameterModel.Builder(confType.getName(), key)
- .setType(field.getType().getName())
- .setDescription("Injected field: " +
- field.getAnnotatedField().getDeclaringClass().getName() + '.' + field.toString() +
- ", \nconfigured with keys: " + keys)
- .build());
- }
- }
- }
- for (ConfiguredMethod method : confType.getConfiguredMethods()) {
- Collection<String> keys = method.getConfiguredKeys();
- for (String key : keys) {
- ParameterModel val = ConfigModelManager.getModel(key, ParameterModel.class);
- if (val == null) {
- ConfiguredTypeEventsModelProvider.addConfigModel(
- new ParameterModel.Builder(confType.getName(), key)
- .setType(method.getParameterTypes()[0].getName())
- .setDescription("Injected field: " +
- method.getAnnotatedMethod().getDeclaringClass().getName() + '.' + method.toString() +
- ", \nconfigured with keys: " + keys)
- .build());
- }
- }
- }
- }
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/main/java/org/apache/tamaya/model/internal/ConfiguredTypeEventsModelProvider.java
----------------------------------------------------------------------
diff --git a/modules/model/src/main/java/org/apache/tamaya/model/internal/ConfiguredTypeEventsModelProvider.java b/modules/model/src/main/java/org/apache/tamaya/model/internal/ConfiguredTypeEventsModelProvider.java
deleted file mode 100644
index f54f77a..0000000
--- a/modules/model/src/main/java/org/apache/tamaya/model/internal/ConfiguredTypeEventsModelProvider.java
+++ /dev/null
@@ -1,51 +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.model.internal;
-
-import org.apache.tamaya.model.ConfigModel;
-import org.apache.tamaya.model.spi.ModelProviderSpi;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * Model provider that adds model definitions for the items published as
- * {@link org.apache.tamaya.inject.spi.ConfiguredType} events.
- */
-public class ConfiguredTypeEventsModelProvider implements ModelProviderSpi {
- /** The collected models. */
- private static Collection<ConfigModel> configModels = new ArrayList<>();
-
- /**
- * Adds a model, called from the registered listener class.
- * @param configModel adds the config model.
- */
- static void addConfigModel(ConfigModel configModel){
- List<ConfigModel> newList = new ArrayList<>(configModels);
- newList.add(configModel);
- ConfiguredTypeEventsModelProvider.configModels = newList;
- }
-
- @Override
- public Collection<ConfigModel> getConfigModels() {
- return Collections.unmodifiableCollection(configModels);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/main/java/org/apache/tamaya/model/internal/DefaultConfigUsageStats.java
----------------------------------------------------------------------
diff --git a/modules/model/src/main/java/org/apache/tamaya/model/internal/DefaultConfigUsageStats.java b/modules/model/src/main/java/org/apache/tamaya/model/internal/DefaultConfigUsageStats.java
deleted file mode 100644
index 8910eaf..0000000
--- a/modules/model/src/main/java/org/apache/tamaya/model/internal/DefaultConfigUsageStats.java
+++ /dev/null
@@ -1,176 +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.model.internal;
-
-import org.apache.tamaya.model.Usage;
-import org.apache.tamaya.model.spi.ConfigUsageStatsSpi;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * Created by atsticks on 29.04.16.
- */
-public class DefaultConfigUsageStats implements ConfigUsageStatsSpi {
-
- private Set<String> ignoredPackages = new HashSet<>();
-
- private Map<String, Usage> usages = new ConcurrentHashMap<>();
-
- /** By default usage tracking is not enabled. */
- private boolean usageTrackingEnabled = initEnabled();
-
- /**
- * Method that checks the 'tamaya.usage-report' system property for
- * enabling tamaya usage reporting initially.
- * @return {@code true} iff property is set to {@code true}
- */
- private boolean initEnabled() {
- String val = System.getProperty("tamaya.usage-report");
- if(Boolean.parseBoolean(val)){
- return true;
- }
- return false;
- }
-
- public DefaultConfigUsageStats(){
- ignoredPackages.add("com.intellij");
- ignoredPackages.add("java");
- ignoredPackages.add("org.junit");
- ignoredPackages.add("junit");
- ignoredPackages.add("javax");
- ignoredPackages.add("sun");
- ignoredPackages.add("oracle");
- ignoredPackages.add("com.sun");
- ignoredPackages.add("com.oracle");
- ignoredPackages.add("org.apache.tamaya");
- }
-
- @Override
- public void enableUsageTracking(boolean enabled){
- this.usageTrackingEnabled = enabled;
- }
-
- @Override
- public boolean isUsageTrackingEnabled(){
- return usageTrackingEnabled;
- }
-
- @Override
- public Set<String> getIgnoredPackages() {
- return Collections.unmodifiableSet(ignoredPackages);
- }
-
- @Override
- public void addIgnoredUsagePackages(String... packageName) {
-
- }
-
- @Override
- public Usage getUsage(String key) {
- return this.usages.get(key);
- }
-
- @Override
- public Usage getUsageAllProperties() {
- return this.usages.get("<<all>>");
- }
-
- /**
- * Get the recorded usage references of configuration.
- * @return the recorded usge references, never null.
- */
- @Override
- public Collection<Usage> getUsages() {
- return usages.values();
- }
-
- @Override
- public void trackAllPropertiesAccess(){
- trackSingleKeyAccess("<<all>>", "<not stored>");
- }
-
- @Override
- public void trackSingleKeyAccess(String key, String value){
- // Ignore meta-entries
- if(!isUsageTrackingEnabled() || key.startsWith("_")){
- return;
- }
- Usage usage = this.usages.get(key);
- if(usage==null){
- usage = new Usage(key);
- this.usages.put(key, usage);
- }
- usage.trackUsage(value);
- }
-
-
- /**
- * Access the usage statistics for the recorded uses of configuration.
- */
- @Override
- public String getUsageInfo(){
- StringBuilder b = new StringBuilder();
- b.append("Apache Tamaya Configuration Usage Metrics\n");
- b.append("=========================================\n");
- b.append("DATE: ").append(new Date()).append("\n\n");
- List<Usage> usages = new ArrayList<>(getUsages());
- Collections.sort(usages, new Comparator<Usage>() {
- @Override
- public int compare(Usage k1, Usage k2) {
- return k2.getUsageCount() - k1.getUsageCount();
- }
- });
- for(Usage usage:usages){
- String usageCount = String.valueOf(usage.getUsageCount());
- b.append(usageCount);
- b.append(" ".substring(0, 7-usageCount.length()));
- b.append(usage.getKey()).append(":\n");
- for(Usage.AccessDetail details: usage.getAccessDetails()) {
- String accessCount = String.valueOf(details.getAccessCount());
- b.append(" - ").append(accessCount);
- b.append(" ".substring(0, 6-usageCount.length()));
- b.append(details.getAccessPoint());
- int endIndex = 50-details.getAccessPoint().length();
- if(endIndex<0){
- endIndex = 0;
- }
- b.append(" ".substring(0, endIndex));
- b.append(",");b.append(" first=").append(new Date(details.getFirstAccessTS()))
- .append(",");b.append(" last=").append(new Date(details.getLastAccessTS()))
- .append('\n');
- }
- }
- return b.toString();
- }
-
- @Override
- public void clearUsageStats() {
- this.usages.clear();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/main/java/org/apache/tamaya/model/internal/UsageTrackerFilter.java
----------------------------------------------------------------------
diff --git a/modules/model/src/main/java/org/apache/tamaya/model/internal/UsageTrackerFilter.java b/modules/model/src/main/java/org/apache/tamaya/model/internal/UsageTrackerFilter.java
deleted file mode 100644
index d27491e..0000000
--- a/modules/model/src/main/java/org/apache/tamaya/model/internal/UsageTrackerFilter.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.model.internal;
-
-import org.apache.tamaya.model.spi.ConfigUsageStatsSpi;
-import org.apache.tamaya.spi.FilterContext;
-import org.apache.tamaya.spi.PropertyFilter;
-import org.apache.tamaya.spi.ServiceContextManager;
-
-import javax.annotation.Priority;
-
-/**
- * Configuration filter to be applied at the end of the filter chain. This filter
- * actually does not change the current filter value, but use the filter process
- * to track configuration usage.
- */
-@Priority(Integer.MAX_VALUE)
-public class UsageTrackerFilter implements PropertyFilter{
-
- @Override
- public String filterProperty(String value, FilterContext context) {
- ConfigUsageStatsSpi tracker = ServiceContextManager.getServiceContext().getService(ConfigUsageStatsSpi.class);
- if (context.isSinglePropertyScoped()) {
- tracker.trackSingleKeyAccess(context.getKey(), value);
- } else {
- tracker.trackAllPropertiesAccess();
- }
- return value;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/main/java/org/apache/tamaya/model/spi/AbstractConfigModel.java
----------------------------------------------------------------------
diff --git a/modules/model/src/main/java/org/apache/tamaya/model/spi/AbstractConfigModel.java b/modules/model/src/main/java/org/apache/tamaya/model/spi/AbstractConfigModel.java
deleted file mode 100644
index 9cc746a..0000000
--- a/modules/model/src/main/java/org/apache/tamaya/model/spi/AbstractConfigModel.java
+++ /dev/null
@@ -1,88 +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.model.spi;
-
-import org.apache.tamaya.model.ConfigModel;
-
-import java.util.Objects;
-
-/**
- * Default configuration Model for a configuration area.
- */
-public abstract class AbstractConfigModel implements ConfigModel, Comparable<ConfigModel> {
- private final String owner;
- private final String name;
- private final String description;
- private boolean required = false;
-
-
- protected AbstractConfigModel(String owner, String name, boolean required, String description) {
- this.name = Objects.requireNonNull(name);
- this.owner = Objects.requireNonNull(owner);
- this.description = description;
- this.required = required;
- }
-
- @Override
- public String getOwner() {
- return owner;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public String getDescription() {
- return description;
- }
-
- @Override
- public boolean isRequired() {
- return required;
- }
-
- @Override
- public int compareTo(ConfigModel configModel) {
- int compare = getType().compareTo(configModel.getType());
- if (compare != 0) {
- return compare;
- }
- return getName().compareTo(configModel.getName());
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- AbstractConfigModel that = (AbstractConfigModel) o;
- return getType().equals(that.getType()) && name.equals(that.name);
-
- }
-
- @Override
- public int hashCode() {
- return getType().hashCode() + name.hashCode();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/main/java/org/apache/tamaya/model/spi/ConfigDocumentationMBean.java
----------------------------------------------------------------------
diff --git a/modules/model/src/main/java/org/apache/tamaya/model/spi/ConfigDocumentationMBean.java b/modules/model/src/main/java/org/apache/tamaya/model/spi/ConfigDocumentationMBean.java
deleted file mode 100644
index f5636dc..0000000
--- a/modules/model/src/main/java/org/apache/tamaya/model/spi/ConfigDocumentationMBean.java
+++ /dev/null
@@ -1,53 +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.model.spi;
-
-import org.apache.tamaya.model.ModelTarget;
-
-/**
- * JMX Management bean for accessing current configuration information
- */
-public interface ConfigDocumentationMBean {
- /**
- * Validates the configuration for the given context.
- *
- * @param showUndefined allows filtering for undefined configuration elements.
- * @return the validation results, never null.
- */
- String validate(boolean showUndefined);
-
- String getConfigurationModel();
-
- String getConfigurationModel(ModelTarget type);
-
- /**
- * Find the validations by checking the validation's name using the given regular expression.
- * @param namePattern the regular expression to use, not null.
- * @return the sections defined, never null.
- */
- String findConfigurationModels(String namePattern);
-
- /**
- * Find the validations by checking the validation's name using the given regular expression.
- * @param type the target ModelTypes (optional), not null.
- * @param namePattern the regular expression to use, not null.
- * @return the sections defined, never null.
- */
- String findValidationModels(String namePattern, ModelTarget... type);
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/main/java/org/apache/tamaya/model/spi/ConfigModelReader.java
----------------------------------------------------------------------
diff --git a/modules/model/src/main/java/org/apache/tamaya/model/spi/ConfigModelReader.java b/modules/model/src/main/java/org/apache/tamaya/model/spi/ConfigModelReader.java
deleted file mode 100644
index 72eb7d4..0000000
--- a/modules/model/src/main/java/org/apache/tamaya/model/spi/ConfigModelReader.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.model.spi;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.tamaya.model.ConfigModel;
-
-/**
- * Utility class to read metamodel information from properties. Hereby these properties can be part of a
- * configuration (containing other entriees as well) or be dedicated model definition properties read
- * from any kind of source.
- */
-public final class ConfigModelReader {
-
- /** The default model entries selector. */
- private static final String DEFAULT_META_INFO_SELECTOR = ".model";
- /** parameter to change the selector to be used for filtering out the target values to be used. */
- private static final String META_INFO_SELECTOR_PARAM = "org.apache.tamaya.model.integrated.selector";
-
- /**
- * Utility class only.
- */
- private ConfigModelReader(){}
-
-
- /**
- * Loads validations as configured in the given properties.
- * @param owner owner, not null.
- * @param props the properties to be read
- * @return a collection of config validations.
- */
- public static Collection<ConfigModel> loadValidations(String owner, Map<String,String> props) {
- List<ConfigModel> result = new ArrayList<>();
- Set<String> itemKeys = new HashSet<>();
- for (Object key : props.keySet()) {
- if (key.toString().startsWith("_") &&
- key.toString().endsWith(DEFAULT_META_INFO_SELECTOR + ".target")) {
- itemKeys.add(key.toString().substring(0, key.toString().length() - ".model.target".length()));
- }
- }
- for (String baseKey : itemKeys) {
- String target = props.get(baseKey + ".model.target");
- String type = props.get(baseKey + ".model.type");
- if (type == null) {
- type = String.class.getName();
- }
- String value = props.get(baseKey + ".model.transitive");
- boolean transitive = false;
- if(value!=null) {
- transitive = Boolean.parseBoolean(value);
- }
- String description = props.get(baseKey + ".model.description");
- String regEx = props.get(baseKey + ".model.expression");
- String validations = props.get(baseKey + ".model.validations");
- String requiredVal = props.get(baseKey + ".model.required");
- String targetKey = baseKey.substring(1);
- if ("Parameter".equalsIgnoreCase(target)) {
- result.add(createParameterValidation(owner, targetKey,
- description, type, requiredVal, regEx, validations));
- } else if ("Section".equalsIgnoreCase(target)) {
- if(transitive){
- result.add(createSectionValidation(owner, targetKey+".*",
- description, requiredVal, validations));
- } else {
- result.add(createSectionValidation(owner, targetKey,
- description, requiredVal, validations));
- }
- }
- }
- return result;
- }
-
- /**
- * Creates a parameter validation.
- * @param paramName the param name, not null.
- * @param description the optional description
- * @param type the param type, default is String.
- * @param reqVal the required value, default is 'false'.
- * @param regEx an optional regular expression to be checked for this param
- * @param validations the optional custom validations to be performed.
- * @return the new validation for this parameter.
- */
- private static ConfigModel createParameterValidation(String owner, String paramName, String description, String type, String reqVal,
- String regEx, String validations) {
- boolean required = "true".equalsIgnoreCase(reqVal);
- ParameterModel.Builder builder = ParameterModel.builder(owner, paramName).setRequired(required)
- .setDescription(description).setExpression(regEx).setType(type);
-// if (validations != null) {
-// try {
-// // TODO define validator API
-//// builder.addValidations(loadValidations(validations));
-// } catch (Exception e) {
-// LOGGER.log(Level.WARNING, "Failed to load validations for " + paramName, e);
-// }
-// }
- return builder.build();
- }
-
- /**
- * Creates a section validation.
- * @param sectionName the section's name, not null.
- * @param description the optional description
- * @param reqVal the required value, default is 'false'.
- * @param validations the optional custom validations to be performed.
- * @return the new validation for this section.
- */
- private static ConfigModel createSectionValidation(String owner, String sectionName, String description, String reqVal,
- String validations) {
- boolean required = "true".equalsIgnoreCase(reqVal);
- SectionModel.Builder builder = SectionModel.builder(owner, sectionName).setRequired(required)
- .setDescription(description);
-// if (validations != null) {
-// try {
-// // TODO define validator API
-//// builder.addValidations(loadValidations(valiadtions));
-// } catch (Exception e) {
-// LOGGER.log(Level.WARNING, "Failed to load validations for " + sectionName, e);
-// }
-// }
- return builder.build();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/main/java/org/apache/tamaya/model/spi/ConfigUsageStatsSpi.java
----------------------------------------------------------------------
diff --git a/modules/model/src/main/java/org/apache/tamaya/model/spi/ConfigUsageStatsSpi.java b/modules/model/src/main/java/org/apache/tamaya/model/spi/ConfigUsageStatsSpi.java
deleted file mode 100644
index 5617b73..0000000
--- a/modules/model/src/main/java/org/apache/tamaya/model/spi/ConfigUsageStatsSpi.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.model.spi;
-
-import org.apache.tamaya.model.Usage;
-
-import java.util.Collection;
-import java.util.Set;
-
-/**
- * SPI to be implemented by the component responsible for usage tracking of
- * configuration.
- */
-public interface ConfigUsageStatsSpi {
-
- /**
- * Enables/disables usage tracking.
- * @param enable set to true to enable usage tracking.
- */
- void enableUsageTracking(boolean enable);
-
- /**
- * Allows to check if usage tracking is enabled (should be disbled by default).
- * @return true, if usage tracking is enabled.
- */
- boolean isUsageTrackingEnabled();
-
- /**
- * Get the list of packages, which are not evaluated for tracking configuration access and usage statistics.
- * @return the set of ignored package names.
- */
- Set<String> getIgnoredPackages();
-
- /**
- * Adds the given packageNames to the list of packages to be ignored when collecting usage data.
- * @param packageName the package names to be added, not null.
- */
- void addIgnoredUsagePackages(String... packageName);
-
- /**
- * Access the usage statistics for a given key. If usage stats collection is not
- * activated (default), this method returns null.
- * @param key the fully qualified configuration key, not null.
- * @return the stats collected, or null.
- */
- Usage getUsage(String key);
-
- /**
- * Access the usage statistics for accessing {@link org.apache.tamaya.Configuration#getProperties()}.
- * If usage stats collection is not activated (default), this method returns null.
- * @return the stats collected, or null.
- */
- Usage getUsageAllProperties();
-
- /**
- * Get the recorded usage references of configuration.
- * @return the recorded usge references, never null.
- */
- Collection<Usage> getUsages();
-
- /**
- * Track the access of {@code Configuration#getProperties()} for
- * usage statistics.
- */
- void trackAllPropertiesAccess();
-
- /**
- * Track the access of {@code Configuration#get(String)} for
- * usage statistics.
- * @param key key to track for
- * @param value value to track for
- */
- void trackSingleKeyAccess(String key, String value);
-
- /**
- * Access the usage statistics for the recorded uses of configuration.
- * @return usage statistics info
- */
- String getUsageInfo();
-
- /**
- * Clears all collected usage statistics.
- */
- void clearUsageStats();
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/main/java/org/apache/tamaya/model/spi/GroupModel.java
----------------------------------------------------------------------
diff --git a/modules/model/src/main/java/org/apache/tamaya/model/spi/GroupModel.java b/modules/model/src/main/java/org/apache/tamaya/model/spi/GroupModel.java
deleted file mode 100644
index 0a38dda..0000000
--- a/modules/model/src/main/java/org/apache/tamaya/model/spi/GroupModel.java
+++ /dev/null
@@ -1,110 +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.model.spi;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.model.ConfigModel;
-import org.apache.tamaya.model.ModelTarget;
-import org.apache.tamaya.model.Validation;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Objects;
-
-/**
- * Default configuration Model for a configuration area.
- */
-public class GroupModel implements ConfigModel {
-
- private final String owner;
- private final String name;
- private boolean required;
- private List<ConfigModel> childModels = new ArrayList<>();
-
- public GroupModel(String owner, String name, ConfigModel... configModels){
- this(owner, name, Arrays.asList(configModels));
- }
-
- public GroupModel(String owner, String name, Collection<ConfigModel> configModels){
- this.owner = Objects.requireNonNull(owner);
- this.name = Objects.requireNonNull(name);
- this.childModels.addAll(configModels);
- this.childModels = Collections.unmodifiableList(childModels);
- for(ConfigModel val: configModels) {
- if(val.isRequired()){
- this.required = true;
- break;
- }
- }
- }
-
- @Override
- public String getOwner() {
- return owner;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public boolean isRequired() {
- return required;
- }
-
- @Override
- public ModelTarget getType() {
- return ModelTarget.Group;
- }
-
- @Override
- public String getDescription() {
- if(childModels.isEmpty()){
- return null;
- }
- StringBuilder b = new StringBuilder();
- for(ConfigModel val: childModels){
- b.append(" >> ").append(val);
- }
- return b.toString();
- }
-
- public Collection<ConfigModel> getValidations(){
- return childModels;
- }
-
- @Override
- public Collection<Validation> validate(Configuration config) {
- List<Validation> result = new ArrayList<>(1);
- for(ConfigModel child: childModels){
- result.addAll(child.validate(config));
- }
- return result;
- }
-
- @Override
- public String toString(){
- return String.valueOf(getType()) + ", size: " + childModels.size() + ": " + getDescription();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/main/java/org/apache/tamaya/model/spi/ModelProviderSpi.java
----------------------------------------------------------------------
diff --git a/modules/model/src/main/java/org/apache/tamaya/model/spi/ModelProviderSpi.java b/modules/model/src/main/java/org/apache/tamaya/model/spi/ModelProviderSpi.java
deleted file mode 100644
index 01c0979..0000000
--- a/modules/model/src/main/java/org/apache/tamaya/model/spi/ModelProviderSpi.java
+++ /dev/null
@@ -1,39 +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.model.spi;
-
-import org.apache.tamaya.model.ConfigModel;
-
-import java.util.Collection;
-
-/**
- * Model of a configuration state. A model can be a full model, or a partial model, validating only
- * a configuration subset. This allows better user feedback because big configurations can be grouped
- * and validated by multiple (partial) models.
- */
-public interface ModelProviderSpi {
-
- /**
- * Get the validation defined.
- *
- * @return the sections defined, never null.
- */
- Collection<ConfigModel> getConfigModels();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/main/java/org/apache/tamaya/model/spi/ParameterModel.java
----------------------------------------------------------------------
diff --git a/modules/model/src/main/java/org/apache/tamaya/model/spi/ParameterModel.java b/modules/model/src/main/java/org/apache/tamaya/model/spi/ParameterModel.java
deleted file mode 100644
index 46f0560..0000000
--- a/modules/model/src/main/java/org/apache/tamaya/model/spi/ParameterModel.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.model.spi;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.model.ConfigModel;
-import org.apache.tamaya.model.ModelTarget;
-import org.apache.tamaya.model.Validation;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Objects;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Default configuration Model for a configuration parameter.
- */
-public class ParameterModel extends AbstractConfigModel {
- /** Optional regular expression for validating the value. */
- private final String regEx;
- /** The target type into which the value must be convertible. */
- private final Class<?> type;
-
- /**
- * Internal constructor.
- * @param builder the builder, not null.
- */
- protected ParameterModel(Builder builder) {
- super(builder.owner, builder.name, builder.required, builder.description);
- this.regEx = builder.regEx;
- this.type = builder.type;
- }
-
- @Override
- public ModelTarget getType() {
- return ModelTarget.Parameter;
- }
-
- /**
- * Get the required parameter type.
- *
- * @return the type.
- */
- public Class<?> getParameterType() {
- return type;
- }
-
- @Override
- public Collection<Validation> validate(Configuration config) {
- List<Validation> result = new ArrayList<>(1);
- String configValue = config.get(getName());
- if (configValue == null && isRequired()) {
- result.add(Validation.ofMissing(this));
- }
- if (configValue != null && regEx != null) {
- if (!configValue.matches(regEx)) {
- result.add(Validation.ofError(this, "Config value not matching expression: " + regEx + ", was " +
- configValue));
- }
- }
- return result;
- }
-
- @Override
- public String toString() {
- StringBuilder b = new StringBuilder();
- b.append(getType()).append(": ").append(getName());
- if (isRequired()) {
- b.append(", required: ").append(isRequired());
- }
- if (regEx != null) {
- b.append(", expression: ").append(regEx);
- }
- return b.toString();
- }
-
- /**
- * Creates a new Builder instance.
- * @param owner the owner name, not null.
- * @param name the fully qualified parameter name.
- * @return a new builder, never null.
- */
- public static Builder builder(String owner, String name) {
- return new Builder(owner, name);
- }
-
- /**
- * Creates a new ConfigModel
- * @param owner the owner name, not null.
- * @param name the fully qualified parameter name.
- * @param required the required flag.
- * @param expression an optional regular expression to validate a value.
- * @return the new ConfigModel instance.
- */
- public static ConfigModel of(String owner, String name, boolean required, String expression) {
- return new Builder(owner, name).setRequired(required).setExpression(expression).build();
- }
-
- /**
- * Creates a new ConfigModel
- * @param owner the owner name, not null.
- * @param name the fully qualified parameter name.
- * @param required the required flag.
- * @return the new ConfigModel instance.
- */
- public static ConfigModel of(String owner, String name, boolean required) {
- return new Builder(owner, name).setRequired(required).build();
- }
-
- /**
- * Creates a new ConfigModel. The parameter will be defined as optional.
- * @param owner the owner name, not null.
- * @param name the fully qualified parameter name.
- * @return the new ConfigModel instance.
- */
- public static ConfigModel of(String owner, String name) {
- return new Builder(owner, name).setRequired(false).build();
- }
-
-
- /**
- * A new Builder for creating ParameterModel instances.
- */
- public static class Builder {
- /** The parameter's target type. */
- private Class<?> type;
- /** The owner. */
- private String owner;
- /** The fully qualified parameter name. */
- private String name;
- /** The optional validation expression. */
- private String regEx;
- /** The optional description. */
- private String description;
- /** The required flag. */
- private boolean required;
-
- /**
- * Creates a new Builder.
- * @param owner owner, not null.
- * @param name the fully qualified parameter name, not null.
- */
- public Builder(String owner, String name) {
- this.owner = Objects.requireNonNull(owner);
- this.name = Objects.requireNonNull(name);
- }
-
- /**
- * Sets the target type.
- * @param type the type, not null.
- * @return the Builder for chaining
- */
- public Builder setType(String type) {
- try {
- this.type = Class.forName(type);
- } catch (ClassNotFoundException e) {
- try {
- this.type = Class.forName("java.ui.lang."+type);
- } catch (ClassNotFoundException e2) {
- Logger.getLogger(getClass().getName()).log(Level.INFO, "Failed to load parameter type: " + type, e2);
- }
- }
- return this;
- }
-
- /**
- * Sets the required flag.
- * @param required the required flag.
- * @return the Builder for chaining
- */
- public Builder setRequired(boolean required) {
- this.required = required;
- return this;
- }
-
- /**
- * Sets the optional description
- * @param description the description
- * @return the Builder for chaining
- */
- public Builder setDescription(String description) {
- this.description = description;
- return this;
- }
-
- /**
- * Sets the optional validation expression
- * @param expression the validation expression
- * @return the Builder for chaining
- */
- public Builder setExpression(String expression) {
- this.regEx = expression;
- return this;
- }
-
- /**
- * Sets the owner name.
- * @param owner the owner name, not null.
- * @return the Builder for chaining
- */
- public Builder setOwner(String owner) {
- this.owner = Objects.requireNonNull(owner);
- return this;
- }
-
- /**
- * Sets the fully qualified parameter name.
- * @param name the fully qualified parameter name, not null.
- * @return the Builder for chaining
- */
- public Builder setName(String name) {
- this.name = Objects.requireNonNull(name);
- return this;
- }
-
- /**
- * Creates a new ConfigModel with the given parameters.
- * @return a new ConfigModel , never null.
- */
- public ConfigModel build() {
- return new ParameterModel(this);
- }
- }
-}
[09/24] incubator-tamaya git commit: Removed all modules from the
main repository. They will be reborn in separate ASF repository.
Posted by pl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/json/src/test/resources/arquillian.xml
----------------------------------------------------------------------
diff --git a/modules/json/src/test/resources/arquillian.xml b/modules/json/src/test/resources/arquillian.xml
deleted file mode 100644
index 1eeb58b..0000000
--- a/modules/json/src/test/resources/arquillian.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-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.
--->
-<arquillian xmlns="http://jboss.org/schema/arquillian"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
- <container qualifier="daemon" default="true">
- <configuration>
- <property name="host">localhost</property>
- <property name="port">12346</property>
- <property name="serverJarFile">target/arquillian-daemon-main.jar</property>
- </configuration>
- </container>
-</arquillian>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/json/src/test/resources/configs/invalid/array.json
----------------------------------------------------------------------
diff --git a/modules/json/src/test/resources/configs/invalid/array.json b/modules/json/src/test/resources/configs/invalid/array.json
deleted file mode 100644
index 0c2058a..0000000
--- a/modules/json/src/test/resources/configs/invalid/array.json
+++ /dev/null
@@ -1,21 +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.
-*/
-[
-
-]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/json/src/test/resources/configs/invalid/empty-file.json
----------------------------------------------------------------------
diff --git a/modules/json/src/test/resources/configs/invalid/empty-file.json b/modules/json/src/test/resources/configs/invalid/empty-file.json
deleted file mode 100644
index f396085..0000000
--- a/modules/json/src/test/resources/configs/invalid/empty-file.json
+++ /dev/null
@@ -1,18 +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.
-*/
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/json/src/test/resources/configs/invalid/only-opening-bracket.json
----------------------------------------------------------------------
diff --git a/modules/json/src/test/resources/configs/invalid/only-opening-bracket.json b/modules/json/src/test/resources/configs/invalid/only-opening-bracket.json
deleted file mode 100644
index b936f69..0000000
--- a/modules/json/src/test/resources/configs/invalid/only-opening-bracket.json
+++ /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 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.
-*/
-{
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/json/src/test/resources/configs/invalid/with-array.json
----------------------------------------------------------------------
diff --git a/modules/json/src/test/resources/configs/invalid/with-array.json b/modules/json/src/test/resources/configs/invalid/with-array.json
deleted file mode 100644
index e623e49..0000000
--- a/modules/json/src/test/resources/configs/invalid/with-array.json
+++ /dev/null
@@ -1,27 +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.
-*/
-{
- "a" : "A",
- "b" : {
- "c" : "C",
- "d" : [
- "1", "2"
- ]
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/json/src/test/resources/configs/valid/cyrillic.json
----------------------------------------------------------------------
diff --git a/modules/json/src/test/resources/configs/valid/cyrillic.json b/modules/json/src/test/resources/configs/valid/cyrillic.json
deleted file mode 100644
index b9f07b8..0000000
--- a/modules/json/src/test/resources/configs/valid/cyrillic.json
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
-*/
-{
- "name" : "\u041e\u043b\u0438\u0432\u0435\u0440",
- "\u0444\u0430\u043c\u0438\u043b\u0438\u044f" : "Fischer"
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/json/src/test/resources/configs/valid/empty-object-config.json
----------------------------------------------------------------------
diff --git a/modules/json/src/test/resources/configs/valid/empty-object-config.json b/modules/json/src/test/resources/configs/valid/empty-object-config.json
deleted file mode 100644
index 103c28d..0000000
--- a/modules/json/src/test/resources/configs/valid/empty-object-config.json
+++ /dev/null
@@ -1,20 +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.
-*/
-{
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/json/src/test/resources/configs/valid/simple-flat-string-only-config.json
----------------------------------------------------------------------
diff --git a/modules/json/src/test/resources/configs/valid/simple-flat-string-only-config.json b/modules/json/src/test/resources/configs/valid/simple-flat-string-only-config.json
deleted file mode 100644
index 02e2cd8..0000000
--- a/modules/json/src/test/resources/configs/valid/simple-flat-string-only-config.json
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
-*/
-{
- "a" : "A",
- "b" : "B",
- "c" : "C"
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/json/src/test/resources/configs/valid/simple-nested-string-only-config-1.json
----------------------------------------------------------------------
diff --git a/modules/json/src/test/resources/configs/valid/simple-nested-string-only-config-1.json b/modules/json/src/test/resources/configs/valid/simple-nested-string-only-config-1.json
deleted file mode 100644
index fb2c4fe..0000000
--- a/modules/json/src/test/resources/configs/valid/simple-nested-string-only-config-1.json
+++ /dev/null
@@ -1,27 +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.
-*/
-{
- "a": "A",
- "b": "B",
- "c": "C",
- "d": {
- "o": "O",
- "p": "P"
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/json/src/test/resources/configs/valid/simple-nested-string-only-config-2.json
----------------------------------------------------------------------
diff --git a/modules/json/src/test/resources/configs/valid/simple-nested-string-only-config-2.json b/modules/json/src/test/resources/configs/valid/simple-nested-string-only-config-2.json
deleted file mode 100644
index b037174..0000000
--- a/modules/json/src/test/resources/configs/valid/simple-nested-string-only-config-2.json
+++ /dev/null
@@ -1,26 +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.
-*/
-{
- "a" : "A",
- "b" : {
- "o" : "O",
- "p" : "P"
- },
- "c" : "C"
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/json/src/test/resources/configs/valid/with-explicit-priority.json
----------------------------------------------------------------------
diff --git a/modules/json/src/test/resources/configs/valid/with-explicit-priority.json b/modules/json/src/test/resources/configs/valid/with-explicit-priority.json
deleted file mode 100644
index ed7acc2..0000000
--- a/modules/json/src/test/resources/configs/valid/with-explicit-priority.json
+++ /dev/null
@@ -1,25 +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.
-*/
-{
- /*
- some useful comment here
- */
- "tamaya.ordinal" : 16784,
- "a" : "A" // another comment
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/management/pom.xml
----------------------------------------------------------------------
diff --git a/modules/management/pom.xml b/modules/management/pom.xml
deleted file mode 100644
index 8603cf9..0000000
--- a/modules/management/pom.xml
+++ /dev/null
@@ -1,81 +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.
--->
-<project xmlns="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">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-extensions</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
-
- <artifactId>tamaya-management</artifactId>
- <name>Apache Tamaya Modules - Java Management Extensions</name>
- <packaging>bundle</packaging>
-
- <properties>
- <jdkVersion>1.7</jdkVersion>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-functions</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-core</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>java-hamcrest</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.tamaya.management
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/management/src/main/java/org/apache/tamaya/management/ConfigManagementSupport.java
----------------------------------------------------------------------
diff --git a/modules/management/src/main/java/org/apache/tamaya/management/ConfigManagementSupport.java b/modules/management/src/main/java/org/apache/tamaya/management/ConfigManagementSupport.java
deleted file mode 100644
index 64fa062..0000000
--- a/modules/management/src/main/java/org/apache/tamaya/management/ConfigManagementSupport.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.management;
-
-
-import org.apache.tamaya.spi.ServiceContextManager;
-
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import java.lang.management.ManagementFactory;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Accessor singleton for the JMX configuration support module.
- */
-public class ConfigManagementSupport {
-
- /** The logger used. */
- private final static Logger LOG = Logger.getLogger(ConfigManagementSupport.class.getName());
-
- /**
- * Private singleton constructor.
- */
- private ConfigManagementSupport(){}
-
- /**
- * Creates a new instance of a {@link ManagedConfigMBean} instance. This method uses the
- * current {@link ServiceContextManager} to resolve the implementation to be used.
- * @return a new ManagedConfigMBean instance, or null
- * @throws org.apache.tamaya.ConfigException if there are multiple service implementations with the
- * maximum priority.
- */
- private static ManagedConfigMBean createMBean(){
- return ServiceContextManager.getServiceContext()
- .getService(ManagedConfigMBean.class);
- }
-
- /**
- * Registers a new instance of {@link ManagedConfigMBean} mbean for accessing config documentation into the local platform
- * mbean server.
- * @return the registered ObjectName, or null, if no bean could be created.
- */
- public static ObjectName registerMBean() {
- return registerMBean(null);
- }
-
- /**
- * Registers the {@link ManagedConfigMBean} mbean for accessing config documentation into the local platform
- * mbean server.
- * @param context An optional context parameter to be added to the object name.
- * @return the registered ObjectName, or null, if no bean could be created.
- */
- public static ObjectName registerMBean(String context) {
- try{
- ManagedConfigMBean configMbean = createMBean();
- if(configMbean==null){
- return null;
- }
- MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
- ObjectName on = context==null?new ObjectName("org.apache.tamaya.managemet:type=ManagedConfigMBean"):
- new ObjectName("org.apache.tamaya.management:type=ManagedConfigMBean,context="+context);
- try{
- mbs.getMBeanInfo(on);
- LOG.info("Cannot register mbean " + on + ": already existing.");
- return on;
- } catch(InstanceNotFoundException e) {
- LOG.info("Registering mbean " + on + "...");
- mbs.registerMBean(configMbean, on);
- return on;
- }
- } catch(Exception e){
- LOG.log(Level.WARNING, "Failed to register ManagedConfigMBean.", e);
- }
- return null;
- }
-
- /**
- * Unregisters a new instance of {@link ManagedConfigMBean} mbean for accessing config documentation
- * into the local platform mbean server.
- * @return the unregistered ObjectName, or null, if no bean could be found.
- */
- public static ObjectName unregisterMBean() {
- return unregisterMBean(null);
- }
-
- /**
- * Unegisters the {@link ManagedConfigMBean} mbean for accessing config documentation into the local
- * platform mbean server.
- * @param context An optional context parameter to be added to the object name.
- * @return the unregistered ObjectName, or null, if no bean could be created.
- */
- public static ObjectName unregisterMBean(String context) {
- try{
- MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
- ObjectName on = context==null?new ObjectName("org.apache.tamaya.managemet:type=ManagedConfigMBean"):
- new ObjectName("org.apache.tamaya.management:type=ManagedConfigMBean,context="+context);
- try{
- mbs.unregisterMBean(on);
- LOG.info("Unregistered mbean " + on + ".");
- return on;
- } catch(InstanceNotFoundException e) {
- LOG.log(Level.INFO, "Unregistering mbean " + on + " failed.", e);
- }
- } catch(Exception e){
- LOG.log(Level.WARNING, "Failed to unregister ManagedConfigMBean.", e);
- }
- return null;
- }
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/management/src/main/java/org/apache/tamaya/management/ManagedConfig.java
----------------------------------------------------------------------
diff --git a/modules/management/src/main/java/org/apache/tamaya/management/ManagedConfig.java b/modules/management/src/main/java/org/apache/tamaya/management/ManagedConfig.java
deleted file mode 100644
index dab3457..0000000
--- a/modules/management/src/main/java/org/apache/tamaya/management/ManagedConfig.java
+++ /dev/null
@@ -1,110 +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.management;
-
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.functions.ConfigurationFunctions;
-
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Default implementation of the {@link ManagedConfigMBean} interface. Each bean binds to the
- * current Configuration instance on creation.
- */
-public class ManagedConfig implements ManagedConfigMBean {
-
- /**
- * Classloader that was active when this instance was created.
- */
- private ClassLoader classLoader;
-
- /**
- * Constructor, which binds this instance to the current TCCL. In the rare cases where
- * the TCCL is null, this class's classloader is used.
- */
- public ManagedConfig() {
- this.classLoader = Thread.currentThread().getContextClassLoader();
- if (this.classLoader == null) {
- this.classLoader = ManagedConfigMBean.class.getClassLoader();
- }
- }
-
- @Override
- public String getJsonConfigurationInfo() {
- return getConfigurationInternal().query(ConfigurationFunctions.jsonInfo());
- }
-
- @Override
- public String getXmlConfigurationInfo() {
- return getConfigurationInternal().query(ConfigurationFunctions.xmlInfo());
- }
-
- @Override
- public Map<String, String> getConfiguration() {
- return getConfigurationInternal().getProperties();
- }
-
- @Override
- public Map<String, String> getSection(String area, boolean recursive) {
- return getConfigurationInternal().with(ConfigurationFunctions.section(area, recursive)).getProperties();
- }
-
- @Override
- public Set<String> getSections() {
- return getConfigurationInternal().query(ConfigurationFunctions.sections());
- }
-
- @Override
- public Set<String> getTransitiveSections() {
- return getConfigurationInternal().query(ConfigurationFunctions.transitiveSections());
- }
-
- @Override
- public boolean isAreaExisting(String area) {
- return !getConfigurationInternal().with(
- ConfigurationFunctions.section(area)).getProperties().isEmpty();
- }
-
- @Override
- public boolean isAreaEmpty(String area) {
- return getSection(area, true).isEmpty();
- }
-
-
- /**
- * Evaluate the current configuration. By default this class is temporarely setting the
- * TCCL to the instance active on bean creation and then calls {@link ConfigurationProvider#getConfiguration()}.
- *
- * @return the configuration instance to be used.
- */
- protected Configuration getConfigurationInternal() {
- ClassLoader currentCL = Thread.currentThread().getContextClassLoader();
- try{
- Thread.currentThread().setContextClassLoader(this.classLoader);
- return ConfigurationProvider.getConfiguration();
- } finally{
- Thread.currentThread().setContextClassLoader(currentCL);
- }
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/management/src/main/java/org/apache/tamaya/management/ManagedConfigMBean.java
----------------------------------------------------------------------
diff --git a/modules/management/src/main/java/org/apache/tamaya/management/ManagedConfigMBean.java b/modules/management/src/main/java/org/apache/tamaya/management/ManagedConfigMBean.java
deleted file mode 100644
index 7fa1eef..0000000
--- a/modules/management/src/main/java/org/apache/tamaya/management/ManagedConfigMBean.java
+++ /dev/null
@@ -1,119 +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.management;
-
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Managed bean interface for accessing environment data.
- */
-public interface ManagedConfigMBean {
-
- /**
- * Get a general description of the configuration (context) in place, in JSON format:
- * <pre>
- * Configuration: {
- * "class": "org.apache.tamaya.core.internal.DefaultConfiguration",
- * "timestamp": 1440426409388,
- * "data": {
- * "ALLUSERSPROFILE": "C:\ProgramData",
- * "APPDATA": "C:\Users\Anatole\AppData\Roaming",
- * "COMPUTERNAME": "DEVBOX-WIN",
- * "ComSpec": "C:\Windows\system32\cmd.exe",
- * "CommonProgramFiles": "C:\Program Files\Common Files",
- * "CommonProgramFiles(x86)": "C:\Program Files (x86)\Common Files",
- * "CommonProgramW6432": "C:\Program Files\Common Files",
- * "FP_NO_HOST_CHECK": "NO",
- * "HOMEDRIVE": "C:",
- * // ...
- * }
- * }
- * </pre>
- *
- * @return a JSON formatted meta-information.
- */
- String getJsonConfigurationInfo();
-
- /**
- * Get a general description of the configuration (context) in place, in JSON format:
- * <pre>
- * ConfigurationContext[gqContextClassName] {
- * version = 2345-34334-2333-3434,
- * config {
- * key = "value",
- * key2 = "value2"
- * ...
- * },
- * filters = [...],
- * converters{...},
- * property-sources{...}
- * }
- * </pre>
- *
- * @return a JSON formatted meta-information.
- */
- String getXmlConfigurationInfo();
-
- /**
- * Accesses a configuration current a given type as Map.
- *
- * @return the current configuration map.
- * @throws org.apache.tamaya.ConfigException If the configuration is not available.
- */
- Map<String, String> getConfiguration();
-
- /**
- * Accesses a configuration values for current a given config section as Map.
- * @param area the target section key, not null.
- * @param recursive if set to false only direct child keys of the given section are returned.
- * @return the key/values found, including the recursive child values.
- * @throws org.apache.tamaya.ConfigException If the configuration is not yet loaded.
- */
- Map<String, String> getSection(String area, boolean recursive);
-
- /**
- * Access the defined sections for a given configuration.
- * @return the sections defined (only returning the sections that contain properties).
- * @throws org.apache.tamaya.ConfigException If the configuration is not yet loaded
- */
- Set<String> getSections();
-
- /**
- * Access the transitive sections for the current configuration.
- * @return the transitive sections defined.
- * @throws org.apache.tamaya.ConfigException If the configuration is not yet loaded
- */
- Set<String> getTransitiveSections();
-
- /**
- * Allows to determine if an section is existing.
- * @param area the target section key, not null.
- * @return true, if such an section exists (the section may be empty).
- */
- boolean isAreaExisting(String area);
-
- /**
- * Allows to determine if an section is empty.
- * @param area the target section key, not null.
- * @return true, if such an section exists and is not empty.
- */
- boolean isAreaEmpty(String area);
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/management/src/main/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/modules/management/src/main/resources/META-INF/beans.xml b/modules/management/src/main/resources/META-INF/beans.xml
deleted file mode 100644
index adee378..0000000
--- a/modules/management/src/main/resources/META-INF/beans.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-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.
--->
-<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://jboss.org/schema/cdi/beans_1_0.xsd">
-
-</beans>
-
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/management/src/main/resources/META-INF/javaconfiguration.properties
----------------------------------------------------------------------
diff --git a/modules/management/src/main/resources/META-INF/javaconfiguration.properties b/modules/management/src/main/resources/META-INF/javaconfiguration.properties
deleted file mode 100644
index 333ba9c..0000000
--- a/modules/management/src/main/resources/META-INF/javaconfiguration.properties
+++ /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.
-#
-a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z=alphabet
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/management/src/main/resources/META-INF/services/org.apache.tamaya.management.ManagedConfigMBean
----------------------------------------------------------------------
diff --git a/modules/management/src/main/resources/META-INF/services/org.apache.tamaya.management.ManagedConfigMBean b/modules/management/src/main/resources/META-INF/services/org.apache.tamaya.management.ManagedConfigMBean
deleted file mode 100644
index 4ba72b6..0000000
--- a/modules/management/src/main/resources/META-INF/services/org.apache.tamaya.management.ManagedConfigMBean
+++ /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.management.ManagedConfig
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/management/src/test/java/org/apache/tamaya/management/internal/ManagedConfigTest.java
----------------------------------------------------------------------
diff --git a/modules/management/src/test/java/org/apache/tamaya/management/internal/ManagedConfigTest.java b/modules/management/src/test/java/org/apache/tamaya/management/internal/ManagedConfigTest.java
deleted file mode 100644
index 90ad0bf..0000000
--- a/modules/management/src/test/java/org/apache/tamaya/management/internal/ManagedConfigTest.java
+++ /dev/null
@@ -1,118 +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.management.internal;
-
-import org.apache.tamaya.management.ConfigManagementSupport;
-import org.apache.tamaya.management.ManagedConfig;
-import org.apache.tamaya.management.ManagedConfigMBean;
-
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import java.lang.management.ManagementFactory;
-import java.util.Map;
-import java.util.Set;
-
-import static org.junit.Assert.*;
-
-/**
- * Created by Anatole on 20.08.2015.
- */
-public class ManagedConfigTest {
-
- private final ManagedConfigMBean bean = new ManagedConfig();
-
- @org.junit.Test
- public void testGetJsonConfigurationInfo() throws Exception {
- String info = bean.getJsonConfigurationInfo();
- assertNotNull(info);
- assertTrue(info.contains("java.version"));
- System.out.println(bean.getJsonConfigurationInfo());
- }
-
- @org.junit.Test
- public void testGetXmlConfigurationInfo() throws Exception {
- String info = bean.getXmlConfigurationInfo();
- assertNotNull(info);
- assertTrue(info.contains("java.version"));
- assertTrue(info.contains("<configuration>"));
- System.out.println(bean.getXmlConfigurationInfo());
- }
-
- @org.junit.Test
- public void testGetConfiguration() throws Exception {
- Map<String,String> config = bean.getConfiguration();
- assertNotNull(config);
- for(Map.Entry<Object, Object> en:System.getProperties().entrySet()){
- assertEquals(config.get(en.getKey()),en.getValue());
- }
- }
-
- @org.junit.Test
- public void testGetConfigurationArea() throws Exception {
- Map<String,String> cfg = bean.getSection("java", false);
- for(Map.Entry<String,String> en:cfg.entrySet()){
- assertEquals(System.getProperty(en.getKey()), en.getValue());
- }
- }
-
- @org.junit.Test
- public void testGetAreas() throws Exception {
- Set<String> sections = (bean.getSections());
- assertNotNull(sections);
- assertTrue(sections.contains("java"));
- assertTrue(sections.contains("file"));
- }
-
- @org.junit.Test
- public void testGetTransitiveAreas() throws Exception {
- Set<String> sections = (bean.getTransitiveSections());
- Set<String> sectionsNT = (bean.getSections());
- assertNotNull(sections);
- assertTrue(sections.contains("java"));
- assertTrue(sections.contains("sun"));
- assertTrue(sections.contains("sun.os"));
- assertTrue(sectionsNT.size()<sections.size());
- }
-
- @org.junit.Test
- public void testIsAreaExisting() throws Exception {
- assertTrue(bean.isAreaExisting("java"));
- assertFalse(bean.isAreaExisting("sd.fldsfl.erlwsf"));
- }
-
- @org.junit.Test
- public void testRegisterMBean() throws Exception {
- ObjectName on = ConfigManagementSupport.registerMBean();
- ConfigManagementSupport.registerMBean();
- // Lookup object name
- MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
- assertTrue(mbs.getMBeanInfo(on)!=null);
- }
-
- @org.junit.Test
- public void testRegisterMBean1() throws Exception {
- ObjectName on1 = ConfigManagementSupport.registerMBean("SubContext1");
- ConfigManagementSupport.registerMBean("SubContext1");
- ObjectName on2 = ConfigManagementSupport.registerMBean("SubContext2");
- // Lookup object name
- MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
- assertTrue(mbs.getMBeanInfo(on1)!=null);
- assertTrue(mbs.getMBeanInfo(on2)!=null);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/management/src/test/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/modules/management/src/test/resources/META-INF/beans.xml b/modules/management/src/test/resources/META-INF/beans.xml
deleted file mode 100644
index adee378..0000000
--- a/modules/management/src/test/resources/META-INF/beans.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-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.
--->
-<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://jboss.org/schema/cdi/beans_1_0.xsd">
-
-</beans>
-
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/pom.xml
----------------------------------------------------------------------
diff --git a/modules/model/pom.xml b/modules/model/pom.xml
deleted file mode 100644
index b121c24..0000000
--- a/modules/model/pom.xml
+++ /dev/null
@@ -1,120 +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.
--->
-<project xmlns="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">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-extensions</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
-
- <artifactId>tamaya-model</artifactId>
- <name>Apache Tamaya Modules - Configuration Model Infrastructure</name>
- <description>This extension module provides functionality to describe, document and
- validate configuration during runtime.
- </description>
- <packaging>bundle</packaging>
-
- <properties>
- <jdkVersion>1.7</jdkVersion>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-core</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-injection-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-formats</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-events</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-json</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.apache.johnzon</groupId>
- <artifactId>johnzon-core</artifactId>
- <version>0.9-incubating</version>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-json_1.0_spec</artifactId>
- <version>1.0-alpha-1</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>java-hamcrest</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.tamaya.model,
- org.apache.tamaya.model.spi
- </Export-Package>
- <Private-Package>
- org.apache.tamaya.model.internal
- </Private-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/main/java/org/apache/tamaya/model/ConfigModel.java
----------------------------------------------------------------------
diff --git a/modules/model/src/main/java/org/apache/tamaya/model/ConfigModel.java b/modules/model/src/main/java/org/apache/tamaya/model/ConfigModel.java
deleted file mode 100644
index 88403d1..0000000
--- a/modules/model/src/main/java/org/apache/tamaya/model/ConfigModel.java
+++ /dev/null
@@ -1,78 +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.model;
-
-import org.apache.tamaya.Configuration;
-
-import java.util.Collection;
-
-/**
- * Base structure describing a validated item, by default a parameter or a section.
- */
-public interface ConfigModel {
-
- /**
- * Access the owner.
- * @return the owner of this model, never null.
- */
- String getOwner();
-
- /**
- * Get the type of item that is modelled.
- * @return the modelled type, never null.
- */
- ModelTarget getType();
-
- /**
- * Get the item's name, it should minimally describe the validation. Examples are:
- * <pre>
- * Sections: a.b.c
- * Params: a.b.c.paramName
- * Filter: a.b.c.FilterImplClass
- * Dependency: mydepClassname
- * CombinationPolicy: a.b.c.MyCombinationPolicyClass
- * </pre>
- * @return the item's name.
- */
- String getName();
-
- /**
- * Check if this validation is a required one.
- * @return true, if this validation is required.
- */
- boolean isRequired();
-
- /**
- * Get an description of the item, using the default locale. The description is basically optional
- * though it is higly recommended to provide a description, so the validation issues is well
- * resolvable.
- *
- * @return the description required, or null.
- */
- String getDescription();
-
- /**
- * Validates the item and all its children against the given configuration.
- *
- * @param config the configuration to be validated against, not null.
- * @return the validation result, or null, if not applicable.
- */
- Collection<Validation> validate(Configuration config);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/main/java/org/apache/tamaya/model/ConfigModelManager.java
----------------------------------------------------------------------
diff --git a/modules/model/src/main/java/org/apache/tamaya/model/ConfigModelManager.java b/modules/model/src/main/java/org/apache/tamaya/model/ConfigModelManager.java
deleted file mode 100644
index 078b0dc..0000000
--- a/modules/model/src/main/java/org/apache/tamaya/model/ConfigModelManager.java
+++ /dev/null
@@ -1,289 +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.model;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.model.spi.ConfigDocumentationMBean;
-import org.apache.tamaya.model.spi.ModelProviderSpi;
-import org.apache.tamaya.spi.ServiceContextManager;
-
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import java.lang.management.ManagementFactory;
-import java.util.*;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Validator accessor to validate the current configuration.
- */
-public final class ConfigModelManager {
-
- /** The logger used. */
- private static final Logger LOG = Logger.getLogger(ConfigModelManager.class.getName());
-
- /**
- * Singleton constructor.
- */
- private ConfigModelManager() {
- }
-
- /**
- * Access the usage statistics for the recorded uses of configuration.
- * @return usage statistics
- */
- public static String getConfigInfoText(){
- StringBuilder b = new StringBuilder();
- List<ConfigModel> models = new ArrayList<>(getModels());
- Collections.sort(models, new Comparator<ConfigModel>() {
- @Override
- public int compare(ConfigModel k1, ConfigModel k2) {
- return k2.getName().compareTo(k2.getName());
- }
- });
- b.append("TYPE OWNER NAME MANDATORY DESCRIPTION\n");
- b.append("-----------------------------------------------------------------------------------------------------\n");
- for(ConfigModel model:models){
- switch(model.getType()){
- case Parameter:
- b.append("PARAM ");
- break;
- case Section:
- b.append("SECTION ");
- break;
- case Group:
- b.append("GROUP ");
- break;
- default:
- break;
- }
- b.append(formatWithFixedLength(model.getOwner(), 10)).append(' ');
- b.append(formatWithFixedLength(model.getName(), 50));
- if(model.isRequired()){
- b.append(formatWithFixedLength("yes", 12));
- }else{
- b.append(formatWithFixedLength("no", 12));
- }
- if(model.getDescription()!=null){
- b.append(model.getDescription().replace("\n", "\\\n").replace("\"", "'")).append("\"");
- }
- b.append("\n");
- }
- return b.toString();
- }
-
- private static String formatWithFixedLength(String name, int targetLength) {
- targetLength = targetLength-1;
- StringBuilder b = new StringBuilder();
- if(name.length() > targetLength){
- name = name.substring(0, targetLength);
- }
- b.append(name);
- for(int i=0;i<(targetLength-name.length());i++){
- b.append(' ');
- }
- b.append(' ');
- return b.toString();
- }
-
- /**
- * Get the validations defined.
- *
- * @return the sections defined, never null.
- */
- public static Collection<ConfigModel> getModels() {
- List<ConfigModel> result = new ArrayList<>();
- for (ModelProviderSpi model : ServiceContextManager.getServiceContext().getServices(ModelProviderSpi.class)) {
- result.addAll(model.getConfigModels());
- }
- return result;
- }
-
-
- /**
- * Find the validations by matching the validation's name against the given model type.
- *
- * @param name the name to use, not null.
- * @param modelType classname of the target model type.
- * @param <T> type of the model to filter for.
- * @return the sections defined, never null.
- */
- public static <T extends ConfigModel> T getModel(String name, Class<T> modelType) {
- for (ModelProviderSpi model : ServiceContextManager.getServiceContext().getServices(ModelProviderSpi.class)) {
- for(ConfigModel configModel : model.getConfigModels()) {
- if(configModel.getName().equals(name) && configModel.getClass().equals(modelType)) {
- return modelType.cast(configModel);
- }
- }
- }
- return null;
- }
-
- /**
- * Find the validations by checking the validation's name using the given regular expression.
- * @param namePattern the regular expression to use, not null.
- * @param targets the target types only to be returned (optional).
- * @return the sections defined, never null.
- */
- public static Collection<ConfigModel> findModels(String namePattern, ModelTarget... targets) {
- List<ConfigModel> result = new ArrayList<>();
- for (ModelProviderSpi model : ServiceContextManager.getServiceContext().getServices(ModelProviderSpi.class)) {
- for(ConfigModel configModel : model.getConfigModels()) {
- if(configModel.getName().matches(namePattern)) {
- if(targets.length>0){
- for(ModelTarget tgt:targets){
- if(configModel.getType().equals(tgt)){
- result.add(configModel);
- break;
- }
- }
- }else {
- result.add(configModel);
- }
- }
- }
- }
- return result;
- }
-
- /**
- * Validates the current configuration.
- *
- * @return the validation results, never null.
- */
- public static Collection<Validation> validate() {
- return validate(false);
- }
-
- /**
- * Validates the current configuration.
- * @param showUndefined show any unknown parameters.
- * @return the validation results, never null.
- */
- public static Collection<Validation> validate(boolean showUndefined) {
- return validate(ConfigurationProvider.getConfiguration(), showUndefined);
- }
-
- /**
- * Validates the given configuration.
- *
- * @param config the configuration to be validated against, not null.
- * @return the validation results, never null.
- */
- public static Collection<Validation> validate(Configuration config) {
- return validate(config, false);
- }
-
- /**
- * Validates the given configuration.
- *
- * @param config the configuration to be validated against, not null.
- * @param showUndefined allows filtering for undefined configuration elements.
- * @return the validation results, never null.
- */
- public static Collection<Validation> validate(Configuration config, boolean showUndefined) {
- List<Validation> result = new ArrayList<>();
- for (ConfigModel defConf : getModels()) {
- result.addAll(defConf.validate(config));
- }
- if(showUndefined){
- Map<String,String> map = new HashMap<>(config.getProperties());
- Set<String> areas = extractTransitiveAreas(map.keySet());
- for (ConfigModel defConf : getModels()) {
- if(ModelTarget.Section.equals(defConf.getType())){
- for (Iterator<String> iter = areas.iterator();iter.hasNext();){
- String area = iter.next();
- if(area.matches(defConf.getName())){
- iter.remove();
- }
- }
- }
- if(ModelTarget.Parameter.equals(defConf.getType())){
- map.remove(defConf.getName());
- }
- }
- outer:for(Map.Entry<String,String> entry:map.entrySet()){
- for (ConfigModel defConf : getModels()) {
- if(ModelTarget.Section.equals(defConf.getType())){
- if(defConf.getName().endsWith(".*") && entry.getKey().matches(defConf.getName())){
- // Ignore parameters that are part of transitive section.
- continue outer;
- }
- }
- }
- result.add(Validation.ofUndefined("<auto>", entry.getKey(), ModelTarget.Parameter));
- }
- for(String area:areas){
- result.add(Validation.ofUndefined("<auto>", area, ModelTarget.Section));
- }
- }
- return result;
- }
-
- private static java.util.Set<java.lang.String> extractTransitiveAreas(Set<String> keys) {
- Set<String> transitiveClosure = new HashSet<>();
- for(String key:keys){
- int index = key.lastIndexOf('.');
- while(index>0){
- String areaKey = key.substring(0,index);
- transitiveClosure.add(areaKey);
- index = areaKey.lastIndexOf('.');
- }
- }
- return transitiveClosure;
- }
-
-
- /**
- * Registers the {@link ConfigDocumentationMBean} mbean for accessing config documentation into the local platform
- * mbean server.
- */
- public static void registerMBean() {
- registerMBean(null);
- }
-
- /**
- * Registers the {@link ConfigDocumentationMBean} mbean for accessing config documentation into the local platform
- * mbean server.
- *
- * @param context allows to specify an additional MBean context, maybe {@code null}.
- */
- public static void registerMBean(String context) {
- try{
- ConfigDocumentationMBean configMbean = ServiceContextManager.getServiceContext()
- .getService(ConfigDocumentationMBean.class);
- MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
- ObjectName on = context==null?new ObjectName("org.apache.tamaya.model:type=ConfigDocumentationMBean"):
- new ObjectName("org.apache.tamaya.model:type=ConfigDocumentationMBean,context="+context);
- try{
- mbs.getMBeanInfo(on);
- LOG.warning("Cannot register mbean " + on + ": already existing.");
- } catch(InstanceNotFoundException e) {
- LOG.info("Registering mbean " + on + "...");
- mbs.registerMBean(configMbean, on);
- }
- } catch(Exception e){
- LOG.log(Level.WARNING,
- "Failed to register ConfigDocumentationMBean.", e);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/main/java/org/apache/tamaya/model/ConfigUsageStats.java
----------------------------------------------------------------------
diff --git a/modules/model/src/main/java/org/apache/tamaya/model/ConfigUsageStats.java b/modules/model/src/main/java/org/apache/tamaya/model/ConfigUsageStats.java
deleted file mode 100644
index b502242..0000000
--- a/modules/model/src/main/java/org/apache/tamaya/model/ConfigUsageStats.java
+++ /dev/null
@@ -1,129 +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.model;
-
-import org.apache.tamaya.model.spi.ConfigUsageStatsSpi;
-import org.apache.tamaya.spi.ServiceContextManager;
-
-import java.util.Collection;
-import java.util.Objects;
-import java.util.Set;
-import java.util.logging.Logger;
-
-/**
- * Validator accessor to validate the current configuration.
- */
-public final class ConfigUsageStats {
-
- /** The logger used. */
- private static final Logger LOG = Logger.getLogger(ConfigUsageStats.class.getName());
- private static final String NO_USAGE_TRACKER_SPI_COMPONENT_MESSAGE = "No UsageTrackerSpi component available.";
-
- /** The loaded usage tracking SPI. */
- private static ConfigUsageStatsSpi usageTracker = ServiceContextManager
- .getServiceContext().getService(ConfigUsageStatsSpi.class);
-
- /**
- * Singleton constructor.
- */
- private ConfigUsageStats() {
- }
-
- /**
- * Returns a set of package names that are to be ignored when collecting usage data.
- * @return the ignored package names, not null.
- */
- public static Set<String> getIgnoredUsagePackages(){
- return Objects.requireNonNull(usageTracker, NO_USAGE_TRACKER_SPI_COMPONENT_MESSAGE)
- .getIgnoredPackages();
- }
-
- /**
- * Adds the given packageNames to the list of packages to be ignored when collecting usage data.
- * @param packageName the package names to be added, not null.
- */
- public static void addIgnoredUsagePackages(String... packageName){
- Objects.requireNonNull(usageTracker, NO_USAGE_TRACKER_SPI_COMPONENT_MESSAGE)
- .addIgnoredUsagePackages(packageName);
- }
-
- /**
- * Enables/disables usage tracking.
- * @param enabled set to true to enable usage tracking.
- */
- public static void enableUsageTracking(boolean enabled){
- Objects.requireNonNull(usageTracker, NO_USAGE_TRACKER_SPI_COMPONENT_MESSAGE)
- .enableUsageTracking(enabled);
- }
-
- /**
- * Access the usage statistics for a given key. If usage stats collection is not
- * activated (default), this method returns null.
- * @param key the fully qualified configuration key, not null.
- * @return the stats collected, or null.
- */
- public static Usage getUsage(String key){
- return Objects.requireNonNull(usageTracker, NO_USAGE_TRACKER_SPI_COMPONENT_MESSAGE)
- .getUsage(key);
- }
-
- /**
- * Get the recorded usage references of configuration.
- * @return the recorded usge references, never null.
- */
- public static Collection<Usage> getUsages() {
- return Objects.requireNonNull(usageTracker, NO_USAGE_TRACKER_SPI_COMPONENT_MESSAGE).getUsages();
- }
-
- /**
- * Clears all collected usage statistics.
- */
- public static void clearUsageStats() {
- Objects.requireNonNull(usageTracker, NO_USAGE_TRACKER_SPI_COMPONENT_MESSAGE)
- .clearUsageStats();
- }
-
- /**
- * Access the usage statistics for accessing {@link org.apache.tamaya.Configuration#getProperties()}.
- * If usage stats collection is not activated (default), this method returns null.
- * @return the stats collected, or null.
- */
- public static Usage getUsageAllProperties(){
- return Objects.requireNonNull(usageTracker, NO_USAGE_TRACKER_SPI_COMPONENT_MESSAGE)
- .getUsageAllProperties();
- }
-
- /**
- * Allows to check if usage tracking is enabled (should be disbled by default).
- * @return true, if usage tracking is enabled.
- */
- public static boolean isUsageTrackingEnabled(){
- return Objects.requireNonNull(usageTracker, NO_USAGE_TRACKER_SPI_COMPONENT_MESSAGE)
- .isUsageTrackingEnabled();
- }
-
- /**
- * Access the usage statistics for the recorded uses of configuration.
- * @return usage info or default message.
- */
- public static String getUsageInfo(){
- return Objects.requireNonNull(usageTracker, NO_USAGE_TRACKER_SPI_COMPONENT_MESSAGE).getUsageInfo();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/main/java/org/apache/tamaya/model/ModelTarget.java
----------------------------------------------------------------------
diff --git a/modules/model/src/main/java/org/apache/tamaya/model/ModelTarget.java b/modules/model/src/main/java/org/apache/tamaya/model/ModelTarget.java
deleted file mode 100644
index a8b687b..0000000
--- a/modules/model/src/main/java/org/apache/tamaya/model/ModelTarget.java
+++ /dev/null
@@ -1,37 +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.model;
-
-/**
- * This enumeration defines the types of supported validations.
- */
-public enum ModelTarget {
- /**
- * A configuration section.
- */
- Section,
- /**
- * A configuration paramter.
- */
- Parameter,
- /**
- * ConfigModel that is a container of other validations.
- */
- Group,
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/main/java/org/apache/tamaya/model/Usage.java
----------------------------------------------------------------------
diff --git a/modules/model/src/main/java/org/apache/tamaya/model/Usage.java b/modules/model/src/main/java/org/apache/tamaya/model/Usage.java
deleted file mode 100644
index 2d84915..0000000
--- a/modules/model/src/main/java/org/apache/tamaya/model/Usage.java
+++ /dev/null
@@ -1,312 +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.model;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.logging.Logger;
-
-/**
- * Metrics container containing access statistics for a given configuration key.
- */
-public final class Usage {
- private static final Logger LOG = Logger.getLogger(Usage.class.getName());
- private static final String[] EMPTY_TRACE = new String[0];
- /**
- * the config section.
- */
- private final String key;
-
- /**
- * Maps with usage references, key is the fully qualified package name.
- */
- private final Map<String,AccessDetail> accessDetails = new ConcurrentHashMap<>();
- /**
- * The maximal length of the stacktrace stored.
- */
- private static int maxTrace = 10;
-
- /**
- * Creates a usage metric container for a given key.
- * @param key the parameter (fully qualified).
- */
- public Usage(String key) {
- this.key = Objects.requireNonNull(key);
- }
-
- /**
- * Get the maximal length of the stack traces recorded, default is 10.
- * @return the maximal length of the stack traces recorded
- */
- public static int getMaxTraceLength(){
- return Usage.maxTrace;
- }
-
- /**
- * Sets the maximal length of the stacktraces stored when tracking configuration
- * usage. Setting it to a negative value, disabled stacktrace logging.
- * @param maxTrace the maximal recorded stack length.
- */
- public static void setMaxTraceLength(int maxTrace){
- Usage.maxTrace =maxTrace;
- }
-
- /**
- * Get the configModel section.
- *
- * @return the section, never null.
- */
- public String getKey() {
- return key;
- }
-
- /**
- * Clears all collected usage metrics for this key.
- */
- public void clearMetrics(){
- this.accessDetails.clear();
- }
-
- /**
- * Get the detail message.
- *
- * @return the detail message, or null.
- */
- public int getReferenceCount() {
- return accessDetails.size();
- }
-
- /**
- * Get the detail message.
- *
- * @return the detail message, or null.
- */
- public int getUsageCount() {
- int count = 0;
- for(AccessDetail ref: accessDetails.values()){
- count += ref.getAccessCount();
- }
- return count;
- }
-
- /**
- * Access a usage reference for a given class.
- * @param type class to get usage references for, not null.
- * @return the usage ref, if present, or null.
- */
- public Collection<AccessDetail> getAccessDetails(Class type){
- return getAccessDetails(type.getName() +"\\..*");
- }
-
- /**
- * Access a usage reference for a given package.
- * @param pack package to get usage references for, not null.
- * @return the usage ref, if present, or null.
- */
- public Collection<AccessDetail> getAccessDetails(Package pack){
- return getAccessDetails(pack.getName() +"\\..*");
- }
-
- /**
- * Find usages of this key for the given expression (regex). Hereby the expression is
- * matched with the tracked reference identifier, which has the form
- * {@code f.q.n.ClassName#methodName(line: 123)}.
- * @param lookupExpression the target lookup expression, not null.
- * @return the matching references, not null.
- */
- public Collection<AccessDetail> getAccessDetails(String lookupExpression){
- List<AccessDetail> result = new ArrayList<>();
- for(AccessDetail ref:this.accessDetails.values()){
- if(ref.getAccessPoint().matches(lookupExpression)){
- result.add(ref);
- }
- }
- return result;
- }
-
- @Override
- public String toString() {
- return "Usage Count: " + key + " -> " + getUsageCount() + '\n';
- }
-
- /**
- * Get the access details (stacktrace etc) for this reference.
- * @return return the access details, not null.
- */
- public Collection<AccessDetail> getAccessDetails(){
- return Collections.unmodifiableCollection(accessDetails.values());
- }
-
- /**
- * Evaluates the current access point from the current stacktrace and adds an according
- * usage reference object (or updates any existing one) for the given key. The
- * stacktrace is shortened to a maximal size of 20 items.
- * @param value the value returned, not null.
- */
- public void trackUsage(String value){
- trackUsage(value, maxTrace);
- }
-
- /**
- * Evaluates the current access point from the current stacktrace and adds an according
- * usage reference object (or updates any existing one) for the given key.
- * @param value the value returned, not null.
- * @param maxTraceLength the maximal length of the stored stacktrace.
- */
- public void trackUsage(String value, int maxTraceLength){
- String accessPoint = null;
- if(maxTraceLength>0) {
- Exception e = new Exception();
- List<String> trace = new ArrayList<>();
- stack:
- for (StackTraceElement ste : e.getStackTrace()) {
- for (String ignored : ConfigUsageStats.getIgnoredUsagePackages()) {
- if (ste.getClassName().startsWith(ignored)) {
- continue stack;
- }
- }
- String ref = ste.getClassName() + '#' + ste.getMethodName() + "(line:" + ste.getLineNumber() + ')';
- trace.add(ref);
- if (accessPoint == null) {
- accessPoint = ref;
- }
- if (trace.size() >= maxTraceLength) {
- break;
- }
- }
- if (accessPoint == null) {
- // all ignored, take first one, with different package
- accessPoint = "<unknown/filtered/internal>";
- }
- AccessDetail details = getAccessDetails(accessPoint, trace.toArray(new String[trace.size()]));
- details.trackAccess(value);
- }else{
- accessPoint = "<disabled>";
- AccessDetail details = getAccessDetails(accessPoint, EMPTY_TRACE);
- details.trackAccess(value);
- }
- }
-
- private AccessDetail getAccessDetails(String accessPoint, String[] trace) {
- AccessDetail details = accessDetails.get(accessPoint);
- if(details==null){
- details = new AccessDetail(key, accessPoint, trace);
- accessDetails.put(accessPoint, details);
- }
- return details;
- }
-
- /**
- * Class modelling the access details tracked per detailed item, e.g. per class in the owning package.
- */
- public static final class AccessDetail {
- private String key;
- private AtomicLong accessCount = new AtomicLong();
- private long lastAccessTS;
- private long firstAccessTS;
- private String[] stackTrace;
- private String accessPoint;
- private Map<Long, String> trackedValues;
-
- public AccessDetail(String key, String accessPoint, String[] stackTrace){
- this.key = Objects.requireNonNull(key);
- this.accessPoint = Objects.requireNonNull(accessPoint);
- this.stackTrace = stackTrace.clone();
- }
-
- public void clearStats(){
- lastAccessTS = 0;
- firstAccessTS = 0;
- accessCount.set(0);
- }
-
- public long trackAccess(String value){
- long count = accessCount.incrementAndGet();
- lastAccessTS = System.currentTimeMillis();
- if(firstAccessTS==0){
- firstAccessTS = lastAccessTS;
- }
- if(value!=null){
- synchronized (this) {
- if(trackedValues==null){
- trackedValues = new HashMap<>();
- }
- trackedValues.put(lastAccessTS, value);
- }
- }
- return count;
- }
-
- public String getKey(){
- return key;
- }
-
- public long getAccessCount() {
- return accessCount.get();
- }
-
- public String getAccessPoint() {
- return accessPoint;
- }
-
- public long getFirstAccessTS() {
- return firstAccessTS;
- }
-
- public long getLastAccessTS() {
- return lastAccessTS;
- }
-
- public String[] getStackTrace() {
- return stackTrace.clone();
- }
-
- public Map<Long, String> getTrackedValues(){
- synchronized (this) {
- if (trackedValues == null) {
- return Collections.emptyMap();
- } else {
- return new HashMap<>(trackedValues);
- }
- }
- }
-
- @Override
- public String toString() {
- return "AccessDetails{" +
- "key=" + key +
- ", accessCount=" + accessCount +
- ", lastAccessTS=" + lastAccessTS +
- ", firstAccessTS=" + firstAccessTS +
- ", stackTrace=" + Arrays.toString(stackTrace) +
- ", accessPoint='" + accessPoint + '\'' +
- ", trackedValues=" + trackedValues +
- '}';
- }
- }
-
-}
[16/24] incubator-tamaya git commit: Removed all modules from the
main repository. They will be reborn in separate ASF repository.
Posted by pl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/functions/src/main/java/org/apache/tamaya/functions/PropertySourceFunctions.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/PropertySourceFunctions.java b/modules/functions/src/main/java/org/apache/tamaya/functions/PropertySourceFunctions.java
deleted file mode 100644
index 93ff699..0000000
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/PropertySourceFunctions.java
+++ /dev/null
@@ -1,348 +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.functions;
-
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-
-/**
- * Accessor that provides useful functions along with configuration.
- */
-public final class PropertySourceFunctions {
- /**
- * Implementation of an empty propertySource.
- */
- private static final PropertySource EMPTY_PROPERTYSOURCE = new PropertySource() {
- @Override
- public int getOrdinal() {
- return 0;
- }
-
- @Override
- public String getName() {
- return "<empty>";
- }
-
- @Override
- public PropertyValue get(String key) {
- return null;
- }
-
- @Override
- public Map<String, String> getProperties() {
- return Collections.emptyMap();
- }
-
- @Override
- public boolean isScannable() {
- return true;
- }
-
- @Override
- public String toString() {
- return "PropertySource<empty>";
- }
- };
-
- /**
- * Private singleton constructor.
- */
- private PropertySourceFunctions() {
- }
-
- /**
- * Calculates the current section key and compares it to the given key.
- *
- * @param key the fully qualified entry key, not null
- * @param sectionKey the section key, not null
- * @return true, if the entry is exact in this section
- */
- public static boolean isKeyInSection(String key, String sectionKey) {
- int lastIndex = key.lastIndexOf('.');
- String curAreaKey = lastIndex > 0 ? key.substring(0, lastIndex) : "";
- return curAreaKey.equals(sectionKey);
- }
-
- /**
- * Calculates the current section key and compares it to the given section keys.
- *
- * @param key the fully qualified entry key, not null
- * @param sectionKeys the section keys, not null
- * @return true, if the entry is exact in this section
- */
- public static boolean isKeyInSections(String key, String... sectionKeys) {
- for (String areaKey : sectionKeys) {
- if (isKeyInSection(key, areaKey)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Return a query to evaluate the set with all fully qualified section names. This method should return the sections as accurate as possible,
- * but may not provide a complete set of sections that are finally accessible, especially when the underlying storage
- * does not support key iteration.
- *
- * @param properties properties to find sections in.
- * @return set with all sections, never {@code null}.
- */
- public static Set<String> sections(Map<String, String> properties) {
- final Set<String> areas = new HashSet<>();
- for (String s : properties.keySet()) {
- int index = s.lastIndexOf('.');
- if (index > 0) {
- areas.add(s.substring(0, index));
- } else {
- areas.add("<root>");
- }
- }
- return areas;
- }
-
- /**
- * Return a query to evaluate the set with all fully qualified section names, containing the transitive closure also including all
- * subarea names, regardless if properties are accessible or not. This method should return the sections as accurate
- * as possible, but may not provide a complete set of sections that are finally accessible, especially when the
- * underlying storage does not support key iteration.
- *
- * @param properties properties to find transitive sections in.
- * @return s set with all transitive sections, never {@code null}.
- */
- public static Set<String> transitiveSections(Map<String, String> properties) {
- final Set<String> transitiveAreas = new HashSet<>();
- for (String s : sections(properties)) {
- int index = s.lastIndexOf('.');
- if (index < 0) {
- transitiveAreas.add("<root>");
- } else {
- while (index > 0) {
- s = s.substring(0, index);
- transitiveAreas.add(s);
- index = s.lastIndexOf('.');
- }
- }
- }
- return transitiveAreas;
- }
-
- /**
- * Return a query to evaluate the set with all fully qualified section names, containing only the
- * sections that match the predicate and have properties attached. This method should return the sections as accurate as possible,
- * but may not provide a complete set of sections that are finally accessible, especially when the underlying storage
- * does not support key iteration.
- *
- * @param properties properties to find sections in.
- * @param predicate A predicate to determine, which sections should be returned, not {@code null}.
- * @return s set with all sections, never {@code null}.
- */
- public static Set<String> sections(Map<String, String> properties, final Predicate<String> predicate) {
- Set<String> treeSet = new TreeSet<>();
- for (String area : sections(properties)) {
- if (predicate.test(area)) {
- treeSet.add(area);
- }
- }
- return treeSet;
- }
-
- /**
- * Return a query to evaluate the set with all fully qualified section names, containing the transitive closure also including all
- * subarea names, regardless if properties are accessible or not. This method should return the sections as accurate as possible,
- * but may not provide a complete set of sections that are finally accessible, especially when the underlying storage
- * does not support key iteration.
- *
- * @param properties properties to find transitive sections in.
- * @param predicate A predicate to determine, which sections should be returned, not {@code null}.
- * @return s set with all transitive sections, never {@code null}.
- */
- public static Set<String> transitiveSections(Map<String, String> properties, Predicate<String> predicate) {
- Set<String> treeSet = new TreeSet<>();
- for (String area : transitiveSections(properties)) {
- if (predicate.test(area)) {
- treeSet.add(area);
- }
- }
- return treeSet;
- }
-
-
- /**
- * Creates a ConfigOperator that creates a Configuration containing only keys
- * that are contained in the given section (recursive). Hereby
- * the section key is stripped away from the Map of the resulting keys.
- *
- * @param properties properties to find recursive sections in.
- * @param sectionKeys the section keys, not null
- * @return the section configuration, with the areaKey stripped away.
- */
- public static Map<String, String> sectionsRecursive(Map<String, String> properties, String... sectionKeys) {
- return sectionRecursive(properties, true, sectionKeys);
- }
-
- /**
- * Creates a ConfigOperator that creates a Configuration containing only keys
- * that are contained in the given section (recursive).
- *
- * @param properties properties to find sections in.
- * @param sectionKeys the section keys, not null
- * @param stripKeys if set to true, the section key is stripped away fromMap the resulting key.
- * @return the section configuration, with the areaKey stripped away.
- */
- public static Map<String, String> sectionRecursive(Map<String, String> properties, boolean stripKeys, String... sectionKeys) {
- Map<String, String> result = new HashMap<>(properties.size());
- if (stripKeys) {
- for (Map.Entry<String, String> en : properties.entrySet()) {
- if (isKeyInSections(en.getKey(), sectionKeys)) {
- result.put(en.getKey(), en.getValue());
- }
- }
- } else {
- for (Map.Entry<String, String> en : properties.entrySet()) {
- if (isKeyInSections(en.getKey(), sectionKeys)) {
- result.put(stripSectionKeys(en.getKey(), sectionKeys), en.getValue());
- }
- }
- }
- return result;
- }
-
- /**
- * Strips the section key of the given absolute key, if it is one of the areaKeys passed.
- *
- * @param key the current key, not null.
- * @param areaKeys the areaKeys, not null.
- * @return the stripped key, or the original key (if no section was matching).
- */
- static String stripSectionKeys(String key, String... areaKeys) {
- for (String areaKey : areaKeys) {
- if (key.startsWith(areaKey + '.')) {
- return key.substring(areaKey.length() + 1);
- }
- }
- return key;
- }
-
- /**
- * Creates a ConfigOperator that adds the given items.
- *
- * @param propertySource source property source that is changed.
- * @param items the items to be added/replaced.
- * @param override if true, all items existing are overridden by the new ones passed.
- * @return the ConfigOperator, never null.
- */
- public static PropertySource addItems(PropertySource propertySource, final Map<String, String> items, final boolean override) {
- return new EnrichedPropertySource(propertySource, items, override);
- }
-
- /**
- * Creates an operator that adds items to the instance.
- *
- * @param propertySource source property source that is changed.
- * @param items the items, not null.
- * @return the operator, never null.
- */
- public static PropertySource addItems(PropertySource propertySource, Map<String, String> items) {
- return addItems(propertySource, items, false);
- }
-
- /**
- * Creates an operator that replaces the given items.
- *
- * @param propertySource source property source that is changed.
- * @param items the items.
- * @return the operator for replacing the items.
- */
- public static PropertySource replaceItems(PropertySource propertySource, Map<String, String> items) {
- return addItems(propertySource, items, true);
- }
-
- /**
- * Accesses an empty PropertySource.
- *
- * @return an empty PropertySource, never null.
- */
- public static PropertySource emptyPropertySource() {
- return EMPTY_PROPERTYSOURCE;
- }
-
- /**
- * Find all {@link PropertySource} instances managed by the current
- * {@link org.apache.tamaya.spi.ConfigurationContext} that are assignable to the given type.
- *
- * @param expression the regular expression to match the source's name.
- * @return the list of all {@link PropertySource} instances matching, never null.
- */
- public static Collection<? extends PropertySource> findPropertySourcesByName(String expression) {
- List result = new ArrayList<>();
- for (PropertySource src : ConfigurationProvider.getConfigurationContext().getPropertySources()) {
- if (src.getName().matches(expression)) {
- result.add(src);
- }
- }
- return result;
- }
-
- /**
- * Get a list of all {@link PropertySource} instances managed by the current
- * {@link org.apache.tamaya.spi.ConfigurationContext} that are assignable to the given type.
- *
- * @param <T> the type of the property source instances requested
- * @param type target type to filter for property sources.
- * @return the list of all {@link PropertySource} instances matching, never null.
- */
- public static <T> Collection<T> getPropertySources(Class<T> type) {
- List<T> result = new ArrayList<>();
- for (PropertySource src : ConfigurationProvider.getConfigurationContext().getPropertySources()) {
- if (type.isAssignableFrom(src.getClass())) {
- result.add((T) src);
- }
- }
- return result;
- }
-
- /**
- * Get a list of all {@link PropertySource} instances managed by the current
- * {@link org.apache.tamaya.spi.ConfigurationContext} that are assignable to the given type.
- *
- * @param <T> the type of the property source instances requested
- * @param type target type to filter for property sources.
- * @return the list of all {@link PropertySource} instances matching, never null.
- */
- public static <T> T getPropertySource(Class<T> type) {
- for (PropertySource src : ConfigurationProvider.getConfigurationContext().getPropertySources()) {
- if (type.isAssignableFrom(src.getClass())) {
- return (T) src;
- }
- }
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/functions/src/main/java/org/apache/tamaya/functions/ValueMappedPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/ValueMappedPropertySource.java b/modules/functions/src/main/java/org/apache/tamaya/functions/ValueMappedPropertySource.java
deleted file mode 100644
index a06b8b6..0000000
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/ValueMappedPropertySource.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.functions;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-
-
-/**
- * Property source which filters any key/values dynamically.
- */
-class ValueMappedPropertySource implements PropertySource{
-
- private final String name;
- private final PropertyMapper valueFilter;
- private final PropertySource source;
-
- public ValueMappedPropertySource(String name, PropertyMapper valueFilter, PropertySource current) {
- this.name = name!=null?name:"<valueFiltered> -> name="+current.getName()+", valueFilter="+valueFilter.toString();
- this.valueFilter = valueFilter;
- this.source = Objects.requireNonNull(current);
- }
-
- @Override
- public int getOrdinal() {
- return source.getOrdinal();
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public PropertyValue get(String key) {
- PropertyValue value = this.source.get(key);
- if(value!=null) {
- return PropertyValue.of(key, valueFilter.mapProperty(key, value.getValue()), getName());
- }
- return null;
- }
-
- @Override
- public Map<String, String> getProperties() {
- Map<String, String> map = new HashMap<>();
- for(Map.Entry<String,String> entry:source.getProperties().entrySet()) {
- map.put(entry.getKey(), valueFilter.mapProperty(entry.getKey(), entry.getValue()));
- }
- return map;
- }
-
- @Override
- public boolean isScannable() {
- return source.isScannable();
- }
-
- @Override
- public String toString() {
- return "ValueMappedPropertySource{" +
- "source=" + source.getName() +
- ", name='" + name + '\'' +
- ", valueFilter=" + valueFilter +
- '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/functions/src/main/java/org/apache/tamaya/functions/package-info.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/package-info.java b/modules/functions/src/main/java/org/apache/tamaya/functions/package-info.java
deleted file mode 100644
index c602920..0000000
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-/**
- * Contains additional useful operators and queries.
- */
-package org.apache.tamaya.functions;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/functions/src/test/java/org/apache/tamaya/functions/ConfigurationFunctionsTest.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/test/java/org/apache/tamaya/functions/ConfigurationFunctionsTest.java b/modules/functions/src/test/java/org/apache/tamaya/functions/ConfigurationFunctionsTest.java
deleted file mode 100644
index 93a7da9..0000000
--- a/modules/functions/src/test/java/org/apache/tamaya/functions/ConfigurationFunctionsTest.java
+++ /dev/null
@@ -1,143 +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.functions;
-
-import org.apache.tamaya.Configuration;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Created by Anatole on 01.10.2015.
- */
-public class ConfigurationFunctionsTest {
-
- @Test
- public void testFilter() throws Exception {
-// TODO implement test
- }
-
- @Test
- public void testMap() throws Exception {
-// TODO implement test
- }
-
- @Test
- public void testSection() throws Exception {
-// TODO implement test
- }
-
- @Test
- public void testSection1() throws Exception {
-// TODO implement test
- }
-
- @Test
- public void testIsKeyInSection() throws Exception {
-// TODO implement test
- }
-
- @Test
- public void testIsKeyInSections() throws Exception {
-// TODO implement test
- }
-
- @Test
- public void testSections() throws Exception {
-// TODO implement test
- }
-
- @Test
- public void testTransitiveSections() throws Exception {
-// TODO implement test
- }
-
- @Test
- public void testSections1() throws Exception {
-// TODO implement test
- }
-
- @Test
- public void testTransitiveSections1() throws Exception {
-// TODO implement test
- }
-
- @Test
- public void testSectionsRecursive() throws Exception {
-// TODO implement test
- }
-
- @Test
- public void testCombine() throws Exception {
-// TODO implement test
- }
-
- @Test
- public void testPropertySourceFrom() throws Exception {
-// TODO implement test
- }
-
- @Test
- public void testSectionRecursive() throws Exception {
-// TODO implement test
- }
-
- @Test
- public void testJsonInfo() throws Exception {
-// TODO implement test
- }
-
- @Test
- public void testJsonInfo1() throws Exception {
-// TODO implement test
- }
-
- @Test
- public void testXmlInfo() throws Exception {
-// TODO implement test
- }
-
- @Test
- public void testXmlInfo1() throws Exception {
-// TODO implement test
- }
-
- @Test
- public void testTextInfo() throws Exception {
-// TODO implement test
- }
-
- @Test
- public void testTextInfo1() throws Exception {
-// TODO implement test
- }
-
- @Test
- public void testAddItems() throws Exception {
-// TODO implement test
- }
-
- @Test
- public void testEmptyConfiguration() throws Exception {
- Configuration ps = ConfigurationFunctions.emptyConfiguration();
- assertNotNull(ps);
- assertNotNull(ps.getProperties());
- assertTrue(ps.getProperties().isEmpty());
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/functions/src/test/java/org/apache/tamaya/functions/PropertySourceFunctionsTest.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/test/java/org/apache/tamaya/functions/PropertySourceFunctionsTest.java b/modules/functions/src/test/java/org/apache/tamaya/functions/PropertySourceFunctionsTest.java
deleted file mode 100644
index 2e90fbc..0000000
--- a/modules/functions/src/test/java/org/apache/tamaya/functions/PropertySourceFunctionsTest.java
+++ /dev/null
@@ -1,106 +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.functions;
-
-import org.apache.tamaya.functions.PropertySourceFunctions;
-import org.apache.tamaya.spi.PropertySource;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Created by Anatole on 01.10.2015.
- */
-public class PropertySourceFunctionsTest {
-
- @Test
- public void testAddMetaData() throws Exception {
-// TODO implement test
- }
-
- @Test
- public void testIsKeyInSection() throws Exception {
-// TODO implement test
- }
-
- @Test
- public void testIsKeyInSections() throws Exception {
-// TODO implement test
- }
-
- @Test
- public void testSections() throws Exception {
-// TODO implement test
- }
-
- @Test
- public void testTransitiveSections() throws Exception {
-// TODO implement test
- }
-
- @Test
- public void testSections1() throws Exception {
-// TODO implement test
- }
-
- @Test
- public void testTransitiveSections1() throws Exception {
-// TODO implement test
- }
-
- @Test
- public void testSectionsRecursive() throws Exception {
-// TODO implement test
- }
-
- @Test
- public void testSectionRecursive() throws Exception {
-// TODO implement test
- }
-
- @Test
- public void testStripSectionKeys() throws Exception {
-// TODO implement test
- }
-
- @Test
- public void testAddItems() throws Exception {
-// TODO implement test
- }
-
- @Test
- public void testAddItems1() throws Exception {
-// TODO implement test
- }
-
- @Test
- public void testReplaceItems() throws Exception {
-// TODO implement test
- }
-
- @Test
- public void testEmptyPropertySource() throws Exception {
- PropertySource ps = PropertySourceFunctions.emptyPropertySource();
- assertNotNull(ps);
- assertNotNull(ps.getProperties());
- assertTrue(ps.getProperties().isEmpty());
- assertEquals(ps.getName(), "<empty>" );
- assertTrue(ps.isScannable());
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/injection-api/pom.xml
----------------------------------------------------------------------
diff --git a/modules/injection-api/pom.xml b/modules/injection-api/pom.xml
deleted file mode 100644
index 1eb11b8..0000000
--- a/modules/injection-api/pom.xml
+++ /dev/null
@@ -1,79 +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.
--->
-<project xmlns="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">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-extensions</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>tamaya-injection-api</artifactId>
- <name>Apache Tamaya Modules - Injection Support API</name>
- <packaging>bundle</packaging>
-
- <properties>
- <jdkVersion>1.7</jdkVersion>
- <geronimo-atinject-1.0-spec.version>1.0</geronimo-atinject-1.0-spec.version>
- <geronimo-jcdi-1.1-spec.version>1.0</geronimo-jcdi-1.1-spec.version>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-api</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-atinject_1.0_spec</artifactId>
- <version>${geronimo-atinject-1.0-spec.version}</version>
- <scope>provided</scope>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-jcdi_1.1_spec</artifactId>
- <version>${geronimo-jcdi-1.1-spec.version}</version>
- <scope>provided</scope>
- <optional>true</optional>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.tamaya.inject.api,
- org.apache.tamaya.inject.spi
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/BaseDynamicValue.java
----------------------------------------------------------------------
diff --git a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/BaseDynamicValue.java b/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/BaseDynamicValue.java
deleted file mode 100644
index 2f8c559..0000000
--- a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/BaseDynamicValue.java
+++ /dev/null
@@ -1,125 +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.inject.api;
-
-
-import java.io.Serializable;
-
-/**
- * <p>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 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.</p>
- *
- * <p>Types of this interface can be used as injection targets in injected beans or as template resiult on configuration
- * templates.</p>
- *
- * <h3>Implementation Specification</h3>
- * Implementation of this interface must be
- * <ul>
- * <li>Serializable, when also the item stored is serializable</li>
- * <li>Thread safe</li>
- * </ul>
- *
- * @param <T> The type of the value.
- */
-public abstract class BaseDynamicValue<T> implements DynamicValue<T>, Serializable {
-
- private static final long serialVersionUID = 1L;
-
- /**
- * Performs a commit, if necessary, and returns the current value.
- *
- * @return the non-null value held by this {@code DynamicValue}
- * @throws org.apache.tamaya.ConfigException if there is no value present
- * @see DynamicValue#isPresent()
- */
- public T commitAndGet() {
- commit();
- return get();
- }
-
- /**
- * Return {@code true} if there is a value present, otherwise {@code false}.
- *
- * @return {@code true} if there is a value present, otherwise {@code false}
- */
- public boolean isPresent() {
- return get() != null;
- }
-
-
- /**
- * Return the value if present, otherwise return {@code other}.
- *
- * @param other the value to be returned if there is no value present, may
- * be null
- * @return the value, if present, otherwise {@code other}
- */
- public T orElse(T other) {
- T value = get();
- if (value == null) {
- return other;
- }
- return value;
- }
-
- /**
- * Return the value if present, otherwise invoke {@code other} and return
- * the result of that invocation.
- *
- * @param other a {@code ConfiguredItemSupplier} whose result is returned if no value
- * is present
- * @return the value if present otherwise the result of {@code other.get()}
- * @throws NullPointerException if value is not present and {@code other} is
- * null
- */
- public T orElseGet(ConfiguredItemSupplier<? extends T> other) {
- T value = get();
- if (value == null) {
- return other.get();
- }
- return value;
- }
-
- /**
- * Return the contained value, if present, otherwise throw an exception
- * to be created by the provided supplier.
- * <p>
- * NOTE A method reference to the exception constructor with an empty
- * argument list can be used as the supplier. For example,
- * {@code IllegalStateException::new}
- *
- * @param <X> Type of the exception to be thrown
- * @param exceptionSupplier The supplier which will return the exception to
- * be thrown
- * @return the present value
- * @throws X if there is no value present
- * @throws NullPointerException if no value is present and
- * {@code exceptionSupplier} is null
- */
- public <X extends Throwable> T orElseThrow(ConfiguredItemSupplier<? extends X> exceptionSupplier) throws X {
- T value = get();
- if (value == null) {
- throw exceptionSupplier.get();
- }
- return value;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/Config.java
----------------------------------------------------------------------
diff --git a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/Config.java b/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/Config.java
deleted file mode 100644
index 2484934..0000000
--- a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/Config.java
+++ /dev/null
@@ -1,93 +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.inject.api;
-
-
-import javax.enterprise.util.Nonbinding;
-import javax.inject.Qualifier;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/** todo The author of this should fix this invalid Javadoc. Oliver B. Fischer, 2015-12-27 */
-///**
-// * Annotation to enable injection current a configured property or define the returned data for
-// * a configuration template method. Hereby this annotation can be used in multiple ways and combined
-// * with other annotations such as {@link ConfigDefault}, {@link WithConfigOperator}, {@link WithPropertyConverter}.
-// *
-// * Below the most simple variant current a configured class is given:
-// * {@code
-// * pubic class ConfiguredItem{
-// *
-// * @ConfiguredProperty
-// * private String aValue;
-// * }
-// * When this class is configured, e.g. by passing it to {@link org.apache.tamaya.Configuration#configure(Object)},
-// * the following is happening:
-// * <ul>
-// * <li>The current valid Configuration is evaluated by calling {@code Configuration cfg = ConfigurationProvider.getConfiguration();}</li>
-// * <li>The current possible property keys are evaluated by calling {@code cfg.get("aValue");}</li>
-// * <li>if not successful, and a @ConfigDefault annotation is present, the default value is used.
-// * <li>If no value could be evaluated a ({@link org.apache.tamaya.ConfigException} is thrown.</li>
-// * <li>On success, since no type conversion is involved, the value is injected.</li>
-// * </ul>
-// *
-// * In the next example we explicitly define the property keys:
-// * {@code
-// * @ConfigDefaultSections("section1")
-// * pubic class ConfiguredItem{
-// *
-// * @ConfiguredProperty({"b", "[a.b.deprecated.keys]", "a"})
-// * @ConfigDefault("myDefaultValue")
-// * private String aValue;
-// * }
-// *
-// * Within this example we evaluate multiple possible keys (section1.b, a.b.deprecated.keys, section1.a). Evaluation is
-// * aborted if a key could be successfully resolved. Hereby the ordering current the annotations define the ordering
-// * current resolution, so in the example above
-// * resolution equals to {@code "section1.b", "a.b.deprecated.keys", "section1.a"}. If no value has bee found,
-// * the configured default {@code myDefaultValue} is returned.
-// */
-@Qualifier
-@Retention(RetentionPolicy.RUNTIME)
-@Target(value = { ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER })
-public @interface Config {
-
- /**
- * Get the property names to be used. Hereby the first non null keys evaluated is injected as property keys.
- *
- * @return the property names, not null. If missing the field or method name being injected is used by default.
- */
- @Nonbinding
- String[] value() default {};
-
- /**
- * The default value to be injected, if none of the configuration keys could be resolved. If no key has been
- * resolved and no default value is defined, it is handled as a deployment error. Depending on the extension loaded
- * default values can be fixed Strings or even themselves resolvable. For typed configuration of type T entries
- * that are not Strings the default value must be a valid input to the corresponding
- * {@link org.apache.tamaya.spi.PropertyConverter}.
- *
- * @return default value used in case resolution fails.
- */
- @Nonbinding
- String defaultValue() default "";
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/ConfigAutoInject.java
----------------------------------------------------------------------
diff --git a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/ConfigAutoInject.java b/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/ConfigAutoInject.java
deleted file mode 100644
index 1ed659e..0000000
--- a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/ConfigAutoInject.java
+++ /dev/null
@@ -1,36 +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.inject.api;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotation to control injection of a configured bean. The configuration keys
- * to be resolved are basically determined by the {@link Config}
- * annotation(s). When this annotation is added the injection systems tries to inject all
- * fields found, also including fields not annotated with {@code @ConfigProperty}.
- * Fields not to be injected ccan be annotated with {@code @NoConfig} to exclude them
- * being eleceted for injection.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(value = { ElementType.TYPE })
-public @interface ConfigAutoInject {}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/ConfigDefaultSections.java
----------------------------------------------------------------------
diff --git a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/ConfigDefaultSections.java b/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/ConfigDefaultSections.java
deleted file mode 100644
index 2037de6..0000000
--- a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/ConfigDefaultSections.java
+++ /dev/null
@@ -1,44 +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.inject.api;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/** todo The author of this should fix this invalid Javadoc. Oliver B. Fischer, 2015-12-27 */
-///**
-// * Annotation to control injection and resolution current a configured bean. The configuration keys
-// * to be resolved are basically determined by the {@link org.apache.tamaya.inject.ConfigProperty}
-// * annotation(s). Nevertheless these annotations can also have relative key names. This annotation allows
-// * to define a configuration area that is prefixed to all relative configuration keys within the
-// * corresponding class/template interface.
-// */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(value = { ElementType.TYPE })
-public @interface ConfigDefaultSections {
-
- /**
- * Allows to declare an section names that are prepended to resolve relative configuration keys.
- * @return the section names to used for key resolution.
- */
- String[] value() default {};
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/ConfiguredItemSupplier.java
----------------------------------------------------------------------
diff --git a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/ConfiguredItemSupplier.java b/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/ConfiguredItemSupplier.java
deleted file mode 100644
index 5e57121..0000000
--- a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/ConfiguredItemSupplier.java
+++ /dev/null
@@ -1,41 +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.inject.api;
-
-/**
- * Represents a supplier of results.
- *
- * There is no requirement that a new or distinct result be returned each
- * time the supplier is invoked.
- *
- * This is a functional interface,
- * whose functional method is {@link #get()}.
- *
- * @param <T> the type of results supplied by this supplier
- */
-//@FunctionalInterface
-public interface ConfiguredItemSupplier<T> {
-
- /**
- * Gets a result.
- *
- * @return a result
- */
- T get();
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/DynamicValue.java
----------------------------------------------------------------------
diff --git a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/DynamicValue.java b/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/DynamicValue.java
deleted file mode 100644
index 4cc29da..0000000
--- a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/DynamicValue.java
+++ /dev/null
@@ -1,161 +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.inject.api;
-
-import java.beans.PropertyChangeListener;
-
-
-/**
- * <p>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 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.</p>
- *
- * <p>Types of this interface can be used as injection targets in injected beans or as template resiult on configuration
- * templates.</p>
- *
- * <h3>Implementation Specification</h3>
- * Implementation of this interface must be
- * <ul>
- * <li>Serializable, when also the item stored is serializable</li>
- * <li>Thread safe</li>
- * </ul>
- *
- * @param <T> The type of the value.
- */
-public interface DynamicValue<T> {
-
- /**
- * Performs a commit, if necessary, and returns the current value.
- *
- * @return the non-null value held by this {@code DynamicValue}
- * @throws org.apache.tamaya.ConfigException if there is no value present
- *
- * @see DynamicValue#isPresent()
- */
- T commitAndGet();
-
- /**
- * Commits a new value that has not been committed yet, make it the new value of the instance. On change any
- * registered listeners will be triggered.
- */
- void commit();
-
- /**
- * Access the {@link UpdatePolicy} used for updating this value.
- * @return the update policy, never null.
- */
- UpdatePolicy getUpdatePolicy();
-
- /**
- * Add a listener to be called as weak reference, when this value has been changed.
- * @param l the listener, not null
- */
- void addListener(PropertyChangeListener l);
-
- /**
- * Removes a listener to be called, when this value has been changed.
- * @param l the listner to be removed, not null
- */
- void removeListener(PropertyChangeListener l);
-
- /**
- * If a value is present in this {@code DynamicValue}, returns the value,
- * otherwise throws {@code ConfigException}.
- *
- * @return the non-null value held by this {@code Optional}
- * @throws org.apache.tamaya.ConfigException if there is no value present
- *
- * @see DynamicValue#isPresent()
- */
- T get();
-
- /**
- * Method to check for and apply a new value. Depending on the {@link UpdatePolicy}
- * the value is immediately or deferred visible (or it may even be ignored completely).
- * @return true, if a new value has been detected. The value may not be visible depending on the current
- * {@link UpdatePolicy} in place.
- */
- boolean updateValue();
-
- /**
- * Evaluates the current value dynamically from the underlying configuration.
- * @return the current actual value, or null.
- */
- T evaluateValue();
-
- /**
- * Sets a new {@link UpdatePolicy}.
- * @param updatePolicy the new policy, not null.
- */
- void setUpdatePolicy(UpdatePolicy updatePolicy);
-
- /**
- * Access a new value that has not yet been committed.
- * @return the uncommitted new value, or null.
- */
- T getNewValue();
-
- /**
- * Return {@code true} if there is a value present, otherwise {@code false}.
- *
- * @return {@code true} if there is a value present, otherwise {@code false}
- */
- boolean isPresent();
-
- /**
- * Return the value if present, otherwise return {@code other}.
- *
- * @param other the value to be returned if there is no value present, may
- * be null
- * @return the value, if present, otherwise {@code other}
- */
- T orElse(T other);
-
- /**
- * Return the value if present, otherwise invoke {@code other} and return
- * the result of that invocation.
- *
- * @param other a {@code ConfiguredItemSupplier} whose result is returned if no value
- * is present
- * @return the value if present otherwise the result of {@code other.get()}
- * @throws NullPointerException if value is not present and {@code other} is
- * null
- */
- T orElseGet(ConfiguredItemSupplier<? extends T> other);
-
- /**
- * Return the contained value, if present, otherwise throw an exception
- * to be created by the provided supplier.
- *
- * NOTE A method reference to the exception constructor with an empty
- * argument list can be used as the supplier. For example,
- * {@code IllegalStateException::new}
- *
- * @param <X> Type of the exception to be thrown
- * @param exceptionSupplier The supplier which will return the exception to
- * be thrown
- * @return the present value
- * @throws X if there is no value present
- * @throws NullPointerException if no value is present and
- * {@code exceptionSupplier} is null
- */
- <X extends Throwable> T orElseThrow(ConfiguredItemSupplier<? extends X> exceptionSupplier) throws X;
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/InjectionUtils.java
----------------------------------------------------------------------
diff --git a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/InjectionUtils.java b/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/InjectionUtils.java
deleted file mode 100644
index a010e96..0000000
--- a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/InjectionUtils.java
+++ /dev/null
@@ -1,127 +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.inject.api;
-
-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.List;
-import java.util.ListIterator;
-
-/**
- * Utility class with several commonly used functions.
- */
-public final class InjectionUtils {
-
- private InjectionUtils(){}
-
-
- /**
- * Collects all keys to be be accessed as defined by any annotations of type
- * {@link ConfigDefaultSections}, {@link Config}.
- * @param field the (optionally) annotated field instance
- * @return the regarding key list to be accessed fomr the {@link org.apache.tamaya.Configuration}.
- */
- public static List<String> getKeys(Field field) {
- ConfigDefaultSections areasAnnot = field.getDeclaringClass().getAnnotation(ConfigDefaultSections.class);
- return InjectionUtils.evaluateKeys(field, areasAnnot, field.getAnnotation(Config.class));
- }
-
- /**
- * Collects all keys to be be accessed as defined by any annotations of type
- * {@link ConfigDefaultSections}, {@link Config}.
- * @param method the (optionally) annotated method instance
- * @return the regarding key list to be accessed fomr the {@link org.apache.tamaya.Configuration}.
- */
- public static List<String> getKeys(Method method) {
- ConfigDefaultSections areasAnnot = method.getDeclaringClass().getAnnotation(ConfigDefaultSections.class);
- return InjectionUtils.evaluateKeys(method, areasAnnot, method.getAnnotation(Config.class));
- }
-
- /**
- * Evaluates all absolute configuration keys based on the member name found.
- *
- * @param member member to analyze.
- * @param areasAnnot the (optional) annotation defining areas to be looked up.
- * @return the list of current keys in order how they should be processed/looked up.
- */
- public static List<String> evaluateKeys(Member member, ConfigDefaultSections areasAnnot) {
- List<String> 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);
- keys.add(member.getDeclaringClass().getSimpleName() + '.' + mainKey);
- }
- return keys;
- }
-
- /**
- * Evaluates all absolute configuration keys based on the annotations found in a class.
- *
- * @param member member to analyze.
- * @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<String> evaluateKeys(Member member, ConfigDefaultSections areasAnnot, Config propertyAnnotation) {
- if(propertyAnnotation==null){
- return evaluateKeys(member, areasAnnot);
- }
- List<String> keys = new ArrayList<>(Arrays.asList(propertyAnnotation.value()));
- if (keys.isEmpty()) {
- keys.add(member.getName());
- }
- ListIterator<String> 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 && areasAnnot.value().length>0) {
- // 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;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/LoadPolicy.java
----------------------------------------------------------------------
diff --git a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/LoadPolicy.java b/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/LoadPolicy.java
deleted file mode 100644
index b9540fd..0000000
--- a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/LoadPolicy.java
+++ /dev/null
@@ -1,42 +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.inject.api;
-
-/**
- * Available policies that describe how changes affecting configured values are published/reinjected
- * for a {@link DynamicValue}.
- * The policy also affects the cases were any configured listeners/listener methods are called for
- * propagation current configuration changes.
- */
-public enum LoadPolicy {
- /**
- * The configuration keys is evaluated once, when the owning component is loaded/configured, but never updated later.
- */
- INITIAL,
- /**
- * The configuration keys is evaluated exactly once on its first access/use lazily, but never updated later.
- * @see DynamicValue#get()
- * @see DynamicValue#commitAndGet()
- */
- LAZY,
- /**
- * The configuration value is evaluated evertime it is accessed.
- */
- ALWAYS
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/NoConfig.java
----------------------------------------------------------------------
diff --git a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/NoConfig.java b/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/NoConfig.java
deleted file mode 100644
index c5234d3..0000000
--- a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/NoConfig.java
+++ /dev/null
@@ -1,36 +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.inject.api;
-
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * This is a small marker annotations to inform Tamaya that the annotated element should never be injected with
- * configured data. This is useful because by default Tamaya tries to lookup and inject configuration also by
- * using property or method names without annotations. With that annotation none of these will be happen.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(value = { ElementType.FIELD, ElementType.METHOD })
-public @interface NoConfig {
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/UpdatePolicy.java
----------------------------------------------------------------------
diff --git a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/UpdatePolicy.java b/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/UpdatePolicy.java
deleted file mode 100644
index 231b9b9..0000000
--- a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/UpdatePolicy.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.inject.api;
-
-/**
- * Policy to control how new values are applied to a {@link DynamicValue}.
- */
-public enum UpdatePolicy {
- /** New values are applied immedately and registered listeners are informed about the change. */
- IMMEDEATE,
- /** New values or not applied, but stored in the newValue property. Explcit call to DynamicValue#commit
- of DynamicValue#commitAndGet are required to accept the change and inform the listeners about the change.
- * Registered listeners will be informed, when the commit was performed explicitly.
- */
- EXPLCIT,
- /**
- * New values are always immedately discarded, listeners are not triggered.
- */
- NEVER,
- /**
- * All listeners are informed about the change encountered, but the value will not be applied.
- */
- LOG_ONLY
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/WithConfigOperator.java
----------------------------------------------------------------------
diff --git a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/WithConfigOperator.java b/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/WithConfigOperator.java
deleted file mode 100644
index 6630e53..0000000
--- a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/WithConfigOperator.java
+++ /dev/null
@@ -1,45 +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.inject.api;
-
-import org.apache.tamaya.ConfigOperator;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotation to define an configuration operator to be used before accessing a configured key.
- * This allows filtering the current configuration, e.g. to realize views or ensure security
- * constraints.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(value = {ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER})
-public @interface WithConfigOperator {
-
- /**
- * Define a custom adapter that should be used to adapt the configuration entry injected. This overrides any
- * general org.apache.tamaya.core.internal registered. If no adapter is defined (default) and no corresponding adapter is
- * registered, it is handled as a deployment error.
- * @return adapter used to transform the configuration entry.
- */
- Class<? extends ConfigOperator> value();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/WithPropertyConverter.java
----------------------------------------------------------------------
diff --git a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/WithPropertyConverter.java b/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/WithPropertyConverter.java
deleted file mode 100644
index 499360c..0000000
--- a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/WithPropertyConverter.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.inject.api;
-
-
-import org.apache.tamaya.spi.PropertyConverter;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotation to define a type adapter to be used before injecting a configured key, or for applying changes.
- * This will override any other adapter for performing the type conversion before
- * injecting the field keys.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(value = {ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
-public @interface WithPropertyConverter {
-
- /**
- * Define a custom adapter or codec that should be used to adapt the configuration entry injected. This overrides any
- * general org.apache.tamaya.core.internal registered. If no adapter is defined (default) and no corresponding adapter is
- * registered, it is handled as a deployment error.
- * @return adapter used to change the configuration entry.
- */
- Class<? extends PropertyConverter<?>> value();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/package-info.java
----------------------------------------------------------------------
diff --git a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/package-info.java b/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/package-info.java
deleted file mode 100644
index b5d8bc3..0000000
--- a/modules/injection-api/src/main/java/org/apache/tamaya/inject/api/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-/**
- * Common njection API.
- */
-package org.apache.tamaya.inject.api;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/injection-api/src/main/java/org/apache/tamaya/inject/spi/ConfiguredField.java
----------------------------------------------------------------------
diff --git a/modules/injection-api/src/main/java/org/apache/tamaya/inject/spi/ConfiguredField.java b/modules/injection-api/src/main/java/org/apache/tamaya/inject/spi/ConfiguredField.java
deleted file mode 100644
index 94c0091..0000000
--- a/modules/injection-api/src/main/java/org/apache/tamaya/inject/spi/ConfiguredField.java
+++ /dev/null
@@ -1,68 +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.inject.spi;
-
-import org.apache.tamaya.Configuration;
-
-import java.lang.reflect.Field;
-import java.util.Collection;
-
-/**
- * Abstract model of an field used to inject configuration.
- */
-public interface ConfiguredField {
-
- /**
- * Get the field's type.
- * @return the field type, never null.
- */
- Class<?> getType();
-
- /**
- * Get a list of all target keys for the given field. The first resolvable key normally determines the
- * configuration value injected.
- * @return a list of evaluated keys.
- */
- Collection<String> getConfiguredKeys();
-
- /**
- * Get the field's name.
- * @return the name, not null.
- */
- String getName();
-
- /**
- * Get the field's full signature.
- * @return the signature, not null.
- */
- String getSignature();
-
- /**
- * Get the annotated field.
- * @return the field, not null.
- */
- Field getAnnotatedField();
-
- /**
- * Actually calls the annotated method on the instance, hereby passing the configuration values evaluated.
- * @param instance the instance, not null.
- * @param config the configuration, not null.
- */
- void configure(Object instance, Configuration config);
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/injection-api/src/main/java/org/apache/tamaya/inject/spi/ConfiguredMethod.java
----------------------------------------------------------------------
diff --git a/modules/injection-api/src/main/java/org/apache/tamaya/inject/spi/ConfiguredMethod.java b/modules/injection-api/src/main/java/org/apache/tamaya/inject/spi/ConfiguredMethod.java
deleted file mode 100644
index 128946e..0000000
--- a/modules/injection-api/src/main/java/org/apache/tamaya/inject/spi/ConfiguredMethod.java
+++ /dev/null
@@ -1,70 +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.inject.spi;
-
-import org.apache.tamaya.Configuration;
-
-import java.lang.reflect.Method;
-import java.util.Collection;
-
-/**
- * Abstract model of an method used to inject configuration.
- */
-public interface ConfiguredMethod {
-
- /**
- * Get the key required to be evaluated.
- * @return the configured keys.
- */
- Collection<String> getConfiguredKeys();
-
- /**
- * Get the methods input parameter types.
- * @return the method param types, not null.
- */
- Class<?>[] getParameterTypes();
-
- /**
- * Get the underlying method reflection type.
- * @return the method element.
- */
- Method getAnnotatedMethod();
-
- /**
- * Get the method's name, e.g. {@code setName}.
- * @return the name, never null.
- */
- String getName();
-
- /**
- * Get the methods signature, e.g. {@code void setName(String)}.
- * @return he signature, never null.
- */
- String getSignature();
-
- /**
- * This method actually configures the given method on a instance of its parent type.
- * This evaluates the initial key closure and applies changes on the field.
- *
- * @param instance the target instance, not null.
- * @param config the configuration, not null.
- * @throws org.apache.tamaya.ConfigException if evaluation or conversion failed.
- */
- void configure(Object instance, Configuration config);
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/injection-api/src/main/java/org/apache/tamaya/inject/spi/ConfiguredType.java
----------------------------------------------------------------------
diff --git a/modules/injection-api/src/main/java/org/apache/tamaya/inject/spi/ConfiguredType.java b/modules/injection-api/src/main/java/org/apache/tamaya/inject/spi/ConfiguredType.java
deleted file mode 100644
index 0f81dc7..0000000
--- a/modules/injection-api/src/main/java/org/apache/tamaya/inject/spi/ConfiguredType.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.inject.spi;
-
-import org.apache.tamaya.Configuration;
-
-import java.util.Collection;
-
-/**
- * Abstract model of an type used to inject configuration. This also includes instances passed programmatically.
- */
-public interface ConfiguredType{
-
- /**
- * Get the type's class.
- * @return the base type.
- */
- Class getType();
-
- /**
- * Get the type's name.
- * @return the type's name.
- */
- String getName();
-
- /**
- * Get the registered configured fields.
- * @return the registered configured fields, never null.
- */
- Collection<ConfiguredField> getConfiguredFields();
-
- /**
- * Get the registered configured methods.
- * @return the registered configured methods, never null.
- */
- Collection<ConfiguredMethod> getConfiguredMethods();
-
- /**
- * This method actually configures an instance using the given configuration data.
- *
- * @param instance The instance to be configured, not null.
- * @param config the target config, not null.
- */
- void configure(Object instance, Configuration config);
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/injection/pom.xml
----------------------------------------------------------------------
diff --git a/modules/injection/pom.xml b/modules/injection/pom.xml
deleted file mode 100644
index eae751c..0000000
--- a/modules/injection/pom.xml
+++ /dev/null
@@ -1,102 +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.
--->
-<project xmlns="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">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-extensions</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>tamaya-injection</artifactId>
- <name>Apache Tamaya Modules - Injection Support</name>
- <packaging>bundle</packaging>
-
- <properties>
- <jdkVersion>1.7</jdkVersion>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-api</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-injection-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-core</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-resolver</artifactId>
- <version>${project.version}</version>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-builder</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-events</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>java-hamcrest</artifactId>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.tamaya.inject
- </Export-Package>
- <Private-Package>
- org.apache.tamaya.inject.internal
- </Private-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/injection/src/main/java/org/apache/tamaya/inject/ConfigurationInjection.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/ConfigurationInjection.java b/modules/injection/src/main/java/org/apache/tamaya/inject/ConfigurationInjection.java
deleted file mode 100644
index 79d6218..0000000
--- a/modules/injection/src/main/java/org/apache/tamaya/inject/ConfigurationInjection.java
+++ /dev/null
@@ -1,42 +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.inject;
-
-import org.apache.tamaya.spi.ServiceContextManager;
-
-/**
- * Singleton accessor class for accessing {@link ConfigurationInjector} instances.
- */
-public final class ConfigurationInjection {
-
- /**
- * Singleton constructor.
- */
- private ConfigurationInjection() {
- }
-
- /**
- * Get the current injector instance.
- *
- * @return the current injector, not null.
- */
- public static ConfigurationInjector getConfigurationInjector() {
- return ServiceContextManager.getServiceContext().getService(ConfigurationInjector.class);
- }
-}
[19/24] incubator-tamaya git commit: Removed all modules from the
main repository. They will be reborn in separate ASF repository.
Posted by pl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/main/resources/META-INF/services/org.apache.tamaya.events.ConfigEventListener
----------------------------------------------------------------------
diff --git a/modules/events/src/main/resources/META-INF/services/org.apache.tamaya.events.ConfigEventListener b/modules/events/src/main/resources/META-INF/services/org.apache.tamaya.events.ConfigEventListener
deleted file mode 100644
index f9942c1..0000000
--- a/modules/events/src/main/resources/META-INF/services/org.apache.tamaya.events.ConfigEventListener
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy current the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-org.apache.tamaya.events.internal.DefaultConfigurationContextChangeListener
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/main/resources/META-INF/services/org.apache.tamaya.events.spi.ConfigEventManagerSpi
----------------------------------------------------------------------
diff --git a/modules/events/src/main/resources/META-INF/services/org.apache.tamaya.events.spi.ConfigEventManagerSpi b/modules/events/src/main/resources/META-INF/services/org.apache.tamaya.events.spi.ConfigEventManagerSpi
deleted file mode 100644
index d45dc43..0000000
--- a/modules/events/src/main/resources/META-INF/services/org.apache.tamaya.events.spi.ConfigEventManagerSpi
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy current the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-org.apache.tamaya.events.internal.DefaultConfigEventManagerSpi
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/test/java/org/apache/tamaya/events/ChangeableGlobalPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/events/src/test/java/org/apache/tamaya/events/ChangeableGlobalPropertySource.java b/modules/events/src/test/java/org/apache/tamaya/events/ChangeableGlobalPropertySource.java
deleted file mode 100644
index 0384064..0000000
--- a/modules/events/src/test/java/org/apache/tamaya/events/ChangeableGlobalPropertySource.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.events;
-
-import org.apache.tamaya.core.propertysource.BasePropertySource;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * PropertySource implementation that accesses properties that are statically stored.
- */
-public class ChangeableGlobalPropertySource extends BasePropertySource{
-
- private static final Map<String,String> STORED_ENTRIES = new ConcurrentHashMap<>();
-
- @Override
- public String getName() {
- return getClass().getSimpleName();
- }
-
- @Override
- public Map<String, String> getProperties() {
- return null;
- }
-
- /**
- * Put a value (globally) into this property source.
- * @param key the key, not null
- * @param value the value, not null
- * @return the entry replaced, or null.
- */
- public static String put(String key, String value){
- return STORED_ENTRIES.put(key,value);
- }
-
- /**
- * Put all the properties, overriding any existing ones with the same key.
- * @param properties the properties, not null.
- */
- public static void putAll(Map<String,String> properties){
- STORED_ENTRIES.putAll(properties);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/test/java/org/apache/tamaya/events/ChangeableThreadLocalPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/events/src/test/java/org/apache/tamaya/events/ChangeableThreadLocalPropertySource.java b/modules/events/src/test/java/org/apache/tamaya/events/ChangeableThreadLocalPropertySource.java
deleted file mode 100644
index cc6c812..0000000
--- a/modules/events/src/test/java/org/apache/tamaya/events/ChangeableThreadLocalPropertySource.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.events;
-
-import org.apache.tamaya.core.propertysource.BasePropertySource;
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-/**
- * PropertySource implementation that accesses properties that are stored on ThreadLocal level, e.g. good to use for
- * testing..
- */
-public class ChangeableThreadLocalPropertySource extends BasePropertySource{
-
- private static final ThreadLocal<Map<String,String>> STORED_ENTRIES = new ThreadLocal<Map<String,String>>(){
- protected Map<String,String> initialValue(){
- return new HashMap<>();
- }
- };
-
- @Override
- public String getName() {
- return getClass().getSimpleName();
- }
-
- @Override
- public Map<String, String> getProperties() {
- return null;
- }
-
- public static String put(String key, String value){
- return STORED_ENTRIES.get().put(key,value);
- }
-
- public static void putAll(Map<String,String> properties){
- STORED_ENTRIES.get().putAll(properties);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/test/java/org/apache/tamaya/events/ConfigEventManagerTest.java
----------------------------------------------------------------------
diff --git a/modules/events/src/test/java/org/apache/tamaya/events/ConfigEventManagerTest.java b/modules/events/src/test/java/org/apache/tamaya/events/ConfigEventManagerTest.java
deleted file mode 100644
index b56407c..0000000
--- a/modules/events/src/test/java/org/apache/tamaya/events/ConfigEventManagerTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.events;
-
-import org.junit.Test;
-
-import java.util.UUID;
-
-import static org.junit.Assert.*;
-
-/**
- * Tests for {@link ConfigEventManager}.
- */
-public class ConfigEventManagerTest {
-
- private Object testAddListenerValue;
-
- @Test
- public void testAddRemoveListener() throws Exception {
- ConfigEventListener testListener = new ConfigEventListener() {
- @Override
- public void onConfigEvent(ConfigEvent<?> event) {
- testAddListenerValue = event.getResource();
- }
- };
- ConfigEventManager.addListener(testListener);
- ConfigEventManager.fireEvent(new SimpleEvent("Event1"));
- assertEquals(testAddListenerValue, "Event1");
- ConfigEventManager.removeListener(testListener);
- ConfigEventManager.fireEvent(new SimpleEvent("Event2"));
- assertEquals(testAddListenerValue, "Event1");
- }
-
- @Test
- public void testFireEvent() throws Exception {
- ConfigEventListener testListener = new ConfigEventListener() {
- @Override
- public void onConfigEvent(ConfigEvent<?> event) {
- testAddListenerValue = event.getResource();
- }
- };
- ConfigEventManager.addListener(testListener);
- ConfigEventManager.fireEvent(new SimpleEvent("Event1"));
- assertEquals(testAddListenerValue, "Event1");
- ConfigEventManager.removeListener(testListener);
- ConfigEventManager.fireEvent(new SimpleEvent("Event2"));
- assertEquals(testAddListenerValue, "Event1");
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/test/java/org/apache/tamaya/events/FrozenPropertySourceTest.java
----------------------------------------------------------------------
diff --git a/modules/events/src/test/java/org/apache/tamaya/events/FrozenPropertySourceTest.java b/modules/events/src/test/java/org/apache/tamaya/events/FrozenPropertySourceTest.java
deleted file mode 100644
index 1431228..0000000
--- a/modules/events/src/test/java/org/apache/tamaya/events/FrozenPropertySourceTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.events;
-
-import org.apache.tamaya.core.propertysource.SystemPropertySource;
-import org.apache.tamaya.spi.PropertySource;
-import org.junit.Test;
-
-import java.util.Map;
-
-import static org.junit.Assert.*;
-
-/**
- * Tests for {@link org.apache.tamaya.events.FrozenPropertySource}.
- */
-public class FrozenPropertySourceTest {
-
- private static final PropertySource myPS = new SystemPropertySource();
-
- @Test
- public void testOf() throws Exception {
- PropertySource ps = FrozenPropertySource.of(myPS);
- assertNotNull(ps);
- }
-
- @Test
- public void testGetName() throws Exception {
- PropertySource ps = FrozenPropertySource.of(myPS);
- String name = ps.getName();
- assertNotNull(name);
- assertEquals(name, ps.getName());
- }
-
- @Test
- public void testGetOrdinal() throws Exception {
- PropertySource ps = FrozenPropertySource.of(myPS);
- assertEquals(myPS.getOrdinal(), ps.getOrdinal());
- }
-
- @Test
- public void testGet() throws Exception {
- PropertySource ps = FrozenPropertySource.of(myPS);
- assertNotNull(ps);
- for (Map.Entry<String, String> e : myPS.getProperties().entrySet()) {
- assertEquals(ps.get(e.getKey()).getValue(), e.getValue());
- }
- }
-
- @Test
- public void testGetProperties() throws Exception {
- PropertySource ps = FrozenPropertySource.of(myPS);
- assertNotNull(ps);
- assertNotNull(ps.getProperties());
- assertFalse(ps.getProperties().isEmpty());
- }
-
- @Test
- public void testEquals() throws Exception {
- PropertySource ps1 = FrozenPropertySource.of(myPS);
- PropertySource ps2 = FrozenPropertySource.of(myPS);
- assertEquals(ps1.getName(), ps2.getName());
- assertEquals(ps1.getProperties().size(), ps2.getProperties().size());
- }
-
- @Test
- public void testHashCode() throws Exception {
- boolean alwaysDifferent = true;
- for(int i=0;i<10;i++){
- PropertySource ps1 = FrozenPropertySource.of(myPS);
- PropertySource ps2 = FrozenPropertySource.of(myPS);
- // sometimes not same, because frozenAt in ms maybe different
- if(ps1.hashCode()==ps2.hashCode()){
- alwaysDifferent=false;
- break;
- }
- }
- if(alwaysDifferent){
- fail("HashCode should be same if frozenAt is in the same ms...");
- }
- }
-
- @Test
- public void testToString() throws Exception {
- PropertySource ps = FrozenPropertySource.of(myPS);
- String toString = ps.toString();
- assertNotNull(toString);
- assertTrue(toString.contains("FrozenPropertySource"));
- assertTrue(toString.contains(myPS.getName()));
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/test/java/org/apache/tamaya/events/ObservedConfigTest.java
----------------------------------------------------------------------
diff --git a/modules/events/src/test/java/org/apache/tamaya/events/ObservedConfigTest.java b/modules/events/src/test/java/org/apache/tamaya/events/ObservedConfigTest.java
deleted file mode 100644
index 0cd9e2b..0000000
--- a/modules/events/src/test/java/org/apache/tamaya/events/ObservedConfigTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.events;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Map;
-
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertEquals;
-
-/**
- * Test (currently manual) to test configuration changes.
- */
-public class ObservedConfigTest {
-
- @Test
- @Ignore // reactivate later...
- public void testChangingConfig() throws IOException {
- Configuration config = ConfigurationProvider.getConfiguration().with(TestConfigView.of());
-
- Map<String, String> props = config.getProperties();
- assertEquals(props.get("test"), "test2");
- assertEquals(props.get("testValue1"), "value");
- assertNull(props.get("testValue2"));
-
- //insert a new properties file into the tempdirectory
- FileUtils.writeStringToFile(
- new File(TestObservingProvider.propertyLocation.toFile(), "test2.properties"),
- "testValue2=anotherValue");
-
- try {
- Thread.sleep(10000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-
- config = ConfigurationProvider.getConfiguration().with(TestConfigView.of());
-
- props = config.getProperties();
-
- assertEquals(props.get("test"), "test2");
- assertEquals(props.get("testValue1"), "value");
- assertEquals(props.get("testValue2"), "anotherValue");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/test/java/org/apache/tamaya/events/RandomPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/events/src/test/java/org/apache/tamaya/events/RandomPropertySource.java b/modules/events/src/test/java/org/apache/tamaya/events/RandomPropertySource.java
deleted file mode 100644
index dead0d9..0000000
--- a/modules/events/src/test/java/org/apache/tamaya/events/RandomPropertySource.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.events;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * PropertySource that provides a randome entry, different on each access!
- */
-public class RandomPropertySource implements PropertySource{
-
- private Map<String, String> data = new HashMap<>();
-
- @Override
- public int getOrdinal() {
- return 0;
- }
-
- @Override
- public String getName() {
- return "random";
- }
-
- @Override
- public PropertyValue get(String key) {
- if(key.equals("random.new")){
- return PropertyValue.of(key, String.valueOf(Math.random()),getName());
- }
- return null;
- }
-
- @Override
- public Map<String, String> getProperties() {
- synchronized(data) {
- data.put("random.new", String.valueOf(Math.random()));
- data.put("_random.new.source", getName());
- data.put("_random.new.timestamp", String.valueOf(System.currentTimeMillis()));
- return new HashMap<>(data);
- }
- }
-
- @Override
- public boolean isScannable() {
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/test/java/org/apache/tamaya/events/SimpleEvent.java
----------------------------------------------------------------------
diff --git a/modules/events/src/test/java/org/apache/tamaya/events/SimpleEvent.java b/modules/events/src/test/java/org/apache/tamaya/events/SimpleEvent.java
deleted file mode 100644
index 5017aa1..0000000
--- a/modules/events/src/test/java/org/apache/tamaya/events/SimpleEvent.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.events;
-
-import org.apache.tamaya.events.spi.BaseConfigEvent;
-
-/**
- * Simple test event for testing only.
- */
-public class SimpleEvent extends BaseConfigEvent<String> {
-
- public SimpleEvent(String paylod) {
- super(paylod, String.class);
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/test/java/org/apache/tamaya/events/TestConfigView.java
----------------------------------------------------------------------
diff --git a/modules/events/src/test/java/org/apache/tamaya/events/TestConfigView.java b/modules/events/src/test/java/org/apache/tamaya/events/TestConfigView.java
deleted file mode 100644
index 8e5b397..0000000
--- a/modules/events/src/test/java/org/apache/tamaya/events/TestConfigView.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.events;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.ConfigOperator;
-import org.apache.tamaya.ConfigQuery;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.spi.ConfigurationContext;
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Created by Anatole on 24.03.2015.
- */
-public class TestConfigView implements ConfigOperator{
-
- private static final TestConfigView INSTANCE = new TestConfigView();
-
- private TestConfigView(){}
-
- public static ConfigOperator of(){
- return INSTANCE;
- }
-
- @Override
- public Configuration operate(final Configuration config) {
- return new Configuration() {
- @Override
- public Map<String, String> getProperties() {
- Map<String, String> result = new HashMap<>();
- for (Map.Entry<String, String> en : config.getProperties().entrySet()) {
- if (en.getKey().startsWith("test")) {
- result.put(en.getKey(), en.getValue());
- }
- }
- return result;
-// return config.getProperties().entrySet().stream().filter(e -> e.getKey().startsWith("test")).collect(
-// Collectors.toMap(en -> en.getKey(), en -> en.getValue()));
- }
-
- @Override
- public Configuration with(ConfigOperator operator) {
- return null;
- }
-
- @Override
- public <T> T query(ConfigQuery<T> query) {
- return null;
- }
-
- @Override
- public ConfigurationContext getContext() {
- return config.getContext();
- }
-
- @Override
- public String get(String key) {
- return getProperties().get(key);
- }
-
- @Override
- public String getOrDefault(String key, String defaultValue) {
- String val = get(key);
- if(val==null){
- return defaultValue;
- }
- return val;
- }
-
- @Override
- public <T> T getOrDefault(String key, Class<T> type, T defaultValue) {
- T val = get(key, type);
- if(val==null){
- return defaultValue;
- }
- return val;
- }
-
- @Override
- public <T> T get(String key, Class<T> type) {
- return (T) get(key, TypeLiteral.of(type));
- }
-
- /**
- * Accesses the current String value for the given key and tries to convert it
- * using the {@link org.apache.tamaya.spi.PropertyConverter} instances provided by the current
- * {@link org.apache.tamaya.spi.ConfigurationContext}.
- *
- * @param key the property's absolute, or relative path, e.g. @code
- * a/b/c/d.myProperty}.
- * @param type The target type required, not null.
- * @param <T> the value type
- * @return the converted value, never null.
- */
- @Override
- public <T> T get(String key, TypeLiteral<T> type) {
- String value = get(key);
- if (value != null) {
- List<PropertyConverter<T>> converters = ConfigurationProvider.getConfigurationContext()
- .getPropertyConverters(type);
- ConversionContext context = new ConversionContext.Builder(
- key,type).build();
- for (PropertyConverter<T> converter : converters) {
- try {
- T t = converter.convert(value, context);
- if (t != null) {
- return t;
- }
- } catch (Exception e) {
- Logger.getLogger(getClass().getName())
- .log(Level.FINEST, "PropertyConverter: " + converter + " failed to convert value: "
- + value, e);
- }
- }
- throw new ConfigException("Unparseable config value for type: " + type.getRawType().getName() + ": "
- + key + ", supportedFormats: " + context.getSupportedFormats());
- }
- return null;
- }
-
- @Override
- public <T> T getOrDefault(String key, TypeLiteral<T> type, T defaultValue) {
- T val = get(key, type);
- if(val==null){
- return defaultValue;
- }
- return val;
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/test/java/org/apache/tamaya/events/TestObservingProvider.java
----------------------------------------------------------------------
diff --git a/modules/events/src/test/java/org/apache/tamaya/events/TestObservingProvider.java b/modules/events/src/test/java/org/apache/tamaya/events/TestObservingProvider.java
deleted file mode 100644
index 2685d3e..0000000
--- a/modules/events/src/test/java/org/apache/tamaya/events/TestObservingProvider.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.events;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.tamaya.events.folderobserver.ObservingPropertySourceProvider;
-
-import java.io.File;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Test configuration property source provider that observes a directory and updated the config if necessary.
- */
-public class TestObservingProvider extends ObservingPropertySourceProvider{
-
- public static Path propertyLocation;
-
- static{
- try {
- // create some temporary config
- Path tempDir = Files.createTempDirectory("observedFolder");
-
- TestObservingProvider.propertyLocation = tempDir;
-
- FileUtils.copyInputStreamToFile(
- TestObservingProvider.class.getResourceAsStream("/test.properties"),
- new File(tempDir.toFile(), "test.properties"));
-
- Runtime.getRuntime().addShutdownHook(new Thread(){
- @Override
- public void run(){
- try{
- // cleanup directory
- Files.deleteIfExists(getTargetFile("test1.properties"));
- Files.deleteIfExists(getTargetFile("test2.properties"));
- Files.deleteIfExists(getTargetFile("test3.properties"));
- }
- catch(Exception e){
- Logger.getLogger("TestObservingProvider").log(Level.WARNING,
- "Failed to cleanup config test dir", e);
- }
- }
- });
- }
- catch(Exception e){
- Logger.getLogger("TestObservingProvider").log(Level.WARNING, "Failed to init config test dir", e);
- }
- }
-
- private static Path getTargetFile(String name) {
- File testFile = new File(TestObservingProvider.getTestDirectory(), name);
- return Paths.get(testFile.toURI());
- }
-
- public TestObservingProvider(){
- super(propertyLocation);
- Logger.getLogger(getClass().getName()).info("Using test directory: " + getTestPath());
- }
-
- public static File getTestDirectory(){
- String tempDir = System.getProperty("java.io.tmpdir");
- File dir = new File(tempDir, "tamaya-events-testdir");
- if(!dir.exists()){
- dir.mkdirs();
- }
- return dir;
- }
-
- private static String getTestPath(){
- return getTestDirectory().getAbsolutePath();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/test/java/org/apache/tamaya/events/delta/ConfigurationChangeTest.java
----------------------------------------------------------------------
diff --git a/modules/events/src/test/java/org/apache/tamaya/events/delta/ConfigurationChangeTest.java b/modules/events/src/test/java/org/apache/tamaya/events/delta/ConfigurationChangeTest.java
deleted file mode 100644
index b20ebef..0000000
--- a/modules/events/src/test/java/org/apache/tamaya/events/delta/ConfigurationChangeTest.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.events.delta;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.events.ConfigurationChange;
-import org.apache.tamaya.events.ConfigurationChangeBuilder;
-import org.junit.Test;
-
-import java.util.Map;
-
-import static org.junit.Assert.*;
-
-/**
- * Test class for {@link ConfigurationChange}.
- */
-public class ConfigurationChangeTest {
-
- @Test
- public void testEmptyChangeSet() throws Exception {
- ConfigurationChange change = ConfigurationChange.emptyChangeSet(ConfigurationProvider.getConfiguration());
- assertNotNull(change);
- assertTrue(change.isEmpty());
- }
-
- @Test
- public void testGetConfiguration() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationChange change = ConfigurationChangeBuilder.of(config).build();
- assertNotNull(change);
- assertTrue(change.getUpdatedSize()==0);
- assertTrue(change.getAddedSize()==0);
- assertTrue(change.getRemovedSize()==0);
- assertTrue(change.getChanges().size()==0);
- for (Map.Entry<String, String> en : config.getProperties().entrySet()) {
- if (!"[meta]frozenAt".equals(en.getKey())) {
- if(en.getKey().contains("random.new")){ // dynamic generated value!
- continue;
- }
- assertEquals("Error for " + en.getKey(), en.getValue(), change.getResource().get(en.getKey()));
- }
- }
- }
-
- @Test
- public void testGetVersion() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationChange change = ConfigurationChangeBuilder.of(config).build();
- assertNotNull(change.getVersion());
- change = ConfigurationChangeBuilder.of(config).setVersion("version2").build();
- assertNotNull(change.getVersion());
- assertEquals("version2", change.getVersion());
- }
-
- @Test
- public void testGetTimestamp() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationChange change = ConfigurationChangeBuilder.of(config).build();
- assertTrue((System.currentTimeMillis() - change.getTimestamp()) <= 10L);
- change = ConfigurationChangeBuilder.of(config).setTimestamp(10L).build();
- assertEquals(10L, change.getTimestamp());
- }
-
- @Test
- public void testGetEvents() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationChange change = ConfigurationChangeBuilder.of(config).removeKey("key1", "key2").build();
- assertTrue(change.getChanges().size() == 2);
- change = ConfigurationChangeBuilder.of(config).addChange("key1Added", "value1Added").build();
- assertTrue(change.getChanges().size() == 1);
- }
-
- @Test
- public void testGetRemovedSize() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationChange change = ConfigurationChangeBuilder.of(config).removeKey("java.version", "key2").build();
- assertTrue(change.getRemovedSize() == 2);
- assertTrue(change.getAddedSize() == 0);
- }
-
- @Test
- public void testGetAddedSize() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationChange change = ConfigurationChangeBuilder.of(config).addChange("key1", "key2").build();
- assertTrue(change.getAddedSize() == 1);
- assertTrue(change.getRemovedSize() == 0);
- }
-
- @Test
- public void testGetUpdatedSize() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationChange change = ConfigurationChangeBuilder.of(config).addChange("java.version", "1.8").build();
- assertTrue(change.getUpdatedSize() == 1);
- }
-
- @Test
- public void testIsRemoved() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationChange change = ConfigurationChangeBuilder.of(config).removeKey("java.version").build();
- assertTrue(change.isRemoved("java.version"));
- }
-
- @Test
- public void testIsAdded() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationChange change = ConfigurationChangeBuilder.of(config).addChange("key1", "key2").build();
- assertTrue(change.isAdded("key1"));
- }
-
- @Test
- public void testIsUpdated() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationChange change = ConfigurationChangeBuilder.of(config).addChange("java.version", "1.8").build();
- assertTrue(change.isUpdated("java.version"));
- }
-
- @Test
- public void testContainsKey() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationChange change = ConfigurationChangeBuilder.of(config).addChange("key1", "key2").build();
- assertTrue(change.isKeyAffected("key1"));
- assertFalse(change.isKeyAffected("key2"));
- change = ConfigurationChangeBuilder.of(config).removeKey("java.version").build();
- assertFalse(change.isKeyAffected("java.version"));
- assertFalse(change.isKeyAffected("key2"));
- }
-
- @Test
- public void testIsEmpty() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationChange change = ConfigurationChangeBuilder.of(config).build();
- assertTrue(change.isEmpty());
- }
-
- @Test
- public void testToString() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationChange change = ConfigurationChangeBuilder.of(config).addChange("key1", "key2").build();
- change = ConfigurationChangeBuilder.of(config).removeKey("java.version").build();
- assertTrue(change.toString().contains("timestamp"));
- assertTrue(change.toString().contains("version"));
- assertTrue(change.toString().contains("configuration"));
- assertFalse(change.toString().contains("key1"));
- assertFalse(change.toString().contains("key2"));
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/test/java/org/apache/tamaya/events/delta/ConfigurationContextChangeTest.java
----------------------------------------------------------------------
diff --git a/modules/events/src/test/java/org/apache/tamaya/events/delta/ConfigurationContextChangeTest.java b/modules/events/src/test/java/org/apache/tamaya/events/delta/ConfigurationContextChangeTest.java
deleted file mode 100644
index ee631ce..0000000
--- a/modules/events/src/test/java/org/apache/tamaya/events/delta/ConfigurationContextChangeTest.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.events.delta;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.core.propertysource.SystemPropertySource;
-import org.apache.tamaya.events.ChangeType;
-import org.apache.tamaya.events.ConfigurationContextChange;
-import org.apache.tamaya.events.ConfigurationContextChangeBuilder;
-import org.apache.tamaya.events.PropertySourceChangeBuilder;
-import org.apache.tamaya.spi.PropertySource;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Test class for {@link ConfigurationContextChange}.
- */
-public class ConfigurationContextChangeTest {
-
- @Test
- public void testEmptyChangeSet() throws Exception {
- ConfigurationContextChange change = ConfigurationContextChange.emptyChangeSet(
- ConfigurationProvider.getConfigurationContext());
- assertNotNull(change);
- assertTrue(change.isEmpty());
- }
-
- @Test
- public void testGetVersion() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationContextChange change = ConfigurationContextChangeBuilder.of().build();
- assertNotNull(change.getVersion());
- change = ConfigurationContextChangeBuilder.of().setVersion("version2").build();
- assertNotNull(change.getVersion());
- assertEquals("version2", change.getVersion());
- }
-
- @Test
- public void testGetTimestamp() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationContextChange change = ConfigurationContextChangeBuilder.of().build();
- assertTrue((System.currentTimeMillis() - change.getTimestamp()) <= 10L);
- change = ConfigurationContextChangeBuilder.of().setTimestamp(10L).build();
- assertEquals(10L, change.getTimestamp());
- }
-
- @Test
- public void testGetPropertySourceChanges() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationContextChange change = ConfigurationContextChangeBuilder.of().build();
- assertTrue(change.getPropertySourceChanges(). isEmpty());
- change = ConfigurationContextChangeBuilder.of().build();
- assertTrue(change.getPropertySourceChanges(). isEmpty());
- }
-
- @Test
- public void testGetPropertySourceUpdates() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationContextChange change = ConfigurationContextChangeBuilder.of().build();
- assertTrue(change.getPropertySourceChanges(). isEmpty());
- change = ConfigurationContextChangeBuilder.of().build();
- assertTrue(change.getPropertySourceUpdates(). isEmpty());
- }
-
- @Test
- public void testGetRemovedPropertySources() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationContextChange change = ConfigurationContextChangeBuilder.of().build();
- assertTrue(change.getPropertySourceChanges(). isEmpty());
- change = ConfigurationContextChangeBuilder.of().build();
- assertTrue(change.getRemovedPropertySources(). isEmpty());
- }
-
- @Test
- public void testGetAddedPropertySources() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationContextChange change = ConfigurationContextChangeBuilder.of().build();
- assertTrue(change.getPropertySourceChanges(). isEmpty());
- change = ConfigurationContextChangeBuilder.of().build();
- assertTrue(change.getAddedPropertySources().isEmpty());
- }
-
- @Test
- public void testGetUpdatedPropertySources() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationContextChange change = ConfigurationContextChangeBuilder.of().build();
- assertTrue(change.getPropertySourceChanges(). isEmpty());
- change = ConfigurationContextChangeBuilder.of().build();
- assertTrue(change.getUpdatedPropertySources().isEmpty());
- }
-
- @Test
- public void testIsAffected() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- PropertySource ps = new SystemPropertySource();
- ConfigurationContextChange change = ConfigurationContextChangeBuilder.of().changedPropertySource(
- PropertySourceChangeBuilder.of(ps, ChangeType.UPDATED).build()
- ).build();
- String toString = change.toString();
- assertTrue(change.isAffected(ps));
- }
-
- @Test
- public void testIsEmpty() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationContextChange change = ConfigurationContextChangeBuilder.of().build();
- assertTrue(change.isEmpty());
- change = ConfigurationContextChangeBuilder.of().newPropertySource(new SystemPropertySource()).build();
- assertFalse(change.isEmpty());
- }
-
- @Test
- public void testToString() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- ConfigurationContextChange change = ConfigurationContextChangeBuilder.of().newPropertySource(new SystemPropertySource()).build();
- String toString = change.toString();
- assertNotNull(toString);
- assertTrue(toString.contains(new SystemPropertySource().getName()));
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/test/java/org/apache/tamaya/events/delta/PropertySourceChangeTest.java
----------------------------------------------------------------------
diff --git a/modules/events/src/test/java/org/apache/tamaya/events/delta/PropertySourceChangeTest.java b/modules/events/src/test/java/org/apache/tamaya/events/delta/PropertySourceChangeTest.java
deleted file mode 100644
index 0dcdfba..0000000
--- a/modules/events/src/test/java/org/apache/tamaya/events/delta/PropertySourceChangeTest.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.events.delta;
-
-import org.apache.tamaya.core.propertysource.EnvironmentPropertySource;
-import org.apache.tamaya.core.propertysource.SimplePropertySource;
-import org.apache.tamaya.core.propertysource.SystemPropertySource;
-import org.apache.tamaya.events.ChangeType;
-import org.apache.tamaya.events.PropertySourceChange;
-import org.apache.tamaya.events.PropertySourceChangeBuilder;
-import org.apache.tamaya.spi.PropertySource;
-import org.junit.Test;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.junit.Assert.*;
-
-/**
- * Tests for {@link PropertySourceChange} and its builder.
- */
-public class PropertySourceChangeTest {
-
- private static final PropertySource myPS = new SystemPropertySource();
-
- @Test
- public void testGetChangeType() throws Exception {
- PropertySourceChange change = PropertySourceChangeBuilder.of(myPS, ChangeType.DELETED).build();
- assertEquals(change.getChangeType(), ChangeType.DELETED);
- change = PropertySourceChangeBuilder.of(myPS, ChangeType.UPDATED).build();
- assertEquals(change.getChangeType(), ChangeType.UPDATED);
- }
-
- @Test
- public void testGetPropertySource() throws Exception {
- PropertySourceChange change = PropertySourceChangeBuilder.of(myPS, ChangeType.DELETED).build();
- assertEquals(change.getResource().getName(), myPS.getName());
- }
-
- @Test
- public void testGetVersion() throws Exception {
- PropertySourceChange change = PropertySourceChangeBuilder.of(myPS, ChangeType.DELETED)
- .setVersion("myVersion1").build();
- assertEquals(change.getVersion(), "myVersion1");
- }
-
- @Test
- public void testGetTimestamp() throws Exception {
- PropertySourceChange change = PropertySourceChangeBuilder.of(myPS, ChangeType.DELETED)
- .setTimestamp(111L).build();
- assertEquals(change.getTimestamp(), 111L);
- }
-
- @Test
- public void testGetEvents() throws Exception {
- PropertySourceChange change = PropertySourceChangeBuilder.of(myPS, ChangeType.DELETED)
- .addChanges(
- new EnvironmentPropertySource()
- ).build();
- assertTrue(change.getChanges().size()>0);
- }
-
- @Test
- public void testGetRemovedSize() throws Exception {
- PropertySourceChange change = PropertySourceChangeBuilder.of(myPS, ChangeType.UPDATED)
- .addChanges(
- new EnvironmentPropertySource()
- ).build();
- assertTrue(change.getRemovedSize()>0);
- }
-
- @Test
- public void testGetAddedSize() throws Exception {
- PropertySourceChange change = PropertySourceChangeBuilder.of(myPS, ChangeType.DELETED)
- .addChanges(
- new EnvironmentPropertySource()
- ).build();
- assertTrue(change.getAddedSize()>0);
- }
-
- @Test
- public void testGetUpdatedSize() throws Exception {
- PropertySourceChange change = PropertySourceChangeBuilder.of(myPS, ChangeType.DELETED)
- .addChanges(
- new EnvironmentPropertySource()
- ).build();
- assertTrue(change.getUpdatedSize()==0);
- }
-
- @Test
- public void testIsRemoved() throws Exception {
- Map<String, String> testData = new HashMap<>();
- testData.put("key1", "value1");
- testData.put("key2", "value2");
- PropertySource ps1 = new SimplePropertySource("test", testData);
- testData = new HashMap<>();
- testData.put("key1", "value2");
- testData.put("key3", "value3");
- PropertySource ps2 = new SimplePropertySource("test", testData);
- PropertySourceChange change = PropertySourceChangeBuilder.of(ps1, ChangeType.UPDATED)
- .addChanges(
- ps2
- ).build();
- assertFalse(change.isRemoved("key1"));
- assertTrue(change.isRemoved("key2"));
- assertFalse(change.isRemoved("key3"));
- }
-
- @Test
- public void testIsAdded() throws Exception {
- Map<String, String> testData = new HashMap<>();
- testData.put("key1", "value1");
- testData.put("key2", "value2");
- PropertySource ps1 = new SimplePropertySource("test", testData);
- testData = new HashMap<>();
- testData.put("key1", "value2");
- testData.put("key3", "value3");
- PropertySource ps2 = new SimplePropertySource("test", testData);
- PropertySourceChange change = PropertySourceChangeBuilder.of(ps1, ChangeType.UPDATED)
- .addChanges(
- ps2
- ).build();
- assertTrue(change.isAdded("key3"));
- assertFalse(change.isAdded("key2"));
- assertFalse(change.isAdded("key1"));
- }
-
- @Test
- public void testIsUpdated() throws Exception {
- Map<String, String> testData = new HashMap<>();
- testData.put("key1", "value1");
- testData.put("key2", "value2");
- PropertySource ps1 = new SimplePropertySource("test", testData);
- testData = new HashMap<>();
- testData.put("key1", "value2");
- testData.put("key3", "value3");
- PropertySource ps2 = new SimplePropertySource("test", testData);
- PropertySourceChange change = PropertySourceChangeBuilder.of(ps1, ChangeType.UPDATED)
- .addChanges(
- ps2
- ).build();
- assertTrue(change.isUpdated("key1"));
- assertFalse(change.isUpdated("key2"));
- assertFalse(change.isUpdated("key3"));
- }
-
- @Test
- public void testContainsKey() throws Exception {
- PropertySourceChange change = PropertySourceChangeBuilder.of(new EnvironmentPropertySource(), ChangeType.DELETED)
- .addChanges(
- myPS
- ).build();
- assertTrue(change.isKeyAffected("java.version"));
- }
-
- @Test
- public void testIsEmpty() throws Exception {
- PropertySourceChange change = PropertySourceChangeBuilder.of(new EnvironmentPropertySource(), ChangeType.DELETED)
- .build();
- assertTrue(change.isEmpty());
- change = PropertySourceChangeBuilder.of(new EnvironmentPropertySource(), ChangeType.DELETED)
- .addChanges(
- myPS
- ).build();
- assertFalse(change.isEmpty());
- }
-
- @Test
- public void testOfAdded() throws Exception {
- PropertySourceChange change = PropertySourceChange.ofAdded(myPS);
- assertNotNull(change);
- assertEquals(change.getChangeType(), ChangeType.NEW);
- }
-
- @Test
- public void testOfDeleted() throws Exception {
- PropertySourceChange change = PropertySourceChange.ofDeleted(myPS);
- assertNotNull(change);
- assertEquals(change.getChangeType(), ChangeType.DELETED);
- }
-
- @Test
- public void testToString() throws Exception {
- PropertySourceChange change = PropertySourceChange.ofAdded(myPS);
- String toString = change.toString();
- assertNotNull(toString);
- assertTrue(toString.contains(myPS.getName()));
- change = PropertySourceChange.ofDeleted(myPS);
- toString = change.toString();
- assertNotNull(toString);
- assertTrue(toString.contains(myPS.getName()));
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/test/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpiTest.java
----------------------------------------------------------------------
diff --git a/modules/events/src/test/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpiTest.java b/modules/events/src/test/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpiTest.java
deleted file mode 100644
index d54a66e..0000000
--- a/modules/events/src/test/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpiTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.events.internal;
-
-import org.apache.tamaya.events.ConfigEvent;
-import org.apache.tamaya.events.ConfigEventListener;
-import org.apache.tamaya.events.SimpleEvent;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Tests for {@link DefaultConfigEventManagerSpi}.
- */
-public class DefaultConfigEventManagerSpiTest {
-
- private final DefaultConfigEventManagerSpi spi = new DefaultConfigEventManagerSpi();
- private Object testAddListenerValue;
-
- @Test
- public void testAddListener() throws Exception {
- ConfigEventListener testListener = new ConfigEventListener() {
- @Override
- public void onConfigEvent(ConfigEvent<?> event) {
- testAddListenerValue = event.getResource();
- }
- };
- spi.addListener(testListener);
- spi.fireEvent(new SimpleEvent("Event1"));
- assertEquals(testAddListenerValue, "Event1");
- spi.removeListener(testListener);
- spi.fireEvent(new SimpleEvent("Event2"));
- assertEquals(testAddListenerValue, "Event1");
-
- }
-
- @Test
- public void testRemoveListener() throws Exception {
- ConfigEventListener testListener = new ConfigEventListener() {
-
- @Override
- public void onConfigEvent(ConfigEvent<?> event) {
- testAddListenerValue = event;
- }
- };
- spi.removeListener(testListener);
- spi.removeListener(testListener);
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/test/resources/META-INF/services/org.apache.tamaya.events.ConfigEventListener
----------------------------------------------------------------------
diff --git a/modules/events/src/test/resources/META-INF/services/org.apache.tamaya.events.ConfigEventListener b/modules/events/src/test/resources/META-INF/services/org.apache.tamaya.events.ConfigEventListener
deleted file mode 100644
index f675fd6..0000000
--- a/modules/events/src/test/resources/META-INF/services/org.apache.tamaya.events.ConfigEventListener
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy current the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-org.apache.tamaya.events.internal.DefaultConfigurationContextChangeListener
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
----------------------------------------------------------------------
diff --git a/modules/events/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource b/modules/events/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
deleted file mode 100644
index 9c2b9f6..0000000
--- a/modules/events/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy current the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-org.apache.tamaya.events.RandomPropertySource
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider
----------------------------------------------------------------------
diff --git a/modules/events/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider b/modules/events/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider
deleted file mode 100644
index d34b4a2..0000000
--- a/modules/events/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy current the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-org.apache.tamaya.events.TestObservingProvider
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/test/resources/data/test1.properties
----------------------------------------------------------------------
diff --git a/modules/events/src/test/resources/data/test1.properties b/modules/events/src/test/resources/data/test1.properties
deleted file mode 100644
index 0df3bd1..0000000
--- a/modules/events/src/test/resources/data/test1.properties
+++ /dev/null
@@ -1,20 +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.
-#
-1=val1
-3=val3
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/test/resources/data/test1b.properties
----------------------------------------------------------------------
diff --git a/modules/events/src/test/resources/data/test1b.properties b/modules/events/src/test/resources/data/test1b.properties
deleted file mode 100644
index ec57163..0000000
--- a/modules/events/src/test/resources/data/test1b.properties
+++ /dev/null
@@ -1,20 +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.
-#
-1b=val1
-7=val7
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/test/resources/data/test2.properties
----------------------------------------------------------------------
diff --git a/modules/events/src/test/resources/data/test2.properties b/modules/events/src/test/resources/data/test2.properties
deleted file mode 100644
index 0643c1d..0000000
--- a/modules/events/src/test/resources/data/test2.properties
+++ /dev/null
@@ -1,20 +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.
-#
-4=val4
-6=val6
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/test/resources/data/test3.properties
----------------------------------------------------------------------
diff --git a/modules/events/src/test/resources/data/test3.properties b/modules/events/src/test/resources/data/test3.properties
deleted file mode 100644
index bb856c7..0000000
--- a/modules/events/src/test/resources/data/test3.properties
+++ /dev/null
@@ -1,20 +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.
-#
-2=val2
-5=val5
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/test/resources/test.properties
----------------------------------------------------------------------
diff --git a/modules/events/src/test/resources/test.properties b/modules/events/src/test/resources/test.properties
deleted file mode 100644
index af06631..0000000
--- a/modules/events/src/test/resources/test.properties
+++ /dev/null
@@ -1,21 +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.
-#
-testValue1=value
-test=test2
-a=b
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/filter/pom.xml
----------------------------------------------------------------------
diff --git a/modules/filter/pom.xml b/modules/filter/pom.xml
deleted file mode 100644
index d9d4854..0000000
--- a/modules/filter/pom.xml
+++ /dev/null
@@ -1,81 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-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.
--->
-<project xmlns="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">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-extensions</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
- </parent>
-
- <artifactId>tamaya-filter</artifactId>
- <name>Apache Tamaya Modules - Adaptive Configuration Filtering</name>
- <packaging>bundle</packaging>
-
- <properties>
- <jdkVersion>1.7</jdkVersion>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-api</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-core</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>java-hamcrest</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.tamaya.filter,
- </Export-Package>
- <!--<Private-Package>-->
- <!--org.apache.tamaya.events.internal-->
- <!--</Private-Package>-->
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/filter/src/main/java/org/apache/tamaya/filter/ConfigurationFilter.java
----------------------------------------------------------------------
diff --git a/modules/filter/src/main/java/org/apache/tamaya/filter/ConfigurationFilter.java b/modules/filter/src/main/java/org/apache/tamaya/filter/ConfigurationFilter.java
deleted file mode 100644
index c2739a1..0000000
--- a/modules/filter/src/main/java/org/apache/tamaya/filter/ConfigurationFilter.java
+++ /dev/null
@@ -1,121 +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.filter;
-
-import org.apache.tamaya.spi.FilterContext;
-import org.apache.tamaya.spi.PropertyFilter;
-
-
-/**
- * Hereby
- * <ul>
- * <li><b>Single</b> filters are applied only when values are explicitly accessed. This is useful, e.g. for
- * filtering passwords into clear text variants. Nevertheless metadata keys hidden on map level must be
- * accessible (=not filtered) when accessed as single values.</li>
- * <li><b>Map</b> filters are applied when values are filtered as part of a full properties access.
- * Often filtering in these cases is more commonly applied, e.g. you dont want to show up all kind of metadata.
- * </li>
- * </ul>
- * For both variants individual filter rules can be applied here. All filters configured are managed on a
- * thread-local level, so this class is typically used to temporarely filter out some values. Do not forget to
- * restore its state, when not using a thread anymore (especially important in multi-threaded environments), not
- * doing so will create nasty side effects of configuration not being visisble depending on the thread
- * active.
- */
-public final class ConfigurationFilter implements PropertyFilter{
-
- static final ThreadLocal<Boolean> THREADED_METADATA_FILTERED = new ThreadLocal<Boolean>(){
- @Override
- protected Boolean initialValue() {
- return Boolean.TRUE;
- }
- };
-
- private static final ThreadLocal<ProgrammableFilter> THREADED_MAP_FILTERS = new ThreadLocal<ProgrammableFilter>(){
- @Override
- protected ProgrammableFilter initialValue() {
- return new ProgrammableFilter();
- }
- };
-
- private static final ThreadLocal<ProgrammableFilter> THREADED_SINGLE_FILTERS = new ThreadLocal<ProgrammableFilter>(){
- @Override
- protected ProgrammableFilter initialValue() {
- return new ProgrammableFilter();
- }
- };
-
- /**
- * Flag if metadata entries (starting with an '_') are filtered out on when accessing multiple properties, default
- * is {@code true}.
- * @return true, if metadata entries (starting with an '_') are to be filtered.
- */
- public static boolean isMetadataFiltered(){
- return THREADED_METADATA_FILTERED.get();
- }
-
- /**
- * Seactivates metadata filtering also on global map access for this thread.
- * @see #clearFilters()
- * @param filtered true,to enable metadata filtering (default).
- */
- public static void setMetadataFiltered(boolean filtered){
- THREADED_METADATA_FILTERED.set(filtered);
- }
-
- /**
- * Access the filtering configuration that is used for filtering single property values accessed.
- * @return the filtering config, never null.
- */
- public static ProgrammableFilter getSingleFilters(){
- return THREADED_SINGLE_FILTERS.get();
- }
-
- /**
- * Access the filtering configuration that is used for filtering configuration properties accessed as full
- * map.
- * @return the filtering config, never null.
- */
- public static ProgrammableFilter getMapFilters(){
- return THREADED_MAP_FILTERS.get();
- }
-
- /**
- * Removes all programmable filters active on the current thread.
- */
- public static void clearFilters(){
- THREADED_MAP_FILTERS.get().clearFilters();
- THREADED_SINGLE_FILTERS.get().clearFilters();
- THREADED_METADATA_FILTERED.set(true);
- }
-
- @Override
- public String filterProperty(String valueToBeFiltered, FilterContext context) {
- if(context.isSinglePropertyScoped()){
- for(PropertyFilter pred: THREADED_SINGLE_FILTERS.get().getFilters()){
- valueToBeFiltered = pred.filterProperty(valueToBeFiltered, context);
- }
- }else{
- for(PropertyFilter pred: THREADED_MAP_FILTERS.get().getFilters()){
- valueToBeFiltered = pred.filterProperty(valueToBeFiltered, context);
- }
- }
- return valueToBeFiltered;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/filter/src/main/java/org/apache/tamaya/filter/ProgrammableFilter.java
----------------------------------------------------------------------
diff --git a/modules/filter/src/main/java/org/apache/tamaya/filter/ProgrammableFilter.java b/modules/filter/src/main/java/org/apache/tamaya/filter/ProgrammableFilter.java
deleted file mode 100644
index ec6040c..0000000
--- a/modules/filter/src/main/java/org/apache/tamaya/filter/ProgrammableFilter.java
+++ /dev/null
@@ -1,118 +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.filter;
-
-import org.apache.tamaya.spi.FilterContext;
-import org.apache.tamaya.spi.PropertyFilter;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * A set of property filter and accessor methods.
- */
-public final class ProgrammableFilter implements PropertyFilter{
- /** The filters. */
- private List<PropertyFilter> filters = new ArrayList<>();
-
- /**
- * Add a filter.
- * @param filter the filter.
- */
- public void addFilter(PropertyFilter filter){
- filters.add(filter);
- }
-
- /**
- * Adds a filter at given position.
- * @param pos the position.
- * @param filter the filter.
- */
- public void addFilter(int pos, PropertyFilter filter){
- filters.add(pos, filter);
- }
-
- /**
- * Removes a filter at a given position.
- * @param pos the position.
- * @return the filter removed, or null.
- */
- public PropertyFilter removeFilter(int pos){
- return filters.remove(pos);
- }
-
- /**
- * Removes a filter.
- * @param filter the filter to be removed, not null.
- */
- public void removeFilter(PropertyFilter filter) {
- filters.remove(filter);
- }
-
- /**
- * Clears all filters.
- */
- public void clearFilters(){
- filters.clear();
- }
-
- /**
- * Set the filters.
- * @param filters the filters to be applied.
- */
- public void setFilters(PropertyFilter... filters){
- setFilters(Arrays.asList(filters));
- }
-
- /**
- * Set the filters.
- * @param filters the filters to be applied.
- */
- public void setFilters(Collection<PropertyFilter> filters) {
- this.filters.clear();
- this.filters.addAll(filters);
- }
-
- /**
- * Get all filters.
- * @return all filters.
- */
- public List<PropertyFilter> getFilters(){
- return Collections.unmodifiableList(filters);
- }
-
- @Override
- public String filterProperty(String valueToBeFiltered, FilterContext context) {
- for(PropertyFilter filter:filters){
- valueToBeFiltered = filter.filterProperty(valueToBeFiltered, context);
- }
- return valueToBeFiltered;
- }
-
- @Override
- public String toString() {
- return "ProgrammableFilter{" +
- "filters=" + filters +
- '}';
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/filter/src/main/java/org/apache/tamaya/filter/RegexPropertyFilter.java
----------------------------------------------------------------------
diff --git a/modules/filter/src/main/java/org/apache/tamaya/filter/RegexPropertyFilter.java b/modules/filter/src/main/java/org/apache/tamaya/filter/RegexPropertyFilter.java
deleted file mode 100644
index 1ed43ba..0000000
--- a/modules/filter/src/main/java/org/apache/tamaya/filter/RegexPropertyFilter.java
+++ /dev/null
@@ -1,56 +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.filter;
-
-import org.apache.tamaya.spi.FilterContext;
-import org.apache.tamaya.spi.PropertyFilter;
-
-import java.util.Objects;
-
-/**
- * Predicate filtering using a regex expression operating on the key.
- */
-public final class RegexPropertyFilter implements PropertyFilter{
- /** The expression used to filter. */
- private String expression;
-
- /**
- * Creates a new regex filter expression.
- * @param expression the reged expression, not null.
- */
- public RegexPropertyFilter(String expression){
- this.expression = Objects.requireNonNull(expression);
- }
-
- @Override
- public String filterProperty(String valueToBeFiltered, FilterContext context) {
- if(context.getKey().matches(expression)){
- return null;
- }
- return valueToBeFiltered;
- }
-
- @Override
- public String toString() {
- return "RegexPropertyFilter{" +
- "expression='" + expression + '\'' +
- '}';
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/filter/src/main/java/org/apache/tamaya/filter/internal/DefaultMetadataFilter.java
----------------------------------------------------------------------
diff --git a/modules/filter/src/main/java/org/apache/tamaya/filter/internal/DefaultMetadataFilter.java b/modules/filter/src/main/java/org/apache/tamaya/filter/internal/DefaultMetadataFilter.java
deleted file mode 100644
index 95e9d25..0000000
--- a/modules/filter/src/main/java/org/apache/tamaya/filter/internal/DefaultMetadataFilter.java
+++ /dev/null
@@ -1,43 +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.filter.internal;
-
-import org.apache.tamaya.filter.ConfigurationFilter;
-import org.apache.tamaya.spi.FilterContext;
-import org.apache.tamaya.spi.PropertyFilter;
-
-/**
- * Default property filter that hides metadta entries starting with an '_', similar ti {@code etcd}.
- */
-public final class DefaultMetadataFilter implements PropertyFilter{
- @Override
- public String filterProperty(String valueToBeFiltered, FilterContext context) {
- if(context.isSinglePropertyScoped()){
- // When accessing keys explicitly, do not hide anything.
- return valueToBeFiltered;
- }
- if(ConfigurationFilter.isMetadataFiltered()) {
- if (context.getKey().startsWith("_")) {
- // Hide metadata entries.
- return null;
- }
- }
- return valueToBeFiltered;
- }
-}
[03/24] incubator-tamaya git commit: Removed all modules from the
main repository. They will be reborn in separate ASF repository.
Posted by pl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resources/src/test/resources/resources_testroot/aa_a/a2.file
----------------------------------------------------------------------
diff --git a/modules/resources/src/test/resources/resources_testroot/aa_a/a2.file b/modules/resources/src/test/resources/resources_testroot/aa_a/a2.file
deleted file mode 100644
index 7220975..0000000
--- a/modules/resources/src/test/resources/resources_testroot/aa_a/a2.file
+++ /dev/null
@@ -1,18 +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.
- */
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resources/src/test/resources/resources_testroot/aa_a/a3.file
----------------------------------------------------------------------
diff --git a/modules/resources/src/test/resources/resources_testroot/aa_a/a3.file b/modules/resources/src/test/resources/resources_testroot/aa_a/a3.file
deleted file mode 100644
index 7220975..0000000
--- a/modules/resources/src/test/resources/resources_testroot/aa_a/a3.file
+++ /dev/null
@@ -1,18 +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.
- */
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resources/src/test/resources/resources_testroot/aa_a/z3.file
----------------------------------------------------------------------
diff --git a/modules/resources/src/test/resources/resources_testroot/aa_a/z3.file b/modules/resources/src/test/resources/resources_testroot/aa_a/z3.file
deleted file mode 100644
index 7220975..0000000
--- a/modules/resources/src/test/resources/resources_testroot/aa_a/z3.file
+++ /dev/null
@@ -1,18 +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.
- */
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resources/src/test/resources/resources_testroot/bb/b1/b2/b12.file
----------------------------------------------------------------------
diff --git a/modules/resources/src/test/resources/resources_testroot/bb/b1/b2/b12.file b/modules/resources/src/test/resources/resources_testroot/bb/b1/b2/b12.file
deleted file mode 100644
index 7220975..0000000
--- a/modules/resources/src/test/resources/resources_testroot/bb/b1/b2/b12.file
+++ /dev/null
@@ -1,18 +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.
- */
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resources/src/test/resources/resources_testroot/bb/b2/b2_1.file
----------------------------------------------------------------------
diff --git a/modules/resources/src/test/resources/resources_testroot/bb/b2/b2_1.file b/modules/resources/src/test/resources/resources_testroot/bb/b2/b2_1.file
deleted file mode 100644
index 7220975..0000000
--- a/modules/resources/src/test/resources/resources_testroot/bb/b2/b2_1.file
+++ /dev/null
@@ -1,18 +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.
- */
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resources/src/test/resources/resources_testroot/bb/b2/b2_2.datei
----------------------------------------------------------------------
diff --git a/modules/resources/src/test/resources/resources_testroot/bb/b2/b2_2.datei b/modules/resources/src/test/resources/resources_testroot/bb/b2/b2_2.datei
deleted file mode 100644
index 7220975..0000000
--- a/modules/resources/src/test/resources/resources_testroot/bb/b2/b2_2.datei
+++ /dev/null
@@ -1,18 +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.
- */
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resources/src/test/resources/resources_testroot/bb/b2/b3.foo
----------------------------------------------------------------------
diff --git a/modules/resources/src/test/resources/resources_testroot/bb/b2/b3.foo b/modules/resources/src/test/resources/resources_testroot/bb/b2/b3.foo
deleted file mode 100644
index 7220975..0000000
--- a/modules/resources/src/test/resources/resources_testroot/bb/b2/b3.foo
+++ /dev/null
@@ -1,18 +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.
- */
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resources/src/test/resources/test.properties
----------------------------------------------------------------------
diff --git a/modules/resources/src/test/resources/test.properties b/modules/resources/src/test/resources/test.properties
deleted file mode 100644
index f3199f2..0000000
--- a/modules/resources/src/test/resources/test.properties
+++ /dev/null
@@ -1,18 +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.
-#
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/server/pom.xml
----------------------------------------------------------------------
diff --git a/modules/server/pom.xml b/modules/server/pom.xml
deleted file mode 100644
index 9b302d8..0000000
--- a/modules/server/pom.xml
+++ /dev/null
@@ -1,203 +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.
--->
-<project xmlns="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">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-extensions</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
-
- <artifactId>tamaya-server</artifactId>
- <name>Apache Tamaya Modules - Server Extension</name>
- <packaging>bundle</packaging>
-
- <properties>
- <jdkVersion>1.7</jdkVersion>
- <tomcat.version>7.0.57</tomcat.version>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tomcat.embed</groupId>
- <artifactId>tomcat-embed-core</artifactId>
- <version>${tomcat.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tomcat.embed</groupId>
- <artifactId>tomcat-embed-jasper</artifactId>
- <version>${tomcat.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tomcat.embed</groupId>
- <artifactId>tomcat-embed-logging-juli</artifactId>
- <version>${tomcat.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-jaxrs_2.0_spec</artifactId>
- <version>1.0-alpha-1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-frontend-jaxrs</artifactId>
- <version>3.1.6</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-core</artifactId>
- <version>${project.version}</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>tamaya-json</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>tamaya-functions</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>java-hamcrest</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <resources>
- <resource>
- <directory>${project.basedir}/src/main/resources</directory>
- <filtering>true</filtering>
- <includes>
- <include>META-INF/server-version.properties</include>
- </includes>
- </resource>
- <resource>
- <directory>${project.basedir}/src/main/resources</directory>
- <filtering>false</filtering>
- <excludes>
- <exclude>META-INF/server-version.properties</exclude>
- </excludes>
- </resource>
-
- </resources>
- <plugins>
- <plugin>
- <groupId>com.spotify</groupId>
- <artifactId>docker-maven-plugin</artifactId>
- <version>0.3.258</version>
- <configuration>
- <imageName>apache/tamaya/config-server</imageName>
- <imageTags>
- <imageTag>${project.version}</imageTag>
- </imageTags>
- <baseImage>java:8-jre</baseImage>
- <entryPoint>["java", "-jar", "/${project.build.finalName}.jar", "server", "/config-server.yml"]</entryPoint>
- <exposes>
- <expose>8080</expose>
- </exposes>
- <resources>
- <resource>
- <targetPath>/</targetPath>
- <directory>${project.build.directory}</directory>
- <include>${project.build.finalName}.jar</include>
- </resource>
- <resource>
- <targetPath>/</targetPath>
- <directory>${project.build.directory}/classes</directory>
- <include>config-server.yml</include>
- </resource>
- </resources>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <configuration>
- <archive>
- <manifest>
- <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
- </manifest>
- </archive>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <version>2.3</version>
- <configuration>
- <createDependencyReducedPom>true</createDependencyReducedPom>
- <filters>
- <filter>
- <artifact>*:*</artifact>
- <excludes>
- <exclude>META-INF/*.SF</exclude>
- <exclude>META-INF/*.DSA</exclude>
- <exclude>META-INF/*.RSA</exclude>
- </excludes>
- </filter>
- </filters>
- </configuration>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <transformers>
- <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
- <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
- <mainClass>org.apache.tamaya.server.ConfigServiceApp</mainClass>
- </transformer>
- </transformers>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.tamaya.server,
- org.apache.tamaya.server.spi
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/server/src/main/java/org/apache/tamaya/server/ConfigServiceApp.java
----------------------------------------------------------------------
diff --git a/modules/server/src/main/java/org/apache/tamaya/server/ConfigServiceApp.java b/modules/server/src/main/java/org/apache/tamaya/server/ConfigServiceApp.java
deleted file mode 100644
index 1db06f3..0000000
--- a/modules/server/src/main/java/org/apache/tamaya/server/ConfigServiceApp.java
+++ /dev/null
@@ -1,77 +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.server;
-
-import org.apache.catalina.Context;
-import org.apache.catalina.Wrapper;
-import org.apache.catalina.startup.Tomcat;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-
-import javax.ws.rs.core.Application;
-import java.io.File;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Main Application for the Tamaya Configuration Server.
- */
-public class ConfigServiceApp {
-
- /**
- * Utility class.
- */
- private ConfigServiceApp(){}
-
- /**
- * JAX RS Application.
- */
- public static class ResourceLoader extends Application{
-
- @Override
- public Set<Class<?>> getClasses() {
- final Set<Class<?>> classes = new HashSet<>();
- // register root resource
- classes.add(ConfigurationResource.class);
- return classes;
- }
- }
-
- public static void main(String... args) throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- String contextPath = config.getOrDefault("tamaya.server.contextPath", "/");
- String appBase = ".";
- Tomcat tomcat = new Tomcat();
- tomcat.setPort(config.getOrDefault("tamaya.server.port", Integer.class, 8085));
-
- // Define a web application context.
- Context context = tomcat.addWebapp(contextPath, new File(
- appBase).getAbsolutePath());
- // Add servlet that will register Jersey REST resources
- String servletName = "cxf-servlet";
- Wrapper wrapper = tomcat.addServlet(context, servletName,
- org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet.class.getName());
- wrapper.addInitParameter("javax.ws.rs.Application", ResourceLoader.class.getName());
- context.addServletMapping("/*", servletName);
- tomcat.start();
- tomcat.getServer().await();
- }
-
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/server/src/main/java/org/apache/tamaya/server/ConfigurationResource.java
----------------------------------------------------------------------
diff --git a/modules/server/src/main/java/org/apache/tamaya/server/ConfigurationResource.java b/modules/server/src/main/java/org/apache/tamaya/server/ConfigurationResource.java
deleted file mode 100644
index f13446a..0000000
--- a/modules/server/src/main/java/org/apache/tamaya/server/ConfigurationResource.java
+++ /dev/null
@@ -1,310 +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.server;
-
-import java.io.StringWriter;
-import java.util.Map;
-import java.util.Objects;
-import java.util.concurrent.atomic.AtomicLong;
-
-import javax.json.Json;
-import javax.json.JsonArray;
-import javax.json.JsonArrayBuilder;
-import javax.json.JsonObject;
-import javax.json.JsonObjectBuilder;
-import javax.json.JsonWriter;
-import javax.json.stream.JsonGenerator;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.FormParam;
-import javax.ws.rs.GET;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.functions.ConfigurationFunctions;
-
-/**
- * Configuration resource with an etcd compatible REST API
- * (excluding the blocking API calls).
- */
-@Path("/")
-@Produces({MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN})
-public class ConfigurationResource {
- private final AtomicLong readCounter = new AtomicLong();
- private final AtomicLong writeCounter = new AtomicLong();
- private final AtomicLong deleteCounter = new AtomicLong();
-
-
- @GET
- @Path("/version")
- @Produces({MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN})
- public String version() {
- String product = VersionProperties.getProduct().replace("\"", "\\\"");
- String version = VersionProperties.getVersion().replace("\"", "\\\"");
-
- return String.format("{ \"version\" : \"%s: %s\" }", product, version);
- }
-
- @GET
- @Path("/v2/keys")
- public String readEtcdConfig(@QueryParam("recursive") Boolean recursive) {
- return readConfig(recursive);
- }
-
- /**
- * This models a etcd2 compliant access point for getting a property value.
- *
- * @param recursive NOT YET IMPLEMENTED!
- * @return all configuration property values.
- */
- @GET
- @Path("/keys")
- public String readConfig(@QueryParam("recursive") Boolean recursive) {
- readCounter.incrementAndGet();
- final Configuration config = ConfigurationProvider.getConfiguration();
- final Map<String, String> children = config.getProperties();
- final JsonArrayBuilder ab = Json.createArrayBuilder();
- for (final Map.Entry<String, String> en : children.entrySet()) {
- final Node node = new Node(config, en.getKey(), "node");
- ab.add(node.createJsonObject());
- }
- final Node node = new Node(config, null, "node", ab.build());
- final JsonObjectBuilder root = Json.createObjectBuilder().add("action", "get")
- .add("node", node.createJsonObject());
- final StringWriter writer = new StringWriter();
- final JsonWriter jwriter = Json.createWriter(writer);
- jwriter.writeObject(root.build());
- return writer.toString();
- }
-
- /**
- * This models a etcd2 compliant access point for getting a property value.
- *
- * @param key name of the key to show
- * @param recursive NOT YET IMPLEMENTED!
- * @return specific configuration key derived from the given key name.
- */
- @GET
- @Path("/v2/keys/{key}")
- public String readEtcdConfig(@PathParam("key") String key, @QueryParam("recursive") Boolean recursive) {
- return readConfig(key, recursive);
- }
-
- /**
- * This models a etcd2 compliant access point for getting a property value.
- *
- * @param key name of the key to show
- * @param recursive NOT YET IMPLEMENTED!
- * @return configuration value of the given key.
- */
- @GET
- @Path("/keys/{key}")
- public String readConfig(@PathParam("key") String key, @QueryParam("recursive") Boolean recursive) {
- readCounter.incrementAndGet();
- final Configuration config = ConfigurationProvider.getConfiguration();
- if (key != null) {
- if (key.startsWith("/")) {
- key = key.substring(1);
- }
- if (config.get(key) != null && !recursive) {
- final Node node = new Node(config, key, "node");
- final JsonObjectBuilder root = Json.createObjectBuilder().add("action", "get")
- .add("node", node.createJsonObject());
- final StringWriter writer = new StringWriter();
- final JsonGenerator gen = Json.createGenerator(writer);
- gen.write(root.build());
- return writer.toString();
- }
- }
- Map<String, String> children = null;
- if (key == null) {
- children = config.getProperties();
- } else {
- children = config.with(ConfigurationFunctions.section(key)).getProperties();
- }
- final JsonArrayBuilder ab = Json.createArrayBuilder();
- for (final Map.Entry<String, String> en : children.entrySet()) {
- final Node node = new Node(config, en.getKey(), "node");
- ab.add(node.createJsonObject());
- }
- final Node node = new Node(config, key, "node", ab.build());
- final JsonObjectBuilder root = Json.createObjectBuilder().add("action", "get")
- .add("node", node.createJsonObject());
- final StringWriter writer = new StringWriter();
- final JsonWriter jwriter = Json.createWriter(writer);
- jwriter.writeObject(root.build());
- return writer.toString();
- }
-
- @PUT
- @Path("/v2/keys/{key}")
- public String writeEtcdConfig(@PathParam("key") String key, @javax.ws.rs.FormParam("value") String value,
- @FormParam("ttl") Integer ttl) {
- return writeConfig(key, value, ttl);
- }
-
- /**
- * This models a etcd2 compliant access point for setting a property value:
- * <pre>
- * {
- * "action": "set",
- * "node": {
- * "createdIndex": 3,
- * "key": "/message",
- * "modifiedIndex": 3,
- * "value": "Hello etcd"
- * },
- * "prevNode": {
- * "createdIndex": 2,
- * "key": "/message",
- * "value": "Hello world",
- * "modifiedIndex": 2
- * }
- * }
- * </pre>
- *
- * @param key name of the key to show
- * @param value configuration value for the given key
- * @param ttl time to live
- * @return written configuration value.
- */
- @PUT
- @Path("/keys/{key}")
- public String writeConfig(@PathParam("key") String key, @javax.ws.rs.FormParam("value") String value,
- @FormParam("ttl") Integer ttl) {
- writeCounter.incrementAndGet();
- final Configuration config = ConfigurationProvider.getConfiguration();
- if (key.startsWith("/")) {
- key = key.substring(1);
- }
- final Node prevNode = new Node(config, key, "prevNode");
- // TODO implement write! value and ttl as input
- final Node node = new Node(config, key, "node");
- final JsonObjectBuilder root = Json.createObjectBuilder().add("action", "set")
- .add("node", node.createJsonObject())
- .add("prevNode", prevNode.createJsonObject());
- final StringWriter writer = new StringWriter();
- final JsonWriter jwriter = Json.createWriter(writer);
- jwriter.writeObject(root.build());
- return writer.toString();
- }
-
- @DELETE
- @Path("/v2/keys/{key}")
- public String deleteEtcdConfig(@PathParam("key") String key) {
- return deleteConfig(key);
- }
-
- @DELETE
- @Path("/keys/{key}")
- public String deleteConfig(@PathParam("key") String key) {
- deleteCounter.incrementAndGet();
- final Configuration config = ConfigurationProvider.getConfiguration();
- if (key.startsWith("/")) {
- key = key.substring(1);
- }
- final Node prevNode = new Node(config, key, "prevNode");
- // TODO implement write! value and ttl as input
- final Node node = new Node(config, key, "node");
- final JsonObjectBuilder root = Json.createObjectBuilder().add("action", "delete")
- .add("node", node.createJsonObject())
- .add("prevNode", prevNode.createJsonObject());
- final StringWriter writer = new StringWriter();
- final JsonWriter jwriter = Json.createWriter(writer);
- jwriter.writeObject(root.build());
- return writer.toString();
- }
-
- public long getDeleteCounter() {
- return deleteCounter.get();
- }
-
- public long getReadCounter() {
- return readCounter.get();
- }
-
- public long getWriteCounter() {
- return writeCounter.get();
- }
-
- /**
- * Internal representation of a configuration node as modeled by etc.
- */
- private static final class Node {
- private Integer createdIndex;
- private Integer modifiedIndex;
- private final String key;
- private String value;
- private final String nodeId;
- private Integer ttl;
- private String expiration;
- private final JsonArray nodes;
-
- Node(Configuration config, String key, String nodeId) {
- this(config, key, nodeId, null);
- }
-
- Node(Configuration config, String key, String nodeId, JsonArray nodes) {
- this.key = key;
- this.nodeId = Objects.requireNonNull(nodeId);
- if (key != null) {
- value = config.get(key);
- createdIndex = config.getOrDefault("_" + key + ".createdIndex", Integer.class, null);
- modifiedIndex = config.getOrDefault("_" + key + ".modifiedIndex", Integer.class, null);
- ttl = config.getOrDefault("_" + key + ".ttl", Integer.class, null);
- expiration = config.getOrDefault("_" + key + ".expiration", null);
- }
- this.nodes = nodes;
- }
-
- JsonObject createJsonObject() {
- final JsonObjectBuilder nodeBuilder = Json.createObjectBuilder();
- if (key != null) {
- nodeBuilder.add("key", '/' + key);
- } else {
- nodeBuilder.add("dir", true);
- }
- if (value != null) {
- nodeBuilder.add("value", value);
- }
- if (createdIndex != null) {
- nodeBuilder.add("createdIndex", createdIndex.intValue());
- }
- if (modifiedIndex != null) {
- nodeBuilder.add("modifiedIndex", modifiedIndex.intValue());
- }
- if (ttl != null) {
- nodeBuilder.add("ttl", ttl.intValue());
- }
- if (expiration != null) {
- nodeBuilder.add("expiration", value);
- }
- if (nodes != null) {
- nodeBuilder.add("nodes", nodes);
- }
- return nodeBuilder.build();
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/server/src/main/java/org/apache/tamaya/server/VersionProperties.java
----------------------------------------------------------------------
diff --git a/modules/server/src/main/java/org/apache/tamaya/server/VersionProperties.java b/modules/server/src/main/java/org/apache/tamaya/server/VersionProperties.java
deleted file mode 100644
index e271694..0000000
--- a/modules/server/src/main/java/org/apache/tamaya/server/VersionProperties.java
+++ /dev/null
@@ -1,68 +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.server;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-
-/**
- * <p>This class gives access to the current name and the current version information
- * at runtime.</p>
- *
- * <p>All information offered by this is loaded from a properties file at
- * {@link VersionProperties#VERSION_PROPERTY_FILE}.</p>
- */
-public class VersionProperties {
- private static final String VERSION_PROPERTY_FILE = "/META-INF/tamaya-server-version.properties";
-
- static {
- try (InputStream resource = VersionProperties.class.getResourceAsStream(VERSION_PROPERTY_FILE)) {
- if (null == resource) {
- throw new ExceptionInInitializerError("Failed to version information resource. " +
- VERSION_PROPERTY_FILE + " not found.");
- }
-
- Properties properties = new Properties();
- properties.load(resource);
-
- product = properties.getProperty("server.product", "n/a");
- version = properties.getProperty("server.version", "n/a");
-
- } catch (IOException e) {
- throw new ExceptionInInitializerError(e);
- }
- }
-
- private static String product;
- private static String version;
-
- private VersionProperties() {
- }
-
- public static String getProduct() {
- return product;
- }
-
- public static String getVersion() {
- return version;
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/server/src/main/java/org/apache/tamaya/server/spi/ScopeManager.java
----------------------------------------------------------------------
diff --git a/modules/server/src/main/java/org/apache/tamaya/server/spi/ScopeManager.java b/modules/server/src/main/java/org/apache/tamaya/server/spi/ScopeManager.java
deleted file mode 100644
index 3d2757a..0000000
--- a/modules/server/src/main/java/org/apache/tamaya/server/spi/ScopeManager.java
+++ /dev/null
@@ -1,84 +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.server.spi;
-
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.ConfigOperator;
-import org.apache.tamaya.spi.ServiceContextManager;
-
-/**
- * Singleton manager for scopes, used by the server component to filtering returned configurations.
- */
-public final class ScopeManager {
- /** The logger used. */
- private static final Logger LOG = Logger.getLogger(ScopeManager.class.getName());
-
- private static Map<String, ScopeProvider> scopeProviders = initProviders();
-
- /**
- * Singleton constructor.
- */
- private static Map<String, ScopeProvider> initProviders(){
- final Map<String, ScopeProvider> result = new ConcurrentHashMap<>();
- for(final ScopeProvider prov: ServiceContextManager.getServiceContext().getServices(ScopeProvider.class)){
- try{
- result.put(prov.getScopeType(), prov);
- } catch(final Exception e){
- LOG.log(Level.WARNING, "Error loading scopes from " + prov, e);
- }
- }
- return result;
- }
-
- /**
- * Singleton constructor.
- */
- private ScopeManager(){}
-
- /**
- * Get the scope given its id and provider.
- *
- * @param scopeId the scope name
- * @param targetScope name of the targetScope
- * @return the scope matching
- * @throws ConfigException if no such scope is defined
- */
- public static ConfigOperator getScope(String scopeId, String targetScope)
- throws ConfigException {
- final ScopeProvider prov = scopeProviders.get(scopeId);
- if(prov==null){
- throw new ConfigException("No such scope: " + scopeId);
- }
- return prov.getScope(targetScope);
- }
-
- /**
- * Get the defined scope names.
- * @return the defined scope names, never null.
- */
- public static Set<String> getScopes(){
- return scopeProviders.keySet();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/server/src/main/java/org/apache/tamaya/server/spi/ScopeProvider.java
----------------------------------------------------------------------
diff --git a/modules/server/src/main/java/org/apache/tamaya/server/spi/ScopeProvider.java b/modules/server/src/main/java/org/apache/tamaya/server/spi/ScopeProvider.java
deleted file mode 100644
index 5c247d8..0000000
--- a/modules/server/src/main/java/org/apache/tamaya/server/spi/ScopeProvider.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.server.spi;
-
-import org.apache.tamaya.ConfigOperator;
-
-/**
- * Simple registrable provider class to register scopes for the server extension.
- */
-public interface ScopeProvider {
-
- /**
- * Access the unique scope name.
- * @return the unique scope name.
- */
- String getScopeType();
-
- /**
- * Return the scope operator that implements the scope for the given scope id.
- * @param scopeId target scope id.
- * @return the scope operator, never null.
- */
- ConfigOperator getScope(String scopeId);
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/server/src/main/resources/META-INF/tamaya-server-version.properties
----------------------------------------------------------------------
diff --git a/modules/server/src/main/resources/META-INF/tamaya-server-version.properties b/modules/server/src/main/resources/META-INF/tamaya-server-version.properties
deleted file mode 100644
index ef0ca70..0000000
--- a/modules/server/src/main/resources/META-INF/tamaya-server-version.properties
+++ /dev/null
@@ -1,22 +0,0 @@
-
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy 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.
-#
-
-server.product=Apache Tamaya
-server.version=${project.version}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/server/src/main/resources/banner.txt
----------------------------------------------------------------------
diff --git a/modules/server/src/main/resources/banner.txt b/modules/server/src/main/resources/banner.txt
deleted file mode 100644
index 4e2714b..0000000
--- a/modules/server/src/main/resources/banner.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-
- \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557
-\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255d\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255d \u255a\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255d\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u255a\u2588\u2588\u2557 \u2588\u2588\u2554\u255d\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557
-\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255d\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2554\u2588\u2588\u2588\u2588\u2554\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551 \u255a\u2588\u2588\u2588\u2588\u2554\u255d \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551
-\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u255d \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u255d \u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2551\u255a\u2588\u2588\u2554\u255d\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551 \u255a\u2588\u2588\u2554\u255d \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551
-\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u255a\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u255a\u2550\u255d \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551
-\u255a\u2550\u255d \u255a\u2550\u255d\u255a\u2550\u255d \u255a\u2550\u255d \u255a\u2550\u255d \u255a\u2550\u2550\u2550\u2550\u2550\u255d\u255a\u2550\u255d \u255a\u2550\u255d\u255a\u2550\u2550\u2550\u2550\u2550\u2550\u255d \u255a\u2550\u255d \u255a\u2550\u255d \u255a\u2550\u255d\u255a\u2550\u255d \u255a\u2550\u255d\u255a\u2550\u255d \u255a\u2550\u255d \u255a\u2550\u255d \u255a\u2550\u255d \u255a\u2550\u255d
- \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2557
- \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255d\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255d\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255d\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557
- \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255d\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255d
- \u255a\u2550\u2550\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u255d \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u255a\u2588\u2588\u2557 \u2588\u2588\u2554\u255d\u2588\u2588\u2554\u2550\u2550\u255d \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557
- \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551 \u255a\u2588\u2588\u2588\u2588\u2554\u255d \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551
- \u255a\u2550\u2550\u2550\u2550\u2550\u2550\u255d\u255a\u2550\u2550\u2550\u2550\u2550\u2550\u255d\u255a\u2550\u255d \u255a\u2550\u255d \u255a\u2550\u2550\u2550\u255d \u255a\u2550\u2550\u2550\u2550\u2550\u2550\u255d\u255a\u2550\u255d \u255a\u2550\u255d
-
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/server/src/main/resources/config-server.yml
----------------------------------------------------------------------
diff --git a/modules/server/src/main/resources/config-server.yml b/modules/server/src/main/resources/config-server.yml
deleted file mode 100644
index 2e210a6..0000000
--- a/modules/server/src/main/resources/config-server.yml
+++ /dev/null
@@ -1,31 +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.
-#
-
-scope: java
-
-server:
- applicationConnectors:
- - type: http
- port: 4001
- adminConnectors:
- - type: http
- port: 4099
-
- # ${project.version}
-
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/server/src/test/java/org/apache/tamaya/server/ConfigServiceAppTest.java
----------------------------------------------------------------------
diff --git a/modules/server/src/test/java/org/apache/tamaya/server/ConfigServiceAppTest.java b/modules/server/src/test/java/org/apache/tamaya/server/ConfigServiceAppTest.java
deleted file mode 100644
index 5f7163d..0000000
--- a/modules/server/src/test/java/org/apache/tamaya/server/ConfigServiceAppTest.java
+++ /dev/null
@@ -1,32 +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.server;
-
-//import static org.junit.Assert.*;
-
-/**
- * Created by atsticks on 22.01.16.
- */
-public class ConfigServiceAppTest {
-
-// @org.junit.Test
-// public void testMain() throws Exception {
-//
-// }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/server/src/test/java/org/apache/tamaya/server/EtcdAccessor.java
----------------------------------------------------------------------
diff --git a/modules/server/src/test/java/org/apache/tamaya/server/EtcdAccessor.java b/modules/server/src/test/java/org/apache/tamaya/server/EtcdAccessor.java
deleted file mode 100644
index 1c8e94b..0000000
--- a/modules/server/src/test/java/org/apache/tamaya/server/EtcdAccessor.java
+++ /dev/null
@@ -1,519 +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.etcd;
-//
-//import org.apache.http.HttpEntity;
-//import org.apache.http.HttpStatus;
-//import org.apache.http.NameValuePair;
-//import org.apache.http.client.config.RequestConfig;
-//import org.apache.http.client.entity.UrlEncodedFormEntity;
-//import org.apache.http.client.methods.CloseableHttpResponse;
-//import org.apache.http.client.methods.HttpDelete;
-//import org.apache.http.client.methods.HttpGet;
-//import org.apache.http.client.methods.HttpPut;
-//import org.apache.http.impl.client.CloseableHttpClient;
-//import org.apache.http.impl.client.HttpClients;
-//import org.apache.http.message.BasicNameValuePair;
-//import org.apache.http.util.EntityUtils;
-//
-//import javax.json.Json;
-//import javax.json.JsonArray;
-//import javax.json.JsonObject;
-//import javax.json.JsonReader;
-//import javax.json.JsonReaderFactory;
-//import java.io.IOException;
-//import java.io.StringReader;
-//import java.util.ArrayList;
-//import java.util.HashMap;
-//import java.util.List;
-//import java.util.Map;
-//import java.util.logging.Level;
-//import java.util.logging.Logger;
-//
-///**
-// * Accessor for reading/writing an etcd endpoint.
-// */
-//public class EtcdAccessor {
-//
-// private static final Logger LOG = Logger.getLogger(EtcdAccessor.class.getName());
-//
-// /** Timeout in seconds. */
-// private int timeout = 2;
-// /** Property that make Johnzon accept commentc. */
-// public static final String JOHNZON_SUPPORTS_COMMENTS_PROP = "org.apache.johnzon.supports-comments";
-// /** The JSON reader factory used. */
-// private final JsonReaderFactory readerFactory = initReaderFactory();
-//
-// /** Initializes the factory to be used for creating readers. */
-// private JsonReaderFactory initReaderFactory() {
-// Map<String, Object> config = new HashMap<>();
-// config.put(JOHNZON_SUPPORTS_COMMENTS_PROP, true);
-// return Json.createReaderFactory(config);
-// }
-//
-// /** The base server url. */
-// private final String serverURL;
-// /** The http client. */
-// private CloseableHttpClient httpclient = HttpClients.createDefault();
-//
-// /**
-// * Creates a new instance with the basic access url.
-// * @param server server url, e.g. {@code http://127.0.0.1:4001}, not null.
-// */
-// public EtcdAccessor(String server){
-// this(server, 2);
-// }
-//
-// public EtcdAccessor(String server, int timeout) {
-// this.timeout = timeout;
-// if(server.endsWith("/")){
-// serverURL = server.substring(0, server.length()-1);
-// } else{
-// serverURL = server;
-// }
-//
-// }
-//
-// /**
-// * Get the etcd server version.
-// * @return the etcd server version, never null.
-// */
-// public String getVersion(){
-// CloseableHttpResponse response = null;
-// String version = "<ERROR>";
-// try {
-// CloseableHttpClient httpclient = HttpClients.createDefault();
-// HttpGet httpGet = new HttpGet(serverURL + "/version");
-// httpGet.setConfig(RequestConfig.copy(RequestConfig.DEFAULT).setSocketTimeout(timeout)
-// .setConnectionRequestTimeout(timeout).setConnectTimeout(timeout).build());
-// response = httpclient.execute(httpGet);
-// HttpEntity entity;
-// if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
-// entity = response.getEntity();
-// // and ensure it is fully consumed
-// version = EntityUtils.toString(entity);
-// EntityUtils.consume(entity);
-// }
-// return version;
-// } catch(Exception e){
-// LOG.log(Level.INFO, "Error getting etcd version from: " + serverURL, e);
-// } finally {
-// if(response!=null){
-// try {
-// response.close();
-// } catch (IOException e) {
-// LOG.log(Level.WARNING, "Failed to close http response", e);
-// }
-// }
-// }
-// return version;
-// }
-//
-// /**
-// * Ask etcd for s aingle key, value pair. Hereby the response returned from etcd:
-// * <pre>
-// * {
-// "action": "get",
-// "node": {
-// "createdIndex": 2,
-// "key": "/message",
-// "modifiedIndex": 2,
-// "value": "Hello world"
-// }
-// * }
-// * </pre>
-// * is mapped to:
-// * <pre>
-// * key=value
-// * _key.source=[etcd]http://127.0.0.1:4001
-// * _key.createdIndex=12
-// * _key.modifiedIndex=34
-// * _key.ttl=300
-// * _key.expiration=...
-// * </pre>
-// * @param key the requested key
-// * @return the mapped result, including meta-entries.
-// */
-// public Map<String,String> get(String key){
-// CloseableHttpResponse response = null;
-// Map<String,String> result = new HashMap<>();
-// try {
-// HttpGet httpGet = new HttpGet(serverURL + "/v2/keys/"+key);
-// httpGet.setConfig(RequestConfig.copy(RequestConfig.DEFAULT).setSocketTimeout(timeout)
-// .setConnectionRequestTimeout(timeout).setConnectTimeout(timeout).build());
-// response = httpclient.execute(httpGet);
-// if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
-// HttpEntity entity = response.getEntity();
-// JsonReader reader = readerFactory.createReader(new StringReader(EntityUtils.toString(entity)));
-// JsonObject o = reader.readObject();
-// JsonObject node = o.getJsonObject("node");
-// result.put(key, node.getString("value"));
-// result.put("_" + key +".source", "[etcd]"+serverURL);
-// if(node.containsKey("createdIndex")) {
-// result.put("_" + key +".createdIndex", String.valueOf(node.getInt("createdIndex")));
-// }
-// if(node.containsKey("modifiedIndex")) {
-// result.put("_" + key +".modifiedIndex", String.valueOf(node.getInt("modifiedIndex")));
-// }
-// if(node.containsKey("expiration")) {
-// result.put("_" + key +".expiration", String.valueOf(node.getString("expiration")));
-// }
-// if(node.containsKey("ttl")) {
-// result.put("_" + key +".ttl", String.valueOf(node.getInt("ttl")));
-// }
-// EntityUtils.consume(entity);
-// }else{
-// result.put("_" + key +".NOT_FOUND.target", "[etcd]"+serverURL);
-// }
-// } catch(Exception e){
-// LOG.log(Level.INFO, "Error reading key '"+key+"' from etcd: " + serverURL, e);
-// result.put("_ERROR", "Error reading key '"+key+"' from etcd: " + serverURL + ": " + e.toString());
-// } finally {
-// if(response!=null){
-// try {
-// response.close();
-// } catch (IOException e) {
-// LOG.log(Level.WARNING, "Failed to close http response", e);
-// }
-// }
-// }
-// return result;
-// }
-//
-// /**
-// * Creates/updates an entry in etcd without any ttl set.
-// * @see #set(String, String, Integer)
-// * @param key the property key, not null
-// * @param value the value to be set
-// * @return the result map as described above.
-// */
-// public Map<String,String> set(String key, String value){
-// return set(key, value, null);
-// }
-//
-// /**
-// * Creates/updates an entry in etcd. The response as follows:
-// * <pre>
-// * {
-// "action": "set",
-// "node": {
-// "createdIndex": 3,
-// "key": "/message",
-// "modifiedIndex": 3,
-// "value": "Hello etcd"
-// },
-// "prevNode": {
-// "createdIndex": 2,
-// "key": "/message",
-// "value": "Hello world",
-// "modifiedIndex": 2
-// }
-// }
-// * </pre>
-// * is mapped to:
-// * <pre>
-// * key=value
-// * _key.source=[etcd]http://127.0.0.1:4001
-// * _key.createdIndex=12
-// * _key.modifiedIndex=34
-// * _key.ttl=300
-// * _key.expiry=...
-// * // optional
-// * _key.prevNode.createdIndex=12
-// * _key.prevNode.modifiedIndex=34
-// * _key.prevNode.ttl=300
-// * _key.prevNode.expiration=...
-// * </pre>
-// * @param key the property key, not null
-// * @param value the value to be set
-// * @param ttlSeconds the ttl in seconds (optional)
-// * @return the result map as described above.
-// */
-// public Map<String,String> set(String key, String value, Integer ttlSeconds){
-// CloseableHttpResponse response = null;
-// Map<String,String> result = new HashMap<>();
-// try{
-// HttpPut put = new HttpPut(serverURL + "/v2/keys/"+key);
-// put.setConfig(RequestConfig.copy(RequestConfig.DEFAULT).setSocketTimeout(timeout)
-// .setConnectionRequestTimeout(timeout).setConnectTimeout(timeout).build());
-// List<NameValuePair> nvps = new ArrayList<>();
-// nvps.add(new BasicNameValuePair("value", value));
-// if(ttlSeconds!=null){
-// nvps.add(new BasicNameValuePair("ttl", ttlSeconds.toString()));
-// }
-// put.setEntity(new UrlEncodedFormEntity(nvps));
-// response = httpclient.execute(put);
-// if (response.getStatusLine().getStatusCode() == HttpStatus.SC_CREATED ||
-// response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
-// HttpEntity entity = response.getEntity();
-// JsonReader reader = readerFactory.createReader(new StringReader(EntityUtils.toString(entity)));
-// JsonObject o = reader.readObject();
-// JsonObject node = o.getJsonObject("node");
-// if(node.containsKey("createdIndex")) {
-// result.put("_" + key +".createdIndex", String.valueOf(node.getInt("createdIndex")));
-// }
-// if(node.containsKey("modifiedIndex")) {
-// result.put("_" + key +".modifiedIndex", String.valueOf(node.getInt("modifiedIndex")));
-// }
-// if(node.containsKey("expiration")) {
-// result.put("_" + key +".expiration", String.valueOf(node.getString("expiration")));
-// }
-// if(node.containsKey("ttl")) {
-// result.put("_" + key +".ttl", String.valueOf(node.getInt("ttl")));
-// }
-// result.put(key, node.getString("value"));
-// result.put("_" + key +".source", "[etcd]"+serverURL);
-// if(node.containsKey("prevNode")){
-// JsonObject prevNode = node.getJsonObject("prevNode");
-// if (prevNode.containsKey("createdIndex")) {
-// result.put("_" + key +".prevNode.createdIndex", String.valueOf(prevNode.getInt("createdIndex")));
-// }
-// if (prevNode.containsKey("modifiedIndex")) {
-// result.put("_" + key +".prevNode.modifiedIndex", String.valueOf(prevNode.getInt("modifiedIndex")));
-// }
-// if(prevNode.containsKey("expiration")) {
-// result.put("_" + key +".prevNode.expiration", String.valueOf(prevNode.getString("expiration")));
-// }
-// if(prevNode.containsKey("ttl")) {
-// result.put("_" + key +".prevNode.ttl", String.valueOf(prevNode.getInt("ttl")));
-// }
-// result.put("_" + key +".prevNode.value", prevNode.getString("value"));
-// }
-// EntityUtils.consume(entity);
-// }
-// } catch(Exception e){
-// LOG.log(Level.INFO, "Error writing to etcd: " + serverURL, e);
-// result.put("_ERROR", "Error writing '"+key+"' to etcd: " + serverURL + ": " + e.toString());
-// } finally {
-// if(response!=null){
-// try {
-// response.close();
-// } catch (IOException e) {
-// LOG.log(Level.WARNING, "Failed to close http response", e);
-// }
-// }
-// }
-// return result;
-// }
-//
-//
-// /**
-// * Deletes a given key. The response is as follows:
-// * <pre>
-// * _key.source=[etcd]http://127.0.0.1:4001
-// * _key.createdIndex=12
-// * _key.modifiedIndex=34
-// * _key.ttl=300
-// * _key.expiry=...
-// * // optional
-// * _key.prevNode.createdIndex=12
-// * _key.prevNode.modifiedIndex=34
-// * _key.prevNode.ttl=300
-// * _key.prevNode.expiration=...
-// * _key.prevNode.value=...
-// * </pre>
-// * @param key the key to be deleted.
-// * @return the response mpas as described above.
-// */
-// public Map<String,String> delete(String key){
-// CloseableHttpResponse response = null;
-// Map<String,String> result = new HashMap<>();
-// try{
-// HttpDelete delete = new HttpDelete(serverURL + "/v2/keys/"+key);
-// delete.setConfig(RequestConfig.copy(RequestConfig.DEFAULT).setSocketTimeout(timeout)
-// .setConnectionRequestTimeout(timeout).setConnectTimeout(timeout).build());
-// response = httpclient.execute(delete);
-// if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
-// HttpEntity entity = response.getEntity();
-// JsonReader reader = readerFactory.createReader(new StringReader(EntityUtils.toString(entity)));
-// JsonObject o = reader.readObject();
-// JsonObject node = o.getJsonObject("node");
-// if(node.containsKey("createdIndex")) {
-// result.put("_" + key +".createdIndex", String.valueOf(node.getInt("createdIndex")));
-// }
-// if(node.containsKey("modifiedIndex")) {
-// result.put("_" + key +".modifiedIndex", String.valueOf(node.getInt("modifiedIndex")));
-// }
-// if(node.containsKey("expiration")) {
-// result.put("_" + key +".expiration", String.valueOf(node.getString("expiration")));
-// }
-// if(node.containsKey("ttl")) {
-// result.put("_" + key +".ttl", String.valueOf(node.getInt("ttl")));
-// }
-// if(o.containsKey("prevNode")){
-// JsonObject prevNode = o.getJsonObject("prevNode");
-// if (prevNode.containsKey("createdIndex")) {
-// result.put("_" + key +".prevNode.createdIndex", String.valueOf(prevNode.getInt("createdIndex")));
-// }
-// if (prevNode.containsKey("modifiedIndex")) {
-// result.put("_" + key +".prevNode.modifiedIndex", String.valueOf(prevNode.getInt("modifiedIndex")));
-// }
-// if(prevNode.containsKey("expiration")) {
-// result.put("_" + key +".prevNode.expiration", String.valueOf(prevNode.getString("expiration")));
-// }
-// if(prevNode.containsKey("ttl")) {
-// result.put("_" + key +".prevNode.ttl", String.valueOf(prevNode.getInt("ttl")));
-// }
-// result.put("_" + key +".prevNode.value", prevNode.getString("value"));
-// }
-// EntityUtils.consume(entity);
-// }
-// } catch(Exception e){
-// LOG.log(Level.INFO, "Error deleting key '"+key+"' from etcd: " + serverURL, e);
-// result.put("_ERROR", "Error deleting '"+key+"' from etcd: " + serverURL + ": " + e.toString());
-// } finally {
-// if(response!=null){
-// try {
-// response.close();
-// } catch (IOException e) {
-// LOG.log(Level.WARNING, "Failed to close http response", e);
-// }
-// }
-// }
-// return result;
-// }
-//
-// /**
-// * Get all properties for the given directory key recursively.
-// * @see #getProperties(String, boolean)
-// * @param directory the directory entry
-// * @return the properties and its metadata
-// */
-// public Map<String,String> getProperties(String directory){
-// return getProperties(directory, true);
-// }
-//
-// /**
-// * Access all properties.
-// * The response of:
-// * <pre>
-// {
-// "action": "get",
-// "node": {
-// "key": "/",
-// "dir": true,
-// "nodes": [
-// {
-// "key": "/foo_dir",
-// "dir": true,
-// "modifiedIndex": 2,
-// "createdIndex": 2
-// },
-// {
-// "key": "/foo",
-// "value": "two",
-// "modifiedIndex": 1,
-// "createdIndex": 1
-// }
-// ]
-// }
-//}
-// </pre>
-// is mapped to a regular Tamaya properties map as follows:
-// <pre>
-// * key1=myvalue
-// * _key1.source=[etcd]http://127.0.0.1:4001
-// * _key1.createdIndex=12
-// * _key1.modifiedIndex=34
-// * _key1.ttl=300
-// * _key1.expiration=...
-// *
-// * key2=myvaluexxx
-// * _key2.source=[etcd]http://127.0.0.1:4001
-// * _key2.createdIndex=12
-// *
-// * key3=val3
-// * _key3.source=[etcd]http://127.0.0.1:4001
-// * _key3.createdIndex=12
-// * _key3.modifiedIndex=2
-// * </pre>
-// */
-// public Map<String,String> getProperties(String directory, boolean recursive){
-// CloseableHttpResponse response = null;
-// Map<String,String> result = new HashMap<>();
-// try{
-// HttpGet get = new HttpGet(serverURL + "/v2/keys/"+directory+"?recursive="+recursive);
-// get.setConfig(RequestConfig.copy(RequestConfig.DEFAULT).setSocketTimeout(timeout)
-// .setConnectionRequestTimeout(timeout).setConnectTimeout(timeout).build());
-// response = httpclient.execute(get);
-// if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
-// HttpEntity entity = response.getEntity();
-// JsonReader reader = readerFactory.createReader(new StringReader(EntityUtils.toString(entity)));
-// JsonObject o = reader.readObject();
-// JsonObject node = o.getJsonObject("node");
-// if(node!=null){
-// addNodes(result, node);
-// }
-// EntityUtils.consume(entity);
-// }
-// } catch(Exception e){
-// LOG.log(Level.INFO, "Error reading properties for '"+directory+"' from etcd: " + serverURL, e);
-// result.put("_ERROR", "Error reading properties for '"+directory+"' from etcd: " + serverURL + ": " + e.toString());
-// } finally {
-// if(response!=null){
-// try {
-// response.close();
-// } catch (IOException e) {
-// LOG.log(Level.WARNING, "Failed to close http response", e);
-// }
-// }
-// }
-// return result;
-// }
-//
-// /**
-// * Recursively read out all key/values from this etcd JSON array.
-// * @param result map with key, values and metadata.
-// * @param node the node to parse.
-// */
-// private void addNodes(Map<String, String> result, JsonObject node) {
-// if(!node.containsKey("dir") || "false".equals(node.get("dir").toString())) {
-// String key = node.getString("key").substring(1);
-// result.put(key, node.getString("value"));
-// if (node.containsKey("createdIndex")) {
-// result.put("_" + key + ".createdIndex", String.valueOf(node.getInt("createdIndex")));
-// }
-// if (node.containsKey("modifiedIndex")) {
-// result.put("_" + key + ".modifiedIndex", String.valueOf(node.getInt("modifiedIndex")));
-// }
-// if (node.containsKey("expiration")) {
-// result.put("_" + key + ".expiration", String.valueOf(node.getString("expiration")));
-// }
-// if (node.containsKey("ttl")) {
-// result.put("_" + key + ".ttl", String.valueOf(node.getInt("ttl")));
-// }
-// result.put("_" + key +".source", "[etcd]"+serverURL);
-// } else {
-// JsonArray nodes = node.getJsonArray("nodes");
-// if (nodes != null) {
-// for (int i = 0; i < nodes.size(); i++) {
-// addNodes(result, nodes.getJsonObject(i));
-// }
-// }
-// }
-// }
-//
-// /**
-// * Access the server root URL used by this accessor.
-// * @return
-// */
-// public String getUrl() {
-// return serverURL;
-// }
-//}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/server/src/test/java/org/apache/tamaya/server/VersionPropertiesTest.java
----------------------------------------------------------------------
diff --git a/modules/server/src/test/java/org/apache/tamaya/server/VersionPropertiesTest.java b/modules/server/src/test/java/org/apache/tamaya/server/VersionPropertiesTest.java
deleted file mode 100644
index 18bc0ba..0000000
--- a/modules/server/src/test/java/org/apache/tamaya/server/VersionPropertiesTest.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.server;
-
-import org.hamcrest.Matchers;
-import org.junit.Test;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-
-import static org.hamcrest.Matchers.not;
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.*;
-
-public class VersionPropertiesTest {
-
- @Test
- public void correctVersionPropertiesAreReadAndSet() throws IOException {
- InputStream resource = VersionProperties.class.getResourceAsStream("/META-INF/tamaya-server-version.properties");
-
- Properties properties = new Properties();
- properties.load(resource);
-
- assertThat(VersionProperties.getVersion(), not(Matchers.isEmptyOrNullString()));
- assertThat(VersionProperties.getVersion(), equalTo(properties.get("server.version")));
- assertThat(VersionProperties.getProduct(), not(Matchers.isEmptyOrNullString()));
- assertThat(VersionProperties.getProduct(), equalTo(properties.get("server.product")));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/spi-support/pom.xml
----------------------------------------------------------------------
diff --git a/modules/spi-support/pom.xml b/modules/spi-support/pom.xml
deleted file mode 100644
index 62082eb..0000000
--- a/modules/spi-support/pom.xml
+++ /dev/null
@@ -1,75 +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.
--->
-<project xmlns="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">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-extensions</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
-
- <artifactId>tamaya-spisupport</artifactId>
- <name> Apache Tamaya Modules - Common Support Classes</name>
- <description>Apache Tamaya Support Classes useful when implementing the Tamaya SPI or code independent of the core RI
- implementation.</description>
- <packaging>bundle</packaging>
-
- <properties>
- <jdkVersion>1.7</jdkVersion>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <!-- Test scope only, do not create a code dependency! -->
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-core</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.tamaya.spisupport
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/BasePropertySource.java
----------------------------------------------------------------------
diff --git a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/BasePropertySource.java b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/BasePropertySource.java
deleted file mode 100644
index 0d90c8c..0000000
--- a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/BasePropertySource.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 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.spisupport;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Abstract {@link org.apache.tamaya.spi.PropertySource} that allows to set a default ordinal that will be used, if no
- * ordinal is provided with the config.
- */
-public abstract class BasePropertySource implements PropertySource{
- /** default ordinal that will be used, if no ordinal is provided with the config. */
- private final int defaultOrdinal;
-
- /**
- * Constructor.
- * @param defaultOrdinal default ordinal that will be used, if no ordinal is provided with the config.
- */
- protected BasePropertySource(int defaultOrdinal){
- this.defaultOrdinal = defaultOrdinal;
- }
-
- /**
- * Constructor, using a default ordinal of 0.
- */
- protected BasePropertySource(){
- this(0);
- }
-
- @Override
- public String getName() {
- return getClass().getSimpleName();
- }
-
- @Override
- public int getOrdinal() {
- PropertyValue configuredOrdinal = get(TAMAYA_ORDINAL);
- if(configuredOrdinal!=null){
- try{
- return Integer.parseInt(configuredOrdinal.get(TAMAYA_ORDINAL));
- } catch(Exception e){
- Logger.getLogger(getClass().getName()).log(Level.WARNING,
- "Configured Ordinal is not an int number: " + configuredOrdinal, e);
- }
- }
- return getDefaultOrdinal();
- }
-
- /**
- * Returns the default ordinal used, when no ordinal is set, or the ordinal was not parseable to an int value.
- * @return the default ordinal used, by default 0.
- */
- public int getDefaultOrdinal(){
- return defaultOrdinal;
- }
-
- @Override
- public PropertyValue get(String key) {
- return PropertyValue.of(key, getProperties().get(key), getName());
- }
-
- @Override
- public boolean isScannable(){
- return true;
- }
-}
[10/24] incubator-tamaya git commit: Removed all modules from the
main repository. They will be reborn in separate ASF repository.
Posted by pl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/osgi/src/main/java/org/apache/tamaya/integration/osgi/TamayaConfigAdminImpl.java
----------------------------------------------------------------------
diff --git a/modules/integration/osgi/src/main/java/org/apache/tamaya/integration/osgi/TamayaConfigAdminImpl.java b/modules/integration/osgi/src/main/java/org/apache/tamaya/integration/osgi/TamayaConfigAdminImpl.java
deleted file mode 100644
index 7bf4da7..0000000
--- a/modules/integration/osgi/src/main/java/org/apache/tamaya/integration/osgi/TamayaConfigAdminImpl.java
+++ /dev/null
@@ -1,196 +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.integration.osgi;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.Filter;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceFactory;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.Configuration;
-import org.osgi.service.cm.ConfigurationAdmin;
-import org.osgi.service.cm.ManagedService;
-import org.osgi.service.cm.ManagedServiceFactory;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * Tamaya based implementation of an OSGI {@link ConfigurationAdmin}.
- */
-public class TamayaConfigAdminImpl implements ConfigurationAdmin {
- /** the logger. */
- private static final Logger LOG = Logger.getLogger(TamayaConfigAdminImpl.class.getName());
-
- /** The OSGI context. */
- private final BundleContext context;
- /** THe optional OSGI parent service. */
- private ConfigurationAdmin parent;
- /** The cached configurations. */
- private Map<String,Configuration> configs = new ConcurrentHashMap<>();
- /** The configuration section mapper. */
- private OSGIConfigRootMapper configRootMapper;
-
- /**
- * Create a new config.
- * @param context the OSGI context
- */
- TamayaConfigAdminImpl(BundleContext context) {
- this.context = context;
- this.configRootMapper = loadConfigRootMapper();
- ServiceReference<ConfigurationAdmin> ref = context.getServiceReference(ConfigurationAdmin.class);
- this.parent = ref!=null?context.getService(ref):null;
- ServiceTracker<ManagedService, ManagedService> serviceTracker = new ServiceTracker<ManagedService,
- ManagedService>(context, ManagedService.class, null) {
- @Override
- public ManagedService addingService(ServiceReference<ManagedService> reference) {
- ManagedService service = context.getService(reference);
- Object pidObj = reference.getProperty(Constants.SERVICE_PID);
- if (pidObj instanceof String) {
- String pid = (String) pidObj;
- try {
- Configuration config = getConfiguration(pid);
- if(config==null){
- service.updated(null);
- } else{
- service.updated(config.getProperties());
- }
- } catch (Exception e) {
- LOG.log(Level.WARNING, "Error configuring ManagedService: " + service, e);
- }
- } else {
- LOG.log(Level.SEVERE, "Unsupported pid: " + pidObj);
- }
- return service;
- }
-
- @Override
- public void removedService(ServiceReference<ManagedService> reference, ManagedService service) {
- context.ungetService(reference);
- }
- };
- serviceTracker.open();
-
- ServiceTracker<ServiceFactory, ServiceFactory> factoryTracker
- = new ServiceTracker<ServiceFactory, ServiceFactory>(context, ServiceFactory.class, null) {
- @Override
- public ServiceFactory addingService(ServiceReference<ServiceFactory> reference) {
- ServiceFactory factory = context.getService(reference);
- if(factory instanceof ManagedServiceFactory) {
- Object pidObj = reference.getProperty(Constants.SERVICE_PID);
- if (pidObj instanceof String) {
- String pid = (String) pidObj;
- try {
- Configuration config = getConfiguration(pid);
- if (config != null) {
- ((ManagedServiceFactory) factory).updated(config.getFactoryPid(), config.getProperties());
- }
- } catch (Exception e) {
- LOG.log(Level.WARNING, "Error configuring ManagedServiceFactory: " + factory, e);
- }
- } else {
- LOG.log(Level.SEVERE, "Unsupported pid: " + pidObj);
- }
- }
- return factory;
- }
-
- @Override
- public void removedService(ServiceReference<ServiceFactory> reference, ServiceFactory service) {
- super.removedService(reference, service);
- }
- };
- factoryTracker.open();
- }
-
- @Override
- public Configuration createFactoryConfiguration(String factoryPid) throws IOException {
- return createFactoryConfiguration(factoryPid, null);
- }
-
- @Override
- public Configuration createFactoryConfiguration(String factoryPid, String location) throws IOException {
- return new TamayaConfigurationImpl(factoryPid, null, configRootMapper, this.parent);
- }
-
- @Override
- public Configuration getConfiguration(String pid, String location) throws IOException {
- return getConfiguration(pid);
- }
-
- @Override
- public Configuration getConfiguration(String pid) throws IOException {
- return new TamayaConfigurationImpl(pid, null, configRootMapper, this.parent);
- }
-
- @Override
- public Configuration[] listConfigurations(String filter) throws IOException, InvalidSyntaxException {
- Collection<Configuration> result;
- if (filter == null) {
- result = this.configs.values();
- } else {
- result = new ArrayList<>();
- Filter flt = context.createFilter(filter);
- for (Configuration config : this.configs.values()) {
- if (flt.match(config.getProperties())) {
- result.add(config);
- }
- }
- }
- return result.isEmpty() ? null : result.toArray(new Configuration[configs.size()]);
- }
-
- /**
- * Loads the configuration toor mapper using the OSGIConfigRootMapper OSGI service resolving mechanism. If no
- * such service is available it loads the default mapper.
- * @return the mapper to be used, bever null.
- */
- private OSGIConfigRootMapper loadConfigRootMapper() {
- OSGIConfigRootMapper mapper = null;
- ServiceReference<OSGIConfigRootMapper> ref = context.getServiceReference(OSGIConfigRootMapper.class);
- if(ref!=null){
- mapper = context.getService(ref);
- }
- if(mapper==null){
- mapper = new OSGIConfigRootMapper() {
- @Override
- public String getTamayaConfigRoot(String pid, String factoryPid) {
- if(pid!=null) {
- return "[bundle:" + pid +']';
- } else{
- return "[bundle:" + factoryPid +']';
- }
- }
- @Override
- public String toString(){
- return "Default OSGIConfigRootMapper(pid -> [bundle:pid], factoryPid -> [bundle:factoryPid]";
- }
- };
- }
- return mapper;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/osgi/src/main/java/org/apache/tamaya/integration/osgi/TamayaConfigurationImpl.java
----------------------------------------------------------------------
diff --git a/modules/integration/osgi/src/main/java/org/apache/tamaya/integration/osgi/TamayaConfigurationImpl.java b/modules/integration/osgi/src/main/java/org/apache/tamaya/integration/osgi/TamayaConfigurationImpl.java
deleted file mode 100644
index c7b0864..0000000
--- a/modules/integration/osgi/src/main/java/org/apache/tamaya/integration/osgi/TamayaConfigurationImpl.java
+++ /dev/null
@@ -1,127 +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.integration.osgi;
-
-import java.io.IOException;
-import java.util.*;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.functions.PropertyMatcher;
-import org.apache.tamaya.functions.ConfigurationFunctions;
-import org.osgi.service.cm.Configuration;
-import org.osgi.service.cm.ConfigurationAdmin;
-
-/**
- * Tamaya based implementation of an OSGI {@link Configuration}.
- */
-public class TamayaConfigurationImpl implements Configuration {
- private static final Logger LOG = Logger.getLogger(TamayaConfigurationImpl.class.getName());
- private final String pid;
- private final String factoryPid;
- private Map<String, String> properties = new HashMap<>();
- private org.apache.tamaya.Configuration config;
-
- /**
- * Constructor.
- * @param confPid the OSGI pid
- * @param factoryPid the factory pid
- * @param configRootMapper the mapper that maps the pids to a tamaya root section.
- * @param parent the (optional delegating parent, used as default).
- */
- TamayaConfigurationImpl(String confPid, String factoryPid, OSGIConfigRootMapper configRootMapper,
- ConfigurationAdmin parent) {
- this.pid = confPid;
- this.factoryPid = factoryPid;
- if(parent!=null){
- try {
- Dictionary<String, Object> conf = parent.getConfiguration(confPid, factoryPid).getProperties();
- if(conf!=null) {
- LOG.info("Configuration: Adding default parameters from parent: " + parent.getClass().getName());
- Enumeration<String> keys = conf.keys();
- while (keys.hasMoreElements()) {
- String key = keys.nextElement();
- this.properties.put(key, conf.get(key).toString());
- }
- }
- } catch (IOException e) {
- LOG.log(Level.WARNING, "Error reading parent OSGI config.", e);
- }
- }
- this.config = ConfigurationProvider.getConfiguration();
- final String rootKey = configRootMapper.getTamayaConfigRoot(pid, factoryPid);
- LOG.info("Configuration: Evaluating Tamaya configuration for '" + rootKey + "'.");
- this.properties.putAll(
- config.with(ConfigurationFunctions.section(rootKey, true)).getProperties());
- }
-
- @Override
- public String getPid() {
- return pid;
- }
-
- @Override
- public Dictionary<String, Object> getProperties() {
- return new Hashtable<String, Object>(properties);
- }
-
- @Override
- public void update(Dictionary<String, ?> properties) throws IOException {
- throw new UnsupportedOperationException("Nuatability not yet supported.");
- // ConfigChangeProvider.createChangeRequest(this.config)
- }
-
- @Override
- public void delete() throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String getFactoryPid() {
- return factoryPid;
- }
-
- @Override
- public void update() throws IOException {
- this.config = ConfigurationProvider.getConfiguration();
- this.properties = config.with(ConfigurationFunctions.filter(new PropertyMatcher() {
- @Override
- public boolean test(String key, String value) {
-// TODO define name space / SPI
- return false;
- }
- })).getProperties();
- }
-
- @Override
- public void setBundleLocation(String location) {
- }
-
- @Override
- public String getBundleLocation() {
- return null;
- }
-
- @Override
- public long getChangeCount() {
- return 0;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/osgi/src/test/resources/META-INF/javaconfiguration.properties
----------------------------------------------------------------------
diff --git a/modules/integration/osgi/src/test/resources/META-INF/javaconfiguration.properties b/modules/integration/osgi/src/test/resources/META-INF/javaconfiguration.properties
deleted file mode 100644
index 0f09ce9..0000000
--- a/modules/integration/osgi/src/test/resources/META-INF/javaconfiguration.properties
+++ /dev/null
@@ -1,18 +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.
-#
-[bundle:tamaya]my.testProperty=success!
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/osgi/src/test/resources/arquillian.xml
----------------------------------------------------------------------
diff --git a/modules/integration/osgi/src/test/resources/arquillian.xml b/modules/integration/osgi/src/test/resources/arquillian.xml
deleted file mode 100644
index a4c885a..0000000
--- a/modules/integration/osgi/src/test/resources/arquillian.xml
+++ /dev/null
@@ -1,27 +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.
--->
-<arquillian xmlns="http://jboss.org/schema/arquillian" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
-
- <container qualifier="osgi" default="true">
- <configuration>
- <property name="frameworkProperties">src/test/resources/felix.properties</property>
- </configuration>
- </container>
-</arquillian>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/osgi/src/test/resources/felix.properties
----------------------------------------------------------------------
diff --git a/modules/integration/osgi/src/test/resources/felix.properties b/modules/integration/osgi/src/test/resources/felix.properties
deleted file mode 100644
index de50401..0000000
--- a/modules/integration/osgi/src/test/resources/felix.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-# org.osgi.service.cm;org.apache.felix.cm;org.apache.tamaya;org.apache.tamaya.spi;
-org.osgi.framework.bootdelegation=org.apache.tamaya,org.apache.tamaya.integration.osgi,org.apache.tamaya.integration.osgi.test
-felix.log.level=4 #debug logging
-# felix.auto.deploy.dir=../test-bundles
-org.osgi.framework.storage=target/felix-cache
-felix.fileinstall.dir=./test-bundles
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/pom.xml
----------------------------------------------------------------------
diff --git a/modules/integration/pom.xml b/modules/integration/pom.xml
deleted file mode 100644
index df4775d..0000000
--- a/modules/integration/pom.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-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.
--->
-<project xmlns="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">
-
- <parent>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-extensions</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
- </parent>
-
- <packaging>pom</packaging>
- <modelVersion>4.0.0</modelVersion>
- <artifactId>tamaya-integration</artifactId>
- <name>Apache Tamaya Integration - all</name>
-
- <modules>
- <module>spring</module>
- <module>cdi-se</module>
- <module>cdi</module>
- <module>osgi</module>
- <module>camel</module>
- <module>etcd</module>
- <module>consul</module>
- </modules>
-
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/spring/pom.xml
----------------------------------------------------------------------
diff --git a/modules/integration/spring/pom.xml b/modules/integration/spring/pom.xml
deleted file mode 100644
index ee1628c..0000000
--- a/modules/integration/spring/pom.xml
+++ /dev/null
@@ -1,116 +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.
--->
-<project xmlns="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">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-integration</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
- </parent>
-
- <artifactId>tamaya-spring</artifactId>
- <name>Apache Tamaya Integration - Spring</name>
- <packaging>bundle</packaging>
-
- <properties>
- <spring.version>4.2.1.RELEASE</spring.version>
- <spring.boot.version>1.2.6.RELEASE</spring.boot.version>
- </properties>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.jacoco</groupId>
- <artifactId>jacoco-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>prepare-agent</id>
- <goals>
- <goal>prepare-agent</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.tamaya.integration.spring
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>java-hamcrest</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-core</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-api</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-injection</artifactId>
- <version>${project.version}</version>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-core</artifactId>
- <version>${spring.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- <version>${spring.version}</version>
- <scope>provided</scope>
- </dependency>
- <!-- Test -->
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-test</artifactId>
- <version>${spring.version}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/spring/src/main/java/org/apache/tamaya/integration/spring/SpringConfigInjectionPostProcessor.java
----------------------------------------------------------------------
diff --git a/modules/integration/spring/src/main/java/org/apache/tamaya/integration/spring/SpringConfigInjectionPostProcessor.java b/modules/integration/spring/src/main/java/org/apache/tamaya/integration/spring/SpringConfigInjectionPostProcessor.java
deleted file mode 100644
index e25b230..0000000
--- a/modules/integration/spring/src/main/java/org/apache/tamaya/integration/spring/SpringConfigInjectionPostProcessor.java
+++ /dev/null
@@ -1,42 +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.integration.spring;
-
-import org.apache.tamaya.inject.ConfigurationInjection;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.config.BeanPostProcessor;
-import org.springframework.stereotype.Component;
-
-/**
- * PostProcessor that performs injection of configured values using Tamaya {@link ConfigurationInjection}.
- */
-@Component
-public class SpringConfigInjectionPostProcessor implements BeanPostProcessor{
-
- @Override
- public Object postProcessBeforeInitialization(Object o, String s) throws BeansException {
- ConfigurationInjection.getConfigurationInjector().configure(o);
- return o;
- }
-
- @Override
- public Object postProcessAfterInitialization(Object o, String s) throws BeansException {
- return o;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/spring/src/main/java/org/apache/tamaya/integration/spring/TamayaEnvironment.java
----------------------------------------------------------------------
diff --git a/modules/integration/spring/src/main/java/org/apache/tamaya/integration/spring/TamayaEnvironment.java b/modules/integration/spring/src/main/java/org/apache/tamaya/integration/spring/TamayaEnvironment.java
deleted file mode 100644
index 7f1000e..0000000
--- a/modules/integration/spring/src/main/java/org/apache/tamaya/integration/spring/TamayaEnvironment.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.integration.spring;
-
-import org.springframework.core.env.MutablePropertySources;
-import org.springframework.core.env.StandardEnvironment;
-
-/**
- * Tamaya specific environment for Spring.
- */
-public class TamayaEnvironment extends StandardEnvironment{
-
- protected void customizePropertySources(MutablePropertySources propertySources) {
- super.customizePropertySources(propertySources);
- propertySources.addLast(new TamayaSpringPropertySource());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/spring/src/main/java/org/apache/tamaya/integration/spring/TamayaSpringConfig.java
----------------------------------------------------------------------
diff --git a/modules/integration/spring/src/main/java/org/apache/tamaya/integration/spring/TamayaSpringConfig.java b/modules/integration/spring/src/main/java/org/apache/tamaya/integration/spring/TamayaSpringConfig.java
deleted file mode 100644
index cacab20..0000000
--- a/modules/integration/spring/src/main/java/org/apache/tamaya/integration/spring/TamayaSpringConfig.java
+++ /dev/null
@@ -1,56 +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.integration.spring;
-
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
-import org.springframework.core.env.ConfigurableEnvironment;
-import org.springframework.core.env.MutablePropertySources;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.PostConstruct;
-
-/**
- * Spring Configuration Bean adding {@link TamayaSpringPropertySource} to the current
- * {@link org.springframework.core.env.Environment}.
- */
-@Component
-@Configuration
-public class TamayaSpringConfig {
-
- @Autowired
- private ConfigurableEnvironment env;
-
- @PostConstruct
- public void init() {
- env.getPropertySources().addFirst(new TamayaSpringPropertySource());
- }
-
- @Bean
- public static PropertySourcesPlaceholderConfigurer placeHolderConfigurer() {
- PropertySourcesPlaceholderConfigurer cfgBean = new PropertySourcesPlaceholderConfigurer();
- MutablePropertySources sources = new MutablePropertySources();
- sources.addFirst(new TamayaSpringPropertySource());
- cfgBean.setPropertySources(sources);
- return cfgBean;
- }
- }
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/spring/src/main/java/org/apache/tamaya/integration/spring/TamayaSpringPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/integration/spring/src/main/java/org/apache/tamaya/integration/spring/TamayaSpringPropertySource.java b/modules/integration/spring/src/main/java/org/apache/tamaya/integration/spring/TamayaSpringPropertySource.java
deleted file mode 100644
index 2e8ac1c..0000000
--- a/modules/integration/spring/src/main/java/org/apache/tamaya/integration/spring/TamayaSpringPropertySource.java
+++ /dev/null
@@ -1,39 +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.integration.spring;
-
-
-import org.apache.tamaya.ConfigurationProvider;
-import org.springframework.core.env.PropertySource;
-
-/**
- * Spring PropertySource bridging to Tamaya {@link org.apache.tamaya.Configuration}.
- */
-public class TamayaSpringPropertySource extends PropertySource<String> {
-
- public TamayaSpringPropertySource() {
- super("ApacheTamayaConfig");
- }
-
- @Override
- public String getProperty(String name) {
- return ConfigurationProvider.getConfiguration().get(name);
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/spring/src/main/resources/spring-config.xml
----------------------------------------------------------------------
diff --git a/modules/integration/spring/src/main/resources/spring-config.xml b/modules/integration/spring/src/main/resources/spring-config.xml
deleted file mode 100644
index c1d6eda..0000000
--- a/modules/integration/spring/src/main/resources/spring-config.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:context="http://www.springframework.org/schema/context"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
- <context:annotation-config />
- <context:component-scan base-package="org.apache.tamaya.integration.spring"/>
-
- <!-- Our dependencies -->
- <bean id="tamayaInjectionProcessor" name="tamayaInjectionProcessor" class="org.apache.tamaya.integration.spring.SpringConfigInjectionPostProcessor"/>
- <bean id="tamayaConfigProvider" name="tamayaConfigProvider" class="org.apache.tamaya.integration.spring.TamayaSpringConfig"/>
-
-</beans>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/spring/src/test/java/org/apache/tamaya/integration/spring/ConfiguredSpringBean.java
----------------------------------------------------------------------
diff --git a/modules/integration/spring/src/test/java/org/apache/tamaya/integration/spring/ConfiguredSpringBean.java b/modules/integration/spring/src/test/java/org/apache/tamaya/integration/spring/ConfiguredSpringBean.java
deleted file mode 100644
index c43dde0..0000000
--- a/modules/integration/spring/src/test/java/org/apache/tamaya/integration/spring/ConfiguredSpringBean.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.integration.spring;
-
-import org.apache.tamaya.inject.api.Config;
-import org.apache.tamaya.inject.api.ConfigDefaultSections;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.env.Environment;
-
-/**
- * Created by Anatole on 25.09.2015.
- */
-@ConfigDefaultSections
-public class ConfiguredSpringBean {
-
- private String message;
-
- @Autowired
- private Environment env;
-
- @Config("java.version")
- private String javaVersion;
-
- @Config(defaultValue = "23")
- private int testNumber;
-
- public String getJavaVersion(){
- return javaVersion;
- }
-
- public int getTestNumber(){
- return testNumber;
- }
-
- public Environment getEnv(){
- return env;
- }
-
- public void setMessage(String message){
- this.message = message;
- }
-
- public String getMessage() {
- return message;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/spring/src/test/java/org/apache/tamaya/integration/spring/SpringConfigTest.java
----------------------------------------------------------------------
diff --git a/modules/integration/spring/src/test/java/org/apache/tamaya/integration/spring/SpringConfigTest.java b/modules/integration/spring/src/test/java/org/apache/tamaya/integration/spring/SpringConfigTest.java
deleted file mode 100644
index 1f28816..0000000
--- a/modules/integration/spring/src/test/java/org/apache/tamaya/integration/spring/SpringConfigTest.java
+++ /dev/null
@@ -1,61 +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.integration.spring;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-/**
- * Created by Anatole on 25.09.2015.
- */
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration("classpath:spring-config.xml")
-public class SpringConfigTest {
-
- @Autowired
- private ConfiguredSpringBean configuredBean;
-
- @Test
- public void assertBeanNotNull(){
- assertNotNull(configuredBean);
- }
-
- @Test
- public void assert_JavaVersion_Injected(){
- assertNotNull(configuredBean.getJavaVersion());
- assertEquals(System.getProperty("java.version"), configuredBean.getJavaVersion());
- }
-
- @Test
- public void assert_Number_Injected(){
- assertEquals(configuredBean.getTestNumber(), 23);
- }
-
- @Test
- public void assert_Number_From_Environment(){
- assertEquals("value11", configuredBean.getEnv().getProperty("myConfiguredValue"));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/spring/src/test/java/org/apache/tamaya/integration/spring/SpringConfigTest2.java
----------------------------------------------------------------------
diff --git a/modules/integration/spring/src/test/java/org/apache/tamaya/integration/spring/SpringConfigTest2.java b/modules/integration/spring/src/test/java/org/apache/tamaya/integration/spring/SpringConfigTest2.java
deleted file mode 100644
index 6eab61d..0000000
--- a/modules/integration/spring/src/test/java/org/apache/tamaya/integration/spring/SpringConfigTest2.java
+++ /dev/null
@@ -1,47 +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.integration.spring;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-/**
- * Test using standard Spring setup.
- */
-public class SpringConfigTest2 {
-
- @Test
- public void assertDefaultSetup(){
- ApplicationContext context = new ClassPathXmlApplicationContext("classpath:spring-config-scanOnly.xml");
- ConfiguredSpringBean configuredBean = context.getBean(ConfiguredSpringBean.class);
- assertNotNull(configuredBean.getJavaVersion());
- assertEquals(System.getProperty("java.version"), configuredBean.getJavaVersion());
- assertNotNull(configuredBean.getMessage());
- assertEquals("value2", configuredBean.getMessage());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/spring/src/test/resources/META-INF/javaconfiguration.properties
----------------------------------------------------------------------
diff --git a/modules/integration/spring/src/test/resources/META-INF/javaconfiguration.properties b/modules/integration/spring/src/test/resources/META-INF/javaconfiguration.properties
deleted file mode 100644
index 3366128..0000000
--- a/modules/integration/spring/src/test/resources/META-INF/javaconfiguration.properties
+++ /dev/null
@@ -1,20 +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.
-#
-myConfiguredValue=value11
-propertyValue=value2
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/spring/src/test/resources/spring-config-scanOnly.xml
----------------------------------------------------------------------
diff --git a/modules/integration/spring/src/test/resources/spring-config-scanOnly.xml b/modules/integration/spring/src/test/resources/spring-config-scanOnly.xml
deleted file mode 100644
index 6e98d80..0000000
--- a/modules/integration/spring/src/test/resources/spring-config-scanOnly.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:context="http://www.springframework.org/schema/context"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
- <context:annotation-config />
- <context:component-scan base-package="org.apache.tamaya.integration.spring"/>
-
- <!-- Our dependencies -->
- <!--<bean id="tamayaInjectionProcessor" name="tamayaInjectionProcessor" class="org.apache.tamaya.integration.spring.SpringConfigInjectionPostProcessor"/>-->
- <!--<bean id="tamayaConfigProvider" name="tamayaConfigProvider" class="org.apache.tamaya.integration.spring.TamayaSpringConfig"/>-->
- <bean id="configuredBean" name="configuredBean" class="org.apache.tamaya.integration.spring.ConfiguredSpringBean">
- <property name="message" value="${propertyValue}"/>
- </bean>
-
-</beans>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/spring/src/test/resources/spring-config.xml
----------------------------------------------------------------------
diff --git a/modules/integration/spring/src/test/resources/spring-config.xml b/modules/integration/spring/src/test/resources/spring-config.xml
deleted file mode 100644
index fc3f9d8..0000000
--- a/modules/integration/spring/src/test/resources/spring-config.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-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.
--->
-
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:context="http://www.springframework.org/schema/context"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
-
- <!-- Our dependencies -->
- <bean id="tamayaInjectionProcessor" name="tamayaInjectionProcessor" class="org.apache.tamaya.integration.spring.SpringConfigInjectionPostProcessor"/>
- <bean id="tamayaConfigProvider" name="tamayaConfigProvider" class="org.apache.tamaya.integration.spring.TamayaSpringConfig"/>
- <bean id="configuredBean" name="configuredBean" class="org.apache.tamaya.integration.spring.ConfiguredSpringBean"/>
-
-</beans>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/json/pom.xml
----------------------------------------------------------------------
diff --git a/modules/json/pom.xml b/modules/json/pom.xml
deleted file mode 100644
index 49f4629..0000000
--- a/modules/json/pom.xml
+++ /dev/null
@@ -1,147 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-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.
--->
-<project xmlns="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">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-extensions</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>tamaya-json</artifactId>
- <name>Apache Tamaya Modules - JSON Support</name>
- <packaging>bundle</packaging>
- <inceptionYear>2015</inceptionYear>
-
- <properties>
- <jdkVersion>1.7</jdkVersion>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-api</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-core</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-formats</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-json_1.0_spec</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.johnzon</groupId>
- <artifactId>johnzon-core</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.arquillian.daemon</groupId>
- <artifactId>arquillian-daemon-container-managed</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.arquillian.daemon</groupId>
- <artifactId>arquillian-daemon-container-common</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.arquillian.daemon</groupId>
- <artifactId>arquillian-daemon-main</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.arquillian.daemon</groupId>
- <artifactId>arquillian-daemon-protocol-arquillian</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.arquillian.daemon</groupId>
- <artifactId>arquillian-daemon-protocol-wire</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.arquillian.daemon</groupId>
- <artifactId>arquillian-daemon-server</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.arquillian.junit</groupId>
- <artifactId>arquillian-junit-container</artifactId>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>java-hamcrest</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>copyMain</id>
- <phase>process-test-sources</phase>
- <goals>
- <goal>copy</goal>
- </goals>
- <configuration>
- <outputDirectory>${project.build.directory}</outputDirectory>
- <overWriteReleases>false</overWriteReleases>
- <overWriteSnapshots>false</overWriteSnapshots>
- <overWriteIfNewer>true</overWriteIfNewer>
- <stripVersion>true</stripVersion>
- <artifactItems>
- <artifactItem>
- <groupId>org.jboss.arquillian.daemon</groupId>
- <artifactId>arquillian-daemon-main</artifactId>
- </artifactItem>
- </artifactItems>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.tamaya.json
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/json/src/main/java/org/apache/tamaya/json/JSONFormat.java
----------------------------------------------------------------------
diff --git a/modules/json/src/main/java/org/apache/tamaya/json/JSONFormat.java b/modules/json/src/main/java/org/apache/tamaya/json/JSONFormat.java
deleted file mode 100644
index 8bdd414..0000000
--- a/modules/json/src/main/java/org/apache/tamaya/json/JSONFormat.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.json;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.format.ConfigurationData;
-import org.apache.tamaya.format.ConfigurationDataBuilder;
-import org.apache.tamaya.format.ConfigurationFormat;
-
-import java.io.InputStream;
-import java.net.URL;
-import java.nio.charset.Charset;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-
-import javax.json.Json;
-import javax.json.JsonException;
-import javax.json.JsonObject;
-import javax.json.JsonReader;
-import javax.json.JsonReaderFactory;
-
-/**
- * Implementation of the {@link org.apache.tamaya.format.ConfigurationFormat}
- * able to read configuration properties represented in JSON
- *
- * @see <a href="http://www.json.org">JSON format specification</a>
- */
-public class JSONFormat implements ConfigurationFormat {
- /** Property that make Johnzon accept commentc. */
- public static final String JOHNZON_SUPPORTS_COMMENTS_PROP = "org.apache.johnzon.supports-comments";
- /** The reader factory used. */
- private final JsonReaderFactory readerFactory;
-
- /**
- * Constructor, itniaitlizing zhe JSON reader factory.
- */
- public JSONFormat(){
- Map<String, Object> config = new HashMap<>();
- config.put(JOHNZON_SUPPORTS_COMMENTS_PROP, true);
- this.readerFactory = Json.createReaderFactory(config);
- }
-
- @Override
- public String getName() {
- return "json";
- }
-
- @Override
- public boolean accepts(URL url) {
- return Objects.requireNonNull(url).getPath().endsWith(".json");
- }
-
- @Override
- public ConfigurationData readConfiguration(String resource, InputStream inputStream) {
-
- try {
- final JsonReader reader = this.readerFactory.createReader(inputStream, Charset.forName("UTF-8"));
- JsonObject root = reader.readObject();
- HashMap<String, String> values = new HashMap<>();
- JSONVisitor visitor = new JSONVisitor(root, values);
- visitor.run();
- return ConfigurationDataBuilder.of(resource, this).addProperties(values)
- .build();
- } catch (JsonException e) {
- throw new ConfigException("Failed to read data from " + resource, e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/json/src/main/java/org/apache/tamaya/json/JSONPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/json/src/main/java/org/apache/tamaya/json/JSONPropertySource.java b/modules/json/src/main/java/org/apache/tamaya/json/JSONPropertySource.java
deleted file mode 100644
index 43cfa73..0000000
--- a/modules/json/src/main/java/org/apache/tamaya/json/JSONPropertySource.java
+++ /dev/null
@@ -1,149 +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.json;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-
-import java.io.InputStream;
-import java.net.URL;
-import java.nio.charset.Charset;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.json.Json;
-import javax.json.JsonObject;
-import javax.json.JsonReaderFactory;
-import javax.json.JsonStructure;
-
-import static java.lang.String.format;
-
-/**
- * Property source based on a JSON file.
- */
-public class JSONPropertySource implements PropertySource {
- /** Constant for enabling comments in Johnzon. */
- public static final String JOHNZON_SUPPORTS_COMMENTS_PROP = "org.apache.johnzon.supports-comments";
-
- /** The underlying resource. */
- private final URL urlResource;
- /** The values read. */
- private final Map<String, String> values;
- /** The evaluated ordinal. */
- private int ordinal;
- /** The JSON reader factory used. */
- private JsonReaderFactory readerFactory = initReaderFactory();
-
- /** Initializes the factory to be used for creating readers. */
- private JsonReaderFactory initReaderFactory() {
- Map<String, Object> config = new HashMap<>();
- config.put(JOHNZON_SUPPORTS_COMMENTS_PROP, true);
- return Json.createReaderFactory(config);
- }
-
- /**
- * Constructor, hereby using 0 as the default ordinal.
- * @param resource the resource modelled as URL, not null.
- */
- public JSONPropertySource(URL resource) {
- this(resource, 0);
- }
-
- /**
- * Constructor.
- * @param resource the resource modelled as URL, not null.
- * @param defaultOrdinal the defaultOrdinal to be used.
- */
- public JSONPropertySource(URL resource, int defaultOrdinal) {
- urlResource = Objects.requireNonNull(resource);
- this.ordinal = defaultOrdinal; // may be overriden by read...
- this.values = readConfig(urlResource);
- if (this.values.containsKey(TAMAYA_ORDINAL)) {
- this.ordinal = Integer.parseInt(this.values.get(TAMAYA_ORDINAL));
- }
- Map<String, Object> config = new HashMap<>();
- config.put(JOHNZON_SUPPORTS_COMMENTS_PROP, true);
- this.readerFactory = Json.createReaderFactory(config);
- }
-
-
- @Override
- public int getOrdinal() {
- PropertyValue configuredOrdinal = get(TAMAYA_ORDINAL);
- if(configuredOrdinal!=null){
- try{
- return Integer.parseInt(configuredOrdinal.getValue());
- } catch(Exception e){
- Logger.getLogger(getClass().getName()).log(Level.WARNING,
- "Configured Ordinal is not an int number: " + configuredOrdinal, e);
- }
- }
- return ordinal;
- }
-
- @Override
- public String getName() {
- return urlResource.toExternalForm();
- }
-
- @Override
- public PropertyValue get(String key) {
- return PropertyValue.of(key, getProperties().get(key), getName());
- }
-
- @Override
- public Map<String, String> getProperties() {
- return Collections.unmodifiableMap(values);
- }
-
- /**
- * Reads the configuration.
- * @param urlResource soure of the configuration.
- * @return the configuration read from the given resource URL.
- * @throws ConfigException if resource URL cannot be read.
- */
- protected Map<String, String> readConfig(URL urlResource) {
- try (InputStream is = urlResource.openStream()) {
- JsonStructure root = this.readerFactory.createReader(is, Charset.forName("UTF-8")).read();
-
- // Test added. H. Saly, 15. Aug. 2015
- if (!(root instanceof JsonObject)) {
- throw new ConfigException("Currently only JSON objects are supported");
- }
-
- Map<String, String> values = new HashMap<>();
- JSONVisitor visitor = new JSONVisitor((JsonObject)root, values);
- visitor.run();
- return values;
- }
- catch (Throwable t) {
- throw new ConfigException(format("Failed to read properties from %s", urlResource.toExternalForm()), t);
- }
- }
-
- @Override
- public boolean isScannable() {
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/json/src/main/java/org/apache/tamaya/json/JSONVisitor.java
----------------------------------------------------------------------
diff --git a/modules/json/src/main/java/org/apache/tamaya/json/JSONVisitor.java b/modules/json/src/main/java/org/apache/tamaya/json/JSONVisitor.java
deleted file mode 100644
index 2135ec5..0000000
--- a/modules/json/src/main/java/org/apache/tamaya/json/JSONVisitor.java
+++ /dev/null
@@ -1,119 +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.json;
-
-import org.apache.tamaya.ConfigException;
-
-import java.util.*;
-
-import javax.json.JsonArray;
-import javax.json.JsonObject;
-import javax.json.JsonString;
-import javax.json.JsonStructure;
-import javax.json.JsonValue;
-
-/**
- * Visitor implementation to read a JSON formatted input source.
- */
-class JSONVisitor {
- private final JsonObject rootNode;
- private final Map<String, String> targetStore;
-
- JSONVisitor(JsonObject startNode, Map<String, String> target) {
- rootNode = startNode;
- targetStore = target;
- }
-
- public void run() {
- Deque<VisitingContext> stack = new ArrayDeque<>();
-
- stack.add(new VisitingContext(rootNode));
- boolean goOn = stack.peek().hasNext();
-
- if (goOn) {
- do {
- Map.Entry<String, JsonValue> current = stack.peek().nextElement();
-
- if (!(current.getValue() instanceof JsonStructure)) {
- String key = stack.peek().getNSPrefix() + current.getKey();
- String value;
- JsonValue jsonValue = current.getValue();
- switch(jsonValue.getValueType()) {
- case NULL: value = null; break;
- case FALSE: value = Boolean.FALSE.toString(); break;
- case TRUE: value = Boolean.TRUE.toString(); break;
- case NUMBER: value = jsonValue.toString(); break;
- case STRING: value = ((JsonString) jsonValue).getString(); break;
- default:
- throw new ConfigException("Internal failure while processing JSON document.");
- }
-
- targetStore.put(key, value);
- } else if (current.getValue() instanceof JsonObject) {
- String key = stack.peek().getNSPrefix() + current.getKey();
- JsonObject node = (JsonObject) current.getValue();
- stack.push(new VisitingContext(node, key));
- } else if (current.getValue() instanceof JsonArray) {
- throw new ConfigException("Arrays are not supported at the moment.");
- } else {
- throw new ConfigException("Internal failure while processing JSON document.");
- }
-
- goOn = stack.peek().hasNext();
-
- while (!goOn && stack.size() > 0) {
- stack.remove();
- goOn = (stack.size() > 0) && stack.peek().hasNext();
- }
- } while (goOn);
- }
- }
-
- /**
- * Context for a sub context visited.
- */
- private static class VisitingContext {
- private final String namespace;
- private final JsonObject node;
- private final Iterator<Map.Entry<String, JsonValue>> elements;
-
- public VisitingContext(JsonObject node) {
- this(node, "");
- }
-
- public VisitingContext(JsonObject rootNode, String currentNamespace) {
- namespace = currentNamespace;
- node = rootNode;
- elements = node.entrySet().iterator();
- }
-
- public Map.Entry<String, JsonValue> nextElement() {
- return elements.next();
- }
-
-
- public boolean hasNext() {
- return elements.hasNext();
- }
-
- public String getNSPrefix() {
- return namespace.isEmpty() ? namespace : namespace + ".";
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/json/src/main/resources/META-INF/services/org.apache.tamaya.format.ConfigurationFormat
----------------------------------------------------------------------
diff --git a/modules/json/src/main/resources/META-INF/services/org.apache.tamaya.format.ConfigurationFormat b/modules/json/src/main/resources/META-INF/services/org.apache.tamaya.format.ConfigurationFormat
deleted file mode 100644
index a843cbe..0000000
--- a/modules/json/src/main/resources/META-INF/services/org.apache.tamaya.format.ConfigurationFormat
+++ /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.json.JSONFormat
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/json/src/test/java/org/apache/tamaya/json/CommonJSONTestCaseCollection.java
----------------------------------------------------------------------
diff --git a/modules/json/src/test/java/org/apache/tamaya/json/CommonJSONTestCaseCollection.java b/modules/json/src/test/java/org/apache/tamaya/json/CommonJSONTestCaseCollection.java
deleted file mode 100644
index 946878c..0000000
--- a/modules/json/src/test/java/org/apache/tamaya/json/CommonJSONTestCaseCollection.java
+++ /dev/null
@@ -1,190 +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.json;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-import org.hamcrest.CoreMatchers;
-import org.hamcrest.Matchers;
-import org.junit.Test;
-
-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.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.hasSize;
-
-/**
- * Class with a collection of common test cases each JSON processing
- * class must be able to pass.
- */
-public abstract class CommonJSONTestCaseCollection {
-
- abstract PropertySource getPropertiesFrom(URL source) throws Exception;
-
- @Test
- public void canReadNonLatinCharacters() throws Exception {
- URL configURL = JSONPropertySourceTest.class
- .getResource("/configs/valid/cyrillic.json");
-
- assertThat(configURL, Matchers.notNullValue());
-
- PropertySource propertySource = getPropertiesFrom(configURL);
-
- assertThat(propertySource.get("name"), Matchers.notNullValue());
- assertThat(propertySource.get("name").getValue(), equalTo("\u041e\u043b\u0438\u0432\u0435\u0440"));
- assertThat(propertySource.get("\u0444\u0430\u043c\u0438\u043b\u0438\u044f"), Matchers.notNullValue());
- assertThat(propertySource.get("\u0444\u0430\u043c\u0438\u043b\u0438\u044f").getValue(), Matchers.equalTo("Fischer"));
- }
-
- @Test
- public void canReadNestedStringOnlyJSONConfigFile() throws Exception {
- URL configURL = JSONPropertySourceTest.class
- .getResource("/configs/valid/simple-nested-string-only-config-1.json");
-
- assertThat(configURL, CoreMatchers.notNullValue());
-
- PropertySource properties = getPropertiesFrom(configURL);
-
- assertThat(properties.getProperties().keySet(), hasSize(5));
-
- PropertyValue keyB = properties.get("b");
- PropertyValue keyDO = properties.get("d.o");
- PropertyValue keyDP = properties.get("d.p");
-
- assertThat(keyB, notNullValue());
- assertThat(keyB.getValue(), equalTo("B"));
- assertThat(keyDO, notNullValue());
- assertThat(keyDO.getValue(), equalTo("O"));
- assertThat(keyDP, Matchers.notNullValue());
- assertThat(keyDP.getValue(), is("P"));
- }
-
- @Test
- public void canReadNestedStringOnlyJSONConfigFileWithObjectInTheMiddle()
- throws Exception {
- URL configURL = JSONPropertySourceTest.class
- .getResource("/configs/valid/simple-nested-string-only-config-2.json");
-
- assertThat(configURL, CoreMatchers.notNullValue());
-
- PropertySource properties = getPropertiesFrom(configURL);
-
- assertThat(properties.getProperties().keySet(), hasSize(4));
-
- PropertyValue keyA = properties.get("a");
- PropertyValue keyDO = properties.get("b.o");
- PropertyValue keyDP = properties.get("b.p");
- PropertyValue keyC = properties.get("c");
-
- assertThat(keyA, notNullValue());
- assertThat(keyA.getValue(), is("A"));
- assertThat(keyC, notNullValue());
- assertThat(keyC.getValue(), equalTo("C"));
- assertThat(keyDO, notNullValue());
- assertThat(keyDO.getValue(), equalTo("O"));
- assertThat(keyDP, notNullValue());
- assertThat(keyDP.getValue(), is("P"));
- }
-
- @Test(expected = ConfigException.class)
- public void canHandleIllegalJSONFileWhichContainsAnArray() throws Exception {
- URL configURL = JSONPropertySourceTest.class.getResource("/configs/invalid/with-array.json");
-
- assertThat(configURL, CoreMatchers.notNullValue());
-
- getPropertiesFrom(configURL).getProperties();
- }
-
- @Test(expected = ConfigException.class)
- public void canHandleIllegalJSONFileConsistingOfOneOpeningBracket() throws Exception {
- URL configURL = JSONPropertySourceTest.class.getResource("/configs/invalid/only-opening-bracket.json");
-
- assertThat(configURL, CoreMatchers.notNullValue());
-
- getPropertiesFrom(configURL).getProperties();
- }
-
- @Test(expected = ConfigException.class)
- public void canHandleIllegalJSONFileWhichIsEmpty() throws Exception {
- URL configURL = JSONPropertySourceTest.class.getResource("/configs/invalid/empty-file.json");
-
- assertThat(configURL, CoreMatchers.notNullValue());
-
- getPropertiesFrom(configURL).getProperties();
- }
-
- @Test
- public void priorityInConfigFileOverwriteExplicitlyGivenPriority() throws Exception {
- URL configURL = JSONPropertySourceTest.class.getResource("/configs/valid/with-explicit-priority.json");
-
- assertThat(configURL, CoreMatchers.notNullValue());
-
- PropertySource properties = getPropertiesFrom(configURL);
-
- assertThat(properties.getOrdinal(), is(16784));
- }
-
- @Test
- public void canReadFlatStringOnlyJSONConfigFile() throws Exception {
- URL configURL = JSONPropertySourceTest.class.getResource("/configs/valid/simple-flat-string-only-config.json");
-
- assertThat(configURL, CoreMatchers.notNullValue());
-
- PropertySource properties = getPropertiesFrom(configURL);
-
- assertThat(properties.getProperties().keySet(), hasSize(3));
-
- PropertyValue keyA = properties.get("a");
- PropertyValue keyB = properties.get("b");
- PropertyValue keyC = properties.get("c");
-
- assertThat(keyA, notNullValue());
- assertThat(keyA.getValue(), equalTo("A"));
- assertThat(keyB, notNullValue());
- assertThat(keyB.getValue(), is("B"));
- assertThat(keyC, notNullValue());
- assertThat(keyC.getValue(), is("C"));
- }
-
- @Test(expected = ConfigException.class)
- public void emptyJSONFileResultsInConfigException() throws Exception {
- URL configURL = JSONPropertySourceTest.class.getResource("/configs/invalid/empty-file.json");
-
- assertThat(configURL, CoreMatchers.notNullValue());
-
- PropertySource properties = getPropertiesFrom(configURL);
-
- properties.getProperties();
- }
-
- @Test
- public void canHandleEmptyJSONObject() throws Exception {
- URL configURL = JSONPropertySourceTest.class.getResource("/configs/valid/empty-object-config.json");
-
- assertThat(configURL, CoreMatchers.notNullValue());
-
- PropertySource properties = getPropertiesFrom(configURL);
-
- assertThat(properties.getProperties().keySet(), hasSize(0));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/json/src/test/java/org/apache/tamaya/json/JSONFormatIT.java
----------------------------------------------------------------------
diff --git a/modules/json/src/test/java/org/apache/tamaya/json/JSONFormatIT.java b/modules/json/src/test/java/org/apache/tamaya/json/JSONFormatIT.java
deleted file mode 100644
index 851655e..0000000
--- a/modules/json/src/test/java/org/apache/tamaya/json/JSONFormatIT.java
+++ /dev/null
@@ -1,48 +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.json;
-
-import org.apache.tamaya.format.ConfigurationFormat;
-import org.apache.tamaya.spi.ServiceContextManager;
-import org.junit.Test;
-
-import java.util.List;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.notNullValue;
-
-/**
- * Integration tests for {@link JSONFormat}.
- */
-public class JSONFormatIT {
- @Test
- public void jsonFormatCanBeFoundViaServiceLoader() throws Exception {
- List<ConfigurationFormat> formats = ServiceContextManager.getServiceContext()
- .getServices(ConfigurationFormat.class);
-
- ConfigurationFormat format = null;
- for (ConfigurationFormat f : formats) {
- if (f instanceof JSONFormat) {
- format = f;
- break;
- }
- }
- assertThat(format, notNullValue());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/json/src/test/java/org/apache/tamaya/json/JSONFormatTest.java
----------------------------------------------------------------------
diff --git a/modules/json/src/test/java/org/apache/tamaya/json/JSONFormatTest.java b/modules/json/src/test/java/org/apache/tamaya/json/JSONFormatTest.java
deleted file mode 100644
index 9218046..0000000
--- a/modules/json/src/test/java/org/apache/tamaya/json/JSONFormatTest.java
+++ /dev/null
@@ -1,75 +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.json;
-
-
-import org.apache.tamaya.format.ConfigurationData;
-import org.apache.tamaya.format.FlattenedDefaultPropertySource;
-import org.apache.tamaya.spi.PropertySource;
-import org.junit.Test;
-
-import java.io.InputStream;
-import java.net.URL;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
-
-public class JSONFormatTest extends CommonJSONTestCaseCollection {
- private final JSONFormat format = new JSONFormat();
-
- @Test(expected = NullPointerException.class)
- public void acceptsNeedsNonNullParameter() throws Exception {
- format.accepts(null);
- }
-
- @Test
- public void aNonJSONFileBasedURLIsNotAccepted() throws Exception {
- URL url = new URL("file:///etc/service/conf.conf");
-
- assertThat(format.accepts(url), is(false));
- }
-
- @Test
- public void aJSONFileBasedURLIsAccepted() throws Exception {
- URL url = new URL("file:///etc/service/conf.json");
-
- assertThat(format.accepts(url), is(true));
- }
-
- @Test
- public void aHTTPBasedURLIsNotAccepted() throws Exception {
- URL url = new URL("http://nowhere.somewhere/conf.json");
- assertThat(format.accepts(url), is(true));
- }
-
- @Test
- public void aFTPBasedURLIsNotAccepted() throws Exception {
- URL url = new URL("ftp://nowhere.somewhere/a/b/c/d/conf.json");
-
- assertThat(format.accepts(url), is(true));
- }
-
- @Override
- PropertySource getPropertiesFrom(URL source) throws Exception {
- try (InputStream is = source.openStream()) {
- ConfigurationData data = format.readConfiguration(source.toString(), is);
- return new FlattenedDefaultPropertySource(data);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/json/src/test/java/org/apache/tamaya/json/JSONPropertySourceTest.java
----------------------------------------------------------------------
diff --git a/modules/json/src/test/java/org/apache/tamaya/json/JSONPropertySourceTest.java b/modules/json/src/test/java/org/apache/tamaya/json/JSONPropertySourceTest.java
deleted file mode 100644
index 9892446..0000000
--- a/modules/json/src/test/java/org/apache/tamaya/json/JSONPropertySourceTest.java
+++ /dev/null
@@ -1,56 +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.json;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.spi.PropertySource;
-import org.hamcrest.CoreMatchers;
-import org.junit.Test;
-
-import java.net.URL;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-
-public class JSONPropertySourceTest extends CommonJSONTestCaseCollection {
-
- @Test
- public void tamayaOrdinalKeywordIsNotPropagatedAsNormalProperty() throws Exception {
- URL configURL = JSONPropertySourceTest.class.getResource("/configs/valid/with-explicit-priority.json");
-
- assertThat(configURL, CoreMatchers.notNullValue());
-
- JSONPropertySource source = new JSONPropertySource(configURL, 4);
- assertEquals(source.get(PropertySource.TAMAYA_ORDINAL).getValue(), "16784");
- }
-
- @Test(expected=ConfigException.class)
- public void testDoNotAcceptJsonArrays() throws Exception {
- URL configURL = JSONPropertySourceTest.class.getResource("/configs/invalid/array.json");
-
- assertThat(configURL, CoreMatchers.notNullValue());
-
- new JSONPropertySource(configURL);
- }
-
- @Override
- PropertySource getPropertiesFrom(URL source) throws Exception {
- return new JSONPropertySource(source);
- }
-}
[20/24] incubator-tamaya git commit: Removed all modules from the
main repository. They will be reborn in separate ASF repository.
Posted by pl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/main/java/org/apache/tamaya/events/ConfigurationContextChangeBuilder.java
----------------------------------------------------------------------
diff --git a/modules/events/src/main/java/org/apache/tamaya/events/ConfigurationContextChangeBuilder.java b/modules/events/src/main/java/org/apache/tamaya/events/ConfigurationContextChangeBuilder.java
deleted file mode 100644
index b586428..0000000
--- a/modules/events/src/main/java/org/apache/tamaya/events/ConfigurationContextChangeBuilder.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.events;
-
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.spi.ConfigurationContext;
-import org.apache.tamaya.spi.PropertySource;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-
-/**
- * Models a set of current changes applied to a {@link org.apache.tamaya.spi.PropertySource}. Consumers of these events
- * can observe changes to property sources and
- * <ol>
- * <li>check if their current configuration instance ({@link org.apache.tamaya.spi.ConfigurationContext}
- * contains the changed {@link org.apache.tamaya.spi.PropertySource} (Note: the reference to a property source is never affected by a
- * change, it is the data of the property source only).</li>
- * <li>if so, a corresponding action may be taken, such as reevaluating the configuration values (depending on
- * the update policy) or reevaluating the complete {@link org.apache.tamaya.Configuration} to create a change
- * event on configuration level.
- * </ol>
- */
-public final class ConfigurationContextChangeBuilder {
- /**
- * The recorded changes.
- */
- final List<PropertySourceChange> changedPropertySources = new ArrayList<>();
- /**
- * The version configured, or null, for generating a default.
- */
- String version;
- /**
- * The optional timestamp in millis of this epoch.
- */
- Long timestamp;
-
- final ConfigurationContext configurationContext;
-
- /**
- * Constructor.
- */
- private ConfigurationContextChangeBuilder(ConfigurationContext configurationContext) {
- this.configurationContext = Objects.requireNonNull(configurationContext);
- }
-
- /**
- * Just creates a new ConfigurationContextBuilder using the current COnfigurationContext has root resource.
- * @return a new ConfigurationContextBuilder, never null.
- */
- public static ConfigurationContextChangeBuilder of() {
- return of(ConfigurationProvider.getConfigurationContext());
- }
-
- /**
- * Creates a new instance current this builder.
- *
- * @param context context to use for creating changesets.
- * @return the builder for chaining.
- */
- public static ConfigurationContextChangeBuilder of(ConfigurationContext context) {
- return new ConfigurationContextChangeBuilder(context);
- }
-
- /**
- * Apply a version/UUID to the set being built.
- * @param version the version to apply, or null, to let the system generate a version for you.
- * @return the builder for chaining.
- */
- public ConfigurationContextChangeBuilder setVersion(String version) {
- this.version = version;
- return this;
- }
-
- /**
- * Apply given timestamp to the set being built.
- * @param timestamp timestamp to set.
- * @return the builder for chaining.
- */
- public ConfigurationContextChangeBuilder setTimestamp(long timestamp) {
- this.timestamp = timestamp;
- return this;
- }
-
- /**
- * This method records all changes to be applied to the base property provider/configuration to
- * achieve the given target state.
- *
- * @param propertySource the new target state, not null.
- * @return the builder for chaining.
- */
- public ConfigurationContextChangeBuilder newPropertySource(PropertySource propertySource) {
- this.changedPropertySources.add(PropertySourceChange.ofAdded(propertySource));
- return this;
- }
-
- /**
- * This method records all changes to be applied to the base property provider/configuration to
- * achieve the given target state.
- *
- * @param propertySource the new target state, not null.
- * @return the builder for chaining.
- */
- public ConfigurationContextChangeBuilder removedPropertySource(PropertySource propertySource) {
- this.changedPropertySources.add(PropertySourceChange.ofDeleted(propertySource));
- return this;
- }
-
- /**
- * This method records all changes to be applied to the base property provider/configuration to
- * achieve the given target state.
- *
- * @param propertySourceChange the change state, not null.
- * @return the builder for chaining.
- */
- public ConfigurationContextChangeBuilder changedPropertySource(PropertySourceChange propertySourceChange) {
- this.changedPropertySources.add(Objects.requireNonNull(propertySourceChange));
- return this;
- }
-
- /**
- * Checks if the change set is empty, i.e. does not contain any changes.
- *
- * @return true, if the set is empty.
- */
- public boolean isEmpty() {
- return this.changedPropertySources.isEmpty();
- }
-
- /**
- * Resets this change set instance. This will clear all changes done to this builder, so the
- * set will be empty.
- */
- public void reset() {
- this.changedPropertySources.clear();
- }
-
- /**
- * Builds the corresponding change set.
- *
- * @return the new change set, never null.
- */
- public ConfigurationContextChange build() {
- return new ConfigurationContextChange(this);
- }
-
- /*
- * (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "ConfigurationContextChangeBuilder [propertySources=" + changedPropertySources + "]";
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/main/java/org/apache/tamaya/events/FrozenConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/events/src/main/java/org/apache/tamaya/events/FrozenConfiguration.java b/modules/events/src/main/java/org/apache/tamaya/events/FrozenConfiguration.java
deleted file mode 100644
index 304ddba..0000000
--- a/modules/events/src/main/java/org/apache/tamaya/events/FrozenConfiguration.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.events;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.ConfigOperator;
-import org.apache.tamaya.ConfigQuery;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.functions.ConfigurationFunctions;
-import org.apache.tamaya.spi.ConfigurationContext;
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-import java.io.Serializable;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * /**
- * Configuration implementation that stores all current values of a given (possibly dynamic, contextual and non server
- * capable instance) and is fully serializable. Note that hereby only the scannable key/value pairs are considered.
- */
-public final class FrozenConfiguration implements Configuration, Serializable {
- private static final long serialVersionUID = -6373137316556444171L;
- /**
- * The properties frozen.
- */
- private Map<String, String> properties = new HashMap<>();
-
- /**
- * Constructor.
- *
- * @param config The base configuration.
- */
- private FrozenConfiguration(Configuration config) {
- this.properties.putAll(config.getProperties());
- this.properties.put("[meta]frozenAt", String.valueOf(System.currentTimeMillis()));
- this.properties = Collections.unmodifiableMap(this.properties);
- }
-
- /**
- * Creates a new FrozenConfiguration instance based on a Configuration given.
- *
- * @param config the configuration to be frozen, not null.
- * @return the frozen Configuration.
- */
- public static FrozenConfiguration of(Configuration config) {
- if (config instanceof FrozenConfiguration) {
- return (FrozenConfiguration) config;
- }
- return new FrozenConfiguration(config);
- }
-
- @Override
- public String get(String key) {
- return this.properties.get(key);
- }
-
- @Override
- public String getOrDefault(String key, String defaultValue) {
- String val = get(key);
- if(val==null){
- return defaultValue;
- }
- return val;
- }
-
- @Override
- public <T> T getOrDefault(String key, Class<T> type, T defaultValue) {
- T val = get(key, type);
- if(val==null){
- return defaultValue;
- }
- return val;
- }
-
- @Override
- public <T> T get(String key, Class<T> type) {
- return (T) get(key, TypeLiteral.of(type));
- }
-
- /**
- * Accesses the current String value for the given key and tries to convert it
- * using the {@link org.apache.tamaya.spi.PropertyConverter} instances provided by the current
- * {@link org.apache.tamaya.spi.ConfigurationContext}.
- *
- * @param key the property's absolute, or relative path, e.g. @code
- * a/b/c/d.myProperty}.
- * @param type The target type required, not null.
- * @param <T> the value type
- * @return the converted value, never null.
- */
- @Override
- public <T> T get(String key, TypeLiteral<T> type) {
- String value = get(key);
- if (value != null) {
- List<PropertyConverter<T>> converters = ConfigurationProvider.getConfigurationContext()
- .getPropertyConverters(type);
- ConversionContext context = new ConversionContext.Builder(this,
- ConfigurationProvider.getConfigurationContext(), key,type).build();
- for (PropertyConverter<T> converter : converters) {
- try {
- T t = converter.convert(value, context);
- if (t != null) {
- return t;
- }
- } catch (Exception e) {
- Logger.getLogger(getClass().getName())
- .log(Level.FINEST, "PropertyConverter: " + converter + " failed to convert value: " + value,
- e);
- }
- }
- throw new ConfigException("Unparseable config value for type: " + type.getRawType().getName() + ": " + key
- + ", supported formats: " + context.getSupportedFormats());
- }
-
- return null;
- }
-
- @Override
- public <T> T getOrDefault(String key, TypeLiteral<T> type, T defaultValue) {
- T val = get(key, type);
- if(val==null){
- return defaultValue;
- }
- return val;
- }
-
- @Override
- public Map<String, String> getProperties() {
- return properties;
- }
-
- @Override
- public Configuration with(ConfigOperator operator) {
- return operator.operate(this);
- }
-
- @Override
- public <T> T query(ConfigQuery<T> query) {
- return query.query(this);
- }
-
- @Override
- public ConfigurationContext getContext() {
- return ConfigurationFunctions.emptyConfigurationContext();
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- FrozenConfiguration that = (FrozenConfiguration) o;
- return properties.equals(that.properties);
- }
-
- @Override
- public int hashCode() {
- return properties.hashCode();
- }
-
- @Override
- public String toString() {
- return "FrozenConfiguration{" +
- "properties=" + properties +
- '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/events/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java b/modules/events/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java
deleted file mode 100644
index 81e6dca..0000000
--- a/modules/events/src/main/java/org/apache/tamaya/events/FrozenPropertySource.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.events;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-
-import java.io.Serializable;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * PropertySource implementation that stores all current values of a given (possibly dynamic, contextual and non server
- * capable instance) and is fully serializable. Note that hereby only the scannable key/value pairs are considered.
- */
-public final class FrozenPropertySource implements PropertySource, Serializable {
- private static final long serialVersionUID = -6373137316556444171L;
- /**
- * The ordinal.
- */
- private final int ordinal;
- /**
- * The properties read.
- */
- private Map<String, String> properties = new HashMap<>();
- /**
- * The PropertySource's name.
- */
- private final String name;
-
- /**
- * Constructor.
- *
- * @param propertySource The base PropertySource.
- */
- private FrozenPropertySource(PropertySource propertySource) {
- this.properties.putAll(propertySource.getProperties());
- this.properties.put("[meta]frozenAt", String.valueOf(System.currentTimeMillis()));
- this.properties = Collections.unmodifiableMap(this.properties);
- this.ordinal = propertySource.getOrdinal();
- this.name = propertySource.getName();
- }
-
- /**
- * Creates a new FrozenPropertySource instance based on a PropertySource given.
- *
- * @param propertySource the property source to be frozen, not null.
- * @return the frozen property source.
- */
- public static FrozenPropertySource of(PropertySource propertySource) {
- if (propertySource instanceof FrozenPropertySource) {
- return (FrozenPropertySource) propertySource;
- }
- return new FrozenPropertySource(propertySource);
- }
-
- @Override
- public String getName() {
- return this.name;
- }
-
- @Override
- public int getOrdinal() {
- return this.ordinal;
- }
-
- @Override
- public PropertyValue get(String key) {
- return PropertyValue.of(key, this.properties.get(key), getName());
- }
-
- @Override
- public Map<String, String> getProperties() {
- return properties;
- }
-
- @Override
- public boolean isScannable() {
- return true;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof FrozenPropertySource)) {
- return false;
- }
- FrozenPropertySource that = (FrozenPropertySource) o;
- return ordinal == that.ordinal && properties.equals(that.properties);
- }
-
- @Override
- public int hashCode() {
- int result = ordinal;
- result = 31 * result + properties.hashCode();
- return result;
- }
-
- @Override
- public String toString() {
- return "FrozenPropertySource{" +
- "name=" + name +
- ", ordinal=" + ordinal +
- ", properties=" + properties +
- '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/main/java/org/apache/tamaya/events/PropertySourceChange.java
----------------------------------------------------------------------
diff --git a/modules/events/src/main/java/org/apache/tamaya/events/PropertySourceChange.java b/modules/events/src/main/java/org/apache/tamaya/events/PropertySourceChange.java
deleted file mode 100644
index 063612c..0000000
--- a/modules/events/src/main/java/org/apache/tamaya/events/PropertySourceChange.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.events;
-
-import org.apache.tamaya.spi.PropertySource;
-
-import java.beans.PropertyChangeEvent;
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-/**
- * Event that contains a set current changes that were applied or could be applied.
- * This class is immutable and thread-safe. To create instances use
- * {@link PropertySourceChangeBuilder}.
- *
- * Created by Anatole on 22.10.2014.
- */
-public final class PropertySourceChange implements ConfigEvent<PropertySource>, Serializable{
-
- private static final long serialVersionUID = 1L;
- /** The base property provider/configuration. */
- private final FrozenPropertySource propertySource;
- /** The base version, usable for optimistic locking. */
- private String version = UUID.randomUUID().toString();
- /** The timestamp of the change set in millis from the epoch. */
- private long timestamp = System.currentTimeMillis();
- /** The recorded changes. */
- private final Map<String,PropertyChangeEvent> changes = new HashMap<>();
- /** The overall type of change. */
- private final ChangeType changeType;
-
- /**
- * Constructor used by {@link PropertySourceChangeBuilder}.
- * @param builder The builder used, not null.
- */
- PropertySourceChange(PropertySourceChangeBuilder builder) {
- this.propertySource = FrozenPropertySource.of(builder.source);
- for (PropertyChangeEvent c : builder.delta.values()) {
- this.changes.put(c.getPropertyName(), c);
- }
- if(builder.version!=null){
- this.version = builder.version;
- }
- if(builder.timestamp!=null){
- this.timestamp = builder.timestamp;
- }
- this.changeType = builder.changeType;
- }
-
- /**
- * Gets the type of change for this PropertySource.
- * @return the type of change for this PropertySource, never null.
- */
- public ChangeType getChangeType(){
- return this.changeType;
- }
-
- @Override
- public Class<PropertySource> getResourceType() {
- return PropertySource.class;
- }
-
- /**
- * Get the underlying property provider/configuration.
- * @return the underlying property provider/configuration, or null, if the change instance was deserialized.
- */
- @Override
- public PropertySource getResource(){
- return this.propertySource;
- }
-
- /**
- * Get the base version, usable for optimistic locking.
- * @return the base version.
- */
- @Override
- public String getVersion(){
- return version;
- }
-
- /**
- * Get the timestamp in millis from the current epoch. it is expected that the timestamp and the version are unique to
- * identify a changeset.
- * @return the timestamp, when this changeset was created.
- */
- @Override
- public long getTimestamp(){
- return timestamp;
- }
-
- /**
- * Get the changes recorded.
- * @return the recorded changes, never null.
- */
- public Collection<PropertyChangeEvent> getChanges(){
- return Collections.unmodifiableCollection(this.changes.values());
- }
-
- /**
- * Access the number current removed entries.
- * @return the number current removed entries.
- */
- public int getRemovedSize() {
- int removedCount = 0;
- for (PropertyChangeEvent ev : this.changes.values()) {
- if (ev.getNewValue() == null) {
- removedCount++;
- }
- }
- return removedCount;
-// return (int) this.changes.values().stream().filter((e) -> e.getNewValue() == null).count();
- }
-
- /**
- * Access the number current added entries.
- * @return the number current added entries.
- */
- public int getAddedSize() {
- int addedCount = 0;
- for (PropertyChangeEvent ev : this.changes.values()) {
- if (ev.getOldValue() == null &&
- ev.getNewValue() != null) {
- addedCount++;
- }
- }
- return addedCount;
-// return (int) this.changes.values().stream().filter((e) -> e.getOldValue() == null).count();
- }
-
- /**
- * Access the number current updated entries.
- * @return the number current updated entries.
- */
- public int getUpdatedSize() {
- int updatedCount = 0;
- for (PropertyChangeEvent ev : this.changes.values()) {
- if (ev.getOldValue() != null && ev.getNewValue() != null) {
- updatedCount++;
- }
- }
- return updatedCount;
-// return (int) this.changes.values().stream().filter((e) -> e.getOldValue()!=null && e.getNewValue()!=null).count();
- }
-
-
- /**
- * Checks if the given key was removed.
- * @param key the target key, not null.
- * @return true, if the given key was removed.
- */
- public boolean isRemoved(String key) {
- PropertyChangeEvent change = this.changes.get(key);
- return change != null && change.getNewValue() == null;
- }
-
- /**
- * Checks if the given key was added.
- * @param key the target key, not null.
- * @return true, if the given key was added.
- */
- public boolean isAdded(String key) {
- PropertyChangeEvent change = this.changes.get(key);
- return change != null && change.getOldValue() == null;
- }
-
- /**
- * Checks if the given key was updated.
- * @param key the target key, not null.
- * @return true, if the given key was updated.
- */
- public boolean isUpdated(String key) {
- PropertyChangeEvent change = this.changes.get(key);
- return change != null && change.getOldValue() != null && change.getNewValue() != null;
- }
-
- /**
- * Checks if the given key is added, or updated AND NOT removed.
- * @param key the target key, not null.
- * @return true, if the given key was added, or updated BUT NOT removed.
- */
- public boolean isKeyAffected(String key) {
- PropertyChangeEvent change = this.changes.get(key);
- return change != null && change.getNewValue() != null;
- }
-
- /**
- * CHecks if the current change set does not contain any changes.
- * @return tru, if the change set is empty.
- */
- public boolean isEmpty(){
- return this.changes.isEmpty();
- }
-
-
- /**
- * Create a change event for a new PropertySource that was added.
- * @param propertySource the new property source, not null.
- * @return a new PropertySourceChange, representing a PropertySource that was added.
- */
- public static PropertySourceChange ofAdded(PropertySource propertySource) {
- return PropertySourceChangeBuilder.of(propertySource, ChangeType.NEW).build();
- }
-
- /**
- * Create a change event for a deleted PropertySource.
- * @param propertySource the deleted property source, not null.
- * @return a new PropertySourceChange, representing a PropertySource that was deleted.
- */
- public static PropertySourceChange ofDeleted(PropertySource propertySource) {
- return PropertySourceChangeBuilder.of(propertySource, ChangeType.DELETED).build();
- }
-
- @Override
- public String toString() {
- return "PropertySourceChange{" +
- "changeType=" + changeType +
- ", propertySource=" + propertySource +
- ", version='" + version + '\'' +
- ", timestamp=" + timestamp +
- '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java
----------------------------------------------------------------------
diff --git a/modules/events/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java b/modules/events/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java
deleted file mode 100644
index b7a4483..0000000
--- a/modules/events/src/main/java/org/apache/tamaya/events/PropertySourceChangeBuilder.java
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.events;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-
-import java.beans.PropertyChangeEvent;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
-/**
- * Models a set current changes applied to a {@link org.apache.tamaya.spi.PropertySource}. Consumers of these events
- * can observing changes to property sources and
- * <ol>
- * <li>Check if their current configuration instance ({@link org.apache.tamaya.spi.ConfigurationContext}
- * contains the changed {@link org.apache.tamaya.spi.PropertySource} (Note: the reference tova property source is never affected by a
- * change, its only the data of the property source).</li>
- * <li>If so corresponding action may be taken, such as reevaluating the configuration values (depending on
- * the update policy) or reevaluating the complete {@link org.apache.tamaya.Configuration} to create a change
- * event on configuration level.
- * </ol>
- */
-public final class PropertySourceChangeBuilder {
- /**
- * The recorded changes.
- */
- final SortedMap<String, PropertyChangeEvent> delta = new TreeMap<>();
- /**
- * The underlying configuration/provider.
- */
- final PropertySource source;
- /**
- * The version configured, or null, for generating a default.
- */
- String version;
- /**
- * The optional timestamp in millis of this epoch.
- */
- Long timestamp;
-
- /** The type of change. */
- ChangeType changeType;
-
- /**
- * Constructor.
- *
- * @param source the underlying configuration/provider, not null.
- * @param changeType kind of change.
- */
- private PropertySourceChangeBuilder(PropertySource source, ChangeType changeType) {
- this.source = Objects.requireNonNull(source);
- this.changeType = Objects.requireNonNull(changeType);
- }
-
- /**
- * Creates a new instance of this builder.
- *
- * @param source the underlying property provider/configuration, not null.
- * @param changeType kind of change.
- * @return the builder for chaining.
- */
- public static PropertySourceChangeBuilder of(PropertySource source, ChangeType changeType) {
- return new PropertySourceChangeBuilder(source, changeType);
- }
-
- /**
- * Compares the two property config/configurations and creates a collection current all changes
- * that must be applied to render {@code map1} into {@code map2}.
- *
- * @param map1 the source map, not null.
- * @param map2 the target map, not null.
- * @return a collection current change events, never null.
- */
- public static Collection<PropertyChangeEvent> compare(PropertySource map1, PropertySource map2) {
- List<PropertyChangeEvent> changes = new ArrayList<>();
- for (Map.Entry<String, String> en : map1.getProperties().entrySet()) {
- PropertyValue val = map2.get(en.getKey());
- if (val == null) {
- changes.add(new PropertyChangeEvent(map1, en.getKey(), null, en.getValue()));
- } else if (!val.getValue().equals(en.getValue())) {
- changes.add(new PropertyChangeEvent(map1, en.getKey(), val.getValue(), en.getValue()));
- }
- }
- for (Map.Entry<String, String> en : map2.getProperties().entrySet()) {
- PropertyValue val = map1.get(en.getKey());
- if (val == null) {
- changes.add(new PropertyChangeEvent(map1, en.getKey(), en.getValue(), null));
- } else if (!val.equals(en.getValue())) {
- changes.add(new PropertyChangeEvent(map1, en.getKey(), en.getValue(), val.getValue()));
- }
- }
- return changes;
- }
-
- /*
- * Apply a version/UUID to the set being built.
- * @param version the version to apply, or null, to let the system generate a version for you.
- * @return the builder for chaining.
- */
- public PropertySourceChangeBuilder setVersion(String version) {
- this.version = version;
- return this;
- }
-
- /*
- * Apply given timestamp to the set being built.
- * @param version the version to apply, or null, to let the system generate a version for you.
- * @return the builder for chaining.
- */
- public PropertySourceChangeBuilder setTimestamp(long timestamp) {
- this.timestamp = timestamp;
- return this;
- }
-
- /**
- * This method records all changes to be applied to the base property provider/configuration to
- * achieve the given target state.
- *
- * @param newState the new target state, not null.
- * @return the builder for chaining.
- */
- public PropertySourceChangeBuilder addChanges(PropertySource newState) {
- Collection<PropertyChangeEvent> events = PropertySourceChangeBuilder.compare(newState, this.source);
- for (PropertyChangeEvent c : events) {
- this.delta.put(c.getPropertyName(), c);
- }
- return this;
- }
-
- /**
- * Get the current values, also considering any changes recorded within this change set.
- *
- * @param key the key current the entry, not null.
- * @return the keys, or null.
- */
- public String get(String key) {
- PropertyChangeEvent change = this.delta.get(key);
- if (change != null && !(change.getNewValue() == null)) {
- return (String) change.getNewValue();
- }
- return null;
- }
-
- /**
- * Marks the given key(s) fromMap the configuration/properties to be removed.
- *
- * @param key the key current the entry, not null.
- * @param otherKeys additional keys to be removed (convenience), not null.
- * @return the builder for chaining.
- */
- public PropertySourceChangeBuilder remove(String key, String... otherKeys) {
- PropertyValue oldValue = this.source.get(key);
- if (oldValue == null) {
- this.delta.remove(key);
- }
- this.delta.put(key, new PropertyChangeEvent(this.source, key, oldValue, null));
- for (String addKey : otherKeys) {
- oldValue = this.source.get(addKey);
- if (oldValue == null) {
- this.delta.remove(addKey);
- }
- this.delta.put(addKey, new PropertyChangeEvent(this.source, addKey, oldValue, null));
- }
- return this;
- }
-
- /**
- * Apply all the given values to the base configuration/properties.
- * Note that all values passed must be convertible to String, either
- * <ul>
- * <li>the registered codecs provider provides codecs for the corresponding keys, or </li>
- * <li>default codecs are present for the given type, or</li>
- * <li>the value is an instanceof String</li>
- * </ul>
- *
- * @param changes the changes to be applied, not null.
- * @return the builder for chaining.
- */
- public PropertySourceChangeBuilder putAll(Map<String, String> changes) {
- for (Map.Entry<String, String> en : this.source.getProperties().entrySet()) {
- this.delta.put(en.getKey(), new PropertyChangeEvent(this.source, en.getKey(), null, en.getValue()));
- }
- return this;
- }
-
- /**
- * This method will create a change set that clears all entries fromMap the given base configuration/properties.
- *
- * @return the builder for chaining.
- */
- public PropertySourceChangeBuilder deleteAll() {
- this.delta.clear();
- for (Map.Entry<String, String> en : this.source.getProperties().entrySet()) {
- this.delta.put(en.getKey(), new PropertyChangeEvent(this.source, en.getKey(), en.getValue(), null));
- }
- return this;
- }
-
- /**
- * Checks if the change set is empty, i.e. does not contain any changes.
- *
- * @return true, if the set is empty.
- */
- public boolean isEmpty() {
- return this.delta.isEmpty();
- }
-
- /**
- * Resets this change set instance. This will clear all changes done to this builder, so the
- * set will be empty.
- */
- public void reset() {
- this.delta.clear();
- }
-
- public PropertySourceChangeBuilder setChangeType(ChangeType changeType) {
- this.changeType = changeType;
- return this;
- }
-
- /**
- * Builds the corresponding change set.
- *
- * @return the new change set, never null.
- */
- public PropertySourceChange build() {
- return new PropertySourceChange(this);
- }
-
- /*
- * (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "PropertiesChangeBuilder [source=" + source + ", " +
- ", delta=" + delta + "]";
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/main/java/org/apache/tamaya/events/delta/package-info.java
----------------------------------------------------------------------
diff --git a/modules/events/src/main/java/org/apache/tamaya/events/delta/package-info.java b/modules/events/src/main/java/org/apache/tamaya/events/delta/package-info.java
deleted file mode 100644
index 2006717..0000000
--- a/modules/events/src/main/java/org/apache/tamaya/events/delta/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-/**
- * This package contains artifacts to describe the changes (delta) of a
- * Configuration or a PropertySource.
- */
-package org.apache.tamaya.events.delta;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeListener.java
----------------------------------------------------------------------
diff --git a/modules/events/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeListener.java b/modules/events/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeListener.java
deleted file mode 100644
index 283719e..0000000
--- a/modules/events/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeListener.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.events.folderobserver;
-
-import org.apache.tamaya.ConfigException;
-
-import java.io.IOException;
-import java.nio.file.FileSystem;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.StandardWatchEventKinds;
-import java.nio.file.WatchEvent;
-import java.nio.file.WatchKey;
-import java.nio.file.WatchService;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-
-/**
- * Class that has the responsibility to watch the folder and then publish the changes to a
- * {@link org.apache.tamaya.events.PropertySourceChange}.
- * @see ObservingPropertySourceProvider
- * This listener will wait to events and wait to one second to watch again.
- * <p>If new file was created or modified will commit from this file.</p>
- * <p>If a file was removed then the listener will load using all files left.</p>
- * @author otaviojava
- */
-class FileChangeListener implements Runnable {
-
- private static final Logger LOGGER = Logger.getLogger(FileChangeListener.class.getName());
-
- private final WatchService watchService;
-
- private final FileChangeObserver observer;
-
- private final Path directory;
-
- private volatile boolean running = true;
-
- public FileChangeListener(Path directory, FileChangeObserver observer) {
- this.observer = observer;
- this.directory = directory;
- this.watchService = getWatchService();
-
- if (watchService!=null && directory!=null) {
- try {
- directory.register(watchService,
- StandardWatchEventKinds.ENTRY_DELETE,
- StandardWatchEventKinds.ENTRY_MODIFY,
- StandardWatchEventKinds.ENTRY_CREATE);
- } catch (IOException e) {
- throw new FileChangeListenerException("An error happened when does try to registry to watch the folder", e);
- }
- }
- }
-
- /**
- * Stops the listener service from observing the target directory.
- */
- public void stopListener(){
- running = false;
- }
-
- @Override
- public void run() {
- if (watchService!=null || directory!=null) {
- return;
- }
- while (running) {
- watchFolder();
- }
- }
-
- /**
- * Start watching the current folder.
- */
- private void watchFolder() {
- try {
- WatchKey watckKey = watchService.take();
- for (WatchEvent<?> event : watckKey.pollEvents()) {
- Path filePath = (Path) watckKey.watchable();
- if(event.kind().equals(StandardWatchEventKinds.ENTRY_CREATE)||
- event.kind().equals(StandardWatchEventKinds.ENTRY_MODIFY) ||
- event.kind().equals(StandardWatchEventKinds.ENTRY_DELETE)){
- LOGGER.info("File change detected in: " + filePath.getFileName());
- observer.directoryChanged(filePath);
- }
- }
- watckKey.reset();
- Thread.sleep(1_000L);
- } catch (Exception e) {
- throw new FileChangeListenerException("An error happened when does try to watch the folder", e);
- }
- }
-
- /**
- * Get the watch service.
- * @return the watch service, or null, if the watch service is not supported.
- */
- private WatchService getWatchService() {
- try {
- FileSystem fileSystem = Paths.get(".").getFileSystem();
- return fileSystem.newWatchService();
- } catch (IOException e) {
- LOGGER.log(Level.WARNING, "The file System does not supports WatchService", e);
- return null;
- }
-
- }
-
- /**
- * Exception if file listening fails.
- */
- static class FileChangeListenerException extends ConfigException {
- /** Serialversion UID. */
- private static final long serialVersionUID = -8965486770881001513L;
-
- /**
- * Constructor.
- * @param message a message
- * @param cause an (optional) root cause.
- */
- public FileChangeListenerException(String message, Throwable cause) {
- super(message, cause);
- }
-
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeObserver.java
----------------------------------------------------------------------
diff --git a/modules/events/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeObserver.java b/modules/events/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeObserver.java
deleted file mode 100644
index 63d25cd..0000000
--- a/modules/events/src/main/java/org/apache/tamaya/events/folderobserver/FileChangeObserver.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.events.folderobserver;
-
-import java.nio.file.Path;
-
-/**
- * Observer to be used in {@link FileChangeListener} to commit all configurations and provider.
- */
-interface FileChangeObserver {
- /**
- * Called when a file has been modified.
- * @param path the file path, not null.
- */
- void directoryChanged(Path path);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/modules/events/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java b/modules/events/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java
deleted file mode 100644
index feddd70..0000000
--- a/modules/events/src/main/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.events.folderobserver;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.events.ConfigEventManager;
-import org.apache.tamaya.events.ConfigurationContextChange;
-import org.apache.tamaya.events.ConfigurationContextChangeBuilder;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertySourceProvider;
-import org.apache.tamaya.spisupport.BasePropertySource;
-
-/**
- * This implementation runs in a folder taking up all files compatible with the given
- * ConfigurationFormats. When a file is added, deleted or modified the PropertySourceProvider
- * will adapt the changes automatically and trigger according
- * {@link org.apache.tamaya.events.PropertySourceChange} events.
- * The default folder is META-INF/config, but you can change it via an absolute path in the
- * "-Dtamaya.configdir" parameter.
- */
-public class ObservingPropertySourceProvider implements PropertySourceProvider, FileChangeObserver {
- /**
- * The logger.
- */
- private static final Logger LOG = Logger.getLogger(ObservingPropertySourceProvider.class.getName());
- /**
- * The current active property sources of this provider.
- */
- private final List<PropertySource> propertySources = Collections.synchronizedList(new LinkedList<PropertySource>());
- /**
- * The thread pool used.
- */
- private final ExecutorService executor = Executors.newSingleThreadExecutor();
-
- /**
- * Constructorm using an explicit directory, ignoring all kind of configuration, if set.
- *
- * @param directory the target directory. If null, the default configuration and system property are used.
- */
- public ObservingPropertySourceProvider(Path directory) {
- if (directory == null) {
- directory = getDirectory();
- }
- if (directory!=null){
- synchronized (this.propertySources) {
- this.propertySources.addAll(readConfiguration(directory));
- }
- final Runnable runnable = new FileChangeListener(directory, this);
- executor.execute(runnable);
- } else {
- executor.shutdown();
- }
- }
-
- /**
- * Read the initial configuration.
- *
- * @param directory the target directory, not null.
- */
- private List<PropertySource> readConfiguration(Path directory) {
- final List<PropertySource> result = new ArrayList<>();
- try {
- synchronized (propertySources) {
- for (final Path path : Files.newDirectoryStream(directory, "*")) {
- result.addAll(getPropertySources(path));
- }
- return result;
- }
- } catch (final IOException e) {
- LOG.log(Level.WARNING, "Failed to read configuration from dir: " + directory, e);
- }
- return result;
- }
-
- /**
- * Read property sources from the given file.
- *
- * @param file source of the property sources.
- * @return property sources from the given file.
- */
- protected Collection<PropertySource> getPropertySources(final Path file) {
- return Arrays.asList(new PropertySource[]{new BasePropertySource() {
- private final Map<String,String> props = readProperties(file);
-
- @Override
- public Map<String, String> getProperties() {
- return props;
- }
- }});
- }
-
- /**
- * Load a single file.
- *
- * @param file the file, not null.
- * @return properties as read from the given file.
- */
- protected static Map<String,String> readProperties(Path file) {
- try (InputStream is = file.toUri().toURL().openStream()){
- final Properties props = new Properties();
- props.load(is);
- final Map<String,String> result = new HashMap<>();
- for(final Map.Entry<Object,Object> en:props.entrySet()){
- result.put(String.valueOf(en.getKey()), String.valueOf(en.getValue()));
- }
- return result;
- } catch (final Exception e) {
- LOG.log(Level.INFO, "Error reading file: " + file.toString() +
- ", using format: properties", e);
- }
- return Collections.emptyMap();
- }
-
-
- /**
- * Evaluates the target directory from system property (tamaya.configdir) or classpath.
- *
- * @return the directory to be read, or null.
- */
- private Path getDirectory() {
- final String absolutePath = System.getProperty("tamaya.configdir");
- if (null!=absolutePath) {
- final Path path = Paths.get(absolutePath);
- if (Files.isDirectory(path)) {
- return path;
- }
- }
- final URL resource = ObservingPropertySourceProvider.class.getResource("/META-INF/config/");
- if (null!=resource) {
- try {
- return Paths.get(resource.toURI());
- } catch (final URISyntaxException e) {
- throw new ConfigException("An error to find the directory to watch", e);
- }
- }
- return null;
- }
-
-
- @Override
- public void directoryChanged(Path directory) {
- synchronized (this.propertySources) {
- final List<PropertySource> existingPropertySources = new ArrayList<>(propertySources);
- propertySources.clear();
- final Collection<PropertySource> sourcesRead = readConfiguration(directory);
- this.propertySources.addAll(sourcesRead);
- triggerConfigChange(existingPropertySources, propertySources);
- }
- }
-
-
- private void triggerConfigChange(List<PropertySource> originalPropertySources,
- List<PropertySource> newPropertySources) {
- final ConfigurationContextChangeBuilder b = ConfigurationContextChangeBuilder.of();
- for (final PropertySource ps : originalPropertySources) {
- b.removedPropertySource(ps);
- }
- for (final PropertySource ps : newPropertySources) {
- b.newPropertySource(ps);
- }
- final ConfigurationContextChange changeEvent = b.build();
- LOG.fine("Trigger Config Context Change: " + changeEvent);
- ConfigEventManager.fireEvent(changeEvent);
- }
-
- @Override
- public Collection<PropertySource> getPropertySources() {
- synchronized (propertySources) {
- return new ArrayList<>(this.propertySources);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/main/java/org/apache/tamaya/events/folderobserver/package-info.java
----------------------------------------------------------------------
diff --git a/modules/events/src/main/java/org/apache/tamaya/events/folderobserver/package-info.java b/modules/events/src/main/java/org/apache/tamaya/events/folderobserver/package-info.java
deleted file mode 100644
index 347f2d8..0000000
--- a/modules/events/src/main/java/org/apache/tamaya/events/folderobserver/package-info.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-/**
- * This package contains code to observe a folder for file changes and to trigger
- * corresponding events, that are handled by an according {@link org.apache.tamaya.events.folderobserver.ObservingPropertySourceProvider}
- * instance.
- */
-package org.apache.tamaya.events.folderobserver;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/main/java/org/apache/tamaya/events/internal/DefaultConfigChangeObserver.java
----------------------------------------------------------------------
diff --git a/modules/events/src/main/java/org/apache/tamaya/events/internal/DefaultConfigChangeObserver.java b/modules/events/src/main/java/org/apache/tamaya/events/internal/DefaultConfigChangeObserver.java
deleted file mode 100644
index f4457b2..0000000
--- a/modules/events/src/main/java/org/apache/tamaya/events/internal/DefaultConfigChangeObserver.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.events.internal;
-
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.events.ConfigEventManager;
-import org.apache.tamaya.events.ConfigurationChange;
-import org.apache.tamaya.events.ConfigurationChangeBuilder;
-import org.apache.tamaya.events.FrozenConfiguration;
-
-import java.util.*;
-import java.util.logging.Logger;
-
-/**
- * Timer task that regularly checks the configuration for changes.
- */
-public class DefaultConfigChangeObserver {
-
- private static final long START_DELAY = 5000L;
-
- private static final Logger LOG = Logger.getLogger(DefaultConfigChangeObserver.class.getName());
-
- private Timer timer = new Timer("DefaultConfigChangeObserver", true);
-
- private long checkPeriod = 2000L;
-
- private volatile FrozenConfiguration lastConfig;
-
- private volatile boolean running;
-
- /**
- * Constructor. Also loads all registered listeners.
- */
- public DefaultConfigChangeObserver() {
- LOG.info("Registering config change observer, rechecking config changes every " + checkPeriod + " ms.");
- timer.scheduleAtFixedRate(new TimerTask() {
- @Override
- public void run() {
- if(running) {
- checkConfigurationUpdate();
- }
- }
- }, START_DELAY, checkPeriod);
- }
-
-
- public void checkConfigurationUpdate() {
- LOG.finest("Checking configuration for changes...");
- FrozenConfiguration newConfig = FrozenConfiguration.of(ConfigurationProvider.getConfiguration());
- ConfigurationChange changes;
- if(lastConfig==null){
- changes = ConfigurationChangeBuilder.of(newConfig).putAll(newConfig.getProperties())
- .build();
- }else{
- changes = ConfigurationChangeBuilder.of(lastConfig).addChanges(newConfig)
- .build();
- }
- if(!changes.isEmpty()) {
- LOG.info("Identified configuration changes, publishing change event...");
- ConfigEventManager.fireEvent(changes);
- }
- }
-
- public long getCheckPeriod() {
- return checkPeriod;
- }
-
- public boolean isMonitoring(){
- return running;
- }
-
- public void enableMonitoring(boolean enable){
- this.running = true;
- }
-
- /**
- * Sets the new check period, cancels the currently running timer and schedules a new task with the new checkperiod
- * and a startup delay of 500ms.
- * @param checkPeriod the period in ms, for checking on changes.
- */
- public void setCheckPeriod(long checkPeriod) {
- LOG.finest("Resetting check period to " + checkPeriod + " ms, reregistering timer.");
- this.checkPeriod = checkPeriod;
- timer.cancel();
- timer = new Timer("DefaultConfigChangeObserver", true);
- timer.scheduleAtFixedRate(new TimerTask() {
- @Override
- public void run() {
- if(running) {
- checkConfigurationUpdate();
- }
- }
- }, 500L, checkPeriod);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/main/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpi.java
----------------------------------------------------------------------
diff --git a/modules/events/src/main/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpi.java b/modules/events/src/main/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpi.java
deleted file mode 100644
index 586df5c..0000000
--- a/modules/events/src/main/java/org/apache/tamaya/events/internal/DefaultConfigEventManagerSpi.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.events.internal;
-
-import org.apache.tamaya.events.ConfigEvent;
-import org.apache.tamaya.events.ConfigEventListener;
-import org.apache.tamaya.events.spi.ConfigEventManagerSpi;
-import org.apache.tamaya.spi.ServiceContextManager;
-
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Default implementation of {@link DefaultConfigEventManagerSpi} just forwarding all
- * events synchronously to the listeners.
- */
-public class DefaultConfigEventManagerSpi implements ConfigEventManagerSpi {
-
- private static final Logger LOG = Logger.getLogger(DefaultConfigEventManagerSpi.class.getName());
-
- private final Map<Class,List<ConfigEventListener>> listeners = new ConcurrentHashMap<>();
-
- private final ExecutorService publisher = Executors.newCachedThreadPool();
-
- private final DefaultConfigChangeObserver changeObserver = new DefaultConfigChangeObserver();
-
- /**
- * Constructor. Also loads all registered listeners.
- */
- public DefaultConfigEventManagerSpi() {
- try {
- for (ConfigEventListener l : ServiceContextManager.getServiceContext().getServices(ConfigEventListener.class)) {
- try {
- addListener(l);
- } catch (Exception e) {
- LOG.log(Level.WARNING, "Failed to load configured listener: " + l.getClass().getName(), e);
- }
- }
- } catch (Exception e) {
- LOG.log(Level.WARNING, "Failed to load configured listeners.", e);
- }
- }
-
- @Override
- public void addListener(ConfigEventListener l){
- addListener(l, ConfigEvent.class);
- }
-
- @Override
- public <T extends ConfigEvent> void addListener(ConfigEventListener l, Class<T> eventType){
- List<ConfigEventListener> ls = listeners.get(eventType);
- if(ls==null){
- ls = Collections.synchronizedList(new ArrayList<ConfigEventListener>());
- listeners.put(eventType, ls);
- }
- synchronized (ls){
- if(!ls.contains(l)){
- ls.add(l);
- }
- }
- }
-
- @Override
- public void removeListener(ConfigEventListener l){
- removeListener(l, ConfigEvent.class);
- }
-
- @Override
- public <T extends ConfigEvent> void removeListener(ConfigEventListener l, Class<T> eventType) {
- List<ConfigEventListener> targets = this.listeners.get(eventType);
- if(targets!=null) {
- // forward to explicit listeners
- synchronized (targets) {
- targets.remove(l);
- }
- }
- }
-
- @Override
- public Collection<? extends ConfigEventListener> getListeners(Class<? extends ConfigEvent> eventType) {
- List<ConfigEventListener> targets = this.listeners.get(eventType);
- if(targets!=null){
- synchronized(targets){
- return new ArrayList<>(targets);
- }
- }
- return Collections.emptyList();
- }
-
- @Override
- public Collection<? extends ConfigEventListener> getListeners() {
- Set<ConfigEventListener> targets = new HashSet<>();
- for(List<ConfigEventListener> l:this.listeners.values()){
- targets.addAll(l);
- }
- return targets;
- }
-
- @Override
- public void fireEvent(ConfigEvent<?> event) {
- List<ConfigEventListener> targets = this.listeners.get(event.getClass());
- if(targets!=null) {
- // forward to explicit listeners
- synchronized (targets) {
- for (ConfigEventListener l : targets) {
- l.onConfigEvent(event);
- }
- }
- }
- // forward to global listeners
- targets = this.listeners.get(ConfigEvent.class);
- if(targets!=null) {
- synchronized (targets) {
- for (ConfigEventListener l : targets) {
- l.onConfigEvent(event);
- }
- }
- }
- }
-
- @Override
- public void fireEventAsynch(ConfigEvent<?> event) {
- List<ConfigEventListener> targets = this.listeners.get(event.getClass());
- if(targets!=null) {
- // forward to explicit listeners
- synchronized (targets) {
- for (ConfigEventListener l : targets) {
- publisher.execute(new PublishConfigChangeTask(l, event));
- }
- }
- }
- // forward to global listeners
- targets = this.listeners.get(ConfigEvent.class);
- if(targets!=null) {
- synchronized (targets) {
- for (ConfigEventListener l : targets) {
- publisher.execute(new PublishConfigChangeTask(l, event));
- }
- }
- }
- }
-
- @Override
- public long getChangeMonitoringPeriod() {
- return changeObserver.getCheckPeriod();
- }
-
- @Override
- public void setChangeMonitoringPeriod(long millis){
- changeObserver.setCheckPeriod(millis);
- }
-
- @Override
- public boolean isChangeMonitorActive() {
- return changeObserver.isMonitoring();
- }
-
- @Override
- public void enableChangeMonitor(boolean enable) {
- changeObserver.enableMonitoring(enable);
- }
-
-
- /**
- * Tasks to inform observers on detected configuration changes.
- */
- private static final class PublishConfigChangeTask implements Runnable{
-
- private final ConfigEventListener l;
- private final ConfigEvent<?> changes;
-
- public PublishConfigChangeTask(ConfigEventListener l, ConfigEvent<?> changes) {
- this.l = Objects.requireNonNull(l);
- this.changes = Objects.requireNonNull(changes);
- }
-
- @Override
- public void run() {
- l.onConfigEvent(changes);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/main/java/org/apache/tamaya/events/internal/DefaultConfigurationContextChangeListener.java
----------------------------------------------------------------------
diff --git a/modules/events/src/main/java/org/apache/tamaya/events/internal/DefaultConfigurationContextChangeListener.java b/modules/events/src/main/java/org/apache/tamaya/events/internal/DefaultConfigurationContextChangeListener.java
deleted file mode 100644
index e49856d..0000000
--- a/modules/events/src/main/java/org/apache/tamaya/events/internal/DefaultConfigurationContextChangeListener.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.events.internal;
-
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.events.ConfigEvent;
-import org.apache.tamaya.events.ConfigEventListener;
-import org.apache.tamaya.events.ConfigurationContextChange;
-import org.apache.tamaya.spi.ConfigurationContext;
-import org.apache.tamaya.spi.ConfigurationContextBuilder;
-import org.apache.tamaya.spi.PropertySource;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Default ConfigEventListener for ConfigurationContextChange events that updates the current context, if resources were
- * affected.
- */
-public class DefaultConfigurationContextChangeListener implements ConfigEventListener {
-
- private static final Logger LOG = Logger.getLogger(DefaultConfigurationContextChangeListener.class.getName());
-
- @Override
- public void onConfigEvent(ConfigEvent<?> event) {
- if(event.getClass() == ConfigurationContextChange.class) {
- ConfigurationContextChange contextChange = (ConfigurationContextChange) event;
- ConfigurationContext context = ConfigurationProvider.getConfigurationContext();
- List<PropertySource> affectedPropertySources = new ArrayList<>();
- for (PropertySource ps : context.getPropertySources()) {
- if (contextChange.isAffected(ps)) {
- affectedPropertySources.add(ps);
- }
- }
- ConfigurationContextBuilder newContextBuilder = ConfigurationProvider.getConfigurationContextBuilder()
- .setContext(context);
- if (!affectedPropertySources.isEmpty()) {
- Set<String> propertySourceNames = new HashSet<>();
- for (PropertySource removed : contextChange.getRemovedPropertySources()) {
- propertySourceNames.add(removed.getName());
- }
- newContextBuilder.removePropertySources(propertySourceNames);
- }
- newContextBuilder.addPropertySources(contextChange.getAddedPropertySources());
- newContextBuilder.addPropertySources(contextChange.getUpdatedPropertySources());
- ConfigurationContext newContext = newContextBuilder.build();
- try {
- ConfigurationProvider.setConfigurationContext(newContext);
- } catch (Exception e) {
- LOG.log(Level.INFO, "Failed to update the current ConfigurationContext due to config model changes", e);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/main/java/org/apache/tamaya/events/internal/LoggingConfigListener.java
----------------------------------------------------------------------
diff --git a/modules/events/src/main/java/org/apache/tamaya/events/internal/LoggingConfigListener.java b/modules/events/src/main/java/org/apache/tamaya/events/internal/LoggingConfigListener.java
deleted file mode 100644
index be8c404..0000000
--- a/modules/events/src/main/java/org/apache/tamaya/events/internal/LoggingConfigListener.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.events.internal;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.events.ConfigEvent;
-import org.apache.tamaya.events.ConfigEventListener;
-
-import java.util.logging.Logger;
-
-/**
- * Simple ConfigListener that simply logs any detected config changes to INFO level.
- */
-public class LoggingConfigListener implements ConfigEventListener {
-
- private static final Logger LOG = Logger.getLogger(LoggingConfigListener.class.getName());
-
- @Override
- public void onConfigEvent(ConfigEvent<?> event) {
- if(event.getResourceType()== Configuration.class) {
- LOG.info("Configuration changed: " + event);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/main/java/org/apache/tamaya/events/internal/package-info.java
----------------------------------------------------------------------
diff --git a/modules/events/src/main/java/org/apache/tamaya/events/internal/package-info.java b/modules/events/src/main/java/org/apache/tamaya/events/internal/package-info.java
deleted file mode 100644
index 9df5ac3..0000000
--- a/modules/events/src/main/java/org/apache/tamaya/events/internal/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-/**
- * This package contains internal default implementations for the config events module.
- */
-package org.apache.tamaya.events.internal;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/main/java/org/apache/tamaya/events/package-info.java
----------------------------------------------------------------------
diff --git a/modules/events/src/main/java/org/apache/tamaya/events/package-info.java b/modules/events/src/main/java/org/apache/tamaya/events/package-info.java
deleted file mode 100644
index e175ceb..0000000
--- a/modules/events/src/main/java/org/apache/tamaya/events/package-info.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-/**
- * This package provides the main building blocks for handling configuration changes, such as
- * {@link org.apache.tamaya.events.ConfigEventManager}, {@link org.apache.tamaya.events.ConfigEventListener} and
- * artifacts to describe the changes (delta) of a Configuration or a PropertySource.
- */
-package org.apache.tamaya.events;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/main/java/org/apache/tamaya/events/spi/BaseConfigEvent.java
----------------------------------------------------------------------
diff --git a/modules/events/src/main/java/org/apache/tamaya/events/spi/BaseConfigEvent.java b/modules/events/src/main/java/org/apache/tamaya/events/spi/BaseConfigEvent.java
deleted file mode 100644
index f6856d9..0000000
--- a/modules/events/src/main/java/org/apache/tamaya/events/spi/BaseConfigEvent.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.events.spi;
-
-import org.apache.tamaya.events.ConfigEvent;
-
-import java.util.Objects;
-import java.util.UUID;
-
-/**
- * Abstract base class for implementing your own configuration events.
- * @param <T> the vent type
- */
-public abstract class BaseConfigEvent<T> implements ConfigEvent<T> {
- protected long timestamp = System.currentTimeMillis();
- protected String version = UUID.randomUUID().toString();
- protected final T paylod;
- private final Class<T> type;
-
- public BaseConfigEvent(T paylod, Class<T> type){
- this.paylod = Objects.requireNonNull(paylod);
- this.type = Objects.requireNonNull(type);
- }
-
- @Override
- public Class<T> getResourceType() {
- return type;
- }
-
- @Override
- public T getResource() {
- return paylod;
- }
-
- @Override
- public String getVersion() {
- return version;
- }
-
- @Override
- public long getTimestamp() {
- return timestamp;
- }
-
- @Override
- public String toString() {
- return getClass().getSimpleName() + '{' +
- "timestamp=" + timestamp +
- ", version='" + version + '\'' +
- ", paylod='" + paylod + '\'' +
- '}';
- }
- }
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/main/java/org/apache/tamaya/events/spi/ConfigEventManagerSpi.java
----------------------------------------------------------------------
diff --git a/modules/events/src/main/java/org/apache/tamaya/events/spi/ConfigEventManagerSpi.java b/modules/events/src/main/java/org/apache/tamaya/events/spi/ConfigEventManagerSpi.java
deleted file mode 100644
index 66a8f73..0000000
--- a/modules/events/src/main/java/org/apache/tamaya/events/spi/ConfigEventManagerSpi.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.events.spi;
-
-import org.apache.tamaya.events.ConfigEvent;
-import org.apache.tamaya.events.ConfigEventListener;
-
-import java.util.Collection;
-
-/**
- * SPI interface to implement the {@link org.apache.tamaya.events.ConfigEventManager} singleton.
- * Implementations of this interface must be registered with the current {@link org.apache.tamaya.spi.ServiceContext},
- * by default this equals to registering it with {@link java.util.ServiceLoader}. Add {@link javax.annotation.Priority}
- * annotations for overriding (higher values override lower values).
- */
-public interface ConfigEventManagerSpi {
- /**
- * Adds a listener for observing events. References of this
- * component to the listeners must be managed as weak references.
- *
- * @param <T> the type of the events listened to.
- * @param l the listener not null.
- */
- <T> void addListener(ConfigEventListener l);
-
- /**
- * Adds a listener for observing events of a given type.
- *
- * @param <T> the type of the events listened to.
- * @param l the listener not null.
- * @param eventType the type of concrete configuration event this listeners should be informed about. All other
- * event types will never be delivered to this listener instance.
- */
- <T extends ConfigEvent> void addListener(ConfigEventListener l, Class<T> eventType);
-
- /**
- * Removes a listener for observing events.
- *
- * @param l the listener not null.
- */
- void removeListener(ConfigEventListener l);
-
- /**
- * Removes a listener for observing events of a certain type.
- *
- * @param <T> the type of the events listened to.
- * @param l the listener not null.
- * @param eventType the type of concrete configuration event this listeners should be informed about. All other
- * event types will never be delivered toe this listener instance.
- */
- <T extends ConfigEvent> void removeListener(ConfigEventListener l, Class<T> eventType);
-
- /**
- * Access all globally registered listeners.
- *
- * @return the listeners found, never null.
- */
- Collection<? extends ConfigEventListener> getListeners();
-
- /**
- * Access all listeners listening for a certain event type, including any global listeners.
- * @param eventType the type of concrete configuration event this listeners should be informed about. All other
- * event types will never be delivered toe this listener instance.
- * @return the listeners found, never null.
- */
- Collection<? extends ConfigEventListener> getListeners(Class<? extends ConfigEvent> eventType);
-
- /**
- * Publishes an event to all interested listeners, hereby executing all registered listeners sequentually and
- * synchronously.,
- *
- * @param event the event, not null.
- */
- void fireEvent(ConfigEvent<?> event);
-
- /**
- * Publishes an event to all interested listeners, hereby publishing the change events asynchrously and in
- * parallel (multithreaded).
- *
- * @param event the event, not null.
- */
- void fireEventAsynch(ConfigEvent<?> event);
-
- /**
- * Get the current check period to check for configuration changes.
- *
- * @return the check period in ms.
- */
- long getChangeMonitoringPeriod();
-
- void setChangeMonitoringPeriod(long millis);
-
- /**
- * Check if the observer is running currently.
- *
- * @return true, if the change monitoring service is currently running.
- */
- boolean isChangeMonitorActive();
-
- /**
- * Start/stop the change monitoring service, which will observe/reevaluate the current configuration regularly
- * and trigger ConfigurationChange events if something is changed. This is quite handy for publishing
- * configuration changes to whatever systems are interested in. Hereby the origin of a configuration change
- * can be on this machine, or also remotedly. For handling corresponding {@link ConfigEventListener} have
- * to be registered, e.g. listening on {@link org.apache.tamaya.events.ConfigurationChange} events.
- *
- * @param enable whether to enable or disable the change monitoring.
- */
- void enableChangeMonitor(boolean enable);
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/events/src/main/java/org/apache/tamaya/events/spi/package-info.java
----------------------------------------------------------------------
diff --git a/modules/events/src/main/java/org/apache/tamaya/events/spi/package-info.java b/modules/events/src/main/java/org/apache/tamaya/events/spi/package-info.java
deleted file mode 100644
index 63d2b3b..0000000
--- a/modules/events/src/main/java/org/apache/tamaya/events/spi/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-/**
- * This package contains the SPI to implement the
- * {@link org.apache.tamaya.events.ConfigEventManager} singleton.
- */
-package org.apache.tamaya.events.spi;
\ No newline at end of file
[18/24] incubator-tamaya git commit: Removed all modules from the
main repository. They will be reborn in separate ASF repository.
Posted by pl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/filter/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter
----------------------------------------------------------------------
diff --git a/modules/filter/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter b/modules/filter/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter
deleted file mode 100644
index 806b833..0000000
--- a/modules/filter/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter
+++ /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.filter.ConfigurationFilter
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/filter/src/test/java/org/apache/tamaya/filter/ConfigurationFilterTest.java
----------------------------------------------------------------------
diff --git a/modules/filter/src/test/java/org/apache/tamaya/filter/ConfigurationFilterTest.java b/modules/filter/src/test/java/org/apache/tamaya/filter/ConfigurationFilterTest.java
deleted file mode 100644
index 9d0da1f..0000000
--- a/modules/filter/src/test/java/org/apache/tamaya/filter/ConfigurationFilterTest.java
+++ /dev/null
@@ -1,122 +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.filter;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.spi.FilterContext;
-import org.apache.tamaya.spi.PropertyFilter;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Tests for {@link ConfigurationFilter}. Created by atsticks on 11.02.16.
- */
-public class ConfigurationFilterTest {
-
- @Test
- public void testMetadataFiltered() throws Exception {
- ConfigurationFilter.setMetadataFiltered(true);
- assertTrue(ConfigurationFilter.isMetadataFiltered());
- ConfigurationFilter.setMetadataFiltered(false);
- assertFalse(ConfigurationFilter.isMetadataFiltered());
- }
-
- @Test
- public void testGetSingleFilters() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- assertNotNull(ConfigurationFilter.getSingleFilters());
- PropertyFilter testFilter = new PropertyFilter() {
- @Override
- public String filterProperty(String value, FilterContext context) {
- return context.getKey() + ":testGetSingleFilters";
- }
- };
- ConfigurationFilter.getSingleFilters().addFilter(testFilter);
- assertEquals("user.home:testGetSingleFilters", config.get("user.home"));
- ConfigurationFilter.getSingleFilters().removeFilter(testFilter);
- assertNotSame("user.home:testGetSingleFilters", config.get("user.home"));
- }
-
- @Test
- public void testRemoveSingleFiltersAt0() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- assertNotNull(ConfigurationFilter.getSingleFilters());
- PropertyFilter testFilter = new PropertyFilter() {
- @Override
- public String filterProperty(String value, FilterContext context) {
- return context.getKey() + ":testGetSingleFilters";
- }
- };
- ConfigurationFilter.getSingleFilters().addFilter(testFilter);
- assertEquals("user.home:testGetSingleFilters", config.get("user.home"));
- ConfigurationFilter.getSingleFilters().removeFilter(0);
- assertNotSame("user.home:testGetSingleFilters", config.get("user.home"));
- }
-
- @Test
- public void testGetMapFilters() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- assertNotNull(ConfigurationFilter.getMapFilters());
- PropertyFilter testFilter = new PropertyFilter() {
- @Override
- public String filterProperty(String value, FilterContext context) {
- return context.getKey() + ":testGetMapFilters";
- }
- };
- ConfigurationFilter.getMapFilters().addFilter(testFilter);
- assertEquals("user.home:testGetMapFilters", config.getProperties().get("user.home"));
- ConfigurationFilter.getSingleFilters().removeFilter(testFilter);
- assertNotSame("user.home:testGetSingleFilters", config.getProperties().get("user.home"));
- }
-
- @Test
- public void testRemoveMapFilterAt0() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- assertNotNull(ConfigurationFilter.getMapFilters());
- PropertyFilter testFilter = new PropertyFilter() {
- @Override
- public String filterProperty(String value, FilterContext context) {
- return context.getKey() + ":testGetMapFilters";
- }
- };
- ConfigurationFilter.getMapFilters().addFilter(testFilter);
- assertEquals("user.home:testGetMapFilters", config.getProperties().get("user.home"));
- ConfigurationFilter.getMapFilters().removeFilter(0);
- assertNotSame("user.home:testGetSingleFilters", config.getProperties().get("user.home"));
- }
-
- @Test
- public void testClearFilters() throws Exception {
- Configuration config = ConfigurationProvider.getConfiguration();
- assertNotNull(ConfigurationFilter.getSingleFilters());
- PropertyFilter testFilter = new PropertyFilter() {
- @Override
- public String filterProperty(String value, FilterContext context) {
- return context.getKey() + ":testGetSingleFilters";
- }
- };
- ConfigurationFilter.getSingleFilters().addFilter(testFilter);
- assertEquals("user.home:testGetSingleFilters", config.get("user.home"));
- ConfigurationFilter.clearFilters();
- assertNotSame("user.home:testGetSingleFilters", config.get("user.home"));
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/filter/src/test/java/org/apache/tamaya/filter/ProgrammableFilterTest.java
----------------------------------------------------------------------
diff --git a/modules/filter/src/test/java/org/apache/tamaya/filter/ProgrammableFilterTest.java b/modules/filter/src/test/java/org/apache/tamaya/filter/ProgrammableFilterTest.java
deleted file mode 100644
index 73db677..0000000
--- a/modules/filter/src/test/java/org/apache/tamaya/filter/ProgrammableFilterTest.java
+++ /dev/null
@@ -1,141 +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.filter;
-
-import org.apache.tamaya.spi.FilterContext;
-import org.apache.tamaya.spi.PropertyFilter;
-import org.junit.Test;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.junit.Assert.*;
-
-/**
- * Tests for {@link ProgrammableFilter}. Created by atsticks on 11.02.16.
- */
-public class ProgrammableFilterTest {
-
- @Test
- public void testAddRemoveFilter() throws Exception {
- ProgrammableFilter filter = new ProgrammableFilter();
- RegexPropertyFilter regexFilter = new RegexPropertyFilter("test\\..*");
- Map<String,String> map = new HashMap<>();
- map.put("test1", "test1");
- map.put("test2", "test2");
- map.put("test.test3", "test.test3");
- assertEquals(filter.filterProperty("test1", new FilterContext("test1", map, true)), "test1");
- assertEquals(filter.filterProperty("test2", new FilterContext("test2", map, true)), "test2");
- assertEquals(filter.filterProperty("test.test3", new FilterContext("test.test3", map, true)), "test.test3");
- filter.addFilter(regexFilter);
- assertEquals(filter.filterProperty("test1", new FilterContext("test1", map, true)), "test1");
- assertEquals(filter.filterProperty("test2", new FilterContext("test2", map, true)), "test2");
- assertNull(filter.filterProperty("test.test3", new FilterContext("test.test3", map, true)));
- filter.removeFilter(0);
- assertEquals(filter.filterProperty("test1", new FilterContext("test1", map, true)), "test1");
- assertEquals(filter.filterProperty("test2", new FilterContext("test2", map, true)), "test2");
- assertEquals(filter.filterProperty("test.test3", new FilterContext("test.test3", map, true)), "test.test3");
- filter.addFilter(0, regexFilter);
- assertEquals(filter.filterProperty("test1", new FilterContext("test1", map, true)), "test1");
- assertEquals(filter.filterProperty("test2", new FilterContext("test2", map, true)), "test2");
- assertNull(filter.filterProperty("test.test3", new FilterContext("test.test3", map, true)));
- }
-
- @Test
- public void testClearFilters() throws Exception {
- ProgrammableFilter filter = new ProgrammableFilter();
- RegexPropertyFilter regexFilter = new RegexPropertyFilter("test\\..*");
- Map<String,String> map = new HashMap<>();
- map.put("test1", "test1");
- map.put("test2", "test2");
- map.put("test.test3", "test.test3");
- assertEquals(filter.filterProperty("test1", new FilterContext("test1", map, true)), "test1");
- assertEquals(filter.filterProperty("test2", new FilterContext("test2", map, true)), "test2");
- assertEquals(filter.filterProperty("test.test3", new FilterContext("test.test3", map, true)), "test.test3");
- filter.addFilter(regexFilter);
- assertEquals(filter.filterProperty("test1", new FilterContext("test1", map, true)), "test1");
- assertEquals(filter.filterProperty("test2", new FilterContext("test2", map, true)), "test2");
- assertNull(filter.filterProperty("test.test3", new FilterContext("test.test3", map, true)));
- filter.clearFilters();
- assertEquals(filter.filterProperty("test1", new FilterContext("test1", map, true)), "test1");
- assertEquals(filter.filterProperty("test2", new FilterContext("test2", map, true)), "test2");
- assertEquals(filter.filterProperty("test.test3", new FilterContext("test.test3", map, true)), "test.test3");
- }
-
- @Test
- public void testSetFilters() throws Exception {
- ProgrammableFilter filter = new ProgrammableFilter();
- RegexPropertyFilter regexFilter = new RegexPropertyFilter("test\\..*");
- Map<String,String> map = new HashMap<>();
- map.put("test1", "test1");
- map.put("test2", "test2");
- map.put("test.test3", "test.test3");
- assertEquals(filter.filterProperty("test1", new FilterContext("test1", map, true)), "test1");
- assertEquals(filter.filterProperty("test2", new FilterContext("test2", map, true)), "test2");
- assertEquals(filter.filterProperty("test.test3", new FilterContext("test.test3", map, true)), "test.test3");
- filter.setFilters(regexFilter);
- assertEquals(filter.filterProperty("test1", new FilterContext("test1", map, true)), "test1");
- assertEquals(filter.filterProperty("test2", new FilterContext("test2", map, true)), "test2");
- assertNull(filter.filterProperty("test.test3", new FilterContext("test.test3", map, true)));
- }
-
- @Test
- public void testSetFilters1() throws Exception {
- ProgrammableFilter filter = new ProgrammableFilter();
- RegexPropertyFilter regexFilter = new RegexPropertyFilter("test\\..*");
- Map<String,String> map = new HashMap<>();
- map.put("test1", "test1");
- map.put("test2", "test2");
- map.put("test.test3", "test.test3");
- assertEquals(filter.filterProperty("test1", new FilterContext("test1", map, true)), "test1");
- assertEquals(filter.filterProperty("test2", new FilterContext("test2", map, true)), "test2");
- assertEquals(filter.filterProperty("test.test3", new FilterContext("test.test3", map, true)), "test.test3");
- filter.setFilters(Arrays.asList(new PropertyFilter[]{regexFilter}));
- assertEquals(filter.filterProperty("test1", new FilterContext("test1", map, true)), "test1");
- assertEquals(filter.filterProperty("test2", new FilterContext("test2", map, true)), "test2");
- assertNull(filter.filterProperty("test.test3", new FilterContext("test.test3", map, true)));
- }
-
- @Test
- public void testGetFilters() throws Exception {
- ProgrammableFilter filter = new ProgrammableFilter();
- assertNotNull(filter.getFilters());
- assertTrue(filter.getFilters().isEmpty());
- RegexPropertyFilter regexFilter = new RegexPropertyFilter("test\\..*");
- filter.addFilter(regexFilter);
- assertNotNull(filter.getFilters());
- assertFalse(filter.getFilters().isEmpty());
- assertEquals(1, filter.getFilters().size());
- assertEquals(regexFilter, filter.getFilters().get(0));
- }
-
- @Test
- public void testToString() throws Exception {
- ProgrammableFilter filter = new ProgrammableFilter();
- assertFalse(filter.toString().contains("test\\..*"));
- assertTrue(filter.toString().contains("ProgrammableFilter"));
- assertFalse(filter.toString().contains("RegexPropertyFilter"));
- RegexPropertyFilter regexFilter = new RegexPropertyFilter("test\\..*");
- filter.addFilter(regexFilter);
- assertTrue(filter.toString().contains("test\\..*"));
- assertTrue(filter.toString().contains("ProgrammableFilter"));
- assertTrue(filter.toString().contains("RegexPropertyFilter"));
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/filter/src/test/java/org/apache/tamaya/filter/RegexPropertyFilterTest.java
----------------------------------------------------------------------
diff --git a/modules/filter/src/test/java/org/apache/tamaya/filter/RegexPropertyFilterTest.java b/modules/filter/src/test/java/org/apache/tamaya/filter/RegexPropertyFilterTest.java
deleted file mode 100644
index a560b04..0000000
--- a/modules/filter/src/test/java/org/apache/tamaya/filter/RegexPropertyFilterTest.java
+++ /dev/null
@@ -1,55 +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.filter;
-
-import org.apache.tamaya.spi.FilterContext;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.junit.Assert.*;
-
-/**
- * Tests for {@link RegexPropertyFilter}. Created by anatole on 11.02.16.
- */
-public class RegexPropertyFilterTest {
-
- @org.junit.Test
- public void testFilterProperty() throws Exception {
- RegexPropertyFilter filter = new RegexPropertyFilter("test\\..*");
- Map<String,String> map = new HashMap<>();
- map.put("test1", "test1");
- map.put("test2", "test2");
- map.put("test.test3", "test.test3");
- assertEquals(filter.filterProperty("test1", new FilterContext("test1", map, true)), "test1");
- assertEquals(filter.filterProperty("test2", new FilterContext("test2", map, true)), "test2");
- assertNull(filter.filterProperty("test.test3", new FilterContext("test.test3", map, true)));
- filter = new RegexPropertyFilter(".*");
- assertNull(filter.filterProperty("test1", new FilterContext("test1", map, true)));
- assertNull(filter.filterProperty("test2", new FilterContext("test2", map, true)));
- assertNull(filter.filterProperty("test.test3", new FilterContext("test.test3", map, true)));
- }
-
- @org.junit.Test
- public void testToString() throws Exception {
- RegexPropertyFilter filter = new RegexPropertyFilter("test\\..*");
- assertTrue(filter.toString().contains("test\\..*"));
- assertTrue(filter.toString().contains("RegexPropertyFilter"));
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/formats/pom.xml
----------------------------------------------------------------------
diff --git a/modules/formats/pom.xml b/modules/formats/pom.xml
deleted file mode 100644
index 3db73c9..0000000
--- a/modules/formats/pom.xml
+++ /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 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.
--->
-<project xmlns="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">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-extensions</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>tamaya-formats</artifactId>
- <name>Apache Tamaya Modules - Formats</name>
- <packaging>bundle</packaging>
-
- <properties>
- <jdkVersion>1.7</jdkVersion>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-api</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-resources</artifactId>
- <version>${project.version}</version>
- </dependency>
- <!-- Test scope only, do not create a code dependency! -->
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-core</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>java-hamcrest</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.tamaya.format,
- org.apache.tamaya.format.formats
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/formats/src/main/java/org/apache/tamaya/format/BaseFormatPropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/modules/formats/src/main/java/org/apache/tamaya/format/BaseFormatPropertySourceProvider.java b/modules/formats/src/main/java/org/apache/tamaya/format/BaseFormatPropertySourceProvider.java
deleted file mode 100644
index 84d6cfa..0000000
--- a/modules/formats/src/main/java/org/apache/tamaya/format/BaseFormatPropertySourceProvider.java
+++ /dev/null
@@ -1,154 +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.format;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertySourceProvider;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.List;
-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. The resource path are resolved as classpath resources. This can be changed by
- * overriding {@link #getPropertySources()}.
- * For each resource found the configuration formats passed get a chance to read the resource, if they succeed the
- * result is taken as the providers PropertySources to be exposed.
- */
-public abstract class BaseFormatPropertySourceProvider implements PropertySourceProvider {
- /**
- * The logger used.
- */
- private static final Logger LOG = Logger.getLogger(BaseFormatPropertySourceProvider.class.getName());
- /**
- * The config formats supported for the given location/resource paths.
- */
- private final List<ConfigurationFormat> configFormats = new ArrayList<>();
- /**
- * The paths to be evaluated.
- */
- private final Collection<URL> paths = new ArrayList<>();
-
- /**
- * Creates a new instance.
- *
- * @param formats the formats to be used, not null, not empty.
- * @param paths the paths to be resolved, not null, not empty.
- */
- public BaseFormatPropertySourceProvider(
- List<ConfigurationFormat> formats,
- URL... paths) {
- this.configFormats.addAll(Objects.requireNonNull(formats));
- this.paths.addAll(Arrays.asList(Objects.requireNonNull(paths)));
- }
-
- /**
- * Creates a new instance, hereby using the current thread context classloader, or if not available the classloader
- * that loaded this class.
- * @param formats the formats to be used, not null, not empty.
- * @param paths the paths to be resolved, not null, not empty.
- */
- public BaseFormatPropertySourceProvider(
- List<ConfigurationFormat> formats, String... paths) {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- if(cl==null){
- cl = getClass().getClassLoader();
- }
- this.configFormats.addAll(Objects.requireNonNull(formats));
- for(String path:paths) {
- Enumeration<URL> urls;
- try {
- urls = cl.getResources(path);
- } catch (IOException e) {
- LOG.log(Level.WARNING, "Failed to read resource: " + path, e);
- continue;
- }
- while(urls.hasMoreElements()) {
- this.paths.add(urls.nextElement());
- }
- }
- }
-
- /**
- * Creates a new instance.
- *
- * @param classLoader the ClassLoader to be used, not null, not empty.
- * @param formats the formats to be used, not null, not empty.
- * @param paths the paths to be resolved, not null, not empty.
- */
- public BaseFormatPropertySourceProvider(
- List<ConfigurationFormat> formats,
- ClassLoader classLoader, String... paths) {
- this.configFormats.addAll(Objects.requireNonNull(formats));
- for(String path:paths) {
- Enumeration<URL> urls;
- try {
- urls = classLoader.getResources(path);
- } catch (IOException e) {
- LOG.log(Level.WARNING, "Failed to read resource: " + path, e);
- continue;
- }
- while(urls.hasMoreElements()) {
- this.paths.add(urls.nextElement());
- }
- }
- }
-
-
- /**
- * Method to create a {@link org.apache.tamaya.spi.PropertySource} based on the given entries read.
- *
- * @param data the configuration data, not null.
- * @return the {@link org.apache.tamaya.spi.PropertySource} instance ready to be registered.
- */
- protected abstract Collection<PropertySource> getPropertySources(ConfigurationData data);
-
- /**
- * This method does dynamically resolve the paths using the current ClassLoader set. If no ClassLoader was
- * explcitly set during creation the current Thread context ClassLoader is used. If none of the supported
- * formats is able to parse a resource a WARNING log is written.
- *
- * @return the PropertySources successfully read
- */
- @Override
- public Collection<PropertySource> getPropertySources() {
- List<PropertySource> propertySources = new ArrayList<>();
- for (URL res : this.paths) {
- try(InputStream is = res.openStream()) {
- for (ConfigurationFormat format : configFormats) {
- ConfigurationData data = format.readConfiguration(res.toString(), is);
- propertySources.addAll(getPropertySources(data));
- }
- } catch (Exception e) {
- LOG.log(Level.WARNING, "Failed to put resource based config: " + res, e);
- }
- }
- return propertySources;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/formats/src/main/java/org/apache/tamaya/format/ConfigurationData.java
----------------------------------------------------------------------
diff --git a/modules/formats/src/main/java/org/apache/tamaya/format/ConfigurationData.java b/modules/formats/src/main/java/org/apache/tamaya/format/ConfigurationData.java
deleted file mode 100644
index b58d2ab..0000000
--- a/modules/formats/src/main/java/org/apache/tamaya/format/ConfigurationData.java
+++ /dev/null
@@ -1,206 +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.format;
-
-import java.util.*;
-
-/**
- * <p>Data that abstracts the data read from a configuration resources using a certain format. The data can be divided
- * into different sections, similar to ini-files. Herebey different sections the best map to entries with different
- * priorities to be applied, when integrated into PropertySource instances.</p>
- * New instances of this class can be created using a {@link org.apache.tamaya.format.ConfigurationDataBuilder}.
- * <h3>Implementation Specification</h3>
- * This class is
- * <ul>
- * <li>immutable</li>
- * <li>thread-safe</li>
- * </ul>
- */
-public final class ConfigurationData {
- /**
- * The properties of the default section (no name).
- */
- private Map<String, String> defaultProperties;
- /**
- * A normalized flattened set of this configuration data.
- */
- private Map<String, String> combinedProperties;
- /**
- * The sections read.
- */
- private Map<String, Map<String, String>> namedSections;
- /** The format instance used to read this instance. */
- private final ConfigurationFormat format;
- /** The resource read. */
- private final String resource;
-
-
- /**
- * COnstructor used by builder.
- * @param builder the builder instance passing the read configuration data.
- */
- ConfigurationData(ConfigurationDataBuilder builder){
- this.format = builder.format;
- this.resource = builder.resource;
- if (builder.defaultProperties != null) {
- this.defaultProperties = new HashMap<>();
- this.defaultProperties.putAll(builder.defaultProperties);
- }
- if (builder.combinedProperties != null) {
- this.combinedProperties = new HashMap<>();
- this.combinedProperties.putAll(builder.combinedProperties);
- }
- if (builder.namedSections != null) {
- this.namedSections = new HashMap<>();
- this.namedSections.putAll(builder.namedSections);
- }
- if (this.combinedProperties == null || this.combinedProperties.isEmpty()) {
- this.combinedProperties = new HashMap<>();
- this.combinedProperties.putAll(getDefaultProperties());
- // popuilate it with sections...
- for (String sectionName : getSectionNames()) {
- Map<String, String> section = getSection(sectionName);
- for (Map.Entry<String, String> en : section.entrySet()) {
- String key = sectionName + '.' + en.getKey();
- combinedProperties.put(key, en.getValue());
- }
- }
- }
- }
-
- /**
- * Get the {@link org.apache.tamaya.format.ConfigurationFormat} that read this data.
- * @return the {@link org.apache.tamaya.format.ConfigurationFormat} that read this data, never null.
- */
- public ConfigurationFormat getFormat(){
- return format;
- }
-
- /**
- * Get the resource from which this data was read.
- * @return the resource from which this data was read, never null.
- */
- public String getResource(){
- return resource;
- }
-
- /**
- * Access an immutable Set of all present section names, including the default section (if any).
- * @return the set of present section names, never null.
- */
- public Set<String> getSectionNames() {
- if (namedSections == null) {
- return Collections.emptySet();
- }
- return namedSections.keySet();
- }
-
- /**
- * Get a section's data.
- * @param name the section name, not null.
- * @return the data of this section, or null, if no such section exists.
- */
- public Map<String, String> getSection(String name) {
- return this.namedSections.get(name);
- }
-
- /**
- * Convenience accessor for accessing the default section.
- * @return the default section's data, or null, if no such section exists.
- */
- public Map<String, String> getDefaultProperties() {
- if (defaultProperties == null) {
- return Collections.emptyMap();
- }
- return defaultProperties;
- }
-
- /**
- * Get combined properties for this config data instance. If
- *
- * @return the normalized properties.
- */
- public Map<String, String> getCombinedProperties() {
- if (combinedProperties == null) {
- return Collections.emptyMap();
- }
- return combinedProperties;
- }
-
- /**
- * Accessor used for easily creating a new builder based on a given data instance.
- *
- * @return the data contained, never null.
- */
- public Map<String, Map<String, String>> getSections() {
- if (namedSections == null) {
- return Collections.emptyMap();
- }
- return namedSections;
- }
-
- /**
- * Immutable accessor to ckeck, if there are default properties present.
- *
- * @return true, if default properties are present.
- */
- public boolean hasDefaultProperties() {
- return this.defaultProperties != null && !this.defaultProperties.isEmpty();
- }
-
- /**
- * Immutable accessor to ckeck, if there are combined properties set.
- *
- * @return true, if combined properties are set.
- */
- public boolean hasCombinedProperties() {
- return this.combinedProperties != null && !this.combinedProperties.isEmpty();
- }
-
- /**
- * Immutable accessor to ckeck, if there are named sections present.
- *
- * @return true, if at least one named section is present.
- */
- private boolean hasSections() {
- return this.namedSections != null && !this.namedSections.isEmpty();
- }
-
- /**
- * Checks if no properties are contained in this data item.
- *
- * @return true, if no properties are contained in this data item.
- */
- public boolean isEmpty() {
- return !hasCombinedProperties() && !hasDefaultProperties() && !hasSections();
- }
-
- @Override
- public String toString() {
- return "ConfigurationData{" +
- "format=" + format +
- ", default properties=" + defaultProperties +
- ", combined properties=" + combinedProperties +
- ", sections=" + namedSections +
- ", resource=" + resource +
- '}';
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/formats/src/main/java/org/apache/tamaya/format/ConfigurationDataBuilder.java
----------------------------------------------------------------------
diff --git a/modules/formats/src/main/java/org/apache/tamaya/format/ConfigurationDataBuilder.java b/modules/formats/src/main/java/org/apache/tamaya/format/ConfigurationDataBuilder.java
deleted file mode 100644
index da5fa35..0000000
--- a/modules/formats/src/main/java/org/apache/tamaya/format/ConfigurationDataBuilder.java
+++ /dev/null
@@ -1,219 +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.format;
-
-import java.util.*;
-
-
-/**
- * Builder for creating {@link org.apache.tamaya.format.ConfigurationData} instances. This class is not thread-safe.
- */
-public final class ConfigurationDataBuilder {
-
- /** The format instance used to read this instance. */
- final ConfigurationFormat format;
- /** The resource read. */
- final String resource;
- /**
- * The properties of the default section (no name).
- */
- Map<String, String> defaultProperties;
- /**
- * A normalized flattened set of this configuration data.
- */
- Map<String, String> combinedProperties;
- /**
- * The sections read.
- */
- Map<String, Map<String, String>> namedSections;
-
- /**
- * Private constructor.
- * @param resource the configuration resource URL, not null.
- * @param format the format that read this data, not null.
- */
- private ConfigurationDataBuilder(String resource, ConfigurationFormat format){
- this.format = Objects.requireNonNull(format);
- this.resource = Objects.requireNonNull(resource);
- }
-
- /**
- * Creates a new instance.
- * @param resource the configuration resource URL, not null.
- * @param format the format that read this data, not null.
- * @return new instance of this class.
- */
- public static ConfigurationDataBuilder of(String resource, ConfigurationFormat format){
- return new ConfigurationDataBuilder(resource, format);
- }
-
- /**
- * Creates a new instance.
- * @param data an existing ConfigurationData instances used to initialize the builder.
- * @return new instance of this class from the given configuration.
- */
- public static ConfigurationDataBuilder of(ConfigurationData data){
- ConfigurationDataBuilder b = new ConfigurationDataBuilder(data.getResource(), data.getFormat());
- if (data.hasDefaultProperties()) {
- b.getDefaultProperties().putAll(data.getDefaultProperties());
- }
- if (data.hasCombinedProperties()) {
- b.getCombinedProperties().putAll(data.getCombinedProperties());
- }
- if (!data.getSections().isEmpty()) {
- b.getSections().putAll(data.getSections());
- }
- return b;
- }
-
- /**
- * Adds (empty) sections,if they are not yet existing. Already existing sections will not be touched.
- * @param sections the new sections to put.
- * @return the builder for chaining.
- */
- public ConfigurationDataBuilder addSections(String... sections){
- for (String section : sections) {
- if (!getSections().containsKey(section)) {
- getSections().put(section, new HashMap<String, String>());
- }
- }
- return this;
- }
-
- /**
- * Adds a single entry to a target section.
- * @param section the target section (will be created if not existing).
- * @param key the entry's key
- * @param value the entry's value
- * @return the builder for chaining.
- */
- public ConfigurationDataBuilder addSectionProperty(String section, String key, String value) {
- Map<String, String> map = getSections().get(section);
- if (map == null) {
- map = new HashMap<>();
- getSections().put(section, map);
- }
- map.put(key, value);
- return this;
- }
-
- /**
- * Adds a single entry to the <i>default</i> section.
- * @param key the entry's key
- * @param value the entry's value
- * @return the builder for chaining.
- */
- public ConfigurationDataBuilder addProperty(String key, String value) {
- getDefaultProperties().put(key, value);
- return this;
- }
-
- /**
- * Adds the given entries to the given section, all existing values will be overridden.
- * @param section the target section (will be created if not existing).
- * @param properties the entry's data
- * @return the builder for chaining.
- */
- public ConfigurationDataBuilder addSectionProperties(String section, Map<String, String> properties) {
- Map<String, String> map = getSections().get(section);
- if (map == null) {
- map = new HashMap<>();
- getSections().put(section, map);
- }
- map.putAll(properties);
- return this;
- }
-
- /**
- * Adds the given entries to the <i>default</i> section, all existing values will be overridden.
- * @param properties the entry's data
- * @return the builder for chaining.
- */
- public ConfigurationDataBuilder addProperties(Map<String, String> properties) {
- getDefaultProperties().putAll(properties);
- return this;
- }
-
- /**
- * Sets the given entries as the <i>combined</i> properties map, all existing properties of the
- * combined map will be overridden.
- *
- * @param properties the entry's data
- * @return the builder for chaining.
- */
- public ConfigurationDataBuilder setCombinedProperties(Map<String, String> properties) {
- this.combinedProperties = new HashMap<>(properties);
- return this;
- }
-
- /**
- * Access the current default section, if not present a new instance is initialized.
- *
- * @return the current default section, never null.
- */
- public Map<String, String> getDefaultProperties() {
- if (defaultProperties == null) {
- defaultProperties = new HashMap<>();
- }
- return defaultProperties;
- }
-
- /**
- * Access the current combined properties, if not present a new instance is initialized.
- *
- * @return the current combined properties, never null.
- */
- public Map<String, String> getCombinedProperties() {
- if (combinedProperties == null) {
- combinedProperties = new HashMap<>();
- }
- return combinedProperties;
- }
-
- /**
- * Access the current named sections, if not present a new instance is initialized.
- *
- * @return the current named sections, never null.
- */
- public Map<String, Map<String, String>> getSections() {
- if (namedSections == null) {
- namedSections = new HashMap<>();
- }
- return namedSections;
- }
-
- /**
- * Builds a new {@link org.apache.tamaya.format.ConfigurationData} instance.
- * @return a new {@link org.apache.tamaya.format.ConfigurationData} instance, not null.
- */
- public ConfigurationData build(){
- return new ConfigurationData(this);
- }
-
- @Override
- public String toString() {
- return "ConfigurationDataBuilder{" +
- "format=" + format +
- ", default properties=" + defaultProperties +
- ", sections=" + namedSections +
- ", combined properties=" + combinedProperties +
- ", resource=" + resource +
- '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/formats/src/main/java/org/apache/tamaya/format/ConfigurationFormat.java
----------------------------------------------------------------------
diff --git a/modules/formats/src/main/java/org/apache/tamaya/format/ConfigurationFormat.java b/modules/formats/src/main/java/org/apache/tamaya/format/ConfigurationFormat.java
deleted file mode 100644
index 997ef3a..0000000
--- a/modules/formats/src/main/java/org/apache/tamaya/format/ConfigurationFormat.java
+++ /dev/null
@@ -1,103 +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.format;
-
-import java.io.InputStream;
-import java.net.URL;
-
-/**
- * <p>Implementations current this class encapsulate the mechanism how to read a
- * resource including interpreting the format correctly (e.g. xml vs.
- * properties vs. ini). In most cases file only contains entries of the same priority, which would then
- * result in only one {@link org.apache.tamaya.spi.PropertySource}. Complex file formats, however, may contain entries
- * of different priorities. In this cases, each ordinal type found typically is returned as a separate section so the
- * consuming {@link org.apache.tamaya.spi.PropertySourceProvider} implementation can distribute the different part to
- * individual {@link org.apache.tamaya.spi.PropertySource}s.</p>
- *
- * <h3>Implementation Requirements</h3>
- * Implementations of this type must be
- * <ul>
- * <li>thread-safe</li>
- * </ul>
- */
-public interface ConfigurationFormat {
-
- /**
- * Get a unique name of the format. This name can be used to access the format.
- * @return the (unique) format's name, never null and not empty.
- */
- String getName();
-
- /**
- * Allows the format to examine the given resource, e.g. for a matching file ending. Only, if a format accepts an
- * URL, it will be tried for reading the configuration.
- * @param url the url to read the configuration data from (could be a file, a server location, a classpath
- * resource or something else, not null.
- * @return true, if this format accepts the given URL for reading.
- */
- boolean accepts(URL url);
-
- /**
- * Reads a configuration from an URL, hereby parsing the given {@link java.io.InputStream}. Dependening on
- * the capabilities of the format the returned {@link org.apache.tamaya.format.ConfigurationData} may contain
- * different levels of data:
- * <ul>
- * <li>Only a <i>default</i> section is returned, since the configuration format does not support
- * hierarchies. This is the case for properties and xml properties.</li>
- * <li>Hierarchical formats such as INI, XML and JSON can map each node to a section. Each section
- * can have its own key/value pairs. This allows to map also complex formats in a generic way. A
- * format implementation should then additionally flatten the whole data and store it in a accessible as
- * {@link ConfigurationData#getCombinedProperties()}. This allows to use the properties as inout to a default mapping,
- * which is always appropriate as long as no other semnatics
- * are defined in the concrete target scenario.</li>
- * <li>More complex custom scenarios should map their configuration data read into different
- * sections. Typically the data will be mapped into different {@link org.apache.tamaya.spi.PropertySource}
- * instances with different ordinal levels. As an example imagine a custom format that contains sections
- * 'defaults', 'global-defaults', 'application', 'server-overrides'.</li>
- * <li>Alternate formats</li>
- * </ul>
- *
- * Summarizing implementations common formats should always provide
- * <ul>
- * <li>the data organized in sections as useful for the given format. If data is organized in one section, it
- * should be mapped into the DEFAULT section.</li>
- * <li>Formats that do provide multiple sections, should always provide a FLATTENED section as well, where
- * all the data is organized as a flattened key/value pairs, enabling a generic mapping to a
- * {@link org.apache.tamaya.spi.PropertySource}.</li>
- * </ul>
- *
- * If the configuration format only contains entries of one ordinal type, normally only one single
- * instance of PropertySource is returned (the corresponding key/values should end up in the DEFAULT section).
- * Nevertheless custom formats may contain different sections or parts,
- * where each part maps to a different target ordinal (eg defaults, domain config and app config). In the
- * ladder case multiple PropertySources can be returned, each one with its own ordinal and the corresponding
- * entries.
- * @see org.apache.tamaya.spi.PropertySource
- * @param resource a descriptive name for the resource, since an InputStream does not have any)
- * @param inputStream the inputStream to read the configuration data from (could be a file, a server location, a classpath
- * resource or something else.
- * @return the corresponding {@link ConfigurationData} containing sections/properties read, never {@code null}.
- * @throws org.apache.tamaya.ConfigException if parsing of the input fails.
- */
- ConfigurationData readConfiguration(String resource, InputStream inputStream);
-
- //X TODO Add support to access a default format to see a correct formatting
- //X String getFormatExample();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/formats/src/main/java/org/apache/tamaya/format/ConfigurationFormats.java
----------------------------------------------------------------------
diff --git a/modules/formats/src/main/java/org/apache/tamaya/format/ConfigurationFormats.java b/modules/formats/src/main/java/org/apache/tamaya/format/ConfigurationFormats.java
deleted file mode 100644
index bc8aabd..0000000
--- a/modules/formats/src/main/java/org/apache/tamaya/format/ConfigurationFormats.java
+++ /dev/null
@@ -1,187 +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.format;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Objects;
-import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.apache.tamaya.spi.ServiceContextManager;
-
-/**
- * Small accessor and management class dealing with {@link org.apache.tamaya.format.ConfigurationFormat}
- * instances.
- */
-public final class ConfigurationFormats {
- /**
- * The logger used.
- */
- private static final Logger LOG = Logger.getLogger(ConfigurationFormats.class.getName());
-
- /**
- * Singleton constructor.
- */
- private ConfigurationFormats() {
- }
-
- /**
- * Get all currently available formats, ordered by priority.
- *
- * @return the currently available formats, never null.
- */
- public static List<ConfigurationFormat> getFormats() {
- return ServiceContextManager.getServiceContext().getServices(ConfigurationFormat.class);
- }
-
- /**
- * Get all currently available formats, ordered by priority.
- *
- * @param formatNames available formats to be ordered.
- * @return the currently available formats, never null.
- */
- public static List<ConfigurationFormat> getFormats(String... formatNames) {
- final List<ConfigurationFormat> result = new ArrayList<>();
- final Set<String> names = new HashSet<>(Arrays.asList(formatNames));
- for (final ConfigurationFormat f : getFormats()) {
- if (names.contains(f.getName())) {
- result.add(f);
- }
- }
- return result;
- }
-
- // Activate for JDK 8...
-// /**
-// * Get all currently available formats, ordered by priority.
-// *
-// * @return the currently available formats, never null.
-// */
-// public static List<ConfigurationFormat> getFormats(Predicate<String> namePredicate) {
-// List<ConfigurationFormat> result = new ArrayList<>();
-// for(ConfigurationFormat f:getFormats()){
-// if(namePredicate.test(f.getName()){
-// result.add(f);
-// }
-// }
-// return result;
-// }
-
- /**
- * Get all currently available formats, ordered by priority.
- *
- * @param url source to read configuration from.
- * @return the currently available formats, never null.
- */
- public static List<ConfigurationFormat> getFormats(final URL url) {
- final List<ConfigurationFormat> formats = getFormats();
- final List<ConfigurationFormat> result = new ArrayList<>();
- for (final ConfigurationFormat f : formats) {
- if (f.accepts(url)) {
- result.add(f);
- }
- }
- return result;
- }
-
- /**
- * Tries to read configuration data from a given URL, hereby traversing all known formats in order of precedence.
- * Hereby the formats are first filtered to check if the URL is acceptable, before the input is being parsed.
- *
- * @param url the url from where to read, not null.
- * @return the ConfigurationData read, or null.
- * @throws IOException if the resource cannot be read.
- */
- public static ConfigurationData readConfigurationData(final URL url) throws IOException {
- final List<ConfigurationFormat> formats = getFormats(url);
- return readConfigurationData(url, formats.toArray(new ConfigurationFormat[formats.size()]));
- }
-
- /**
- * Tries to read configuration data from a given URL, hereby explicitly trying all given formats in order.
- *
- * @param url the url from where to read, not null.
- * @param formats the formats to try.
- * @return the ConfigurationData read, or null.
- * @throws IOException if the resource cannot be read.
- */
- public static ConfigurationData readConfigurationData(URL url, ConfigurationFormat... formats) throws IOException {
- return readConfigurationData(url.toString(), url.openStream(), formats);
- }
-
- /**
- * @param urls the urls from where to read, not null.
- * @param formats the formats to try.
- * @return the {@link org.apache.tamaya.format.ConfigurationData} of the files successfully decoded by the
- * given formats.
- */
- public static Collection<ConfigurationData> getPropertySources(Collection<URL> urls, ConfigurationFormat... formats) {
- final List<ConfigurationData> dataRead = new ArrayList<>();
- for (final URL url : urls) {
- try {
- final ConfigurationData data = readConfigurationData(url, formats);
- if (data != null) {
- dataRead.add(data);
- }
- } catch (final Exception e) {
- LOG.log(Level.SEVERE, "Error reading file: " + url.toExternalForm(), e);
- }
- }
- return dataRead;
- }
-
- /**
- * Tries to read configuration data from a given URL, hereby explicitly trying all given formats in order.
- *
- * @param resource a descriptive name for the resource, since an InputStream does not have any
- * @param inputStream the inputStream from where to read, not null.
- * @param formats the formats to try.
- * @return the ConfigurationData read, or null.
- * @throws IOException if the resource cannot be read.
- */
- public static ConfigurationData readConfigurationData(String resource, InputStream inputStream,
- ConfigurationFormat... formats) throws IOException {
- Objects.requireNonNull(inputStream);
- Objects.requireNonNull(resource);
- try(InputStreamFactory isFactory = new InputStreamFactory(inputStream)) {
- for (final ConfigurationFormat format : formats) {
- try (InputStream is = isFactory.createInputStream()) {
- final ConfigurationData data = format.readConfiguration(resource, is);
- if (data != null) {
- return data;
- }
- } catch (final Exception e) {
- LOG.log(Level.INFO,
- "Format " + format.getClass().getName() + " failed to read resource " + resource, e);
- }
- }
- }
- return null;
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/formats/src/main/java/org/apache/tamaya/format/FlattenedDefaultPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/formats/src/main/java/org/apache/tamaya/format/FlattenedDefaultPropertySource.java b/modules/formats/src/main/java/org/apache/tamaya/format/FlattenedDefaultPropertySource.java
deleted file mode 100644
index 9d2097f..0000000
--- a/modules/formats/src/main/java/org/apache/tamaya/format/FlattenedDefaultPropertySource.java
+++ /dev/null
@@ -1,118 +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.format;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Flattened default PropertySource that uses the flattened config data read from an URL by a
- * ${@link org.apache.tamaya.format.ConfigurationFormat}.
- */
-public class FlattenedDefaultPropertySource implements PropertySource {
- private static final Logger LOG = Logger.getLogger(FlattenedDefaultPropertySource.class.getName());
- private final Map<String, String> properties;
- private final ConfigurationData data;
- private int defaultOrdinal = 0;
-
-
- /*
- * Constructor, uses hereby the flattened config data read from an URL by a
- * ${@link org.apache.tamaya.format.ConfigurationFormat}, and if not present falls back to the default section.
- */
- public FlattenedDefaultPropertySource(ConfigurationData data) {
- this.properties = populateData(data);
- this.data = data;
- }
-
- /*
- * Constructor, uses hereby the flattened config data read from an URL by a
- * ${@link org.apache.tamaya.format.ConfigurationFormat}, and if not present falls back to the default section.
- */
- public FlattenedDefaultPropertySource(int defaultOrdinal, ConfigurationData data) {
- this.properties = populateData(data);
- this.data = data;
- this.defaultOrdinal = defaultOrdinal;
- }
-
- protected Map<String, String> populateData(ConfigurationData data) {
- Map<String, String> result = data.getCombinedProperties();
- if (result.isEmpty()) {
- result = data.getDefaultProperties();
- }
- if (result.isEmpty()) {
- result = new HashMap<>();
- }
- if(result.isEmpty()){
- for (String section : data.getSectionNames()) {
- Map<String,String> sectionMap = data.getSection(section);
- for(Map.Entry<String,String> en: sectionMap.entrySet()){
- result.put(section + '.' + en.getKey(), en.getValue());
- }
- }
- }
- return Collections.unmodifiableMap(result);
- }
-
- @Override
- public String getName() {
- String name = this.properties.get("[meta].name");
- if (name == null) {
- name = this.data.getResource();
- }
- if (name == null) {
- name = getClass().getSimpleName();
- }
- return name;
- }
-
- @Override
- public int getOrdinal() {
- String ordinalValue = this.properties.get(PropertySource.TAMAYA_ORDINAL);
- if (ordinalValue != null) {
- try {
- return Integer.parseInt(ordinalValue.trim());
- } catch (Exception e) {
- LOG.log(Level.WARNING, "Failed to parse Tamaya ordinal from " + data.getResource(), e);
- }
- }
- return defaultOrdinal;
- }
-
- @Override
- public PropertyValue get(String key) {
- return PropertyValue.of(key, properties.get(key), getName());
- }
-
- @Override
- public Map<String, String> getProperties() {
- return properties;
- }
-
- @Override
- public boolean isScannable() {
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/formats/src/main/java/org/apache/tamaya/format/InputStreamFactory.java
----------------------------------------------------------------------
diff --git a/modules/formats/src/main/java/org/apache/tamaya/format/InputStreamFactory.java b/modules/formats/src/main/java/org/apache/tamaya/format/InputStreamFactory.java
deleted file mode 100644
index 912dd08..0000000
--- a/modules/formats/src/main/java/org/apache/tamaya/format/InputStreamFactory.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.format;
-
-import java.io.*;
-import java.util.Objects;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Wrapper for a given {@link InputStream} to be able to close
- * it via the try-with-resources construct of Java 7.
- *
- * <h1>Usage example</h1>
- *
- * <pre>
- * public void readIt(InputStream inputStream) {
- * try (InputStream is = new ParallelInputStream(inputStream) {
- * // Consume the stream
- * }
- * }
- * </pre>
- */
-public class InputStreamFactory implements Closeable {
- private static final Logger LOG = Logger.getLogger(InputStreamFactory.class.getName());
-
- private byte[] data;
-
- /**
- * Creates a new InputStreamFactory.
- *
- * @param original the InputStream to be read for extract its data into memory.
- * @throws IOException if thrown by the original during read.
- */
- public InputStreamFactory(InputStream original) throws IOException {
- Objects.requireNonNull(original);
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- byte[] bytes = new byte[256];
- try {
- int read = original.read(bytes);
- while (read > 0) {
- bos.write(bytes, 0, read);
- read = original.read(bytes);
- }
- this.data = bos.toByteArray();
- } finally {
- try {
- original.close();
- } catch (IOException e) {
- LOG.log(Level.FINEST, "Error closing stream: " + original, e);
- }
- }
- }
-
- /**
- * Creates a new InputStream with the same data as provided by the InputStream passed on factory creation.
- *
- * @return a new InputStream , never null.
- * @throws IOException if no data is available.
- */
- public InputStream createInputStream() throws IOException {
- byte[] bytes = this.data;
- if (bytes == null) {
- throw new IOException("InputStreamFactory is closed.");
- }
- return new ByteArrayInputStream(bytes);
- }
-
- @Override
- public void close() throws IOException {
- this.data = null;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/formats/src/main/java/org/apache/tamaya/format/formats/IniConfigurationFormat.java
----------------------------------------------------------------------
diff --git a/modules/formats/src/main/java/org/apache/tamaya/format/formats/IniConfigurationFormat.java b/modules/formats/src/main/java/org/apache/tamaya/format/formats/IniConfigurationFormat.java
deleted file mode 100644
index fe27ba7..0000000
--- a/modules/formats/src/main/java/org/apache/tamaya/format/formats/IniConfigurationFormat.java
+++ /dev/null
@@ -1,95 +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.format.formats;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.format.ConfigurationData;
-import org.apache.tamaya.format.ConfigurationDataBuilder;
-import org.apache.tamaya.format.ConfigurationFormat;
-
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Implements a ini file format.
- */
-public class IniConfigurationFormat implements ConfigurationFormat {
-
- /**
- * The logger.
- */
- private final static Logger LOG = Logger.getLogger(IniConfigurationFormat.class.getName());
-
- @Override
- public String getName() {
- return "ini";
- }
-
- @Override
- public boolean accepts(URL url) {
- String fileName = url.getFile();
- return fileName.endsWith(".ini") || fileName.endsWith(".INI");
- }
-
- @Override
- public ConfigurationData readConfiguration(String resource, InputStream inputStream) {
- ConfigurationDataBuilder builder = ConfigurationDataBuilder.of(resource, this);
- try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"))) {
- String line = reader.readLine();
- int lineNum = 0;
- String section = null;
- while (line != null) {
- lineNum++;
- line = line.trim();
- if (line.isEmpty()) {
- line = reader.readLine();
- continue;
- }
- if (line.startsWith("[")) {
- int end = line.indexOf(']');
- if (end < 0) {
- throw new ConfigException(
- "Invalid INI-Format, ']' expected, at " + lineNum + " in " + resource);
- }
- section = line.substring(1, end);
- } else if (line.trim().startsWith("#")) {
- // comment
- } else {
- int sep = line.indexOf('=');
- String key = line.substring(0, sep);
- String value = line.substring(sep + 1);
- if (section != null) {
- builder.addSectionProperty(section, key, value);
- } else {
- builder.addProperty(key, value);
- }
- }
- line = reader.readLine();
- }
- return builder.build();
- } catch (Exception e) {
- LOG.log(Level.SEVERE, "Could not read configuration: " + resource, e);
- }
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/formats/src/main/java/org/apache/tamaya/format/formats/PropertiesFormat.java
----------------------------------------------------------------------
diff --git a/modules/formats/src/main/java/org/apache/tamaya/format/formats/PropertiesFormat.java b/modules/formats/src/main/java/org/apache/tamaya/format/formats/PropertiesFormat.java
deleted file mode 100644
index 35cef77..0000000
--- a/modules/formats/src/main/java/org/apache/tamaya/format/formats/PropertiesFormat.java
+++ /dev/null
@@ -1,71 +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.format.formats;
-
-import org.apache.tamaya.format.ConfigurationData;
-import org.apache.tamaya.format.ConfigurationDataBuilder;
-import org.apache.tamaya.format.ConfigurationFormat;
-
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Properties;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Implementation of a {@link org.apache.tamaya.format.ConfigurationFormat} for -properties files.
- *
- * @see java.util.Properties#load(java.io.InputStream)
- */
-public class PropertiesFormat implements ConfigurationFormat {
- /**
- * The logger.
- */
- private final static Logger LOG = Logger.getLogger(PropertiesFormat.class.getName());
-
-
- @Override
- public String getName() {
- return "properties";
- }
-
- @Override
- public boolean accepts(URL url) {
- String fileName = url.getFile();
- return fileName.endsWith(".properties") || fileName.endsWith(".PROPERTIES") ||
- fileName.endsWith(".conf") || fileName.endsWith(".CONF");
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public ConfigurationData readConfiguration(String resource, InputStream inputStream) {
- Objects.requireNonNull(inputStream);
- Objects.requireNonNull(resource);
- try {
- final Properties p = new Properties();
- p.load(inputStream);
- return ConfigurationDataBuilder.of(resource, this).addProperties(Map.class.cast(p)).build();
- } catch (Exception e) {
- LOG.log(Level.FINEST, "Failed to read config from resource: " + resource, e);
- }
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/formats/src/main/java/org/apache/tamaya/format/formats/PropertiesXmlFormat.java
----------------------------------------------------------------------
diff --git a/modules/formats/src/main/java/org/apache/tamaya/format/formats/PropertiesXmlFormat.java b/modules/formats/src/main/java/org/apache/tamaya/format/formats/PropertiesXmlFormat.java
deleted file mode 100644
index c47b6f6..0000000
--- a/modules/formats/src/main/java/org/apache/tamaya/format/formats/PropertiesXmlFormat.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.format.formats;
-
-import org.apache.tamaya.format.ConfigurationData;
-import org.apache.tamaya.format.ConfigurationDataBuilder;
-import org.apache.tamaya.format.ConfigurationFormat;
-
-import java.io.InputStream;
-import java.net.URL;
-import java.util.*;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Implementation of a {@link org.apache.tamaya.format.ConfigurationFormat} for xml property
- * files.
- *
- * @see java.util.Properties#loadFromXML(java.io.InputStream)
- */
-public class PropertiesXmlFormat implements ConfigurationFormat {
- /**
- * The logger.
- */
- private final static Logger LOG = Logger.getLogger(PropertiesXmlFormat.class.getName());
-
- @Override
- public String getName() {
- return "xml-properties";
- }
-
- @Override
- public boolean accepts(URL url) {
- String fileName = url.getFile();
- return fileName.endsWith(".xml") || fileName.endsWith(".XML");
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public ConfigurationData readConfiguration(String resource, InputStream inputStream) {
- Objects.requireNonNull(inputStream);
- Objects.requireNonNull(resource);
-
- try {
- final Properties p = new Properties();
- p.loadFromXML(inputStream);
- return ConfigurationDataBuilder.of(resource, this).addProperties(Map.class.cast(p)).build();
- } catch (Exception e) {
- LOG.log(Level.FINEST, "Failed to read config from resource: " + resource, e);
- }
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/formats/src/main/java/org/apache/tamaya/format/formats/package-info.java
----------------------------------------------------------------------
diff --git a/modules/formats/src/main/java/org/apache/tamaya/format/formats/package-info.java b/modules/formats/src/main/java/org/apache/tamaya/format/formats/package-info.java
deleted file mode 100644
index db8987d..0000000
--- a/modules/formats/src/main/java/org/apache/tamaya/format/formats/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-/**
- * This package provides implementtion of {@link org.apache.tamaya.format.ConfigurationFormat}
- * for properties, xml-properties and ini files.
- */
-package org.apache.tamaya.format.formats;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/formats/src/main/java/org/apache/tamaya/format/package-info.java
----------------------------------------------------------------------
diff --git a/modules/formats/src/main/java/org/apache/tamaya/format/package-info.java b/modules/formats/src/main/java/org/apache/tamaya/format/package-info.java
deleted file mode 100644
index 39b5f0b..0000000
--- a/modules/formats/src/main/java/org/apache/tamaya/format/package-info.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-/**
- * This package provides an abstraction for parsing a configuration
- * from an input strem, called {@link org.apache.tamaya.format.ConfigurationFormat}
- * and corresponding helper artifacts.
- *
- * @see org.apache.tamaya.format.ConfigurationFormat
- * @see org.apache.tamaya.format.ConfigurationData
- * @see org.apache.tamaya.format.ConfigurationFormats
- */
-package org.apache.tamaya.format;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/formats/src/main/resources/META-INF/services/org.apache.tamaya.format.ConfigurationFormat
----------------------------------------------------------------------
diff --git a/modules/formats/src/main/resources/META-INF/services/org.apache.tamaya.format.ConfigurationFormat b/modules/formats/src/main/resources/META-INF/services/org.apache.tamaya.format.ConfigurationFormat
deleted file mode 100644
index 96e898f..0000000
--- a/modules/formats/src/main/resources/META-INF/services/org.apache.tamaya.format.ConfigurationFormat
+++ /dev/null
@@ -1,21 +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.format.formats.IniConfigurationFormat
-org.apache.tamaya.format.formats.PropertiesFormat
-org.apache.tamaya.format.formats.PropertiesXmlFormat
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/formats/src/test/java/org/apache/tamaya/format/ConfigurationFormatsTest.java
----------------------------------------------------------------------
diff --git a/modules/formats/src/test/java/org/apache/tamaya/format/ConfigurationFormatsTest.java b/modules/formats/src/test/java/org/apache/tamaya/format/ConfigurationFormatsTest.java
deleted file mode 100644
index 0839714..0000000
--- a/modules/formats/src/test/java/org/apache/tamaya/format/ConfigurationFormatsTest.java
+++ /dev/null
@@ -1,68 +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.format;
-
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-/**
- * Tests for {@link org.apache.tamaya.format.ConfigurationFormats}.
- */
-public class ConfigurationFormatsTest {
-
- @org.junit.Test
- public void testGetFormats() throws Exception {
- List<ConfigurationFormat> formats = ConfigurationFormats.getFormats();
- assertNotNull(formats);
- assertEquals(formats.size(), 3);
- }
-
- @org.junit.Test
- public void testReadConfigurationData() throws Exception {
- List<ConfigurationFormat> formats = ConfigurationFormats.getFormats(getClass().getResource("/Test.ini"));
- assertNotNull(formats);
- assertEquals(formats.size(), 1);
- formats = ConfigurationFormats.getFormats(getClass().getResource("/Test.properties"));
- assertNotNull(formats);
- assertEquals(formats.size(), 1);
-// formats = ConfigurationFormats.getFormats(getClass().getResource("/Test.xml"));
-// assertNotNull(formats);
-// assertEquals(formats.size(), 1);
-
- }
-
- @org.junit.Test
- public void testReadConfigurationData_URL() throws Exception {
- ConfigurationData data = ConfigurationFormats.readConfigurationData(getClass().getResource("/Test.ini"));
- assertNotNull(data);
- data = ConfigurationFormats.readConfigurationData(getClass().getResource("/Test.properties"));
- assertNotNull(data);
- }
-
- @org.junit.Test
- public void testReadConfigurationData2() throws Exception {
- List<ConfigurationFormat> formats = ConfigurationFormats.getFormats();
- ConfigurationData data = ConfigurationFormats.readConfigurationData(getClass().getResource("/Test.ini"),
- formats.toArray(new ConfigurationFormat[formats.size()]));
- assertNotNull(data);
- System.out.println(data);
- }
-}
\ No newline at end of file
[05/24] incubator-tamaya git commit: Removed all modules from the
main repository. They will be reborn in separate ASF repository.
Posted by pl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/DefaultExpressionEvaluator.java
----------------------------------------------------------------------
diff --git a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/DefaultExpressionEvaluator.java b/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/DefaultExpressionEvaluator.java
deleted file mode 100644
index 85fe845..0000000
--- a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/DefaultExpressionEvaluator.java
+++ /dev/null
@@ -1,260 +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.resolver.internal;
-
-import org.apache.tamaya.resolver.spi.ExpressionEvaluator;
-import org.apache.tamaya.resolver.spi.ExpressionResolver;
-import org.apache.tamaya.spi.ServiceContextManager;
-
-import javax.annotation.Priority;
-import java.util.*;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Default expression evaluator that manages several instances of {@link org.apache.tamaya.resolver.spi.ExpressionResolver}.
- * Each resolver is identified by a resolver id. Each expression passed has the form resolverId:resolverExpression, which
- * has the advantage that different resolvers can be active in parallel.
- */
-@Priority(10000)
-public class DefaultExpressionEvaluator implements ExpressionEvaluator {
-
- private static final Logger LOG = Logger.getLogger(DefaultExpressionEvaluator.class.getName());
-
- private final List<ExpressionResolver> resolvers = new ArrayList<>();
-
- /**
- * Comparator used (not needed with Java8).
- */
- private static final Comparator<ExpressionResolver> RESOLVER_COMPARATOR = new Comparator<ExpressionResolver>() {
- @Override
- public int compare(ExpressionResolver o1, ExpressionResolver o2) {
- return compareExpressionResolver(o1, o2);
- }
- };
-
- /**
- * Default constructor.
- */
- public DefaultExpressionEvaluator() {
- for (ExpressionResolver resolver : ServiceContextManager.getServiceContext().getServices(ExpressionResolver.class)) {
- resolvers.add(resolver);
- }
- Collections.sort(resolvers, RESOLVER_COMPARATOR);
- }
-
- /**
- * Order ExpressionResolver reversely, the most important come first.
- *
- * @param res1 the first ExpressionResolver
- * @param res2 the second ExpressionResolver
- * @return the comparison result.
- */
- private static int compareExpressionResolver(ExpressionResolver res1, ExpressionResolver res2) {
- Priority prio1 = res1.getClass().getAnnotation(Priority.class);
- Priority prio2 = res2.getClass().getAnnotation(Priority.class);
- int ord1 = prio1 != null ? prio1.value() : 0;
- int ord2 = prio2 != null ? prio2.value() : 0;
- if (ord1 < ord2) {
- return -1;
- } else if (ord1 > ord2) {
- return 1;
- } else {
- return res1.getClass().getName().compareTo(res2.getClass().getName());
- }
- }
-
- /**
- * Resolves an expression in the form current <code>${resolverId:expression}</code> or
- * <code>${<prefix>expression}</code>. The expression can be
- * part current any type current literal text. Also multiple expressions with mixed matching resolvers are
- * supported.
- * All control characters (${}\) can be escaped using '\'.<br>
- * So all the following are valid expressions:
- * <ul>
- * <li><code>${expression}</code></li>
- * <li><code>bla bla ${expression}</code></li>
- * <li><code>${expression} bla bla</code></li>
- * <li><code>bla bla ${expression} bla bla</code></li>
- * <li><code>${expression}${resolverId2:expression2}</code></li>
- * <li><code>foo ${expression}${resolverId2:expression2}</code></li>
- * <li><code>foo ${expression} bar ${resolverId2:expression2}</code></li>
- * <li><code>${expression}foo${resolverId2:expression2}bar</code></li>
- * <li><code>foor${expression}bar${resolverId2:expression2}more</code></li>
- * <li><code>\${expression}foo${resolverId2:expression2}bar</code> (first expression is escaped).</li>
- * </ul>
- * Given {@code resolverId:} is a valid prefix targeting a {@link java.beans.Expression} explicitly, also the
- * following expressions are valid:
- * <ul>
- * <li><code>${resolverId:expression}</code></li>
- * <li><code>bla bla ${resolverId:expression}</code></li>
- * <li><code>${resolverId:expression} bla bla</code></li>
- * <li><code>bla bla ${resolverId:expression} bla bla</code></li>
- * <li><code>${resolverId:expression}${resolverId2:expression2}</code></li>
- * <li><code>foo ${resolverId:expression}${resolverId2:expression2}</code></li>
- * <li><code>foo ${resolverId:expression} bar ${resolverId2:expression2}</code></li>
- * <li><code>${resolverId:expression}foo${resolverId2:expression2}bar</code></li>
- * <li><code>foor${resolverId:expression}bar${resolverId2:expression2}more</code></li>
- * <li><code>\${resolverId:expression}foo${resolverId2:expression2}bar</code> (first expression is escaped).</li>
- * </ul>
- *
- * @param key the key to be filtered
- * @param value value to be analyzed for expressions
- * @param maskUnresolved if true, not found expression parts will be replaced by surrounding with [].
- * Setting to false will replace the value with an empty String.
- * @return the resolved value, or the input in case where no expression was detected.
- */
- @Override
- public String evaluateExpression(String key, String value, boolean maskUnresolved){
- if(value ==null){
- return null;
- }
- StringTokenizer tokenizer = new StringTokenizer(value, "${}", true);
- StringBuilder resolvedValue = new StringBuilder();
- StringBuilder current = new StringBuilder();
- while (tokenizer.hasMoreTokens()) {
- String token = tokenizer.nextToken();
- switch (token) {
- case "$":
- String nextToken = tokenizer.hasMoreTokens()?tokenizer.nextToken():"";
- if (!"{".equals(nextToken)) {
- current.append(token);
- current.append(nextToken);
- break;
- }
- if(value.indexOf('}')<=0){
- current.append(token);
- current.append(nextToken);
- break;
- }
- String subExpression = parseSubExpression(tokenizer, value);
- String res = evaluateInternal(subExpression, maskUnresolved);
- if(res!=null) {
- current.append(res);
- }
- break;
- default:
- current.append(token);
- }
- }
- if (current.length() > 0) {
- resolvedValue.append(current);
- }
- return resolvedValue.toString();
- }
-
- @Override
- public Collection<ExpressionResolver> getResolvers() {
- return new ArrayList<>(this.resolvers);
- }
-
- /**
- * Parses subexpression from tokenizer, hereby counting all open and closed brackets, but ignoring any
- * meta characters.
- * @param tokenizer the current tokenizer instance
- * @param valueToBeFiltered subexpression to be filtered for
- * @return the parsed sub expression
- */
- private String parseSubExpression(StringTokenizer tokenizer, String valueToBeFiltered) {
- StringBuilder expression = new StringBuilder();
- boolean escaped = false;
- while(tokenizer.hasMoreTokens()) {
- String token = tokenizer.nextToken();
- switch (token) {
- case "\\":
- if(!escaped) {
- escaped = true;
-
- } else {
- expression.append(token);
- escaped = false;
- }
- break;
- case "{":
- if(!escaped) {
- LOG.warning("Ignoring not escaped '{' in : " + valueToBeFiltered);
- }
- expression.append(token);
- escaped = false;
- break;
- case "$":
- if(!escaped) {
- LOG.warning("Ignoring not escaped '$' in : " + valueToBeFiltered);
- }
- expression.append(token);
- escaped = false;
- break;
- case "}":
- if(escaped) {
- expression.append(token);
- escaped = false;
- } else{
- return expression.toString();
- }
- break;
- default:
- expression.append(token);
- escaped = false;
- break;
- }
- }
- LOG.warning("Invalid expression syntax in: " + valueToBeFiltered + ", expression does not close!");
- return valueToBeFiltered;
- }
-
- /**
- * Evaluates the expression parsed, hereby checking for prefixes and trying otherwise all available resolvers,
- * based on priority.
- * @param unresolvedExpression the parsed, but unresolved expression
- * @param maskUnresolved if true, not found expression parts will be replaced by surrounding with [].
- * Setting to false will replace the value with an empty String.
- * @return the resolved expression, or null.
- */
- private String evaluateInternal(String unresolvedExpression, boolean maskUnresolved) {
- String value = null;
- // 1 check for explicit prefix
- for(ExpressionResolver resolver:resolvers){
- if(unresolvedExpression.startsWith(resolver.getResolverPrefix())){
- value = resolver.evaluate(unresolvedExpression.substring(resolver.getResolverPrefix().length()));
- break;
- }
- }
- if(value==null){
- for(ExpressionResolver resolver:resolvers){
- try{
- value = resolver.evaluate(unresolvedExpression);
- if(value!=null){
- return value;
- }
- }catch(Exception e){
- LOG.log(Level.FINEST, "Error during expression resolution from " + resolver, e);
- }
- }
- }
- if(value==null){
- LOG.log(Level.WARNING, "Unresolvable expression encountered " + unresolvedExpression);
- if(maskUnresolved){
- value = "?{" + unresolvedExpression + '}';
- }
- }
- return value;
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/EnvironmentPropertyResolver.java
----------------------------------------------------------------------
diff --git a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/EnvironmentPropertyResolver.java b/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/EnvironmentPropertyResolver.java
deleted file mode 100644
index efe0788..0000000
--- a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/EnvironmentPropertyResolver.java
+++ /dev/null
@@ -1,42 +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.resolver.internal;
-
-import org.apache.tamaya.resolver.spi.ExpressionResolver;
-
-import javax.annotation.Priority;
-
-/**
- * Property resolver implementation that interprets the resolver expressions as environment properties. It can be
- * explicitly addressed by prefixing {@code env:}, e.g. {@code ${env:MACHINE_NAME}}.
- */
-@Priority(0)
-public final class EnvironmentPropertyResolver implements ExpressionResolver{
-
- @Override
- public String getResolverPrefix() {
- return "env:";
- }
-
- @Override
- public String evaluate(String expression){
- return System.getenv(expression);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/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
deleted file mode 100644
index 20e2c7a..0000000
--- a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/ExpressionResolutionFilter.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 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.resolver.internal;
-
-import org.apache.tamaya.resolver.spi.ExpressionEvaluator;
-import org.apache.tamaya.spi.FilterContext;
-import org.apache.tamaya.spi.PropertyFilter;
-import org.apache.tamaya.spi.ServiceContextManager;
-
-import javax.annotation.Priority;
-import java.util.logging.Logger;
-
-/**
- * Default expression evaluator that manages several instances of {@link org.apache.tamaya.resolver.spi.ExpressionResolver}.
- * Each resolver is identified by a resolver id. Each expression passed has the form resolverId:resolverExpression, which
- * has the advantage that different resolvers can be active in parallel.
- */
-@Priority(10000)
-public class ExpressionResolutionFilter implements PropertyFilter {
-
- private static final Logger LOG = Logger.getLogger(ExpressionResolutionFilter.class.getName());
-
- private final ExpressionEvaluator evaluator = ServiceContextManager.getServiceContext().getService(ExpressionEvaluator.class);
-
- /**
- * Resolves an expression in the form current <code>${resolverId:expression}</code> or
- * <code>${<prefix>expression}</code>. The expression can be
- * part current any type current literal text. Also multiple expressions with mixed matching resolvers are
- * supported.
- * All control characters (${}\) can be escaped using '\'.<br>
- * So all the following are valid expressions:
- * <ul>
- * <li><code>${expression}</code></li>
- * <li><code>bla bla ${expression}</code></li>
- * <li><code>${expression} bla bla</code></li>
- * <li><code>bla bla ${expression} bla bla</code></li>
- * <li><code>${expression}${resolverId2:expression2}</code></li>
- * <li><code>foo ${expression}${resolverId2:expression2}</code></li>
- * <li><code>foo ${expression} bar ${resolverId2:expression2}</code></li>
- * <li><code>${expression}foo${resolverId2:expression2}bar</code></li>
- * <li><code>foor${expression}bar${resolverId2:expression2}more</code></li>
- * <li><code>\${expression}foo${resolverId2:expression2}bar</code> (first expression is escaped).</li>
- * </ul>
- * Given {@code resolverId:} is a valid prefix targeting a {@link java.beans.Expression} explicitly, also the
- * following expressions are valid:
- * <ul>
- * <li><code>${resolverId:expression}</code></li>
- * <li><code>bla bla ${resolverId:expression}</code></li>
- * <li><code>${resolverId:expression} bla bla</code></li>
- * <li><code>bla bla ${resolverId:expression} bla bla</code></li>
- * <li><code>${resolverId:expression}${resolverId2:expression2}</code></li>
- * <li><code>foo ${resolverId:expression}${resolverId2:expression2}</code></li>
- * <li><code>foo ${resolverId:expression} bar ${resolverId2:expression2}</code></li>
- * <li><code>${resolverId:expression}foo${resolverId2:expression2}bar</code></li>
- * <li><code>foor${resolverId:expression}bar${resolverId2:expression2}more</code></li>
- * <li><code>\${resolverId:expression}foo${resolverId2:expression2}bar</code> (first expression is escaped).</li>
- * </ul>
- *
- * @param context the filter context
- * @param valueToBeFiltered value to be analyzed for expressions
- * @return the resolved value, or the input in case where no expression was detected.
- */
- @Override
- public String filterProperty(String valueToBeFiltered, FilterContext context){
- LOG.finest("Resolving " + valueToBeFiltered + "(key=" + context.getKey() + ")");
- return evaluator.evaluateExpression(context.getKey(), valueToBeFiltered, true);
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/FileResolver.java
----------------------------------------------------------------------
diff --git a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/FileResolver.java b/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/FileResolver.java
deleted file mode 100644
index 6050ac2..0000000
--- a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/FileResolver.java
+++ /dev/null
@@ -1,120 +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.resolver.internal;
-
-import org.apache.tamaya.resolver.spi.ExpressionResolver;
-import org.apache.tamaya.resource.ResourceResolver;
-import org.apache.tamaya.spi.ServiceContextManager;
-
-import javax.annotation.Priority;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.InputStreamReader;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Collection;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import static java.nio.charset.StandardCharsets.UTF_8;
-
-/**
- * <p>Property resolver implementation that tries to load the given resource from the current file system.</p>
- *
- * <p>If the {@code Resources} module is available this module is used for resolving the expression. It can be
- * explicitly addressed by prefixing {@code file:}, e.g. {@code ${file:c:/temp/mytext.txt}}.</p>
- */
-@Priority(400)
-public final class FileResolver implements ExpressionResolver {
- /**
- * The looger used.
- */
- private final Logger LOG = Logger.getLogger(FileResolver.class.getName());
-
- /**
- * Flag that controls if the Tamaya Resource loader is available.
- */
- private static final boolean IS_RESOURCE_MODULE_AVAILABLE = checkResourceModule();
-
- /**
- * Checks if the Tamaya ResourceLoader can be loaded from the classpath.
- *
- * @return true, if the module is available.
- */
- private static boolean checkResourceModule() {
- try {
- Class.forName("org.apache.tamaya.resource.ResourceResolver.", false, FileResolver.class.getClassLoader());
- return true;
- } catch (Exception e) {
- return false;
- }
- }
-
- @Override
- public String getResolverPrefix() {
- return "file:";
- }
-
- @Override
- public String evaluate(String expression) {
- URL url = getUrl(expression);
- if(url==null){
- return null;
- }
- try (InputStreamReader streamReader = new InputStreamReader(url.openStream(), UTF_8);
- BufferedReader bufferedReader = new BufferedReader(streamReader)) {
- StringBuilder builder = new StringBuilder();
- String inputLine;
-
- while ((inputLine = bufferedReader.readLine()) != null) {
- builder.append(inputLine).append("\n");
- }
-
- return builder.toString();
- } catch (Exception e) {
- LOG.log(Level.FINEST, "Could not resolve URL: " + expression, e);
- return null;
- }
- }
-
- private URL getUrl(String expression) {
- if (IS_RESOURCE_MODULE_AVAILABLE) {
- ResourceResolver resolver = ServiceContextManager.getServiceContext().getService(ResourceResolver.class);
- Collection<URL> resources = resolver.getResources("file:" + expression);
- if (!resources.isEmpty()) {
- if (resources.size() != 1) {
- LOG.log(Level.WARNING, "Unresolvable expression (ambiguous resource): " + expression);
- return null;
- }
- return resources.iterator().next();
- }
- } else {
- File file = new File(expression);
- if (file.exists()) {
- try {
- return file.toURI().toURL();
- } catch (MalformedURLException e) {
- LOG.log(Level.WARNING, "Unresolvable expression (cannot convert file to URL): " + expression, e);
- }
- }
- }
- return null; // no such resource found
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/ResourceResolver.java
----------------------------------------------------------------------
diff --git a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/ResourceResolver.java b/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/ResourceResolver.java
deleted file mode 100644
index 270459c..0000000
--- a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/ResourceResolver.java
+++ /dev/null
@@ -1,151 +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.resolver.internal;
-
-import org.apache.tamaya.resolver.spi.ExpressionResolver;
-import org.apache.tamaya.spi.ServiceContextManager;
-
-import javax.annotation.Priority;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import static java.nio.charset.StandardCharsets.UTF_8;
-
-/**
- * <p>Property resolver implementation that tries to load the given resource from the current classpath using the
- * Thread Context classloader, and as fallback from the classloader that loaded this module and system classloader.
- * It can be explicitly addressed by prefixing {@code resource:}, e.g. {@code ${resource:META-INF/VERSION}}.</p>
- *
- * <p>If the {@code Resources} module is available this module is used for resolving the expression.</p>
- */
-@Priority(300)
-public final class ResourceResolver implements ExpressionResolver {
- /**
- * The looger used.
- */
- private final Logger LOG = Logger.getLogger(ResourceResolver.class.getName());
-
- /**
- * Flag that controls if the Tamaya Resource loader is available.
- */
- private static final boolean IS_RESOURCE_MODULE_AVAILABLE = checkResourceModule();
-
- /**
- * Checks if the Tamaya ResourceLoader can be loaded from the classpath.
- *
- * @return true, if the module is available.
- */
- private static boolean checkResourceModule() {
- try {
- Class.forName("org.apache.tamaya.resource.ResourceResolver", false, ResourceResolver.class.getClassLoader());
- return true;
- } catch (Exception e) {
- return false;
- }
- }
-
- @Override
- public String getResolverPrefix() {
- return "resource:";
- }
-
- @Override
- public String evaluate(String expression) {
- List<ClassLoader> classLoaders = new ArrayList<>();
- for (ClassLoader cl : new ClassLoader[]{Thread.currentThread().getContextClassLoader(), getClass().getClassLoader(), ClassLoader.getSystemClassLoader()}) {
- if (!classLoaders.contains(cl)) {
- classLoaders.add(cl);
- }
- }
- return readURL(expression, classLoaders);
- }
-
- private String readURL(String expression, List<ClassLoader> classLoaders) {
- URL url = getUrl(expression, classLoaders);
- if(url==null){
- return null;
- }
- try (InputStreamReader streamReader = new InputStreamReader(url.openStream(), UTF_8);
- BufferedReader bufferedReader = new BufferedReader(streamReader)){
-
- StringBuilder builder = new StringBuilder();
- String inputLine;
-
- while ((inputLine = bufferedReader.readLine()) != null) {
- builder.append(inputLine).append("\n");
- }
-
- return builder.toString();
- } catch (Exception e) {
- LOG.log(Level.FINEST, "Could not resolve URL: " + expression, e);
- return null;
- }
- }
-
- private URL getUrl(String expression, List<ClassLoader> classLoaders) {
- if (IS_RESOURCE_MODULE_AVAILABLE) {
- org.apache.tamaya.resource.ResourceResolver resolver = ServiceContextManager.getServiceContext()
- .getService(org.apache.tamaya.resource.ResourceResolver.class);
- for (ClassLoader cl : classLoaders) {
- Collection<URL> resources = resolver.getResources(cl, expression);
- if (!resources.isEmpty()) {
- if (resources.size() != 1) {
- LOG.log(Level.WARNING, "Unresolvable expression (ambiguous resource): " + expression);
- return null;
- }
- return resources.iterator().next();
- }
- }
- } else {
- for (ClassLoader cl : classLoaders) {
- List<URL> resources = new ArrayList<>();
- Enumeration<URL> found;
- try {
- found = cl.getResources(expression);
- } catch (Exception e) {
- LOG.log(Level.SEVERE, "Error resolving expression: " + expression, e);
- continue;
- }
- while (found.hasMoreElements()) {
- resources.add(found.nextElement());
- }
- if (!resources.isEmpty()) {
- if (resources.size() != 1) {
- LOG.log(Level.WARNING, "Unresolvable expression (ambiguous resource): " + expression);
- return null;
- }
- return resources.get(0);
- }
- }
- if (expression.contains("*") || expression.contains("?")) {
- LOG.warning("Rouse not found: " + expression + "(Hint: expression contains expression" +
- " placeholders, but resource module is not loaded.");
- }
- }
- return null; // no such resource found
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/SystemPropertyResolver.java
----------------------------------------------------------------------
diff --git a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/SystemPropertyResolver.java b/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/SystemPropertyResolver.java
deleted file mode 100644
index 9b04a4f..0000000
--- a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/SystemPropertyResolver.java
+++ /dev/null
@@ -1,42 +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.resolver.internal;
-
-import org.apache.tamaya.resolver.spi.ExpressionResolver;
-
-import javax.annotation.Priority;
-
-/**
- * Property resolver implementation that interprets the resolver expression as system property name.
- * It can be explicitly addressed by prefixing {@code sys:}, e.g. {@code ${sys:mySystemProperty}}.
- */
-@Priority(100)
-public final class SystemPropertyResolver implements ExpressionResolver{
-
- @Override
- public String getResolverPrefix() {
- return "sys:";
- }
-
- @Override
- public String evaluate(String expression){
- return System.getProperty(expression);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/URLResolver.java
----------------------------------------------------------------------
diff --git a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/URLResolver.java b/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/URLResolver.java
deleted file mode 100644
index 32195f8..0000000
--- a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/URLResolver.java
+++ /dev/null
@@ -1,66 +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.resolver.internal;
-
-import org.apache.tamaya.resolver.spi.ExpressionResolver;
-
-import javax.annotation.Priority;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import static java.nio.charset.StandardCharsets.UTF_8;
-
-/**
- * Property resolver implementation that interprets the resolver expression as an URL to be resolved.
- * It can be explicitly addressed by prefixing {@code url:}, e.g. {@code ${url:http//www.oracle.com}}.
- */
-@Priority(500)
-public final class URLResolver implements ExpressionResolver {
-
- private final Logger LOG = Logger.getLogger(URLResolver.class.getName());
-
- @Override
- public String getResolverPrefix() {
- return "url:";
- }
-
- @Override
- public String evaluate(String expression) {
- try {
- URL url = new URL(expression);
- try (InputStreamReader inputStreamReader = new InputStreamReader(url.openStream(), UTF_8);
- BufferedReader bufferedReader = new BufferedReader(inputStreamReader))
- {
- StringBuilder builder = new StringBuilder();
- String inputLine;
- while ((inputLine = bufferedReader.readLine()) != null) {
- builder.append(inputLine).append("\n");
- }
- return builder.toString();
- }
- } catch (Exception e) {
- LOG.log(Level.FINEST, "Could not resolve URL: " + expression, e);
- return null;
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/package-info.java
----------------------------------------------------------------------
diff --git a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/package-info.java b/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/package-info.java
deleted file mode 100644
index e858854..0000000
--- a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-/**
- * This package contains the default implementation for file, classpath and URL resolution, as well as resolution of
- * configuration cross references.
- */
-package org.apache.tamaya.resolver.internal;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resolver/src/main/java/org/apache/tamaya/resolver/package-info.java
----------------------------------------------------------------------
diff --git a/modules/resolver/src/main/java/org/apache/tamaya/resolver/package-info.java b/modules/resolver/src/main/java/org/apache/tamaya/resolver/package-info.java
deleted file mode 100644
index 15ebe22..0000000
--- a/modules/resolver/src/main/java/org/apache/tamaya/resolver/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-/**
- * This package contains the API of the resolver module.
- */
-package org.apache.tamaya.resolver;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/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
deleted file mode 100644
index 96dbb66..0000000
--- a/modules/resolver/src/main/java/org/apache/tamaya/resolver/spi/ExpressionEvaluator.java
+++ /dev/null
@@ -1,66 +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.resolver.spi;
-
-
-import java.util.Collection;
-
-/**
- * Interface that provides an SPI that can be accessed from the current {@link org.apache.tamaya.spi.ServiceContext},
- * which allows to pass expression that contain placeholders and variable expressions. Expressions passed hereby
- * use UNIX styled variable syntax as follows:
- * <pre>
- * ${expression}
- * My name is ${expression}.
- * Also multiple expressions are support, e.g. ${expression1}, ${expression2}.
- * </pre>
- *
- * By default all registered instances of {@link org.apache.tamaya.resolver.spi.ExpressionResolver} are called to
- * evaluate an expression, depending on the annotatated {@link javax.annotation.Priority} on the resolver classes.
- * Nevertheless with {@link ExpressionResolver#getResolverPrefix()} each resolver instance defines a unique id, by
- * which a resolver can be explicitly addressed as follows:
- * <pre>
- * ${env:MACHINE_NAME}
- * My name is ${sys:instance.name}.
- * Also multiple expressions are supported, e.g. ${resource:META-INF/version.conf}, ${file:C:/temp/version.txt},
- * ${url:http://configserver/name}.
- * </pre>
- * Basically this service is consumed by an instance of {@link org.apache.tamaya.spi.PropertyFilter}, which
- * takes the configuration values found and passes them to this evaluator, when expressions are detected. This
- * also done iteratively, so also multi-stepped references (references, which themselves must be evaluated as well)
- * are supported.
- */
-public interface ExpressionEvaluator {
- /**
- * Evaluates the current expression.
- * @param key the key, not null.
- * @param value the value to be filtered/evaluated.
- * @param maskNotFound if true, not found expression parts will be replaced vy surrounding with [].
- * Setting to false will replace the value with an empty String.
- * @return the filtered/evaluated value, including null.
- */
- String evaluateExpression(String key, String value, boolean maskNotFound);
-
- /**
- * Access a collection with the currently registered {@link org.apache.tamaya.resolver.internal.ConfigResolver} instances.
- * @return the resolvers currently known, never null.
- */
- Collection<ExpressionResolver> getResolvers();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/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
deleted file mode 100644
index d07fe05..0000000
--- a/modules/resolver/src/main/java/org/apache/tamaya/resolver/spi/ExpressionResolver.java
+++ /dev/null
@@ -1,48 +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.resolver.spi;
-
-
-/**
- * This interfaces provides a model for expression evaluation. This enables transparently plugin expression languages
- * as needed. In a Java EE context full fledged EL may be used, whereas in ME only simple replacement mechanisms
- * are better suited to the runtime requirements.
- */
-public interface ExpressionResolver {
-
- /**
- * Get the unique resolver prefix. This allows to address a resolver explicitly, in case of conflicts. By
- * default all registered resolvers are called in order as defined by the {@link javax.annotation.Priority}
- * annotation.
- *
- * @return the prefix that identifies this resolver instance, e.g. 'config:'. The ':' hereby is not required as a
- * separator, but it is recommended to use it, because it fits well, with the other existing resolvers and
- * is easy to read.
- */
- String getResolverPrefix();
-
- /**
- * Evaluates the given expression.
- *
- * @param expression the expression to be evaluated, not null. If a resolver was addressed explicitly,
- * the prefix is removed prior to calling this method.
- * @return the evaluated expression, or null, if the evaluator is not able to resolve the expression.
- */
- String evaluate(String expression);
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resolver/src/main/java/org/apache/tamaya/resolver/spi/package-info.java
----------------------------------------------------------------------
diff --git a/modules/resolver/src/main/java/org/apache/tamaya/resolver/spi/package-info.java b/modules/resolver/src/main/java/org/apache/tamaya/resolver/spi/package-info.java
deleted file mode 100644
index ef4a2b8..0000000
--- a/modules/resolver/src/main/java/org/apache/tamaya/resolver/spi/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-/**
- * This package contains the SPI of the resolver module, allowing overriding/adding of resolution mechanisms
- * as well as the overall evaluation mechanism.
- */
-package org.apache.tamaya.resolver.spi;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resolver/src/main/resources/META-INF/services/org.apache.tamaya.resolver.spi.ExpressionEvaluator
----------------------------------------------------------------------
diff --git a/modules/resolver/src/main/resources/META-INF/services/org.apache.tamaya.resolver.spi.ExpressionEvaluator b/modules/resolver/src/main/resources/META-INF/services/org.apache.tamaya.resolver.spi.ExpressionEvaluator
deleted file mode 100644
index aa766b6..0000000
--- a/modules/resolver/src/main/resources/META-INF/services/org.apache.tamaya.resolver.spi.ExpressionEvaluator
+++ /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.resolver.internal.DefaultExpressionEvaluator
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resolver/src/main/resources/META-INF/services/org.apache.tamaya.resolver.spi.ExpressionResolver
----------------------------------------------------------------------
diff --git a/modules/resolver/src/main/resources/META-INF/services/org.apache.tamaya.resolver.spi.ExpressionResolver b/modules/resolver/src/main/resources/META-INF/services/org.apache.tamaya.resolver.spi.ExpressionResolver
deleted file mode 100644
index cb7ced0..0000000
--- a/modules/resolver/src/main/resources/META-INF/services/org.apache.tamaya.resolver.spi.ExpressionResolver
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy 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.resolver.internal.SystemPropertyResolver
-org.apache.tamaya.resolver.internal.EnvironmentPropertyResolver
-org.apache.tamaya.resolver.internal.ResourceResolver
-org.apache.tamaya.resolver.internal.ConfigResolver
-org.apache.tamaya.resolver.internal.FileResolver
-org.apache.tamaya.resolver.internal.URLResolver
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resolver/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter
----------------------------------------------------------------------
diff --git a/modules/resolver/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter b/modules/resolver/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter
deleted file mode 100644
index c8788b5..0000000
--- a/modules/resolver/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter
+++ /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.resolver.internal.ExpressionResolutionFilter
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resolver/src/test/java/org/apache/tamaya/resolver/ConfigResolutionTest.java
----------------------------------------------------------------------
diff --git a/modules/resolver/src/test/java/org/apache/tamaya/resolver/ConfigResolutionTest.java b/modules/resolver/src/test/java/org/apache/tamaya/resolver/ConfigResolutionTest.java
deleted file mode 100644
index f795ee1..0000000
--- a/modules/resolver/src/test/java/org/apache/tamaya/resolver/ConfigResolutionTest.java
+++ /dev/null
@@ -1,121 +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.resolver;
-
-import org.apache.tamaya.ConfigurationProvider;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-/**
- * Test class that test resolution of different values as configured within
- * {@link org.apache.tamaya.resolver.MyTestPropertySource} and on test resource path.
- */
-public class ConfigResolutionTest {
-
- @Test
- public void test_Prefix_Resolution() {
- assertEquals(ConfigurationProvider.getConfiguration().get("Before Text (prefixed)"), "My Java version is " + System.getProperty("java.version"));
- }
-
- @Test
- public void test_Midfix_Resolution() {
- assertEquals(ConfigurationProvider.getConfiguration().get("Before and After Text (prefixed)"), "My Java version is " + System.getProperty("java.version") + ".");
- }
-
- @Test
- public void test_Prefix_Resolution_BadSyntax1() {
- assertEquals(ConfigurationProvider.getConfiguration().get("Will fail1."), "V$java.version");
- }
-
- @Test
- public void test_Prefix_Resolution_BadSyntax2() {
- assertEquals(ConfigurationProvider.getConfiguration().get("Will fail2."), "V$java.version}");
- }
-
- @Test
- public void test_Prefix_Resolution_BadSyntax31() {
- assertEquals(ConfigurationProvider.getConfiguration().get("Will not fail3."), "V${java.version");
- }
-
- @Test
- public void test_Prefix_Resolution_Escaped1() {
- assertEquals(ConfigurationProvider.getConfiguration().get("Will not fail1."), "V$\\{java.version");
- }
-
- @Test
- public void test_Prefix_Resolution_Escaped2() {
- assertEquals(ConfigurationProvider.getConfiguration().get("Will not fail2."), "V\\${java.version");
- }
-
- @Test
- public void test_Prefix_Resolution_EnvKeys() {
- assertEquals(ConfigurationProvider.getConfiguration().get("env.keys"), System.getProperty("java.version") + " plus $java.version");
- }
-
- @Test
- public void test_Prefix_ExpressionOnly_Resolution() {
- assertEquals(ConfigurationProvider.getConfiguration().get("Expression Only"), System.getProperty("java.version"));
- }
-
- @Test
- public void testConfig_Refs() {
- assertEquals(ConfigurationProvider.getConfiguration().get("config-ref"), "Expression Only -> " + System.getProperty("java.version"));
- assertEquals(ConfigurationProvider.getConfiguration().get("config-ref3"), "Config Ref 3 -> Ref 2: Config Ref 2 -> Ref 1: Expression Only -> " + System.getProperty("java.version"));
- assertEquals(ConfigurationProvider.getConfiguration().get("config-ref2"), "Config Ref 2 -> Ref 1: Expression Only -> " + System.getProperty("java.version"));
- }
-
- @Test
- public void testClasspath_Refs() {
- String value = ConfigurationProvider.getConfiguration().get("cp-ref");
- assertNotNull(value);
- assertTrue(value.contains("This content comes from Testresource.txt!"));
- }
-
- @Test
- public void testResource_Refs() {
- String value = ConfigurationProvider.getConfiguration().get("res-ref");
- assertNotNull(value);
- assertTrue(value.contains("This content comes from Testresource.txt!"));
- }
-
- @Test
- public void testFile_Refs() {
- String value = ConfigurationProvider.getConfiguration().get("file-ref");
- assertNotNull(value);
- assertTrue(value.contains("This content comes from Testresource2.txt!"));
- }
-
- @Test
- public void testURL_Refs() {
- String value = ConfigurationProvider.getConfiguration().get("url-ref");
- assertNotNull(value);
- assertTrue(value.contains("doctype html") || "[http://www.google.com]".equals(value));
- }
-
- @Test
- public void testEscaping(){
- assertEquals(ConfigurationProvider.getConfiguration().get("escaped"),
- "Config Ref 3 -> Ref 2: \\${conf:config-ref2 will not be evaluated and will not contain\\t tabs \\n " +
- "newlines or \\r returns...YEP!");
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/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
deleted file mode 100644
index 7d99cbc..0000000
--- a/modules/resolver/src/test/java/org/apache/tamaya/resolver/MyTestPropertySource.java
+++ /dev/null
@@ -1,102 +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.resolver;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-
-import java.io.File;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Created by Anatole on 04.01.2015.
- */
-public class MyTestPropertySource implements PropertySource{
-
- private final Map<String,String> properties = new HashMap<>();
-
- public MyTestPropertySource(){
- properties.put("Expression Only", "${java.version}");
- properties.put("Expression Only (prefixed)", "${sys:java.version}");
- properties.put("Before Text", "My Java version is ${java.version}");
- properties.put("Before Text (prefixed)", "My Java version is ${sys:java.version}");
- properties.put("Before and After Text", "My Java version is ${java.version}.");
- properties.put("Before and After Text (prefixed)", "My Java version is ${sys:java.version}.");
- properties.put("Multi-expression", "Java version ${sys:java.version} and line.separator ${line.separator}.");
-
- properties.put("cp-ref", "${resource:Testresource.txt}");
- properties.put("file-ref", "${file:"+getFileRefAsString()+"}");
- properties.put("res-ref", "${resource:Test?es*ce.txt}");
- properties.put("url-ref", "${url:http://www.google.com}");
- properties.put("config-ref", "Expression Only -> ${conf:Expression Only}");
- properties.put("config-ref2", "Config Ref 2 -> Ref 1: ${conf:config-ref}");
- properties.put("config-ref3", "Config Ref 3 -> Ref 2: ${conf:config-ref2}");
-
- properties.put("Will fail1.", "V$java.version");
- properties.put("Will fail2.", "V$java.version}");
- properties.put("Will not fail3.", "V${java.version");
- properties.put("Will not fail1.", "V$\\{java.version");
- properties.put("Will not fail2.", "V\\${java.version");
-
- properties.put("env.keys", "${java.version} plus $java.version");
-
- properties.put("escaped", "Config Ref 3 -> Ref 2: \\${conf:config-ref2 will not be evaluated and will not contain\\t tabs \\n " +
- "newlines or \\r returns...YEP!");
- }
-
- private String getFileRefAsString() {
- try {
- URL res = getClass().getClassLoader().getResource("Testresource2.txt");
- if(res==null){
- return null;
- }
- return new File(res.toURI()).getAbsolutePath().replaceAll("\\\\","/");
- } catch (URISyntaxException e) {
- return "Failed to evaluate file: Testresource2.txt";
- }
- }
-
- @Override
- public int getOrdinal() {
- return 0;
- }
-
- @Override
- public String getName() {
- return "test";
- }
-
- @Override
- public PropertyValue get(String key) {
- return PropertyValue.of(key, properties.get(key), getName());
- }
-
- @Override
- public Map<String, String> getProperties() {
- return properties;
- }
-
- @Override
- public boolean isScannable() {
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resolver/src/test/java/org/apache/tamaya/resolver/ResolverTest.java
----------------------------------------------------------------------
diff --git a/modules/resolver/src/test/java/org/apache/tamaya/resolver/ResolverTest.java b/modules/resolver/src/test/java/org/apache/tamaya/resolver/ResolverTest.java
deleted file mode 100644
index 74c9d84..0000000
--- a/modules/resolver/src/test/java/org/apache/tamaya/resolver/ResolverTest.java
+++ /dev/null
@@ -1,41 +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.resolver;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Tests for {@link org.apache.tamaya.resolver.Resolver}.
- */
-public class ResolverTest {
-
- @Test
- public void testEvaluateExpression() throws Exception {
- assertEquals(Resolver.evaluateExpression("myKey", "Version ${java.version}"),
- "Version " + System.getProperty("java.version"));
- }
-
- @Test
- public void testEvaluateExpression1() throws Exception {
- assertEquals(Resolver.evaluateExpression("Version ${java.version}"),
- "Version " + System.getProperty("java.version"));
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resolver/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
----------------------------------------------------------------------
diff --git a/modules/resolver/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource b/modules/resolver/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
deleted file mode 100644
index 088aca9..0000000
--- a/modules/resolver/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
+++ /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.resolver.MyTestPropertySource
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resolver/src/test/resources/Testresource.txt
----------------------------------------------------------------------
diff --git a/modules/resolver/src/test/resources/Testresource.txt b/modules/resolver/src/test/resources/Testresource.txt
deleted file mode 100644
index 9731609..0000000
--- a/modules/resolver/src/test/resources/Testresource.txt
+++ /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.
-#
-This content comes from Testresource.txt!
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resolver/src/test/resources/Testresource2.txt
----------------------------------------------------------------------
diff --git a/modules/resolver/src/test/resources/Testresource2.txt b/modules/resolver/src/test/resources/Testresource2.txt
deleted file mode 100644
index a43bf62..0000000
--- a/modules/resolver/src/test/resources/Testresource2.txt
+++ /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.
-#
-This content comes from Testresource2.txt!
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resources/README.md
----------------------------------------------------------------------
diff --git a/modules/resources/README.md b/modules/resources/README.md
deleted file mode 100644
index 96afaa3..0000000
--- a/modules/resources/README.md
+++ /dev/null
@@ -1,26 +0,0 @@
-Apache Tamaya Resources Module
-------------------------------
-
-The Apache Tamaya resources module provides an additional service called 'ResourceLoader', which is accessible
-from the ServiceContext. The new service allows resolution of resources (modelled as URL) using Ant styled
-patterns:
-
-* ? may represent any character (but there must be one)
-* * may represent any character in the path (can be none or multiple)
-* ** may be used to let the pattern matcher go down the hierarchy of files od resources in the current locations.
-
-The resolver supports by default resolving paths in the file system and within the classpath, e.g.
-
- resources_testRoot/**/*.file
- c:\temp\**\*
-
-In case of a conflict the resolver mechanism can also be explicitly addressed by adding the regarding prefix, so
-the above expressions above are equivalent to
-
- classpath:resources_testRoot/**/*.file
- file:c:\temp\**\*
-
-Most benefits are created, when also using the formats module, which provides an implementation of a
-PropertySourceProvider taking a set of paths to be resolved and a number of supported formats.
-
-
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resources/pom.xml
----------------------------------------------------------------------
diff --git a/modules/resources/pom.xml b/modules/resources/pom.xml
deleted file mode 100644
index 1ba7dbe..0000000
--- a/modules/resources/pom.xml
+++ /dev/null
@@ -1,77 +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.
--->
-<project xmlns="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">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-extensions</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>tamaya-resources</artifactId>
- <name>Apache Tamaya Modules - Resource Services</name>
- <packaging>bundle</packaging>
-
- <properties>
- <jdkVersion>1.7</jdkVersion>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-core</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>java-hamcrest</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.tamaya.resource
- </Export-Package>
- <Private-Package>
- org.apache.tamaya.resource.internal
- </Private-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resources/src/main/java/org/apache/tamaya/resource/AbstractPathPropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/modules/resources/src/main/java/org/apache/tamaya/resource/AbstractPathPropertySourceProvider.java b/modules/resources/src/main/java/org/apache/tamaya/resource/AbstractPathPropertySourceProvider.java
deleted file mode 100644
index 1b62c65..0000000
--- a/modules/resources/src/main/java/org/apache/tamaya/resource/AbstractPathPropertySourceProvider.java
+++ /dev/null
@@ -1,193 +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.resource;
-
-import java.io.InputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Objects;
-import java.util.Properties;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertySourceProvider;
-import org.apache.tamaya.spi.PropertyValue;
-
-/**
- * Abstract base class that uses a descriptive resource path to define the locations of configuration files to be
- * included into the configuration. This is especially useful, when the current configuration policy in place
- * does not define the exact file names, but the file locations, where configuration can be provided.
- */
-public abstract class AbstractPathPropertySourceProvider implements PropertySourceProvider{
- /** The log used. */
- private static final Logger LOG = Logger.getLogger(AbstractPathPropertySourceProvider.class.getName());
- /** The resource paths. */
- private String[] resourcePaths;
-
-
- /**
- * Creates a new instance using the given resource paths.
- * @param resourcePaths the resource paths, not null, not empty.
- */
- public AbstractPathPropertySourceProvider(String... resourcePaths){
- if(resourcePaths.length==0){
- throw new IllegalArgumentException("At least one resource path should be configured.");
- }
- this.resourcePaths = resourcePaths.clone();
- }
-
- @Override
- public Collection<PropertySource> getPropertySources() {
- List<PropertySource> propertySources = new ArrayList<>();
- for(String resource:resourcePaths) {
- try {
- Collection<URL> resources = ConfigResources.getResourceResolver().getResources(resource);
- for (URL url : resources) {
- try {
- Collection<PropertySource> propertySourcesToInclude = getPropertySources(url);
- if(propertySourcesToInclude!=null){
- propertySources.addAll(propertySourcesToInclude);
- }
- } catch (Exception e) {
- LOG.log(Level.WARNING, "Failed to read configuration from " + url, e);
- }
- }
- } catch (Exception e) {
- LOG.log(Level.SEVERE, "Invalid resource path: " + resource, e);
- }
- }
- return propertySources;
- }
-
- /**
- * Factory method that creates a {@link org.apache.tamaya.spi.PropertySource} based on the URL found by
- * the resource locator.
- * @param url the URL, not null.
- * @return the {@link org.apache.tamaya.spi.PropertySource}s to be included into the current provider's sources
- * list. It is safe to return {@code null} here, in case the content of the URL has shown to be not relevant
- * as configuration input. In case the input is not valid or accessible an exception can be thrown or logged.
- */
- protected abstract Collection<PropertySource> getPropertySources(URL url);
-
- /**
- * Utility method that reads a .properties file from the given url and creates a corresponding
- * {@link org.apache.tamaya.spi.PropertySource}.
- * @param url the url to read, not null.
- * @return the corresponding PropertySource, or null.
- */
- public static PropertySource createPropertiesPropertySource(URL url) {
- Properties props = new Properties();
- try(InputStream is = url.openStream()){
- props.load(is);
- return new PropertiesBasedPropertySource(url.toString(), props);
- }
- catch(Exception e){
- LOG.log(Level.WARNING, "Failed to read properties from " + url, e);
- return null;
- }
- }
-
- /**
- * Minimal {@link PropertySource} implementation based on {@link Properties} or
- * {@link Map}.
- */
- private final static class PropertiesBasedPropertySource implements PropertySource{
- /** The property source's name. */
- private final String name;
- /** The properties. */
- private final Map<String,String> properties = new HashMap<>();
-
- /**
- * Constructor for a simple properties configuration.
- * @param name the source's name, not null
- * @param props the properties, not null
- */
- public PropertiesBasedPropertySource(String name, Properties props) {
- this.name = name;
- for (Entry<Object, Object> en : props.entrySet()) {
- this.properties.put(en.getKey().toString(), String.valueOf(en.getValue()));
- }
- }
-
- /**
- * Constructor for a simple properties configuration.
- * @param name the source's name, not null
- * @param props the properties, not null
- */
- public PropertiesBasedPropertySource(String name, Map<String,String> props) {
- this.name = Objects.requireNonNull(name);
- this.properties.putAll(props);
- }
-
- @Override
- public int getOrdinal() {
- PropertyValue configuredOrdinal = get(TAMAYA_ORDINAL);
- if (configuredOrdinal != null) {
- try {
- return Integer.parseInt(configuredOrdinal.getValue());
- } catch (Exception e) {
- Logger.getLogger(getClass().getName()).log(Level.WARNING,
- "Configured Ordinal is not an int number: " + configuredOrdinal, e);
- }
- }
- return getDefaultOrdinal();
- }
-
- /**
- * Returns the default ordinal used, when no ordinal is set, or the ordinal was not parseable to an int value.
- *
- * @return the default ordinal used, by default 0.
- */
- public int getDefaultOrdinal() {
- return 0;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public PropertyValue get(String key) {
- return PropertyValue.of(key, getProperties().get(key), getName());
- }
-
- @Override
- public Map<String, String> getProperties() {
- return properties;
- }
-
- @Override
- public boolean isScannable() {
- return false;
- }
-
- @Override
- public String toString(){
- return "PropertiesBasedPropertySource["+name+']';
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resources/src/main/java/org/apache/tamaya/resource/BaseResourceResolver.java
----------------------------------------------------------------------
diff --git a/modules/resources/src/main/java/org/apache/tamaya/resource/BaseResourceResolver.java b/modules/resources/src/main/java/org/apache/tamaya/resource/BaseResourceResolver.java
deleted file mode 100644
index cb8c1f5..0000000
--- a/modules/resources/src/main/java/org/apache/tamaya/resource/BaseResourceResolver.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.resource;
-
-import java.net.URL;
-import java.util.Arrays;
-import java.util.Collection;
-
-/**
- * Interface to be implemented by modules. It supports loading of files or classpath resources either directly or by
- * defining a Ant-styled resource pattern:
- * <ul>
- * <li>'*' is a placeholder for any character (0..n)</li>
- * <li>'**' is a placeholder for any number of subdirectories going down a directory structure recursively.</li>
- * <li>'?' is a placeholder for exact one character</li>
- * </ul>
- * Given that the following expressions are valid expressions:
- * <pre>
- * classpath:javax/annotations/*
- * javax?/annotations/**/*.class
- * org/apache/tamaya/**/tamayaconfig.properties
- * file:C:/temp/*.txt
- * file:C:\**\*.ini
- * C:\Programs\**/*.ini
- * /user/home/A*b101_?.pid
- * /var/logs/**/*.log
- * </pre>
- */
-public abstract class BaseResourceResolver implements ResourceResolver {
-
- /**
- * Resolves resource expressions to a list of {@link URL}s. Hereby
- * the ordering of format matches the input of the resolved expressions. Nevertheless be aware that
- * there is no determined ordering of format located within a classloader.
- *
- * @param expressions the expressions to be resolved, not empty.
- * @return the corresponding collection of current {@link URL}s found, never
- * null.
- * .
- */
- @Override
- public Collection<URL> getResources(Collection<String> expressions) {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- if (cl == null) {
- cl = getClass().getClassLoader();
- }
- return getResources(cl, expressions);
- }
-
- /**
- * Resolves resource expressions to a list of {@link URL}s. Hereby
- * the ordering of format matches the input of the resolved expressions. Nevertheless be aware that
- * there is no determined ordering of format located within a classloader.
- *
- * @param expressions the expressions to be resolved, not empty.
- * @return the corresponding collection of current {@link URL}s found, never
- * null.
- * .
- */
- @Override
- public Collection<URL> getResources(String... expressions) {
- return getResources(Arrays.asList(expressions));
- }
-
- /**
- * Resolves resource expressions to a list of {@link URL}s, considerubg
- * the given classloader for classloader dependent format. Hereby
- * the ordering of format matches the input of the resolved expressions. Nevertheless be aware that
- * there is no determined ordering of format located within a classloader.
- *
- * @param expressions the expressions to be resolved, not empty.
- * @return the corresponding collection of current {@link URL}s found, never
- * null.
- * .
- */
- @Override
- public Collection<URL> getResources(ClassLoader classLoader, String... expressions) {
- return getResources(classLoader, Arrays.asList(expressions));
- }
-
- /**
- * Resolves resource expressions to a list of {@link URL}s, considerubg
- * the given classloader for classloader dependent format. Hereby
- * the ordering of format matches the input of the resolved expressions. Nevertheless be aware that
- * there is no determined ordering of format located within a classloader.
- *
- * @param expressions the expressions to be resolved, not empty.
- * @return the corresponding collection of current {@link URL}s found, never
- * null.
- * .
- */
- @Override
- public abstract Collection<URL> getResources(ClassLoader classLoader, Collection<String> expressions);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resources/src/main/java/org/apache/tamaya/resource/ConfigResources.java
----------------------------------------------------------------------
diff --git a/modules/resources/src/main/java/org/apache/tamaya/resource/ConfigResources.java b/modules/resources/src/main/java/org/apache/tamaya/resource/ConfigResources.java
deleted file mode 100644
index ae08148..0000000
--- a/modules/resources/src/main/java/org/apache/tamaya/resource/ConfigResources.java
+++ /dev/null
@@ -1,51 +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.resource;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.spi.ServiceContextManager;
-
-
-/**
- * Singleton Accessor for accessing the current {@link org.apache.tamaya.resource.ResourceResolver} instance.
- */
-public final class ConfigResources {
-
- /**
- * Singleton constructor.
- */
- private ConfigResources(){}
-
- /**
- * <p>Access the current ResourceResolver.</p>
- *
- * @throws ConfigException if no ResourceResolver is available (should not happen).
- *
- * @return the current ResourceResolver instance, never null.
- */
- public static ResourceResolver getResourceResolver() throws ConfigException {
- ResourceResolver resolver = ServiceContextManager.getServiceContext().getService(ResourceResolver.class);
- if (resolver == null) {
- throw new ConfigException("ResourceResolver not available.");
- }
- return resolver;
- }
-
-
-}
\ No newline at end of file
[04/24] incubator-tamaya git commit: Removed all modules from the
main repository. They will be reborn in separate ASF repository.
Posted by pl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resources/src/main/java/org/apache/tamaya/resource/ResourceLocator.java
----------------------------------------------------------------------
diff --git a/modules/resources/src/main/java/org/apache/tamaya/resource/ResourceLocator.java b/modules/resources/src/main/java/org/apache/tamaya/resource/ResourceLocator.java
deleted file mode 100644
index c301eea..0000000
--- a/modules/resources/src/main/java/org/apache/tamaya/resource/ResourceLocator.java
+++ /dev/null
@@ -1,37 +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.resource;
-
-import java.net.URL;
-import java.util.Collection;
-
-/**
- * Delegate interface for loading URLs from a given data resource locator pattern String.
- */
-public interface ResourceLocator {
-
- /**
- * Method to lookup a given list of URLs, identified by the given expression.
- * @param classLoader the classloader to be used, if necessary.
- * @param expression the expression.
- * @return a collection of URL found.
- */
- Collection<URL> lookup(ClassLoader classLoader, String expression);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resources/src/main/java/org/apache/tamaya/resource/ResourceResolver.java
----------------------------------------------------------------------
diff --git a/modules/resources/src/main/java/org/apache/tamaya/resource/ResourceResolver.java b/modules/resources/src/main/java/org/apache/tamaya/resource/ResourceResolver.java
deleted file mode 100644
index d27b38f..0000000
--- a/modules/resources/src/main/java/org/apache/tamaya/resource/ResourceResolver.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.resource;
-
-import java.net.URL;
-import java.util.Collection;
-
-/**
- * Interface to be implemented by modules. It supports loading of files or classpath resources either directly or by
- * defining an Ant-style resource pattern:
- * <ul>
- * <li>'*' is a placeholder for any character (0..n)</li>
- * <li>'**' is a placeholder for any number of subdirectories going down a directory structure recursively.</li>
- * <li>'?' is a placeholder for exact one character</li>
- * </ul>
- * Given that the following expressions are valid expressions:
- * <pre>
- * classpath:javax/annotations/*
- * javax?/annotations/**/*.class
- * org/apache/tamaya/**/tamayaconfig.properties
- * file:C:/temp/*.txt
- * file:C:\**\*.ini
- * C:\Programs\**/*.ini
- * /user/home/A*b101_?.pid
- * /var/logs/**/*.log
- * </pre>
- */
-public interface ResourceResolver {
-
- /**
- * Resolves resource expressions to a list of {@link URL}s. Hereby
- * the ordering of format matches the input of the resolved expressions. Nevertheless be aware that
- * there is no determined ordering of format located within a classloader.
- *
- * @param expressions the expressions to be resolved, not empty.
- * @return the corresponding collection of current {@link URL}s found, never
- * null.
- * .
- */
- Collection<URL> getResources(Collection<String> expressions);
-
- /**
- * Resolves resource expressions to a list of {@link URL}s. Hereby
- * the ordering of format matches the input of the resolved expressions. Nevertheless be aware that
- * there is no determined ordering of format located within a classloader.
- *
- * @param expressions the expressions to be resolved, not empty.
- * @return the corresponding collection of current {@link URL}s found, never
- * null.
- * .
- */
- Collection<URL> getResources(String... expressions);
-
- /**
- * Resolves resource expressions to a list of {@link URL}s, considerubg
- * the given classloader for classloader dependent format. Hereby
- * the ordering of format matches the input of the resolved expressions. Nevertheless be aware that
- * there is no determined ordering of format located within a classloader.
- *
- * @param classLoader classloader to use for resolving.
- * @param expressions the expressions to be resolved, not empty.
- * @return the corresponding collection of current {@link URL}s found, never {@code null}.
- */
- Collection<URL> getResources(ClassLoader classLoader, String... expressions);
-
- /**
- * Resolves resource expressions to a list of {@link URL}s, considerubg
- * the given classloader for classloader dependent format. Hereby
- * the ordering of format matches the input of the resolved expressions. Nevertheless be aware that
- * there is no determined ordering of format located within a classloader.
- *
- * @param classLoader classloader to use for resolving.
- * @param expressions the expressions to be resolved, not empty.
- * @return the corresponding collection of current {@link URL}s found,
- * never {@code null}.
- */
- Collection<URL> getResources(ClassLoader classLoader, Collection<String> expressions);
-
- /**
- * Access the currently registered {@link ResourceLocator} instances.
- * @return the currently known {@link ResourceLocator} instances, never null.
- */
- Collection<ResourceLocator> getResourceLocators();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resources/src/main/java/org/apache/tamaya/resource/internal/ClassPathResourceLocator.java
----------------------------------------------------------------------
diff --git a/modules/resources/src/main/java/org/apache/tamaya/resource/internal/ClassPathResourceLocator.java b/modules/resources/src/main/java/org/apache/tamaya/resource/internal/ClassPathResourceLocator.java
deleted file mode 100644
index 5a49d50..0000000
--- a/modules/resources/src/main/java/org/apache/tamaya/resource/internal/ClassPathResourceLocator.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.resource.internal;
-
-import org.apache.tamaya.resource.ResourceLocator;
-
-import javax.annotation.Priority;
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.logging.Logger;
-
-/**
- * Created by atsticks on 01.03.16.
- */
-@Priority(90)
-public class ClassPathResourceLocator implements ResourceLocator{
- /**
- * The logger used.
- */
- private static final Logger LOG = Logger.getLogger(ClassPathResourceLocator.class.getName());
-
- /**
- * Tries to evaluate the location passed by loading from the classloader.
- * @param classLoader the class loader to use
- * @param expression the path expression
- * @return the resources found.
- */
- @Override
- public Collection<URL> lookup(ClassLoader classLoader, String expression) {
- List<URL> resources = new ArrayList<>();
- try {
- Enumeration<URL> urls = classLoader.getResources(expression);
- while (urls.hasMoreElements()) {
- URL url = urls.nextElement();
- resources.add(url);
- }
- return resources;
- } catch (IOException | RuntimeException e) {
- LOG.finest("Failed to load resource from CP: " + expression);
- return Collections.emptySet();
- }
- }
-
- @Override
- public String toString() {
- return "ClassPathResourceLocator -> classpath:<expression>, e.g. classpath:META-INF/services/*Resolver";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resources/src/main/java/org/apache/tamaya/resource/internal/ClasspathCollector.java
----------------------------------------------------------------------
diff --git a/modules/resources/src/main/java/org/apache/tamaya/resource/internal/ClasspathCollector.java b/modules/resources/src/main/java/org/apache/tamaya/resource/internal/ClasspathCollector.java
deleted file mode 100644
index 4eb6b3e..0000000
--- a/modules/resources/src/main/java/org/apache/tamaya/resource/internal/ClasspathCollector.java
+++ /dev/null
@@ -1,381 +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.resource.internal;
-
-import java.io.File;
-import java.io.IOException;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.net.JarURLConnection;
-import java.net.MalformedURLException;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.*;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Collector that searches files based on Ant styled patterns. For example the following patterns would be matched:
- * <pre>
- * classpath:javax/annotations/*
- * javax?/annotations/**/*.class
- * org/apache/tamaya/**/tamayaconfig.properties
- * </pre>
- */
-public class ClasspathCollector {
-
- /**
- * JAR protocol.
- */
- private static final String PROTOCOL_JAR = "jar";
-
- /**
- * Separator between JAR file URL and the internal jar file path.
- */
- private static final String JAR_URL_SEPARATOR = "!/";
-
- /**
- * ZIP protocol.
- */
- private static final String PROTOCOL_ZIP = "zip";
-
- /**
- * ZIP protocol for a JBoss jar file entry: "vfszip".
- */
- private static final String PROTOCOL_VFSZIP = "vfszip";
-
- /**
- * URL protocol for an WebSphere jar file: "wsjar".
- */
- private static final String PROTOCOL_WSJAR = "wsjar";
-
- /**
- * URL protocol for an entry from an OC4J jar.
- */
- private static final String PROTOCOL_CODE_SOURCE = "code-source";
-
- /**
- * The logger used.
- */
- private static final Logger LOG = Logger.getLogger(ClasspathCollector.class.getName());
-
- /**
- * Prefix used for explicitly selecting this collector.
- */
- public static final String CLASSPATH_PREFIX = "classpath:";
-
- /**
- * The classloader used to load the resources.
- */
- private final ClassLoader classLoader;
-
- /**
- * Creates a new instance.
- *
- * @param classLoader the class loader to be used, not null.
- */
- public ClasspathCollector(ClassLoader classLoader) {
- this.classLoader = Objects.requireNonNull(classLoader);
- }
-
- /**
- * Collect all classpath resources given the expression.
- *
- * @param expression the expression, not null.
- * @return the resources found.
- */
- public Collection<URL> collectFiles(String expression) {
- if (expression.startsWith(CLASSPATH_PREFIX)) {
- expression = expression.substring(CLASSPATH_PREFIX.length());
- }
- if (expression.startsWith("/")) {
- expression = expression.substring(1);
- }
- Locator locator = Locator.of(expression);
- List<URL> result = new ArrayList<>();
- try {
- Enumeration<URL> rootResources = this.classLoader.getResources(locator.getRootPath());
- while (rootResources.hasMoreElements()) {
- URL resource = rootResources.nextElement();
- try {
- if (isJarFile(resource)) {
- result.addAll(doFindPathMatchingJarResources(resource, locator.getSubPath()));
- } else if (resource.getProtocol().startsWith(PROTOCOL_VFSZIP)) {
- result.addAll(findMatchingVfsResources(resource, locator.getSubPath()));
- } else {
- result.addAll(FileCollector.traverseAndSelectFromChildren(getFile(resource),
- locator.getSubPathTokens(), 0));
- }
- } catch (URISyntaxException | IOException e) {
- LOG.log(Level.SEVERE, "Error locating resources for: " + expression, e);
- }
- }
- } catch (IOException | RuntimeException e) {
- LOG.log(Level.SEVERE, "Error locating resources for: " + expression, e);
- }
- return result;
- }
-
-
- /**
- * Find all resources in jar files that match the given location pattern
- * via the Ant-style PathMatcher.
- *
- * @param rootDirResource the root directory as Resource
- * @param subPattern the sub pattern to match (below the root directory)
- * @return the Set of matching Resource instances
- * @throws java.io.IOException in case of I/O errors
- * @throws java.net.URISyntaxException in case of URL-related errors
- * @see java.net.JarURLConnection
- */
- protected Collection<URL> doFindPathMatchingJarResources(URL rootDirResource, String subPattern)
- throws IOException, URISyntaxException {
- subPattern = subPattern.replace("*", ".*").replace("?", ".?").replace(".*.*", ".*");
- URLConnection con = rootDirResource.toURI().toURL().openConnection();
- JarFile jarFile;
- boolean newJarFile = false;
- String jarFileUrl;
- String rootEntryPath;
- boolean isFileExpression = !subPattern.contains("/");
-
- if (con instanceof JarURLConnection) {
- JarURLConnection jarCon = (JarURLConnection) con;
- jarCon.setUseCaches(false);
- jarFile = jarCon.getJarFile();
- jarFileUrl = jarCon.getJarFileURL().toExternalForm();
- JarEntry jarEntry = jarCon.getJarEntry();
- rootEntryPath = (jarEntry != null ? jarEntry.getName() : "");
- } else {
- // No JarURLConnection -> need to resort to URL file parsing.
- // We'll assume URLs of the format "jar:path!/entry", with the protocol
- // being arbitrary as long as following the entry format.
- // We'll also handle paths with and without leading "file:" prefix.
- String urlFile = rootDirResource.toURI().toURL().getFile();
- int separatorIndex = urlFile.indexOf(JAR_URL_SEPARATOR);
- jarFileUrl = urlFile.substring(0, separatorIndex);
- if (jarFileUrl.startsWith("file:")) {
- jarFileUrl = jarFileUrl.substring("file:".length());
- }
- jarFile = new JarFile(jarFileUrl);
- newJarFile = true;
- jarFileUrl = "file:" + jarFileUrl;
- rootEntryPath = urlFile.substring(separatorIndex + JAR_URL_SEPARATOR.length());
- }
-
- try {
- if (LOG.isLoggable(Level.FINEST)) {
- LOG.finest("Looking for matching resources in jar file [" + jarFileUrl + "]");
- }
- if (!rootEntryPath.isEmpty() && !rootEntryPath.endsWith("/")) {
- // Root entry path must end with slash for correct matching
- rootEntryPath = rootEntryPath + '/';
- }
- Collection<URL> result = new ArrayList<>(10);
- for (Enumeration<JarEntry> entries = jarFile.entries(); entries.hasMoreElements(); ) {
- JarEntry entry = entries.nextElement();
- String entryPath = entry.getName();
- if (entryPath.startsWith(rootEntryPath)) {
- String relativePath = entryPath.substring(rootEntryPath.length());
- if (relativePath.contains("/") && isFileExpression) {
- continue;
- }
- if (relativePath.matches(subPattern)) {
- URL url = createRelativeFrom(rootDirResource, relativePath);
- if(!result.contains(url)) {
- result.add(url);
- }
- }
- }
- }
- return result;
- } finally {
- // Close jar file, but only if freshly obtained -
- // not from JarURLConnection, which might cache the file reference.
- if (newJarFile) {
- jarFile.close();
- }
- }
- }
-
- /**
- * Creates a new URL based on the given root path and the relative path to be added.
- *
- * @param url the root, not null
- * @param relativePath the relative path to be added, not null
- * @return the new URL instance
- * @throws MalformedURLException
- */
- private URL createRelativeFrom(URL url, String relativePath)
- throws MalformedURLException {
- String rootDirResource = url.toExternalForm();
- if (relativePath.startsWith("/")) {
- relativePath = relativePath.substring(1);
- }
- if (!rootDirResource.endsWith("/")) {
- rootDirResource = rootDirResource + '/';
- }
- return new URL(rootDirResource + relativePath);
- }
-
-
- /**
- * Small check if a given URL is a jar file URL.
- *
- * @param url the URL to check, not null.
- * @return true if the URL has one of the following protocols: jar, zip, vfszip, wsjar, code-source.
- */
- private boolean isJarFile(URL url) {
- String protocol = Objects.requireNonNull(url).getProtocol();
- return (PROTOCOL_JAR.equals(protocol) ||
- PROTOCOL_ZIP.equals(protocol) ||
- PROTOCOL_VFSZIP.equals(protocol) ||
- PROTOCOL_WSJAR.equals(protocol) ||
- (PROTOCOL_CODE_SOURCE.equals(protocol) && url.getPath().contains(JAR_URL_SEPARATOR)));
- }
-
- /**
- * Creates a file from an URL.
- *
- * @param resourceUrl the url, not null.
- * @return a new file instance. The instance still may not exist. if the url's protocol is not 'file', {@code null}
- * is returned.
- */
- private File getFile(URL resourceUrl) {
- Objects.requireNonNull(resourceUrl, "Resource URL must not be null");
- if (!"file".equals(resourceUrl.getProtocol())) {
- return null;
- }
- try {
- return new File(resourceUrl.toURI().getSchemeSpecificPart());
- } catch (Exception ex) {
- // Fallback for URLs that are not valid URIs (should hardly ever happen).
- return new File(resourceUrl.getFile());
- }
- }
-
- /**
- * Method that collects resources from a JBoss classloading system using Vfs.
- * @param rootResource the root resource for evaluating its children.
- * @param locationPattern the sub pattern that all children must mach, so they are selected.
- * @return the resources found, never null.
- * @throws IOException
- */
- private static Collection<URL> findMatchingVfsResources(
- URL rootResource, String locationPattern) throws IOException {
- Object root = VfsSupport.getRoot(rootResource);
- PatternVfsVisitor visitor =
- new PatternVfsVisitor(VfsSupport.getPath(root), locationPattern);
- VfsSupport.visit(root, visitor);
- return visitor.getResources();
- }
-
- /**
- * Simple dynamic visitor implementation used for evaluating paths from a JBoss Vfs system.
- */
- private static class PatternVfsVisitor implements InvocationHandler {
- /**
- * The regex pattern to match agains all child resources of the root path against.
- */
- private final String subPattern;
- /**
- * The resource path before yny placeholders/whitespaces are occurring.
- */
- private final String rootPath;
- /**
- * THe resources found so far.
- */
- private final List<URL> resources = new LinkedList<>();
-
- /**
- * Creates a new visitor for cfs resources.
- *
- * @param rootPath the root path, until any patterns are occurring.
- * @param subPattern the sub pattern for looking for.
- */
- public PatternVfsVisitor(String rootPath, String subPattern) {
- this.subPattern = subPattern;
- this.rootPath = (rootPath.length() == 0 || rootPath.endsWith("/") ? rootPath : rootPath + "/");
- }
-
- /**
- * Method called by visitor proxy.
- *
- * @param proxy the proxy instance.
- * @param method the method called.
- * @param args any arguments.
- * @return the result.
- * @throws Throwable in case something goes wrong.
- */
- @Override
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
- String methodName = method.getName();
- if (Object.class.equals(method.getDeclaringClass())) {
- if (methodName.equals("equals")) {
- // Only consider equal when proxies are identical.
- return (proxy == args[0]);
- } else if (methodName.equals("hashCode")) {
- return System.identityHashCode(proxy);
- }
- } else if ("getAttributes".equals(methodName)) {
- return VfsSupport.getVisitorAttributes();
- } else if ("visit".equals(methodName)) {
- visit(args[0]);
- return null;
- } else if ("toString".equals(methodName)) {
- return toString();
- }
-
- throw new IllegalStateException("Unexpected method invocation: " + method);
- }
-
- /**
- * Visitor method.
- *
- * @param vfsResource the vfsResource object.
- */
- public void visit(Object vfsResource) {
- String subPath = VfsSupport.getPath(vfsResource).substring(this.rootPath.length());
- if (subPath.matches(this.subPattern)) {
- try {
- this.resources.add(VfsSupport.getURL(vfsResource));
- } catch (Exception e) {
- LOG.log(Level.WARNING, "Failed to convert vfs resource to URL: " + vfsResource, e);
- }
- }
- }
-
- /**
- * Access the resources found from Vfs during last visit.
- *
- * @return the resources found, not null.
- */
- public Collection<URL> getResources() {
- return this.resources;
- }
-
- @Override
- public String toString() {
- return "sub-pattern: " + this.subPattern + ", resources: " + this.resources;
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resources/src/main/java/org/apache/tamaya/resource/internal/DefaultResourceResolver.java
----------------------------------------------------------------------
diff --git a/modules/resources/src/main/java/org/apache/tamaya/resource/internal/DefaultResourceResolver.java b/modules/resources/src/main/java/org/apache/tamaya/resource/internal/DefaultResourceResolver.java
deleted file mode 100644
index 99e7b3f..0000000
--- a/modules/resources/src/main/java/org/apache/tamaya/resource/internal/DefaultResourceResolver.java
+++ /dev/null
@@ -1,60 +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.resource.internal;
-
-import org.apache.tamaya.resource.BaseResourceResolver;
-import org.apache.tamaya.resource.ResourceLocator;
-import org.apache.tamaya.spi.ServiceContextManager;
-
-import javax.annotation.Priority;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.logging.Logger;
-
-/**
- * Simple default implementation of the resource loader, which does only support direct references to files.
- */
-@Priority(0)
-public class DefaultResourceResolver extends BaseResourceResolver {
-
- private static final Logger LOG = Logger.getLogger(DefaultResourceResolver.class.getName());
-
- @Override
- public List<URL> getResources(ClassLoader classLoader, Collection<String> expressions) {
- List<URL> resources = new ArrayList<>();
- for (String expression : expressions) {
- for(ResourceLocator locator: getResourceLocators()){
- Collection<URL> found = locator.lookup(classLoader, expression);
- if(!found.isEmpty()) {
- resources.addAll(found);
- break;
- }
- }
- }
- return resources;
- }
-
- @Override
- public Collection<ResourceLocator> getResourceLocators() {
- return ServiceContextManager.getServiceContext().getServices(ResourceLocator.class);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resources/src/main/java/org/apache/tamaya/resource/internal/FileCollector.java
----------------------------------------------------------------------
diff --git a/modules/resources/src/main/java/org/apache/tamaya/resource/internal/FileCollector.java b/modules/resources/src/main/java/org/apache/tamaya/resource/internal/FileCollector.java
deleted file mode 100644
index eccb873..0000000
--- a/modules/resources/src/main/java/org/apache/tamaya/resource/internal/FileCollector.java
+++ /dev/null
@@ -1,178 +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.resource.internal;
-
-import java.io.File;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Objects;
-import java.util.logging.Logger;
-
-/**
- * Collector that searches files based on ant styled patterns. For example the following patterns would be matched:
- * <pre>
- * file:C:/temp/*.txt
- * file:C:\**\*.ini
- * C:\Programs\**/*.ini
- * /user/home/A*b101_?.pid
- * /var/logs/**/*.log
- * </pre>
- */
-public class FileCollector {
- /** The prefix used to explicitly select this collector. */
- public static final String FILE_PREFIX = "file:";
-
- /** The logger instance. */
- private static final Logger LOG = Logger.getLogger(FileCollector.class.getName());
-
- /**
- * private constructor.
- */
- private FileCollector() {
- }
-
- /**
- * Collects the files given the expression.
- * @param expression the expression in Ant-styled format, not null.
- * @return the URLs found.
- */
- public static Collection<URL> collectFiles(String expression) {
- expression = expression.replace("\\", "/");
- Locator locator = Locator.of(expression);
- List<URL> result = new ArrayList<>();
- String rootPath = locator.getRootPath();
- if (rootPath.startsWith(FILE_PREFIX)) {
- rootPath = rootPath.substring(FILE_PREFIX.length());
- }
- File file = new File(rootPath);
- if (file.exists()) {
- List<String> subTokens = locator.getSubPathTokens();
- result.addAll(traverseAndSelectFromChildren(file, subTokens, 0));
- }
- return result;
- }
-
- /**
- * Internal method to traverse the file system down, hereby comparing the new path elements with the
- * elements given by {@code subTokens}, starting at the given {@code tokenIndex}.
- * @param dir the directory to start
- * @param subTokens the overall subtoken to be analyzed
- * @param tokenIndex the index where in the token list to start comparing
- * @return the URLs matching the tokens
- */
- static Collection<URL> traverseAndSelectFromChildren(File dir, List<String> subTokens, int tokenIndex) {
- if (tokenIndex >= subTokens.size() || dir.isFile() || !dir.isDirectory()) {
- return Collections.emptyList();
- }
- List<URL> result = new ArrayList<>();
- String token = subTokens.get(tokenIndex);
- if (token.equals("**")) {
- result.addAll(traverseAndSelectFromChildren(dir, getSubExpression(subTokens, tokenIndex + 1)));
- } else {
- token = token.replace("*", ".*").replace("?", ".?");
- File[] files = dir.listFiles();
- if (tokenIndex == subTokens.size() - 1) {
- // select files!
- if(files!=null) {
- for (File f : files) {
- if (f.isFile() && f.getName().matches(token)) {
- result.add(getURL(f));
- }
- }
- }
- } else {
- // check directory pattern
- if(files!=null) {
- for (File f : files) {
- if (f.isDirectory() && f.getName().matches(token)) {
- result.addAll(traverseAndSelectFromChildren(f, subTokens, tokenIndex + 1));
- }
- }
- }
- }
- }
- return result;
- }
-
- /**
- * Internal method to traverse the file system and comparing all child file names with the given expression.
- * @param file the root directory
- * @param expression the regular expression to match
- * @return the URLs matching the expression
- */
- static Collection<URL> traverseAndSelectFromChildren(File file, String expression) {
- List<URL> result = new ArrayList<>();
- File[] files = file.listFiles();
- if(files==null){
- return result;
- }
- for (File childFile : files) {
- if (childFile.isFile()) {
- if (childFile.getName().matches(expression)) {
- try {
- result.add(getURL(childFile));
- } catch (Exception e) {
- LOG.warning("File not convertible to URL: " + childFile);
- }
- }
- } else if (childFile.isDirectory()) {
- result.addAll(traverseAndSelectFromChildren(childFile, expression));
- }
- }
- return result;
- }
-
- /**
- * Get an URL from a file.
- *
- * @param file the file, not null.
- * @return the URL, never null.
- * @throws java.lang.IllegalStateException if it fails to create the URL
- */
- private static URL getURL(File file) {
- Objects.requireNonNull(file);
- try {
- return file.toURI().toURL();
- } catch (Exception e) {
- throw new IllegalStateException("Failed to create URL from file: " + file);
- }
- }
-
- /**
- * Constructs a sub expression, using the tokens from {@code subTokens} starting at index {@code startIndex}.
- *
- * @param subTokens the token list, not null
- * @param startIndex the start index from where tokens should be taken to produce the path.
- * @return the constructed path, never null.
- */
- private static String getSubExpression(List<String> subTokens, int startIndex) {
- StringBuilder b = new StringBuilder();
- for (int i = startIndex; i < subTokens.size(); i++) {
- b.append(subTokens.get(i));
- b.append('/');
- }
- if (b.length() > 0) {
- b.setLength(b.length() - 1);
- }
- return b.toString().replaceAll("\\*", ".*").replaceAll("\\?", ".?");
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resources/src/main/java/org/apache/tamaya/resource/internal/FileResourceLocator.java
----------------------------------------------------------------------
diff --git a/modules/resources/src/main/java/org/apache/tamaya/resource/internal/FileResourceLocator.java b/modules/resources/src/main/java/org/apache/tamaya/resource/internal/FileResourceLocator.java
deleted file mode 100644
index a58b414..0000000
--- a/modules/resources/src/main/java/org/apache/tamaya/resource/internal/FileResourceLocator.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.resource.internal;
-
-import org.apache.tamaya.resource.ResourceLocator;
-
-import javax.annotation.Priority;
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.logging.Logger;
-
-/**
- * {@link ResourceLocator} for locating local files.
- */
-@Priority(80)
-public class FileResourceLocator implements ResourceLocator{
- /**
- * The logger used.
- */
- private static final Logger LOG = Logger.getLogger(FileResourceLocator.class.getName());
-
- /**
- * Tries to evaluate the location passed by loading from the classloader.
- * @param classLoader the class loader to use
- * @param expression the path expression
- * @return the resources found.
- */
- @Override
- public Collection<URL> lookup(ClassLoader classLoader, String expression) {
- List<URL> resources = new ArrayList<>();
- try {
- File file = new File(expression);
- if (file.exists()) {
- resources.add(file.toURI().toURL());
- }
- return resources;
- } catch (IOException | RuntimeException e) {
- LOG.finest("Failed to load resource from file: " + expression);
- return Collections.emptySet();
- }
- }
-
- @Override
- public String toString() {
- return "FileResourceLocator -> file:<expression>, e.g. file:./config/**/*.xml";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resources/src/main/java/org/apache/tamaya/resource/internal/Locator.java
----------------------------------------------------------------------
diff --git a/modules/resources/src/main/java/org/apache/tamaya/resource/internal/Locator.java b/modules/resources/src/main/java/org/apache/tamaya/resource/internal/Locator.java
deleted file mode 100644
index 0c757fa..0000000
--- a/modules/resources/src/main/java/org/apache/tamaya/resource/internal/Locator.java
+++ /dev/null
@@ -1,155 +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.resource.internal;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Small helper class that manages the path parts of a location expression.
- */
-final class Locator {
- /**
- * The tokenized location expression.
- */
- private final List<String> tokens;
-
- /**
- * Creates a new instances based on the tokenized expression.
- *
- * @param tokens the tokenized expression, not null.
- */
- Locator(List<String> tokens) {
- this.tokens = tokens;
- }
-
- /**
- * Creates a new instance of the corresponding expression.
- *
- * @param expression the location expression, not null.
- * @return the tokenized instance.
- */
- public static Locator of(String expression) {
- List<String> expressions = new ArrayList<>();
- for (String expr : expression.split("/")) {
- if(expr.length()==0) {
- expressions.add("/");
- } else{
- expressions.add(expr);
- }
- }
- return new Locator(expressions);
- }
-
- /**
- * Access the root path, which is the location expression, before any wildcards or placeholders are used.
- * It is used as the entry point into the file system or for accessing base classpath resources, before
- * further analysis on the file or jar filesystem can be performed.
- *
- * @return the root path, never null.
- */
- public String getRootPath() {
- StringBuilder sj = new StringBuilder();
- for (String token : this.tokens) {
- if (containsPlaceholder(token)) {
- break;
- } else {
- if(!(sj.length()==0)) {
- sj.append('/');
- }
- sj.append(token);
- }
- }
- return sj.toString();
- }
-
- /**
- * Return the sub expression path, which contains the second part of the expression, starting with a placeholder
- * or wildcard token.
- *
- * @return the sub expression part, never null.
- */
- public String getSubPath() {
- StringBuilder sj = new StringBuilder();
- for (String token : getSubPathTokens()) {
- if(!(sj.length()==0)) {
- sj.append('/');
- }
- sj.append(token);
- }
- return sj.toString();
- }
-
- /**
- * This method returns the single tokenized form of the sub expression.
- *
- * @return the tokenized version of the sub path.
- * @see #getSubPath()
- */
- public List<String> getSubPathTokens() {
- List<String> subTokens = new ArrayList<>();
- boolean subTokensStarted = false;
- for (String token : tokens) {
- if(subTokensStarted){
- subTokens.add(token);
- } else if (containsPlaceholder(token)) {
- subTokensStarted = true;
- subTokens.add(token);
- }
- }
- return subTokens;
- }
-
- /**
- * Access the full reconstructed path. In most cases this should match the original expression.
- *
- * @return the full expression path, never null.
- */
- public String getPath() {
- StringBuilder sj = new StringBuilder();
- for (String token : tokens) {
- if(!(sj.length()==0)) {
- sj.append('/');
- }
- sj.append(token);
- }
- return sj.toString();
- }
-
- /**
- * Short method that checks for '*' and '?' chars.
- *
- * @param token the token to check, not null
- * @return true, if it contains wildcard characters.
- */
- private boolean containsPlaceholder(String token) {
- return token.contains("*") || token.contains("?");
- }
-
- /**
- * Return the expressions' path.
- *
- * @return the locator path.
- */
- @Override
- public String toString() {
- return "Locator: " + getPath();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resources/src/main/java/org/apache/tamaya/resource/internal/PathResourceLocator.java
----------------------------------------------------------------------
diff --git a/modules/resources/src/main/java/org/apache/tamaya/resource/internal/PathResourceLocator.java b/modules/resources/src/main/java/org/apache/tamaya/resource/internal/PathResourceLocator.java
deleted file mode 100644
index e649e3b..0000000
--- a/modules/resources/src/main/java/org/apache/tamaya/resource/internal/PathResourceLocator.java
+++ /dev/null
@@ -1,65 +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.resource.internal;
-
-import org.apache.tamaya.resource.ResourceLocator;
-
-import javax.annotation.Priority;
-import java.net.URL;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.logging.Logger;
-
-/**
- * Created by atsticks on 01.03.16.
- */
-@Priority(100)
-public class PathResourceLocator implements ResourceLocator{
- /**
- * The logger used.
- */
- private static final Logger LOG = Logger.getLogger(PathResourceLocator.class.getName());
-
- /**
- * Tries to evaluate the location passed by Ant path matching.
- * @param classLoader the class loader to use
- * @param expression the path expression
- * @return true, if the expression could be resolved.
- */
- @Override
- public Collection<URL> lookup(ClassLoader classLoader, String expression) {
- try {
- // 1: try file path
- Collection<URL> found = FileCollector.collectFiles(expression);
- if (found.isEmpty()) {
- found = new ClasspathCollector(classLoader).collectFiles(expression);
- }
- return found;
- } catch (RuntimeException e) {
- LOG.finest("Failed to load resource from CP: " + expression);
- return Collections.emptySet();
- }
- }
-
- @Override
- public String toString() {
- return "PathResourceLocator -> <fileExpression>,<classpathExpression>, e.g. /**/*.xml";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resources/src/main/java/org/apache/tamaya/resource/internal/URLResourceLocator.java
----------------------------------------------------------------------
diff --git a/modules/resources/src/main/java/org/apache/tamaya/resource/internal/URLResourceLocator.java b/modules/resources/src/main/java/org/apache/tamaya/resource/internal/URLResourceLocator.java
deleted file mode 100644
index 53ef00a..0000000
--- a/modules/resources/src/main/java/org/apache/tamaya/resource/internal/URLResourceLocator.java
+++ /dev/null
@@ -1,66 +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.resource.internal;
-
-import org.apache.tamaya.resource.ResourceLocator;
-
-import javax.annotation.Priority;
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.logging.Logger;
-
-/**
- * {@link ResourceLocator} for locating URL resources..
- */
-@Priority(70)
-public class URLResourceLocator implements ResourceLocator{
- /**
- * The logger used.
- */
- private static final Logger LOG = Logger.getLogger(URLResourceLocator.class.getName());
-
- /**
- * Tries to evaluate the location passed by loading from the classloader.
- * @param classLoader the class loader to use
- * @param expression the path expression
- * @return the resources found.
- */
- @Override
- public Collection<URL> lookup(ClassLoader classLoader, String expression) {
- List<URL> resources = new ArrayList<>();
- try {
- URL url = new URL(expression);
- resources.add(url);
- return resources;
- } catch (IOException | RuntimeException e) {
- LOG.finest("Failed to load resource from file: " + expression);
- return Collections.emptySet();
- }
- }
-
- @Override
- public String toString() {
- return "URLResourceLocator -> <url>";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resources/src/main/java/org/apache/tamaya/resource/internal/VfsSupport.java
----------------------------------------------------------------------
diff --git a/modules/resources/src/main/java/org/apache/tamaya/resource/internal/VfsSupport.java b/modules/resources/src/main/java/org/apache/tamaya/resource/internal/VfsSupport.java
deleted file mode 100644
index 7e75c99..0000000
--- a/modules/resources/src/main/java/org/apache/tamaya/resource/internal/VfsSupport.java
+++ /dev/null
@@ -1,252 +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.resource.internal;
-
-import java.io.File;
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.Objects;
-
-/**
- * Internal support class dealing with JBoss VFS in the classpath.
- * <p>
- * This code is compatible with JBoss AS 6+ and JBoss AS 7 and
- * WildFly 8.
- */
-class VfsSupport {
-
- private static final String VFS3_PKG = "org.jboss.vfs.";
- private static final String VFS_PROTOCOL = "VFS";
-
- private static Method methodGetRootUrl = null;
- private static Method methodToUrl;
- private static Method methodGetPathName;
- private static Class<?> fileVisitorInterface;
- private static Method methodVisit;
- private static Field visitorAttributesField = null;
- private static Method methodGetPhysicalFile = null;
-
- /**
- * Private constructor.
- */
- private VfsSupport(){}
-
- /*
- * Initialize glue reflection code for communicating with VFS systems.
- */
- static {
- ClassLoader loader = VfsSupport.class.getClassLoader();
- try {
- Class<?> vfsClass = loader.loadClass(VFS3_PKG + VFS_PROTOCOL);
- methodGetRootUrl = findMethod(vfsClass, "getChild", URL.class);
- Class<?> virtualFile = loader.loadClass(VFS3_PKG + "VirtualFile");
- methodToUrl = findMethod(virtualFile, "toURL");
- methodGetPathName = findMethod(virtualFile, "getPathName");
- methodGetPhysicalFile = findMethod(virtualFile, "getPhysicalFile");
- fileVisitorInterface = loader.loadClass(VFS3_PKG + "VirtualFileVisitor");
- methodVisit = findMethod(virtualFile, "visit", fileVisitorInterface);
- Class<?> visitorAttributesClass = loader.loadClass(VFS3_PKG + "VisitorAttributes");
- visitorAttributesField = findField(visitorAttributesClass, "RECURSE");
- } catch (ClassNotFoundException ex) {
- throw new IllegalStateException("JBoss VFS not available.", ex);
- }
- }
-
- /**
- * Visit a VFS resource with the given visitor, modeled as dynamic {@link java.lang.reflect.InvocationHandler}.
- *
- * @param resource the resource
- * @param visitor the visitor.
- * @throws IOException
- */
- static void visit(Object resource, InvocationHandler visitor) throws IOException {
- Object visitorProxy = Proxy.newProxyInstance(
- fileVisitorInterface.getClassLoader(),
- new Class<?>[]{fileVisitorInterface}, visitor);
- invokeVfsMethod(methodVisit, resource, visitorProxy);
- }
-
- /**
- * Helper method to invoke an operation on VFS.
- *
- * @param method the method to invoke
- * @param target the target instance
- * @param args any arguments
- * @return the result
- * @throws IOException if something fails.
- */
- private static Object invokeVfsMethod(Method method, Object target, Object... args) throws IOException {
- try {
- return method.invoke(target, args);
- } catch (Exception ex) {
- throw new IOException("Failed to evaluated method: " + method, ex);
- }
-
- }
-
- /**
- * Transform a VFS resource into an URL.
- *
- * @param vfsResource the cfw resource, not null
- * @return the corresponding URL
- * @throws IOException
- */
- static URL getURL(Object vfsResource) throws IOException {
- return (URL) invokeVfsMethod(methodToUrl, vfsResource);
- }
-
- /**
- * Get a to root VFS resource for the given URL.
- *
- * @param url the url
- * @return the corresponding VFS resource.
- * @throws IOException
- */
- static Object getRelative(URL url) throws IOException {
- return invokeVfsMethod(methodGetRootUrl, null, url);
- }
-
- /**
- * Transform the given VFS resource of a file.
- *
- * @param vfsResource the VFS resource
- * @return the file.
- * @throws IOException
- */
- static File getFile(Object vfsResource) throws IOException {
- return (File) invokeVfsMethod(methodGetPhysicalFile, vfsResource);
- }
-
- /**
- * Convert the given URL to the correspinoding root URL.
- *
- * @param url the url
- * @return the root resource.
- * @throws IOException
- */
- static Object getRoot(URL url) throws IOException {
- return invokeVfsMethod(methodGetRootUrl, null, url);
- }
-
- /**
- * Access the attributes from the current visitor context.
- *
- * @return the attributes.
- */
- static Object getVisitorAttributes() {
- return readField(visitorAttributesField, null);
- }
-
- /**
- * Access the corresponding path to the given VFS resource.
- *
- * @param resource the VFS resource
- * @return the corresponding path.
- */
- static String getPath(Object resource) {
- try {
- return (String) methodGetPathName.invoke(resource);
- } catch (Exception e) {
- throw new IllegalStateException("Failed to get path name - " + resource, e);
- }
- }
-
-
- /**
- * Attempt to find a {@link Method} on the supplied class with the supplied name
- * and parameter types. Searches all superclasses up to {@code Object}.
- * <p>Returns {@code null} if no {@link Method} can be found.
- *
- * @param clazz the class to introspect
- * @param name the name of the method
- * @param paramTypes the parameter types of the method
- * (may be {@code null} to indicate any signature)
- * @return the Method object, or {@code null} if none found
- */
- private static Method findMethod(Class<?> clazz, String name, Class<?>... paramTypes) {
- Objects.requireNonNull(clazz, "Class must not be null");
- Objects.requireNonNull(name, "Method name must not be null");
- Class<?> searchType = clazz;
- while (searchType != null) {
- Method[] methods = (searchType.isInterface() ? searchType.getMethods() : searchType.getDeclaredMethods());
- for (Method method : methods) {
- if (name.equals(method.getName()) &&
- (paramTypes == null || Arrays.equals(paramTypes, method.getParameterTypes()))) {
- return method;
- }
- }
- searchType = searchType.getSuperclass();
- }
- return null;
- }
-
-
- /**
- * Get the field represented by the supplied {@link Field field object} on the
- * specified {@link Object target object}. In accordance with {@link Field#get(Object)}
- * semantics, the returned value is automatically wrapped if the underlying field
- * has a primitive type.
- * <p>Thrown exceptions are rethrown as {@link IllegalStateException}.
- *
- * @param field the field to get
- * @param target the target object from which to get the field
- * @return the field's current value
- */
- private static Object readField(Field field, Object target) {
- try {
- if (!field.isAccessible()) {
- field.setAccessible(true);
- }
- return field.get(target);
- } catch (Exception e) {
- throw new IllegalStateException(
- "Failed to read field: " + field.toGenericString(), e);
- }
- }
-
- /**
- * Attempt to find a {@link Field field} on the supplied {@link Class} with the
- * supplied {@code name}. Searches all superclasses up to {@link Object}.
- *
- * @param clazz the class to introspect
- * @param name the name of the field
- * @return the corresponding Field object, or {@code null} if not found
- */
- private static Field findField(Class<?> clazz, String name) {
- Objects.requireNonNull(clazz, "Class must not be null");
- Objects.requireNonNull(name, "Name must not be null.");
- Class<?> searchType = clazz;
- while (!Object.class.equals(searchType) && searchType != null) {
- Field[] fields = searchType.getDeclaredFields();
- for (Field field : fields) {
- if (name.equals(field.getName())) {
- return field;
- }
- }
- searchType = searchType.getSuperclass();
- }
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resources/src/main/java/org/apache/tamaya/resource/internal/package-info.java
----------------------------------------------------------------------
diff --git a/modules/resources/src/main/java/org/apache/tamaya/resource/internal/package-info.java b/modules/resources/src/main/java/org/apache/tamaya/resource/internal/package-info.java
deleted file mode 100644
index b166853..0000000
--- a/modules/resources/src/main/java/org/apache/tamaya/resource/internal/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-/**
- * Contains the default implementation of the resources module, including special support for
- * JBoss app servers (VFS).
- */
-package org.apache.tamaya.resource.internal;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resources/src/main/java/org/apache/tamaya/resource/package-info.java
----------------------------------------------------------------------
diff --git a/modules/resources/src/main/java/org/apache/tamaya/resource/package-info.java b/modules/resources/src/main/java/org/apache/tamaya/resource/package-info.java
deleted file mode 100644
index 37678a8..0000000
--- a/modules/resources/src/main/java/org/apache/tamaya/resource/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-/**
- * Contains the resources module API.
- */
-package org.apache.tamaya.resource;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resources/src/main/resources/META-INF/services/org.apache.tamaya.resource.ResourceLocator
----------------------------------------------------------------------
diff --git a/modules/resources/src/main/resources/META-INF/services/org.apache.tamaya.resource.ResourceLocator b/modules/resources/src/main/resources/META-INF/services/org.apache.tamaya.resource.ResourceLocator
deleted file mode 100644
index 6d5b094..0000000
--- a/modules/resources/src/main/resources/META-INF/services/org.apache.tamaya.resource.ResourceLocator
+++ /dev/null
@@ -1,22 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy 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.resource.internal.ClassPathResourceLocator
-org.apache.tamaya.resource.internal.FileResourceLocator
-org.apache.tamaya.resource.internal.PathResourceLocator
-org.apache.tamaya.resource.internal.URLResourceLocator
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resources/src/main/resources/META-INF/services/org.apache.tamaya.resource.ResourceResolver
----------------------------------------------------------------------
diff --git a/modules/resources/src/main/resources/META-INF/services/org.apache.tamaya.resource.ResourceResolver b/modules/resources/src/main/resources/META-INF/services/org.apache.tamaya.resource.ResourceResolver
deleted file mode 100644
index aacd0d5..0000000
--- a/modules/resources/src/main/resources/META-INF/services/org.apache.tamaya.resource.ResourceResolver
+++ /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.resource.internal.DefaultResourceResolver
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resources/src/test/java/org/apache/tamaya/resource/AbstractPathPropertySourceProviderTest.java
----------------------------------------------------------------------
diff --git a/modules/resources/src/test/java/org/apache/tamaya/resource/AbstractPathPropertySourceProviderTest.java b/modules/resources/src/test/java/org/apache/tamaya/resource/AbstractPathPropertySourceProviderTest.java
deleted file mode 100644
index 8fe1b2b..0000000
--- a/modules/resources/src/test/java/org/apache/tamaya/resource/AbstractPathPropertySourceProviderTest.java
+++ /dev/null
@@ -1,133 +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.resource;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-import org.apache.tamaya.spi.PropertyValueBuilder;
-import org.junit.Test;
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-public class AbstractPathPropertySourceProviderTest {
-
- private final AbstractPathPropertySourceProvider myProvider = new AbstractPathPropertySourceProvider("*.properties") {
- @Override
- protected Collection<PropertySource> getPropertySources(URL url) {
- List<PropertySource> result = new ArrayList<>();
- result.add(new EmptyPropertySource());
- return result;
- }
- };
-
- @Test
- public void testGetPropertySources() throws Exception {
- assertNotNull(myProvider.getPropertySources());
- }
-
- @Test
- public void testCreatePropertiesPropertySource() throws Exception {
- PropertySource ps = AbstractPathPropertySourceProvider.createPropertiesPropertySource(
- ClassLoader.getSystemClassLoader().getResource("test.properties")
- );
- assertNotNull(ps);
- assertTrue(ps.getProperties().isEmpty());
- }
-
- private static final class EmptyPropertySource implements PropertySource {
- /**
- * Lookup order:
- * TODO rethink whole default PropertySources and ordering:
- * TODO introduce default values or constants for ordinals
- * <ol>
- * <li>System properties (ordinal 400)</li>
- * <li>Environment properties (ordinal 300)</li>
- * <li>JNDI values (ordinal 200)</li>
- * <li>Properties file values (/META-INF/applicationConfiguration.properties) (ordinal 100)</li>
- * </ol>
- * <p/>
- * <p><b>Important Hints for custom implementations</b>:</p>
- * <p>
- * If a custom implementation should be invoked <b>before</b> the default implementations, use a value > 400
- * </p>
- * <p>
- * If a custom implementation should be invoked <b>after</b> the default implementations, use a value < 100
- * </p>
- * <p/>
- * <p>Reordering of the default order of the config-sources:</p>
- * <p>Example: If the properties file/s should be used <b>before</b> the other implementations,
- * you have to configure an ordinal > 400. That means, you have to add e.g. deltaspike_ordinal=401 to
- * /META-INF/apache-deltaspike.properties . Hint: In case of property files every file is handled as independent
- * config-source, but all of them have ordinal 400 by default (and can be reordered in a fine-grained manner.</p>
- *
- * @return the 'importance' aka ordinal of the configured values. The higher, the more important.
- */
- public int getOrdinal() {
- PropertyValue configuredOrdinal = get(TAMAYA_ORDINAL);
- if (configuredOrdinal != null) {
- try {
- return Integer.parseInt(configuredOrdinal.getValue());
- } catch (Exception e) {
- Logger.getLogger(getClass().getName()).log(Level.WARNING,
- "Configured Ordinal is not an int number: " + configuredOrdinal, e);
- }
- }
- return getDefaultOrdinal();
- }
-
- /**
- * Returns the default ordinal used, when no ordinal is set, or the ordinal was not parseable to an int value.
- *
- * @return the default ordinal used, by default 0.
- */
- public int getDefaultOrdinal() {
- return 0;
- }
-
- @Override
- public String getName() {
- return "<empty>";
- }
-
- @Override
- public PropertyValue get(String key) {
- return null;
- }
-
- @Override
- public Map<String, String> getProperties() {
- return Collections.emptyMap();
- }
-
- @Override
- public boolean isScannable() {
- return true;
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resources/src/test/java/org/apache/tamaya/resource/internal/ClasspathCollectorTest.java
----------------------------------------------------------------------
diff --git a/modules/resources/src/test/java/org/apache/tamaya/resource/internal/ClasspathCollectorTest.java b/modules/resources/src/test/java/org/apache/tamaya/resource/internal/ClasspathCollectorTest.java
deleted file mode 100644
index ccdc7bc..0000000
--- a/modules/resources/src/test/java/org/apache/tamaya/resource/internal/ClasspathCollectorTest.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.resource.internal;
-
-import org.junit.Ignore;
-
-import java.net.URL;
-import java.util.Collection;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * This tests is using testing the classpath collector functionality, either by accessing/searching entries
- * from the java.annotation jar as well from the current (file-based classpath).
- */
-@Ignore
-// Tests work within IDE, but not with maven...
-public class ClasspathCollectorTest {
-
- @org.junit.Test
- public void testCollectAllClasses() throws Exception {
- ClasspathCollector cpc = new ClasspathCollector(ClassLoader.getSystemClassLoader());
- Collection<URL> found = cpc.collectFiles("classpath:javax/annotation/*.class");
- assertEquals(8, found.size()); // 7 ordinary, 1 inner class.
- Collection<URL> found2 = cpc.collectFiles("javax/annotation/*.class");
- assertEquals(found, found2);
- }
-
- @org.junit.Test
- public void testCollectAllInPackage() throws Exception {
- ClasspathCollector cpc = new ClasspathCollector(ClassLoader.getSystemClassLoader());
- Collection<URL> found = cpc.collectFiles("classpath:javax/**/sql/*.class");
- assertEquals(2, found.size());
- Collection<URL> found2 = cpc.collectFiles("javax/**/sql/*.class");
- assertEquals(found, found2);
- }
-
- @org.junit.Test
- public void testCollectClassNames() throws Exception {
- ClasspathCollector cpc = new ClasspathCollector(ClassLoader.getSystemClassLoader());
- Collection<URL> found = cpc.collectFiles("classpath:javax/annotation/**/R*.class");
- assertEquals(2, found.size());
- Collection<URL> found2 = cpc.collectFiles("javax/annotation/**/R*.class");
- assertEquals(found, found2);
- }
-
- @org.junit.Test
- public void testCollectWithExpression() throws Exception {
- ClasspathCollector cpc = new ClasspathCollector(ClassLoader.getSystemClassLoader());
- Collection<URL> found = cpc.collectFiles("classpath:javax/annotation/R?so*.class");
- assertEquals(3, found.size());
- Collection<URL> found2 = cpc.collectFiles("javax/annotation/R?so*.class");
- assertEquals(found, found2);
- }
-
- @org.junit.Test
- public void testCollectResources() throws Exception {
- ClasspathCollector cpc = new ClasspathCollector(ClassLoader.getSystemClassLoader());
- Collection<URL> found = cpc.collectFiles("classpath:META-INF/maven/org.apache.geronimo.specs/**/*");
- assertEquals(3, found.size());
- Collection<URL> found2 = cpc.collectFiles("META-INF/maven/org.apache.geronimo.specs/**/*");
- assertEquals(found, found2);
- }
-
- @org.junit.Test
- public void testCollectResourcesFromLocalFSPath() throws Exception {
- ClasspathCollector cpc = new ClasspathCollector(ClassLoader.getSystemClassLoader());
- Collection<URL> found = cpc.collectFiles("classpath:resources_testroot/**/*.file");
- assertEquals(7, found.size());
- Collection<URL> found2 = cpc.collectFiles("resources_testroot/**/*.file");
- assertEquals(found, found2);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resources/src/test/java/org/apache/tamaya/resource/internal/DefaultResourceResolverTest.java
----------------------------------------------------------------------
diff --git a/modules/resources/src/test/java/org/apache/tamaya/resource/internal/DefaultResourceResolverTest.java b/modules/resources/src/test/java/org/apache/tamaya/resource/internal/DefaultResourceResolverTest.java
deleted file mode 100644
index 7729e2c..0000000
--- a/modules/resources/src/test/java/org/apache/tamaya/resource/internal/DefaultResourceResolverTest.java
+++ /dev/null
@@ -1,59 +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.resource.internal;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.File;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.Collection;
-
-import org.junit.Test;
-
-/**
- * Tests the {@link org.apache.tamaya.resource.internal.DefaultResourceResolver} using CP and FS path expressions.
- */
-public class DefaultResourceResolverTest {
-
- private final DefaultResourceResolver resolver = new DefaultResourceResolver();
-
-
- @Test
- public void testGetResources_CP() throws Exception {
- Collection<URL> found = resolver.getResources("classpath:resources_testroot/**/*.file");
- assertEquals(7, found.size());
- Collection<URL> found2 = resolver.getResources("resources_testroot/**/*.file");
- assertEquals(found, found2);
- }
-
- @Test
- public void testGetResources_FS() throws Exception {
- String resDir = getResourceDir();
- Collection<URL> found = resolver.getResources("file:" + resDir + "/resources_testroot/aa?a/*.file");
- assertEquals(5, found.size());
- Collection<URL> found2 = resolver.getResources(resDir + "/resources_testroot/aa?a/*.file");
- assertEquals(found, found2);
- }
-
- private String getResourceDir() throws URISyntaxException {
- URL res = getClass().getResource("/resources_testroot/");
- return new File(res.toURI()).getParentFile().getAbsolutePath();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resources/src/test/java/org/apache/tamaya/resource/internal/FileCollectorTest.java
----------------------------------------------------------------------
diff --git a/modules/resources/src/test/java/org/apache/tamaya/resource/internal/FileCollectorTest.java b/modules/resources/src/test/java/org/apache/tamaya/resource/internal/FileCollectorTest.java
deleted file mode 100644
index ac4e41b..0000000
--- a/modules/resources/src/test/java/org/apache/tamaya/resource/internal/FileCollectorTest.java
+++ /dev/null
@@ -1,72 +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.resource.internal;
-
-import org.junit.Test;
-
-import java.io.File;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.Collection;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Test for checking correct lookup using the filesystem.
- */
-public class FileCollectorTest {
-
- private String getResourceDir() throws URISyntaxException {
- URL res = getClass().getClassLoader().getResource("resources_testroot/");
- if(res==null){
- return null;
- }
- return new File(res.toURI()).getAbsolutePath();
- }
-
- @Test
- public void testCollectResourcesFromLocalFSPath() throws Exception {
- String resDir = getResourceDir();
- Collection<URL> found = FileCollector.collectFiles("file:" + resDir + "/**/*.file");
- assertEquals(7, found.size());
- Collection<URL> found2 = FileCollector.collectFiles(resDir + "/**/*.file");
- assertEquals(found, found2);
- }
-
- @Test
- public void testCollectResourcesFromLocalFSPath_WithFolderPlaceholder() throws Exception {
- String resDir = getResourceDir();
- Collection<URL> found = FileCollector.collectFiles("file:" + resDir + "/aa?a/*.file");
- assertEquals(5, found.size());
- Collection<URL> found2 = FileCollector.collectFiles(resDir + "/aa?a/*.file");
- assertEquals(found, found2);
- }
-
-
- @Test
- public void testCollectResourcesFromLocalFSPath_WithFolderAny() throws Exception {
- String resDir = getResourceDir();
- Collection<URL> found = FileCollector.collectFiles("file:" + resDir + "/b*/b?/*.file");
- assertEquals(1, found.size());
- Collection<URL> found2 = FileCollector.collectFiles(resDir + "/b*/b?/*.file");
- assertEquals(found, found2);
- }
-
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resources/src/test/java/org/apache/tamaya/resource/internal/PathBasedPropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/modules/resources/src/test/java/org/apache/tamaya/resource/internal/PathBasedPropertySourceProvider.java b/modules/resources/src/test/java/org/apache/tamaya/resource/internal/PathBasedPropertySourceProvider.java
deleted file mode 100644
index 7ea9b4c..0000000
--- a/modules/resources/src/test/java/org/apache/tamaya/resource/internal/PathBasedPropertySourceProvider.java
+++ /dev/null
@@ -1,97 +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.resource.internal;
-
-import org.apache.tamaya.resource.AbstractPathPropertySourceProvider;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-import org.apache.tamaya.spi.PropertyValueBuilder;
-
-import java.io.InputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-/**
- * Created by Anatole on 03.03.2015.
- */
-public class PathBasedPropertySourceProvider extends AbstractPathPropertySourceProvider{
-
- public PathBasedPropertySourceProvider() {
- super("META-INF/cfg/**/*.properties");
- }
-
- @Override
- protected Collection<PropertySource> getPropertySources(URL url) {
- List<PropertySource> list = new ArrayList<>();
- Properties props = new Properties();
- try(InputStream is = url.openStream()){
- props.load(is);
- list.add(new PropertiesBasedPropertySource(url.toString(), props));
- }
- catch(Exception e){
- e.printStackTrace();
- return null;
- }
- return list;
- }
-
-
- private final static class PropertiesBasedPropertySource implements PropertySource{
-
- private final String name;
- private final Map<String,String> properties = new HashMap<>();
-
- public PropertiesBasedPropertySource(String name, Properties props) {
- this.name = name;
- for (Map.Entry en : props.entrySet()) {
- this.properties.put(en.getKey().toString(), String.valueOf(en.getValue()));
- }
- }
-
- @Override
- public int getOrdinal() {
- return 0;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public PropertyValue get(String key) {
- return PropertyValue.of(key,properties.get(key), getName());
- }
-
- @Override
- public Map<String, String> getProperties() {
- return properties;
- }
-
- @Override
- public boolean isScannable() {
- return false;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resources/src/test/resources/resources_testroot/aa_a/a1_1.file
----------------------------------------------------------------------
diff --git a/modules/resources/src/test/resources/resources_testroot/aa_a/a1_1.file b/modules/resources/src/test/resources/resources_testroot/aa_a/a1_1.file
deleted file mode 100644
index 7220975..0000000
--- a/modules/resources/src/test/resources/resources_testroot/aa_a/a1_1.file
+++ /dev/null
@@ -1,18 +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.
- */
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/resources/src/test/resources/resources_testroot/aa_a/a1_2.file
----------------------------------------------------------------------
diff --git a/modules/resources/src/test/resources/resources_testroot/aa_a/a1_2.file b/modules/resources/src/test/resources/resources_testroot/aa_a/a1_2.file
deleted file mode 100644
index 7220975..0000000
--- a/modules/resources/src/test/resources/resources_testroot/aa_a/a1_2.file
+++ /dev/null
@@ -1,18 +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.
- */
\ No newline at end of file
[12/24] incubator-tamaya git commit: Removed all modules from the
main repository. They will be reborn in separate ASF repository.
Posted by pl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi/src/main/java/org/apache/tamaya/integration/cdi/ConfigurationExtension.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi/src/main/java/org/apache/tamaya/integration/cdi/ConfigurationExtension.java b/modules/integration/cdi/src/main/java/org/apache/tamaya/integration/cdi/ConfigurationExtension.java
deleted file mode 100644
index 2a3d7db..0000000
--- a/modules/integration/cdi/src/main/java/org/apache/tamaya/integration/cdi/ConfigurationExtension.java
+++ /dev/null
@@ -1,287 +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.integration.cdi;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.ConfigOperator;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.inject.api.Config;
-import org.apache.tamaya.inject.api.ConfigDefaultSections;
-import org.apache.tamaya.inject.api.WithConfigOperator;
-import org.apache.tamaya.inject.api.WithPropertyConverter;
-import org.apache.tamaya.spi.PropertyConverter;
-
-import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.spi.AfterBeanDiscovery;
-import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.BeanManager;
-import javax.enterprise.inject.spi.Extension;
-import javax.enterprise.inject.spi.InjectionPoint;
-import javax.enterprise.inject.spi.ProcessBean;
-import javax.enterprise.inject.spi.ProcessProducerMethod;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Logger;
-
-
-/**
- * CDI Extension module that adds injection mechanism for configuration.
- *
- * @see org.apache.tamaya.inject.api.Config
- * @see org.apache.tamaya.inject.api.ConfigDefaultSections
- * @see ConfigException
- */
-public class ConfigurationExtension implements Extension {
-
- private static final Logger LOG = Logger.getLogger(ConfigurationExtension.class.getName());
-
- static final Map<Class, ConfigOperator> CUSTOM_OPERATORS = new ConcurrentHashMap<>();
- static final Map<Class, PropertyConverter> CUSTOM_CONVERTERS = new ConcurrentHashMap<>();
-
- private final Set<Type> types = new HashSet<>();
- private Bean<?> convBean;
-
- /**
- * Constructor for loading logging its load.
- */
- public ConfigurationExtension(){
- LOG.info("Enabling Tamaya CDI Configuration...");
- }
-
- /**
- * Method that checks the configuration injection points during deployment for available configuration.
- * @param pb the bean to process.
- * @param beanManager the bean manager to notify about new injections.
- */
- public void retrieveTypes(@Observes final ProcessBean<?> pb, BeanManager beanManager) {
-
- final Set<InjectionPoint> ips = pb.getBean().getInjectionPoints();
- CDIConfiguredType configuredType = new CDIConfiguredType(pb.getBean().getBeanClass());
-
- boolean configured = false;
- for (InjectionPoint injectionPoint : ips) {
- if (injectionPoint.getAnnotated().isAnnotationPresent(Config.class)) {
- final Config annotation = injectionPoint.getAnnotated().getAnnotation(Config.class);
- final ConfigDefaultSections typeAnnot = injectionPoint.getAnnotated().getAnnotation(ConfigDefaultSections.class);
- final List<String> keys = evaluateKeys(injectionPoint.getMember().getName(),
- annotation!=null?annotation.value():null,
- typeAnnot!=null?typeAnnot.value():null);
-
- final WithConfigOperator withOperatorAnnot = injectionPoint.getAnnotated().getAnnotation(WithConfigOperator.class);
- if(withOperatorAnnot!=null){
- tryLoadOpererator(withOperatorAnnot.value());
- }
- final WithPropertyConverter withConverterAnnot = injectionPoint.getAnnotated().getAnnotation(WithPropertyConverter.class);
- if(withConverterAnnot!=null){
- tryLoadConverter(withConverterAnnot.value());
- }
-
- // We don't want to wait until the injection really fails at runtime.
- // If there is a non resolvable configuration, we want to know at startup.
- Configuration config = ConfigurationProvider.getConfiguration();
- String value = null;
- for(String key:keys) {
- value = config.get(key);
- if(value!=null){
- break;
- }
- }
- if(value==null && !annotation.defaultValue().isEmpty()){
- value = annotation.defaultValue();
- }
- if(value==null){
- throw new ConfigException(String.format(
- "Cannot resolve any of the possible configuration keys: %s. Please provide one of the given keys " +
- "with a value in your configuration sources.",
- keys.toString()));
- }
- types.add(injectionPoint.getType());
- if(annotation!=null){
- configured = true;
- LOG.info("Enabling Tamaya CDI Configuration on bean: " + configuredType.getName());
- configuredType.addConfiguredMember(injectionPoint, keys);
- }
- }
- }
- if(configured) {
- beanManager.fireEvent(configuredType);
- }
- }
-
-
- public void captureConvertBean(@Observes final ProcessProducerMethod<?, ?> ppm) {
- if (ppm.getAnnotated().isAnnotationPresent(Config.class)) {
- convBean = ppm.getBean();
- }
-
- }
-
- public void addConverter(@Observes final AfterBeanDiscovery abd, final BeanManager bm) {
- if(!types.isEmpty()) {
- abd.addBean(new ConverterBean(convBean, types));
- }
- }
-
- private void tryLoadOpererator(Class<? extends ConfigOperator> operatorClass) {
- Objects.requireNonNull(operatorClass);
- if(ConfigOperator.class == operatorClass){
- return;
- }
- try{
- if(!CUSTOM_OPERATORS.containsKey(operatorClass)) {
- CUSTOM_OPERATORS.put(operatorClass, operatorClass.newInstance());
- }
- } catch(Exception e){
- throw new ConfigException("Custom ConfigOperator could not be loaded: " + operatorClass.getName(), e);
- }
- }
-
- private void tryLoadConverter(Class<? extends PropertyConverter> converterClass) {
- Objects.requireNonNull(converterClass);
- if(PropertyConverter.class == converterClass){
- return;
- }
- try{
- if(!CUSTOM_CONVERTERS.containsKey(converterClass)) {
- CUSTOM_CONVERTERS.put(converterClass, converterClass.newInstance());
- }
- } catch(Exception e){
- throw new ConfigException("Custom PropertyConverter could not be loaded: " + converterClass.getName(), e);
- }
- }
-
- /**
- * Evaluates the effective keys to be used. if no {@code keys} are defined, {@code memberName} is used.
- * The effective keys are then combined with the sections given (if any) and only, if the given keys are not
- * absolute keys (surrounded by brackets).
- * @param memberName the default member name, not null.
- * @param keys the keys, may be empty, or null.
- * @param sections the default sections, may be empty. May also be null.
- * @return the list of keys to be finally used for configuration resolution in order of
- * precedence. The first keys in the list that could be successfully resolved define the final
- * configuration value.
- */
- public static List<String> evaluateKeys(String memberName, String[] keys, String[] sections) {
- List<String> effKeys = new ArrayList<>();
- if(keys!=null){
- effKeys.addAll(Arrays.asList(keys));
- }
- if (effKeys.isEmpty()) {
- effKeys.add(memberName);
- }
- ListIterator<String> iterator = effKeys.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 (sections != null && sections.length>0) {
- // 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 : sections) {
- iterator.add(area.isEmpty() ? next : area + '.' + next);
- }
- }
- }
- }
- return effKeys;
- }
-
-
- /**
- * Internally used conversion bean.
- */
- private static class ConverterBean implements Bean<Object> {
-
- private final Bean<Object> delegate;
- private final Set<Type> types;
-
- public ConverterBean(final Bean convBean, final Set<Type> types) {
- this.types = types;
- this.delegate = convBean;
- }
-
- @Override
- public Set<Type> getTypes() {
- return types;
- }
-
- @Override
- public Class<?> getBeanClass() {
- return delegate.getBeanClass();
- }
-
- @Override
- public Set<InjectionPoint> getInjectionPoints() {
- return delegate.getInjectionPoints();
- }
-
- @Override
- public String getName() {
- return delegate.getName();
- }
-
- @Override
- public Set<Annotation> getQualifiers() {
- return delegate.getQualifiers();
- }
-
- @Override
- public Class<? extends Annotation> getScope() {
- return delegate.getScope();
- }
-
- @Override
- public Set<Class<? extends Annotation>> getStereotypes() {
- return delegate.getStereotypes();
- }
-
- @Override
- public boolean isAlternative() {
- return delegate.isAlternative();
- }
-
- @Override
- public boolean isNullable() {
- return delegate.isNullable();
- }
-
- @Override
- public Object create(CreationalContext<Object> creationalContext) {
- return delegate.create(creationalContext);
- }
-
- @Override
- public void destroy(Object instance, CreationalContext<Object> creationalContext) {
- delegate.destroy(instance, creationalContext);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi/src/main/java/org/apache/tamaya/integration/cdi/ConfigurationProducer.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi/src/main/java/org/apache/tamaya/integration/cdi/ConfigurationProducer.java b/modules/integration/cdi/src/main/java/org/apache/tamaya/integration/cdi/ConfigurationProducer.java
deleted file mode 100644
index 8d5f346..0000000
--- a/modules/integration/cdi/src/main/java/org/apache/tamaya/integration/cdi/ConfigurationProducer.java
+++ /dev/null
@@ -1,146 +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.integration.cdi;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.ConfigOperator;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.inject.api.Config;
-import org.apache.tamaya.inject.api.ConfigDefaultSections;
-import org.apache.tamaya.inject.api.DynamicValue;
-import org.apache.tamaya.inject.api.WithConfigOperator;
-import org.apache.tamaya.inject.api.WithPropertyConverter;
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.enterprise.inject.Produces;
-import javax.enterprise.inject.spi.InjectionPoint;
-import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.Field;
-import java.lang.reflect.Member;
-import java.lang.reflect.Method;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Producer bean for configuration properties.
- */
-@ApplicationScoped
-public class ConfigurationProducer {
-
- private static final Logger LOGGER = Logger.getLogger(ConfigurationProducer.class.getName());
-
- private DynamicValue createynamicValue(final InjectionPoint injectionPoint) {
- Member member = injectionPoint.getMember();
- if (member instanceof Field) {
- return DefaultDynamicValue.of((Field) member, ConfigurationProvider.getConfiguration());
- } else if (member instanceof Method) {
- return DefaultDynamicValue.of((Method) member, ConfigurationProvider.getConfiguration());
- }
- return null;
- }
-
- @Produces
- @Config
- public Object resolveAndConvert(final InjectionPoint injectionPoint) {
- if (DynamicValue.class.equals(injectionPoint.getAnnotated().getBaseType())) {
- return createynamicValue(injectionPoint);
- }
- final Config annotation = injectionPoint.getAnnotated().getAnnotation(Config.class);
- final ConfigDefaultSections typeAnnot = injectionPoint.getAnnotated().getAnnotation(ConfigDefaultSections.class);
- final List<String> keys = ConfigurationExtension.evaluateKeys(injectionPoint.getMember().getName(),
- annotation != null ? annotation.value() : null,
- typeAnnot != null ? typeAnnot.value() : null);
-
- final WithConfigOperator withOperatorAnnot = injectionPoint.getAnnotated().getAnnotation(WithConfigOperator.class);
- ConfigOperator operator = null;
- if (withOperatorAnnot != null) {
- operator = ConfigurationExtension.CUSTOM_OPERATORS.get(withOperatorAnnot.value());
- }
- PropertyConverter customCnverter = null;
- final WithPropertyConverter withConverterAnnot = injectionPoint.getAnnotated().getAnnotation(WithPropertyConverter.class);
- if (withConverterAnnot != null) {
- customCnverter = ConfigurationExtension.CUSTOM_CONVERTERS.get(withConverterAnnot.value());
- }
-
- // unless the extension is not installed, this should never happen because the extension
- // enforces the resolvability of the config
- Configuration config = ConfigurationProvider.getConfiguration();
- if (operator != null) {
- config = operator.operate(config);
- }
- final Class<?> toType = (Class<?>) injectionPoint.getAnnotated().getBaseType();
- String textValue = null;
- String defaultTextValue = annotation.defaultValue().isEmpty() ? null : annotation.defaultValue();
- String keyFound = null;
- for (String key : keys) {
- textValue = config.get(key);
- if (textValue != null) {
- keyFound = key;
- break;
- }
- }
- ConversionContext.Builder builder = new ConversionContext.Builder(config,
- ConfigurationProvider.getConfiguration().getContext(), keyFound, TypeLiteral.of(toType));
- if (injectionPoint.getMember() instanceof AnnotatedElement) {
- builder.setAnnotatedElement((AnnotatedElement) injectionPoint.getMember());
- }
- ConversionContext conversionContext = builder.build();
- Object value = null;
- if (keyFound != null) {
- if (customCnverter != null) {
- value = customCnverter.convert(textValue, conversionContext);
- }
- if (value == null) {
- value = config.get(keyFound, toType);
- }
- } else if (defaultTextValue != null) {
- if (customCnverter != null) {
- value = customCnverter.convert(defaultTextValue, conversionContext);
- }
- if (value == null) {
- List<PropertyConverter<Object>> converters = ConfigurationProvider.getConfiguration().getContext()
- .getPropertyConverters(TypeLiteral.of(toType));
- for (PropertyConverter<Object> converter : converters) {
- try {
- value = converter.convert(defaultTextValue, conversionContext);
- if (value != null) {
- LOGGER.log(Level.FINEST, "Parsed default value from '" + defaultTextValue + "' into " +
- injectionPoint);
- break;
- }
- } catch (Exception e) {
- LOGGER.log(Level.FINEST, "Failed to convert default value '" + defaultTextValue + "' for " +
- injectionPoint, e);
- }
- }
- }
- }
- if (value == null) {
- throw new ConfigException(String.format(
- "Can't resolve any of the possible config keys: %s to the required target type: %s, supported formats: %s",
- keys.toString(), toType.getName(), conversionContext.getSupportedFormats().toString()));
- }
- LOGGER.finest(String.format("Injecting %s for key %s in class %s", keyFound, value.toString(), injectionPoint.toString()));
- return value;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi/src/main/java/org/apache/tamaya/integration/cdi/DefaultDynamicValue.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi/src/main/java/org/apache/tamaya/integration/cdi/DefaultDynamicValue.java b/modules/integration/cdi/src/main/java/org/apache/tamaya/integration/cdi/DefaultDynamicValue.java
deleted file mode 100644
index 98ee05a..0000000
--- a/modules/integration/cdi/src/main/java/org/apache/tamaya/integration/cdi/DefaultDynamicValue.java
+++ /dev/null
@@ -1,499 +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.integration.cdi;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.inject.api.BaseDynamicValue;
-import org.apache.tamaya.inject.api.DynamicValue;
-import org.apache.tamaya.inject.api.InjectionUtils;
-import org.apache.tamaya.inject.api.LoadPolicy;
-import org.apache.tamaya.inject.api.UpdatePolicy;
-import org.apache.tamaya.inject.api.WithPropertyConverter;
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.lang.ref.WeakReference;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Objects;
-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 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.
- * <h3>Implementation Details</h3>
- * This class is
- * <ul>
- * <li>Serializable, when also the item stored is serializable</li>
- * <li>Thread safe</li>
- * </ul>
- *
- * @param <T> The type of the value.
- */
-final class DefaultDynamicValue<T> extends BaseDynamicValue<T> {
-
- private static final long serialVersionUID = -2071172847144537443L;
-
- /**
- * The property name of the entry.
- */
- private final String propertyName;
- /**
- * The keys to be resolved.
- */
- private final String[] keys;
- /**
- * Back reference to the base configuration instance. This reference is used reevalaute the given property and
- * compare the result with the previous value after a configuration change was triggered.
- */
- private final Configuration configuration;
- /**
- * The target type of the property used to lookup a matching {@link PropertyConverter}.
- * If null, {@code propertyConverter} is set and used instead.
- */
- private final TypeLiteral<T> targetType;
- /**
- * The property converter to be applied, may be null. In the ladder case targetType is not null.
- */
- private final PropertyConverter<T> propertyConverter;
- /**
- * Policy that defines how new values are applied, be default it is applied initially once, but never updated
- * anymore.
- */
- private UpdatePolicy updatePolicy;
- /**
- * Load policy.
- */
- private final LoadPolicy loadPolicy;
-
- /**
- * The current value, never null.
- */
- private transient T value;
- /**
- * The new value, or null.
- */
- private transient Object[] newValue;
- /**
- * List of listeners that listen for changes.
- */
- private transient WeakList<PropertyChangeListener> listeners;
-
- /**
- * Constructor.
- *
- * @param propertyName the name of the fields' property/method.
- * @param keys the keys of the property, not null.
- * @param configuration the configuration, not null.
- * @param targetType the target type, not null.
- * @param propertyConverter the optional converter to be used.
- */
- private DefaultDynamicValue(String propertyName, Configuration configuration, TypeLiteral<T> targetType,
- PropertyConverter<T> propertyConverter, List<String> keys, LoadPolicy loadPolicy,
- UpdatePolicy updatePolicy) {
- this.propertyName = Objects.requireNonNull(propertyName);
- this.keys = keys.toArray(new String[keys.size()]);
- this.configuration = Objects.requireNonNull(configuration);
- this.propertyConverter = propertyConverter;
- this.targetType = targetType;
- this.loadPolicy = Objects.requireNonNull(loadPolicy);
- this.updatePolicy = Objects.requireNonNull(updatePolicy);
- if(loadPolicy == LoadPolicy.INITIAL){
- this.value = evaluateValue();
- }
- }
-
- public static DynamicValue of(Field annotatedField, Configuration configuration) {
- return of(annotatedField, configuration, LoadPolicy.ALWAYS, UpdatePolicy.IMMEDEATE);
- }
-
- public static DynamicValue of(Field annotatedField, Configuration configuration, LoadPolicy loadPolicy) {
- return of(annotatedField, configuration, loadPolicy, UpdatePolicy.IMMEDEATE);
- }
-
- public static DynamicValue of(Field annotatedField, Configuration configuration, UpdatePolicy updatePolicy) {
- return of(annotatedField, configuration, LoadPolicy.ALWAYS, updatePolicy);
- }
-
- public static DynamicValue of(Field annotatedField, Configuration configuration, LoadPolicy loadPolicy, UpdatePolicy updatePolicy) {
- // Check for adapter/filter
- Type targetType = annotatedField.getGenericType();
- if (targetType == null) {
- throw new ConfigException("Failed to evaluate target type for " + annotatedField.getDeclaringClass().getName()
- + '.' + annotatedField.getName());
- }
- if (targetType instanceof ParameterizedType) {
- ParameterizedType pt = (ParameterizedType) targetType;
- Type[] types = pt.getActualTypeArguments();
- if (types.length != 1) {
- throw new ConfigException("Failed to evaluate target type for " + annotatedField.getDeclaringClass().getName()
- + '.' + annotatedField.getName());
- }
- targetType = types[0];
- }
- PropertyConverter<?> propertyConverter = null;
- WithPropertyConverter annot = annotatedField.getAnnotation(WithPropertyConverter.class);
- if (annot != null) {
- try {
- propertyConverter = annot.value().newInstance();
- } catch (Exception e) {
- throw new ConfigException("Failed to instantiate annotated PropertyConverter on " +
- annotatedField.getDeclaringClass().getName()
- + '.' + annotatedField.getName(), e);
- }
- }
- List<String> keys = InjectionUtils.getKeys(annotatedField);
- return new DefaultDynamicValue(annotatedField.getName(), configuration,
- TypeLiteral.of(targetType), propertyConverter, keys, loadPolicy, updatePolicy);
- }
-
- public static DynamicValue of(Method method, Configuration configuration) {
- return of(method, configuration, LoadPolicy.ALWAYS, UpdatePolicy.IMMEDEATE);
- }
-
- public static DynamicValue of(Method method, Configuration configuration, UpdatePolicy updatePolicy) {
- return of(method, configuration, LoadPolicy.ALWAYS, updatePolicy);
- }
-
- public static DynamicValue of(Method method, Configuration configuration, LoadPolicy loadPolicy) {
- return of(method, configuration, loadPolicy, UpdatePolicy.IMMEDEATE);
- }
-
- public static DynamicValue of(Method method, Configuration configuration, LoadPolicy loadPolicy, UpdatePolicy updatePolicy) {
- // Check for adapter/filter
- Type targetType = method.getGenericReturnType();
- if (targetType == null) {
- throw new ConfigException("Failed to evaluate target type for " + method.getDeclaringClass()
- .getName() + '.' + method.getName());
- }
- if (targetType instanceof ParameterizedType) {
- ParameterizedType pt = (ParameterizedType) targetType;
- Type[] types = pt.getActualTypeArguments();
- if (types.length != 1) {
- throw new ConfigException("Failed to evaluate target type for " + method.getDeclaringClass()
- .getName() + '.' + method.getName());
- }
- targetType = types[0];
- }
- PropertyConverter<Object> propertyConverter = null;
- WithPropertyConverter annot = method.getAnnotation(WithPropertyConverter.class);
- if (annot != null) {
- try {
- propertyConverter = (PropertyConverter<Object>) annot.value().newInstance();
- } catch (Exception e) {
- throw new ConfigException("Failed to instantiate annotated PropertyConverter on " +
- method.getDeclaringClass().getName()
- + '.' + method.getName(), e);
- }
- }
- return new DefaultDynamicValue<>(method.getName(),
- configuration, TypeLiteral.of(targetType), propertyConverter, InjectionUtils.getKeys(method),
- loadPolicy, updatePolicy);
- }
-
-
- /**
- * Commits a new value that has not been committed yet, make it the new value of the instance. On change any
- * registered listeners will be triggered.
- */
- public void commit() {
- T oldValue = value;
- value = newValue==null?null:(T)newValue[0];
- newValue = null;
- informListeners(oldValue, value);
- }
-
- private void informListeners(T value, T newValue) {
- synchronized (this) {
- PropertyChangeEvent evt = new PropertyChangeEvent(this, propertyName, value,
- newValue);
- if (listeners != null) {
- for (PropertyChangeListener consumer : listeners.get()) {
- consumer.propertyChange(evt);
- }
- }
- }
- }
-
- /**
- * Discards a new value that was published. No listeners will be informed.
- */
- public void discard() {
- newValue = null;
- }
-
-
- /**
- * Access the {@link UpdatePolicy} used for updating this value.
- *
- * @return the update policy, never null.
- */
- public UpdatePolicy getUpdatePolicy() {
- return updatePolicy;
- }
-
- /**
- * Sets a new {@link UpdatePolicy}.
- *
- * @param updatePolicy the new policy, not null.
- */
- public void setUpdatePolicy(UpdatePolicy updatePolicy) {
- this.updatePolicy = Objects.requireNonNull(updatePolicy);
- }
-
- /**
- * Add a listener to be called as weak reference, when this value has been changed.
- *
- * @param l the listener, not null
- */
- public void addListener(PropertyChangeListener l) {
- if (listeners == null) {
- listeners = new WeakList<>();
- }
- listeners.add(l);
- }
-
- /**
- * Removes a listener to be called, when this value has been changed.
- *
- * @param l the listner to be removed, not null
- */
- public void removeListener(PropertyChangeListener l) {
- if (listeners != null) {
- listeners.remove(l);
- }
- }
-
- /**
- * If a value is present in this {@code DynamicValue}, returns the value,
- * otherwise throws {@code ConfigException}.
- *
- * @return the non-null value held by this {@code Optional}
- * @throws ConfigException if there is no value present
- * @see DefaultDynamicValue#isPresent()
- */
- public T get() {
- T newLocalValue;
- if(loadPolicy!=LoadPolicy.INITIAL) {
- newLocalValue = evaluateValue();
- if (this.value == null) {
- this.value = newLocalValue;
- }
- if(!Objects.equals(this.value, newLocalValue)){
- switch (updatePolicy){
- case IMMEDEATE:
- commit();
- break;
- case EXPLCIT:
- this.newValue = new Object[]{newLocalValue};
- break;
- case LOG_ONLY:
- informListeners(this.value, newLocalValue);
- this.newValue = null;
- break;
- case NEVER:
- this.newValue = null;
- break;
- default:
- this.newValue = null;
- break;
- }
- }
- }
- return value;
- }
-
- /**
- * Method to check for and apply a new value. Depending on the {@link UpdatePolicy}
- * the value is immediately or deferred visible (or it may even be ignored completely).
- *
- * @return true, if a new value has been detected. The value may not be visible depending on the current
- * {@link UpdatePolicy} in place.
- */
- public boolean updateValue() {
- if(this.value==null && this.newValue==null){
- this.value = evaluateValue();
- return false;
- }
- T newValue = evaluateValue();
- if (Objects.equals(newValue, this.value)) {
- return false;
- }
- switch (this.updatePolicy) {
- case LOG_ONLY:
- Logger.getLogger(getClass().getName()).info("Discard change on " + this + ", newValue=" + newValue);
- informListeners(value, newValue);
- this.newValue = null;
- break;
- case NEVER:
- this.newValue = null;
- break;
- case EXPLCIT:
- case IMMEDEATE:
- default:
- this.newValue = new Object[]{newValue};
- commit();
- break;
- }
- return true;
- }
-
- /**
- * Evaluates the current value dynamically from the underlying configuration.
- *
- * @return the current actual value, or null.
- */
- public T evaluateValue() {
- T value = null;
-
- for (String key : keys) {
- if (propertyConverter == null) {
- value = configuration.get(key, targetType);
- } else {
- String source = configuration.get(key);
- ConversionContext ctx = new ConversionContext.Builder(configuration,
- configuration.getContext(), key, targetType).build();
- value = propertyConverter.convert(source, ctx);
- }
-
- if (value != null) {
- break;
- }
- }
-
- return value;
- }
-
- /**
- * Access a new value that has not yet been committed.
- *
- * @return the uncommitted new value, or null.
- */
- public T getNewValue() {
- T nv = newValue==null?null:(T)newValue[0];
- if (nv != null) {
- return nv;
- }
- return null;
- }
-
-
- /**
- * Serialization implementation that strips away the non serializable Optional part.
- *
- * @param oos the output stream
- * @throws IOException if serialization fails.
- */
- private void writeObject(ObjectOutputStream oos) throws IOException {
- oos.writeObject(getUpdatePolicy());
- oos.writeObject(get());
- }
-
- /**
- * Reads an instance from the input stream.
- *
- * @param ois the object input stream
- * @throws IOException if deserialization fails.
- * @throws ClassNotFoundException
- */
- private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
- this.updatePolicy = (UpdatePolicy) ois.readObject();
- if (isPresent()) {
- this.value = (T) ois.readObject();
- }
- newValue = null;
- }
-
-
- /**
- * Simple helper that allows keeping the listeners registered as weak references, hereby avoiding any
- * memory leaks.
- *
- * @param <I> the type
- */
- private class WeakList<I> {
- final List<WeakReference<I>> refs = new LinkedList<>();
-
- /**
- * Adds a new instance.
- *
- * @param t the new instance, not null.
- */
- void add(I t) {
- refs.add(new WeakReference<>(t));
- }
-
- /**
- * Removes a instance.
- *
- * @param t the instance to be removed.
- */
- void remove(I t) {
- synchronized (refs) {
- for (Iterator<WeakReference<I>> iterator = refs.iterator(); iterator.hasNext(); ) {
- WeakReference<I> ref = iterator.next();
- I instance = ref.get();
- if (instance == null || instance == t) {
- iterator.remove();
- break;
- }
- }
- }
- }
-
-
- /**
- * Access a list (copy) of the current instances that were not discarded by the GC.
- *
- * @return the list of accessible items.
- */
- public List<I> get() {
- synchronized (refs) {
- List<I> res = new ArrayList<>();
- for (Iterator<WeakReference<I>> iterator = refs.iterator(); iterator.hasNext(); ) {
- WeakReference<I> ref = iterator.next();
- I instance = ref.get();
- if (instance == null) {
- iterator.remove();
- } else {
- res.add(instance);
- }
- }
- return res;
- }
- }
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi/src/main/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/modules/integration/cdi/src/main/resources/META-INF/beans.xml b/modules/integration/cdi/src/main/resources/META-INF/beans.xml
deleted file mode 100644
index 562647f..0000000
--- a/modules/integration/cdi/src/main/resources/META-INF/beans.xml
+++ /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.
--->
-<beans></beans>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
----------------------------------------------------------------------
diff --git a/modules/integration/cdi/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension b/modules/integration/cdi/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
deleted file mode 100644
index e82118a..0000000
--- a/modules/integration/cdi/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
+++ /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.integration.cdi.ConfigurationExtension
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi/src/test/java/org/apache/tamaya/integration/cdi/ConfigurationProducerFailedInjectionTest.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi/src/test/java/org/apache/tamaya/integration/cdi/ConfigurationProducerFailedInjectionTest.java b/modules/integration/cdi/src/test/java/org/apache/tamaya/integration/cdi/ConfigurationProducerFailedInjectionTest.java
deleted file mode 100644
index 6bfda3a..0000000
--- a/modules/integration/cdi/src/test/java/org/apache/tamaya/integration/cdi/ConfigurationProducerFailedInjectionTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tamaya.integration.cdi;
-
-import org.apache.openejb.OpenEjbContainer;
-import org.junit.Test;
-
-import javax.ejb.embeddable.EJBContainer;
-
-public class ConfigurationProducerFailedInjectionTest {
-
- @Test(expected = OpenEjbContainer.AssembleApplicationException.class)
- public void notFoundShouldNotDeploy() {
- // this explicitly tests that a non resolvable config makes
- // the deployment fail and we won't have any failure at runtime
- EJBContainer.createEJBContainer();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi/src/test/java/org/apache/tamaya/integration/cdi/ConfigurationProducerTest.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi/src/test/java/org/apache/tamaya/integration/cdi/ConfigurationProducerTest.java b/modules/integration/cdi/src/test/java/org/apache/tamaya/integration/cdi/ConfigurationProducerTest.java
deleted file mode 100644
index d128191..0000000
--- a/modules/integration/cdi/src/test/java/org/apache/tamaya/integration/cdi/ConfigurationProducerTest.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.integration.cdi;
-
-import org.apache.openejb.jee.EjbJar;
-import org.apache.openejb.junit.ApplicationComposer;
-import org.apache.openejb.testing.Classes;
-import org.apache.openejb.testing.Module;
-import org.apache.tamaya.inject.api.Config;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.tomitribe.util.Duration;
-
-import javax.inject.Inject;
-import java.io.File;
-
-import static org.junit.Assert.*;
-
-@RunWith(ApplicationComposer.class)
-public class ConfigurationProducerTest {
-
- @Module
- @Classes(cdi = true, value = {
- AllTypes.class,
- ConfigurationExtension.class,
- ConfigurationProducer.class
- })
- public EjbJar jar() {
- return new EjbJar("config");
- }
-
- @Inject
- private AllTypes allTypes;
-
- @Test
- public void defaultValues() {
- assertNotNull(allTypes);
- assertEquals("defaultString", allTypes.getDefaultString());
- assertEquals(new File("./"), allTypes.getDefaultFile());
- assertEquals(new Duration("2 hours and 54 minutes"), allTypes.getDefaultDuration());
- assertEquals(true, allTypes.getDefaultBoolean());
- assertEquals(45, (int) allTypes.getDefaultInteger());
- }
-
- @Test
- public void actualPropertyValues() {
- assertNotNull(allTypes);
- assertEquals("hello", allTypes.getString());
- assertEquals(new File("./conf"), allTypes.getFile());
- assertEquals(new Duration("10 minutes and 57 seconds"), allTypes.getDuration());
- assertEquals(true, allTypes.getaBoolean());
- assertEquals(123, (int) allTypes.getInteger());
- }
-
- static class AllTypes {
-
- @Inject
- @Config(value = "string.value", defaultValue = "defaultString")
- private String string;
-
- @Inject
- @Config(value = "defaultString.value", defaultValue = "defaultString")
- private String defaultString;
-
- @Inject
- @Config(value = "file.value", defaultValue = "./")
- private File file;
-
- @Inject
- @Config(value = "defaultFile.value", defaultValue = "./")
- private File defaultFile;
-
- @Inject
- @Config(value = "duration.value", defaultValue = "2 hours and 54 minutes")
- private Duration duration;
-
- @Inject
- @Config(value = "defaultDuration.value", defaultValue = "2 hours and 54 minutes")
- private Duration defaultDuration;
-
- @Inject
- @Config(value = "boolean.value", defaultValue = "true")
- private Boolean aBoolean;
-
- @Inject
- @Config(value = "defaultBoolean.value", defaultValue = "true")
- private Boolean defaultBoolean;
-
- @Inject
- @Config(value = "integer.value", defaultValue = "45")
- private Integer integer;
-
- @Inject
- @Config(value = "defaultInteger.value", defaultValue = "45")
- private Integer defaultInteger;
-
- public String getString() {
- return string;
- }
-
- public File getFile() {
- return file;
- }
-
- public Duration getDuration() {
- return duration;
- }
-
- public Boolean getaBoolean() {
- return aBoolean;
- }
-
- public Integer getInteger() {
- return integer;
- }
-
- public String getDefaultString() {
- return defaultString;
- }
-
- public File getDefaultFile() {
- return defaultFile;
- }
-
- public Duration getDefaultDuration() {
- return defaultDuration;
- }
-
- public Boolean getDefaultBoolean() {
- return defaultBoolean;
- }
-
- public Integer getDefaultInteger() {
- return defaultInteger;
- }
-
- @Override
- public String toString() {
- return "AllTypes{" +
- "string='" + string + '\'' +
- ", defaultString='" + defaultString + '\'' +
- ", file=" + file +
- ", defaultFile=" + defaultFile +
- ", duration=" + duration +
- ", defaultDuration=" + defaultDuration +
- ", aBoolean=" + aBoolean +
- ", defaultBoolean=" + defaultBoolean +
- ", integer=" + integer +
- ", defaultInteger=" + defaultInteger +
- '}';
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi/src/test/java/org/apache/tamaya/integration/cdi/ConfigurationResolverTest.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi/src/test/java/org/apache/tamaya/integration/cdi/ConfigurationResolverTest.java b/modules/integration/cdi/src/test/java/org/apache/tamaya/integration/cdi/ConfigurationResolverTest.java
deleted file mode 100644
index 1c551b2..0000000
--- a/modules/integration/cdi/src/test/java/org/apache/tamaya/integration/cdi/ConfigurationResolverTest.java
+++ /dev/null
@@ -1,112 +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.integration.cdi;
-//
-//import org.apache.openejb.loader.SystemInstance;
-//import org.junit.Before;
-//import org.junit.Test;
-//
-//import static org.junit.Assert.*;
-//
-//public class ConfigurationResolverTest {
-//
-// private ConfigurationResolver resolver;
-//
-// @Before
-// public void cleanEnv() {
-// SystemInstance.reset();
-// System.clearProperty("environment");
-//
-// resolver = new ConfigurationResolver();
-// }
-//
-// @Test
-// public void defaultEnvironment() {
-// assertEquals("test", resolver.getEnvironment());
-// }
-//
-// @Test
-// public void overrideDefaultEnvironment() {
-// System.setProperty("environment", "dev");
-//
-// // don't use the field cause before is invoked before we have a chance to set the environment
-// assertEquals("dev", new ConfigurationResolver().getEnvironment());
-// }
-//
-// @Test
-// public void isResolvable() {
-//
-// { // precondition
-// try {
-// resolver.isResolvableConfig(null, "value");
-// fail("a null key is not resolvable");
-//
-// } catch (final NullPointerException e) {
-// // expected
-// }
-// }
-// { // precondition
-// try {
-// resolver.isResolvableConfig("key", null);
-// fail("a null default value is not resolvable");
-//
-// } catch (final NullPointerException e) {
-// // expected
-// }
-// }
-//
-// // loaded from test.properties
-// assertTrue(resolver.isResolvableConfig("remote.wsdl.location", ""));
-// assertFalse(resolver.isResolvableConfig("something", ""));
-//
-// // loaded from base.properties
-// assertTrue(resolver.isResolvableConfig("remote.username", ""));
-// assertFalse(resolver.isResolvableConfig("bla", ""));
-// }
-//
-// @Test
-// public void found() {
-//
-// { // precondition
-// try {
-// resolver.isResolvableConfig(null, "value");
-// fail("a null key is not resolvable");
-//
-// } catch (final NullPointerException e) {
-// // expected
-// }
-// }
-// { // precondition
-// try {
-// resolver.isResolvableConfig("key", null);
-// fail("a null default value is not resolvable");
-//
-// } catch (final NullPointerException e) {
-// // expected
-// }
-// }
-//
-// // loaded from test.properties
-// assertEquals("classpath:/service-wsdl.xml", resolver.resolve("remote.wsdl.location", ""));
-// assertEquals("something-else", resolver.resolve("something", "something-else"));
-//
-// // loaded from base.properties
-// assertEquals("joecool", resolver.resolve("remote.username", ""));
-// assertEquals("blabla", resolver.resolve("bla", "blabla"));
-// }
-//
-//}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi/src/test/java/org/apache/tamaya/integration/cdi/EnvironmentsTest.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi/src/test/java/org/apache/tamaya/integration/cdi/EnvironmentsTest.java b/modules/integration/cdi/src/test/java/org/apache/tamaya/integration/cdi/EnvironmentsTest.java
deleted file mode 100644
index cb60307..0000000
--- a/modules/integration/cdi/src/test/java/org/apache/tamaya/integration/cdi/EnvironmentsTest.java
+++ /dev/null
@@ -1,83 +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.integration.cdi;
-//
-//import org.junit.Test;
-//
-//import java.util.Map;
-//import java.util.Properties;
-//
-//import static org.junit.Assert.assertEquals;
-//
-///**
-// * Tests the related environment properties exist
-// */
-//public class EnvironmentsTest {
-//
-// @Test
-// public void testGetProperties() throws Exception {
-//
-// final Properties test = Environments.getProperties("test");
-//
-// // loaded from test.properties
-// assertEquals("classpath:/test-service-wsdl.xml", test.getProperty("remote.wsdl.location"));
-//
-// // loaded from base.properties
-// assertEquals("joecool", test.getProperty("remote.username"));
-// }
-//
-// @Test(expected = IllegalArgumentException.class)
-// public void noEnvFound() {
-// Environments.getProperties("does not exists");
-// }
-//
-// @Test
-// public void dev() throws Exception {
-//
-// final Properties test = Environments.getProperties("dev");
-//
-// assertEquals("org.apache.openejb.cipher.StaticDESPasswordCipher", test.getProperty("cipher"));
-// assertEquals("NjAq6q2agYVnvSMz+eYUZg==", test.getProperty("remote.password"));
-// assertEquals("1443", test.getProperty("remote.port"));
-// assertEquals("https://srv1114.supertribe.org:1443/remote/service/url", test.getProperty("remote.target.url"));
-// assertEquals("srv1114.supertribe.org:1443", test.getProperty("remote.address"));
-// assertEquals("srv1114.supertribe.org", test.getProperty("remote.host"));
-// assertEquals("classpath:/service-wsdl.xml", test.getProperty("remote.wsdl.location"));
-// assertEquals("joecool", test.getProperty("remote.username"));
-// }
-//
-// @Test
-// public void cert() throws Exception {
-// final Properties test = Environments.getProperties("cert");
-// assertEquals("srv1016.supertribe.org", test.getProperty("remote.host"));
-// assertEquals("joecool", test.getProperty("remote.username"));
-// }
-//
-// @Test
-// public void prod() throws Exception {
-// final Properties test = Environments.getProperties("prod");
-// assertEquals("remotedb001.supertribe.org", test.getProperty("remote.host"));
-// assertEquals("joecool", test.getProperty("remote.username"));
-// }
-//
-//
-// private static void generateAsserts(Properties test) {
-// for (Map.Entry<Object, Object> entry : test.entrySet()) {
-// System.out.printf("assertEquals(\"%s\", test.getProperty(\"%s\"));%n", entry.getValue(), entry.getKey());
-// }
-// }
-//}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi/src/test/java/org/apache/tamaya/integration/cdi/InterpolationTest.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi/src/test/java/org/apache/tamaya/integration/cdi/InterpolationTest.java b/modules/integration/cdi/src/test/java/org/apache/tamaya/integration/cdi/InterpolationTest.java
deleted file mode 100644
index 56cc8c9..0000000
--- a/modules/integration/cdi/src/test/java/org/apache/tamaya/integration/cdi/InterpolationTest.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tamaya.integration.cdi;
-//
-//import org.junit.Test;
-//import org.tomitribe.util.IO;
-//
-//import java.net.URL;
-//import java.util.Properties;
-//
-//import static org.junit.Assert.assertEquals;
-//
-//public class InterpolationTest {
-//
-// @Test
-// public void testInterpolate() throws Exception {
-// final Properties interpolated;
-// {
-// final Properties properties = new Properties();
-// properties.setProperty("foo.host", "localhost");
-// properties.setProperty("foo.port", "1234");
-// properties.setProperty("address", "http://${foo.host}:${foo.port}");
-// properties.setProperty("url", "${address}/webapp");
-// properties.setProperty("urlUnchanged", "${not an address}/webapp");
-//
-// interpolated = Interpolation.interpolate(properties);
-// }
-//
-// assertEquals("localhost", interpolated.getProperty("foo.host"));
-// assertEquals("1234", interpolated.getProperty("foo.port"));
-// assertEquals("http://localhost:1234", interpolated.getProperty("address"));
-// assertEquals("http://localhost:1234/webapp", interpolated.getProperty("url"));
-// assertEquals("${not an address}/webapp", interpolated.getProperty("urlUnchanged"));
-// }
-//
-// @Test
-// public void test() throws Exception {
-//
-// final ClassLoader loader = Thread.currentThread().getContextClassLoader();
-//
-// final URL resource = loader.getResource("test.properties");
-// final Properties properties = Interpolation.interpolate(IO.readProperties(resource));
-//
-// //remote.wsdl.location = classpath:/lx01116-zhr-active-partner-service-wsdl.xml
-// assertEquals("classpath:/test-service-wsdl.xml", properties.getProperty("remote.wsdl.location"));
-// }
-//
-//}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi/src/test/java/org/apache/tamaya/integration/cdi/NotFoundNoDefault.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi/src/test/java/org/apache/tamaya/integration/cdi/NotFoundNoDefault.java b/modules/integration/cdi/src/test/java/org/apache/tamaya/integration/cdi/NotFoundNoDefault.java
deleted file mode 100644
index afeeb84..0000000
--- a/modules/integration/cdi/src/test/java/org/apache/tamaya/integration/cdi/NotFoundNoDefault.java
+++ /dev/null
@@ -1,78 +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.integration.cdi;
-
-import org.apache.tamaya.inject.api.Config;
-import org.tomitribe.util.Duration;
-
-import javax.inject.Inject;
-import java.io.File;
-
-public class NotFoundNoDefault {
-
- @Inject
- @Config("string.bla")
- private String string;
-
- @Inject
- @Config("file.bla")
- private File file;
-
- @Inject
- @Config("duration.bla")
- private Duration duration;
-
- @Inject
- @Config("boolean.bla")
- private Boolean aBoolean;
-
- @Inject
- @Config("integer.bla")
- private Integer integer;
-
- public String getString() {
- return string;
- }
-
- public File getFile() {
- return file;
- }
-
- public Duration getDuration() {
- return duration;
- }
-
- public Boolean getaBoolean() {
- return aBoolean;
- }
-
- public Integer getInteger() {
- return integer;
- }
-
- @Override
- public String toString() {
- return "NotFoundNoDefault{" +
- "string='" + string + '\'' +
- ", file=" + file +
- ", duration=" + duration +
- ", aBoolean=" + aBoolean +
- ", integer=" + integer +
- '}';
- }
-
- }
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi/src/test/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/modules/integration/cdi/src/test/resources/META-INF/beans.xml b/modules/integration/cdi/src/test/resources/META-INF/beans.xml
deleted file mode 100644
index 562647f..0000000
--- a/modules/integration/cdi/src/test/resources/META-INF/beans.xml
+++ /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.
--->
-<beans></beans>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi/src/test/resources/META-INF/javaconfiguration.properties
----------------------------------------------------------------------
diff --git a/modules/integration/cdi/src/test/resources/META-INF/javaconfiguration.properties b/modules/integration/cdi/src/test/resources/META-INF/javaconfiguration.properties
deleted file mode 100644
index 8d3c5c8..0000000
--- a/modules/integration/cdi/src/test/resources/META-INF/javaconfiguration.properties
+++ /dev/null
@@ -1,32 +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.
-#
-remote.wsdl.location = classpath:/service-wsdl.xml
-remote.port=1443
-remote.address=${remote.host}:${remote.port}
-remote.target.url = https://${remote.address}/remote/service/url
-remote.username = joecool
-# ciphered using built in StaticDESPasswordCipher
-remote.password = NjAq6q2agYVnvSMz+eYUZg==
-cipher=org.apache.openejb.cipher.StaticDESPasswordCipher
-
-string.value = hello
-file.value = ./conf
-duration.value = 10 minutes and 57 seconds
-boolean.value = true
-integer.value = 123
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi/src/test/resources/base.properties
----------------------------------------------------------------------
diff --git a/modules/integration/cdi/src/test/resources/base.properties b/modules/integration/cdi/src/test/resources/base.properties
deleted file mode 100644
index a4d9896..0000000
--- a/modules/integration/cdi/src/test/resources/base.properties
+++ /dev/null
@@ -1,32 +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.
-#
-remote.wsdl.location = classpath:/service-wsdl.xml
-remote.port=1443
-remote.address=${remote.host}:${remote.port}
-remote.target.url = https://${remote.address}/remote/service/url
-remote.username = joecool
-# ciphered using built in StaticDESPasswordCipher
-remote.password = NjAq6q2agYVnvSMz+eYUZg==
-cipher=org.apache.openejb.cipher.StaticDESPasswordCipher
-
-string.value = hello
-file.value = ./conf
-duration.value = 10 minutes and 57 seconds
-boolean.value = true
-integer.value = 123
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi/src/test/resources/cert.properties
----------------------------------------------------------------------
diff --git a/modules/integration/cdi/src/test/resources/cert.properties b/modules/integration/cdi/src/test/resources/cert.properties
deleted file mode 100644
index c2c3712..0000000
--- a/modules/integration/cdi/src/test/resources/cert.properties
+++ /dev/null
@@ -1,20 +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.
-#
-remote.host=srv1016.supertribe.org
-remote.password=vm9oNWJpN8Y=
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi/src/test/resources/dev.properties
----------------------------------------------------------------------
diff --git a/modules/integration/cdi/src/test/resources/dev.properties b/modules/integration/cdi/src/test/resources/dev.properties
deleted file mode 100644
index abd3e03..0000000
--- a/modules/integration/cdi/src/test/resources/dev.properties
+++ /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.
-#
-remote.host=srv1114.supertribe.org
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi/src/test/resources/prod.properties
----------------------------------------------------------------------
diff --git a/modules/integration/cdi/src/test/resources/prod.properties b/modules/integration/cdi/src/test/resources/prod.properties
deleted file mode 100644
index 9f1ad67..0000000
--- a/modules/integration/cdi/src/test/resources/prod.properties
+++ /dev/null
@@ -1,20 +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.
-#
-remote.host=remotedb001.supertribe.org
-remote.password=vm9oNWJpN8Y=
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi/src/test/resources/qa.properties
----------------------------------------------------------------------
diff --git a/modules/integration/cdi/src/test/resources/qa.properties b/modules/integration/cdi/src/test/resources/qa.properties
deleted file mode 100644
index 3f43795..0000000
--- a/modules/integration/cdi/src/test/resources/qa.properties
+++ /dev/null
@@ -1,20 +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.
-#
-remote.host=srv1115.supertribe.org
-remote.password=vm9oNWJpN8Y=
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi/src/test/resources/test.properties
----------------------------------------------------------------------
diff --git a/modules/integration/cdi/src/test/resources/test.properties b/modules/integration/cdi/src/test/resources/test.properties
deleted file mode 100644
index 8e08405..0000000
--- a/modules/integration/cdi/src/test/resources/test.properties
+++ /dev/null
@@ -1,20 +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.
-#
-remote.wsdl.location = classpath:/test-service-wsdl.xml
-
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/consul/pom.xml
----------------------------------------------------------------------
diff --git a/modules/integration/consul/pom.xml b/modules/integration/consul/pom.xml
deleted file mode 100644
index d1f5265..0000000
--- a/modules/integration/consul/pom.xml
+++ /dev/null
@@ -1,112 +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.
--->
-<project xmlns="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">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-integration</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
- </parent>
-
- <artifactId>tamaya-consul</artifactId>
- <name>Apache Tamaya Integration - consul</name>
- <packaging>bundle</packaging>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.jacoco</groupId>
- <artifactId>jacoco-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>prepare-agent</id>
- <goals>
- <goal>prepare-agent</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.tamaya.consul
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>java-hamcrest</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-core</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-functions</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-mutable-config</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>com.orbitz.consul</groupId>
- <artifactId>consul-client</artifactId>
- <version>0.9.16</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-rs-client</artifactId>
- <version>3.0.3</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-transports-http-hc</artifactId>
- <version>3.0.3</version>
- </dependency>
- </dependencies>
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/consul/src/main/java/org/apache/tamaya/consul/ConsulBackends.java
----------------------------------------------------------------------
diff --git a/modules/integration/consul/src/main/java/org/apache/tamaya/consul/ConsulBackends.java b/modules/integration/consul/src/main/java/org/apache/tamaya/consul/ConsulBackends.java
deleted file mode 100644
index 4eab141..0000000
--- a/modules/integration/consul/src/main/java/org/apache/tamaya/consul/ConsulBackends.java
+++ /dev/null
@@ -1,59 +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.consul;
-
-import com.google.common.net.HostAndPort;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Singleton that reads and stores the current consul setup, especially the possible host:ports to be used.
- */
-public final class ConsulBackends {
-
- private static final Logger LOG = Logger.getLogger(ConsulBackends.class.getName());
- private static List<HostAndPort> consulBackends = new ArrayList<>();
-
- static{
- String serverURLs = System.getProperty("tamaya.consul.urls");
- if(serverURLs==null){
- serverURLs = System.getenv("tamaya.consul.urls");
- }
- if(serverURLs==null){
- serverURLs = "127.0.0.1:8300";
- }
- for(String url:serverURLs.split("\\,")) {
- try{
- consulBackends.add(HostAndPort.fromString(url.trim()));
- LOG.info("Using consul endoint: " + url);
- } catch(Exception e){
- LOG.log(Level.SEVERE, "Error initializing consul accessor for URL: " + url, e);
- }
- }
- }
-
- private ConsulBackends(){}
-
- public static List<HostAndPort> getConsulBackends(){
- return consulBackends;
- }
-}
[15/24] incubator-tamaya git commit: Removed all modules from the
main repository. They will be reborn in separate ASF repository.
Posted by pl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/injection/src/main/java/org/apache/tamaya/inject/ConfigurationInjector.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/ConfigurationInjector.java b/modules/injection/src/main/java/org/apache/tamaya/inject/ConfigurationInjector.java
deleted file mode 100644
index 563ae47..0000000
--- a/modules/injection/src/main/java/org/apache/tamaya/inject/ConfigurationInjector.java
+++ /dev/null
@@ -1,94 +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.inject;
-
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.inject.api.ConfiguredItemSupplier;
-
-/**
- * Accessor interface for injection of configuration and configuration templates.
- */
-public interface ConfigurationInjector {
-
- /**
- * Configures the current instance and registers necessary listener to forward config change events as
- * defined by the current annotations in place.
- *
- * Unannotated types are ignored.
- *
- * @param <T> the type of the instance.
- * @param instance the instance to be configured
- * @return the configured instance (allows chaining of operations).
- */
- <T> T configure(T instance);
-
- /**
- * Configures the current instance and registers necessary listener to forward config change events as
- * defined by the current annotations in place.
- *
- * Unannotated types are ignored.
- *
- * @param <T> the type of the instance.
- * @param instance the instance to be configured
- * @param config the configuration to be used for injection.
- * @return the configured instance (allows chaining of operations).
- */
- <T> T configure(T instance, Configuration config);
-
- /**
- * Creates a template implementing the annotated methods based on current configuration data.
- *
- * @param <T> the type of the template.
- * @param templateType the type of the template to be created.
- * @return the configured template.
- */
- <T> T createTemplate(Class<T> templateType);
-
- /**
- * Creates a template implementting the annotated methods based on current configuration data.
- *
- * @param <T> the type of the template.
- * @param config the configuration to be used for backing the template.
- * @param templateType the type of the template to be created.
- * @return the configured template.
- */
- <T> T createTemplate(Class<T> templateType, Configuration config);
-
-
- /**
- * Creates a supplier for configured instances of the given type {@code T}.
- *
- * @param supplier the supplier to create new instances.
- * @param <T> the target type.
- * @return a supplier creating configured instances of {@code T}.
- */
- <T> ConfiguredItemSupplier<T> getConfiguredSupplier(ConfiguredItemSupplier<T> supplier);
-
- /**
- * Creates a supplier for configured instances of the given type {@code T}.
- *
- * @param supplier the supplier to create new instances.
- * @param config the configuration to be used for backing the supplier.
- * @param <T> the target type.
- * @return a supplier creating configured instances of {@code T}.
- */
- <T> ConfiguredItemSupplier<T> getConfiguredSupplier(ConfiguredItemSupplier<T> supplier, Configuration config);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfigTemplateInvocationHandler.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfigTemplateInvocationHandler.java b/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfigTemplateInvocationHandler.java
deleted file mode 100644
index 5d634e1..0000000
--- a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfigTemplateInvocationHandler.java
+++ /dev/null
@@ -1,73 +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.inject.internal;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.inject.api.DynamicValue;
-import org.apache.tamaya.inject.spi.ConfiguredType;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.util.Objects;
-
-/**
- * Invocation handler that handles request against a configuration template.
- */
-public final class ConfigTemplateInvocationHandler implements InvocationHandler {
-
- /**
- * The configured type.
- */
- private final ConfiguredType type;
-
- /**
- * Creates a new handler instance.
- *
- * @param type the target type, not null.
- */
- public ConfigTemplateInvocationHandler(Class<?> type) {
- this.type = new ConfiguredTypeImpl(Objects.requireNonNull(type));
- if (!type.isInterface()) {
- throw new IllegalArgumentException("Can only proxy interfaces as configuration templates.");
- }
- InjectionHelper.sendConfigurationEvent(this.type);
- }
-
- @Override
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
- Configuration config = ConfigurationProvider.getConfiguration();
- if ("toString".equals(method.getName())) {
- return "Configured Proxy -> " + this.type.getType().getName();
- } else if ("hashCode".equals(method.getName())) {
- return Objects.hashCode(proxy);
- } else if ("equals".equals(method.getName())) {
- return Objects.equals(proxy, args[0]);
- } else if ("get".equals(method.getName())) {
- return config;
- }
- if (method.getReturnType() == DynamicValue.class) {
- return DefaultDynamicValue.of(method, config);
- }
- String[] retKey = new String[1];
- String configValue = InjectionHelper.getConfigValue(method, retKey, config);
- return InjectionHelper.adaptValue(method, TypeLiteral.of(method.getReturnType()), retKey[0], configValue);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfiguredFieldImpl.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfiguredFieldImpl.java b/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfiguredFieldImpl.java
deleted file mode 100644
index 64b0c95..0000000
--- a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfiguredFieldImpl.java
+++ /dev/null
@@ -1,170 +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.inject.internal;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.inject.api.DynamicValue;
-import org.apache.tamaya.inject.api.InjectionUtils;
-import org.apache.tamaya.inject.spi.ConfiguredField;
-
-import java.lang.reflect.Field;
-import java.security.AccessController;
-import java.security.PrivilegedExceptionAction;
-import java.util.Collection;
-import java.util.Objects;
-
-/**
- * Small class that contains and manages all information anc access to a configured field and a concrete instance current
- * it (referenced by a weak reference). It also implements all aspects current keys filtering, converting any applying the
- * final keys by reflection.
- */
-public class ConfiguredFieldImpl implements ConfiguredField{
- /**
- * The configured field instance.
- */
- protected final Field annotatedField;
-
- /**
- * Models a configured field and provides mechanisms for injection.
- *
- * @param field the field instance.
- */
- public ConfiguredFieldImpl(Field field) {
- Objects.requireNonNull(field);
- this.annotatedField = field;
- }
-
-
- /**
- * Evaluate the initial keys fromMap the configuration and applyChanges it to the field.
- *
- * @param target the target instance.
- * @throws ConfigException if evaluation or conversion failed.
- */
- public void configure(Object target, Configuration config) throws ConfigException {
- if (this.annotatedField.getType() == DynamicValue.class) {
- applyDynamicValue(target);
- } else {
- applyValue(target, config, false);
- }
- }
-
-
- /**
- * This method instantiates and assigns a dynamic value.
- *
- * @param target the target instance, not null.
- * @throws ConfigException if the configuration required could not be resolved or converted.
- */
- private void applyDynamicValue(Object target) throws ConfigException {
- Objects.requireNonNull(target);
- try {
- AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
- @Override
- public Object run() throws Exception {
- annotatedField.setAccessible(true);
- return annotatedField;
- }
- });
- annotatedField.set(target,
- DefaultDynamicValue.of(annotatedField, ConfigurationProvider.getConfiguration()));
- } catch (Exception e) {
- throw new ConfigException("Failed to annotation configured field: " + this.annotatedField.getDeclaringClass()
- .getName() + '.' + annotatedField.getName(), e);
- }
- }
-
- /**
- * This method applies a configuration to the field.
- *
- * @param target the target instance, not null.
- * @param config The configuration to be used.
- * @param resolve set to true, if expression resolution should be applied on the keys passed.
- * @throws ConfigException if the configuration required could not be resolved or converted.
- */
- private void applyValue(Object target, Configuration config, boolean resolve) throws ConfigException {
- Objects.requireNonNull(target);
- try {
- String[] retKey = new String[1];
- String configValue = InjectionHelper.getConfigValue(this.annotatedField, retKey, config);
- // Next step perform expression resolution, if any
- String evaluatedValue = resolve && configValue != null
- ? InjectionHelper.evaluateValue(configValue)
- : configValue;
-
- // Check for adapter/filter
- Object value = InjectionHelper.adaptValue(this.annotatedField,
- TypeLiteral.of(this.annotatedField.getType()), retKey[0], evaluatedValue);
- AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
- @Override
- public Object run() throws Exception {
- annotatedField.setAccessible(true);
- return annotatedField;
- }
- });
- if(value!=null) {
- annotatedField.set(target, value);
- }
- } catch (Exception e) {
- throw new ConfigException("Failed to evaluate annotated field: " + this.annotatedField.getDeclaringClass()
- .getName() + '.' + annotatedField.getName(), e);
- }
- }
-
- /**
- * Get the field's type.
- * @return the field's type, not null.
- */
- @Override
- public Class<?> getType(){
- return this.annotatedField.getType();
- }
-
- /**
- * Access the applyable configuration keys for this field.
- * @return the configuration keys, never null.
- */
- @Override
- public Collection<String> getConfiguredKeys(){
- return InjectionUtils.getKeys(this.annotatedField);
- }
-
- @Override
- public String toString() {
- return "ConfiguredField[" + getSignature() + ']';
- }
-
- @Override
- public String getName() {
- return annotatedField.getName();
- }
-
- @Override
- public String getSignature() {
- return getName()+':'+getType().getName();
- }
-
- @Override
- public Field getAnnotatedField() {
- return annotatedField;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfiguredSetterMethod.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfiguredSetterMethod.java b/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfiguredSetterMethod.java
deleted file mode 100644
index b69df20..0000000
--- a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfiguredSetterMethod.java
+++ /dev/null
@@ -1,139 +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.inject.internal;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.inject.api.InjectionUtils;
-import org.apache.tamaya.inject.spi.ConfiguredMethod;
-
-import java.lang.reflect.Method;
-import java.security.AccessController;
-import java.security.PrivilegedExceptionAction;
-import java.util.Collection;
-import java.util.Objects;
-
-/**
- * Small class that contains and manages all information and access to a configured field and a concrete instance current
- * it (referenced by a weak reference). It also implements all aspects current keys filtering, conversions any applying the
- * final keys by reflection.
- */
-public class ConfiguredSetterMethod implements ConfiguredMethod {
-
- /**
- * The configured field instance.
- */
- private Method setterMethod;
- private Collection<String> configuredKeys;
-
- /**
- * Models a configured field and provides mechanisms for injection.
- *
- * @param method the method instance.
- */
- public ConfiguredSetterMethod(Method method) {
- if (void.class.equals(method.getReturnType()) &&
- method.getParameterTypes().length == 1) {
- this.setterMethod = method;
- }
- }
-
- @Override
- public void configure(Object target, Configuration config) throws ConfigException {
- String[] retKey = new String[1];
- String configValue = InjectionHelper.getConfigValue(this.setterMethod, retKey, config);
- Objects.requireNonNull(target);
- try {
- String evaluatedString = configValue != null
- ? InjectionHelper.evaluateValue(configValue)
- : configValue;
-
- // Check for adapter/filter
- Object value = InjectionHelper.adaptValue(
- this.setterMethod, TypeLiteral.of(this.setterMethod.getParameterTypes()[0]),
- retKey[0], evaluatedString);
-
- AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
- @Override
- public Object run() throws Exception {
- setterMethod.setAccessible(true);
- return setterMethod;
- }
- });
-
- setterMethod.invoke(target, value);
- } catch (Exception e) {
- throw new ConfigException("Failed to annotation configured method: " + this.setterMethod.getDeclaringClass()
- .getName() + '.' + setterMethod.getName(), e);
- }
- }
-
-
- /**
- * Access the applyable configuration keys for this field.
- *
- * @return the configuration keys, never null.
- */
- @Override
- public Collection<String> getConfiguredKeys() {
- return InjectionUtils.getKeys(this.setterMethod);
- }
-
- /**
- * Get the type to be set on the setter method.
- * @return the setter type.
- */
- @Override
- public Class<?>[] getParameterTypes() {
- return this.setterMethod.getParameterTypes();
- }
-
- /**
- * Access the annotated method.
- * @return the annotated method, not null.
- */
- @Override
- public Method getAnnotatedMethod() {
- return this.setterMethod;
- }
-
- @Override
- public String getName() {
- return this.setterMethod.getName();
- }
-
- @Override
- public String getSignature() {
- return "void " + this.setterMethod.getName()+'('+ printTypes(getParameterTypes())+')';
- }
-
- private String printTypes(Class<?>[] parameterTypes) {
- StringBuilder b = new StringBuilder();
- for(Class cl:parameterTypes){
- b.append(cl.getName());
- b.append(',');
- }
- if(b.length()>0){
- b.setLength(b.length()-1);
- }
- return b.toString();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfiguredTypeImpl.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfiguredTypeImpl.java b/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfiguredTypeImpl.java
deleted file mode 100644
index b40f6c9..0000000
--- a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/ConfiguredTypeImpl.java
+++ /dev/null
@@ -1,237 +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.inject.internal;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.*;
-import java.util.logging.Logger;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.inject.api.ConfigAutoInject;
-import org.apache.tamaya.inject.api.NoConfig;
-import org.apache.tamaya.inject.api.Config;
-import org.apache.tamaya.inject.api.ConfigDefaultSections;
-import org.apache.tamaya.inject.spi.ConfiguredField;
-import org.apache.tamaya.inject.spi.ConfiguredMethod;
-import org.apache.tamaya.inject.spi.ConfiguredType;
-
-/**
- * Structure that contains and manages configuration related things for a configured type registered.
- * Created by Anatole on 03.10.2014.
- */
-@SuppressWarnings({"rawtypes", "unchecked"})
-public class ConfiguredTypeImpl implements ConfiguredType{
- /** The log used. */
- private static final Logger LOG = Logger.getLogger(ConfiguredTypeImpl.class.getName());
- /**
- * A list with all annotated instance variables.
- */
- private final List<ConfiguredField> configuredFields = new ArrayList<>();
- /**
- * A list with all annotated methods (templates).
- */
- private final List<ConfiguredMethod> configuredSetterMethods = new ArrayList<>();
- /**
- * The basic type.
- */
- private final Class type;
-
- /**
- * Creates an instance of this class hereby evaluating the config annotations given for later effective
- * injection (configuration) of instances.
- *
- * @param type the instance type.
- */
- public ConfiguredTypeImpl(Class type) {
- this.type = Objects.requireNonNull(type);
- if(!isConfigured(type)){
- LOG.info("Auto-Configuring type: " + type.getName());
- initFields(type, true);
- initMethods(type, true);
- }else {
- ConfigAutoInject autoInject = (ConfigAutoInject) type.getAnnotation(ConfigAutoInject.class);
- if (autoInject != null) {
- initFields(type, autoInject != null);
- initMethods(type, autoInject != null);
- } else {
- initFields(type, false);
- initMethods(type, false);
- }
- }
- }
-
- private void initFields(Class type, boolean autoConfigure) {
- for (Field f : type.getDeclaredFields()) {
- if (f.isAnnotationPresent(NoConfig.class)) {
- LOG.finest("Ignored @NoConfig annotated field " + f.getClass().getName() + "#" +
- f.toGenericString());
- continue;
- }
- if (Modifier.isFinal(f.getModifiers())) {
- LOG.finest("Ignored final field " + f.getClass().getName() + "#" +
- f.toGenericString());
- continue;
- }
- if (f.isSynthetic()) {
- LOG.finest("Ignored synthetic field " + f.getClass().getName() + "#" +
- f.toGenericString());
- continue;
- }
- try {
- if(isConfiguredField(f) || autoConfigure) {
- ConfiguredField configuredField = new ConfiguredFieldImpl(f);
- configuredFields.add(configuredField);
- LOG.finer("Registered field " + f.getClass().getName() + "#" +
- f.toGenericString());
- }
- } catch (Exception e) {
- throw new ConfigException("Failed to initialized configured field: " +
- f.getDeclaringClass().getName() + '.' + f.getName(), e);
- }
- }
- }
-
- private void initMethods(Class type, boolean autoConfigure) {
- // TODO revisit this logic here...
- for (Method m : type.getDeclaredMethods()) {
- if (m.isAnnotationPresent(NoConfig.class)) {
- LOG.finest("Ignored @NoConfig annotated method " + m.getClass().getName() + "#" +
- m.toGenericString());
- continue;
- }
- if (m.isSynthetic()) {
- LOG.finest("Ignored synthetic method " + m.getClass().getName() + "#" +
- m.toGenericString());
- continue;
- }
- if(isConfiguredMethod(m) || autoConfigure) {
- Config propAnnot = m.getAnnotation(Config.class);
- if (addPropertySetter(m, propAnnot)) {
- LOG.finer("Added configured setter: " + m.getClass().getName() + "#" +
- m.toGenericString());
- }
- }
- }
- }
-
- private boolean addPropertySetter(Method m, Config prop) {
- if (prop!=null) {
- if (m.getParameterTypes().length == 1) {
- // getter method
- Class<?> returnType = m.getReturnType();
- if (void.class.equals(returnType)) {
- try {
- configuredSetterMethods.add(new ConfiguredSetterMethod(m));
- return true;
- } catch (Exception e) {
- throw new ConfigException("Failed to initialized configured setter method: " +
- m.getDeclaringClass().getName() + '.' + m.getName(), e);
- }
- }
- }
- }
- return false;
- }
-
-
- /**
- * Method called to configure an instance.
- *
- * @param instance The instance to be configured.
- */
- public void configure(Object instance) {
- configure(instance, ConfigurationProvider.getConfiguration());
- }
-
- @Override
- public void configure(Object instance, Configuration config) {
- for (ConfiguredField field : configuredFields) {
- field.configure(instance, config);
- }
- for (ConfiguredMethod method : configuredSetterMethods) {
- method.configure(instance, config);
-// // TODO, if method should be recalled on changes, corresponding callbacks could be registered here
- }
- }
-
-
- public static boolean isConfigured(Class type) {
- if (type.getAnnotation(ConfigDefaultSections.class) != null) {
- return true;
- }
- // if no class level annotation is there we might have field level annotations only
- for (Field field : type.getDeclaredFields()) {
- if (isConfiguredField(field)) {
- return true;
- }
- }
- // if no class level annotation is there we might have method level annotations only
- for (Method method : type.getDeclaredMethods()) {
- if(isConfiguredMethod(method)) {
- return true;
- }
- }
- return false;
- }
-
- public static boolean isConfiguredField(Field field) {
- return field.isAnnotationPresent(Config.class);
- }
-
- public static boolean isConfiguredMethod(Method method) {
- return method.isAnnotationPresent(Config.class);
- }
-
- @Override
- public Class getType() {
- return this.type;
- }
-
- @Override
- public String getName() {
- return this.type.getName();
- }
-
- /**
- * Get the registered configured fields.
- * @return the registered configured fields, never null.
- */
- @Override
- public Collection<ConfiguredField> getConfiguredFields(){
- return configuredFields;
- }
-
- /**
- * Get the registered annotated setter methods.
- * @return the registered annotated setter methods, never null.
- */
- @Override
- public Collection<ConfiguredMethod> getConfiguredMethods(){
- return configuredSetterMethods;
- }
-
- @Override
- public String toString() {
- return "ConfigDefaultSections{"+ this.getType().getName() + '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/DefaultConfigurationInjector.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/DefaultConfigurationInjector.java b/modules/injection/src/main/java/org/apache/tamaya/inject/internal/DefaultConfigurationInjector.java
deleted file mode 100644
index a3a7015..0000000
--- a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/DefaultConfigurationInjector.java
+++ /dev/null
@@ -1,179 +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.inject.internal;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.inject.ConfigurationInjector;
-
-import javax.annotation.Priority;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.Map;
-import java.util.Objects;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Logger;
-
-import org.apache.tamaya.inject.api.ConfiguredItemSupplier;
-import org.apache.tamaya.inject.api.NoConfig;
-import org.apache.tamaya.inject.api.Config;
-import org.apache.tamaya.inject.api.ConfigDefaultSections;
-import org.apache.tamaya.inject.spi.ConfiguredType;
-
-/**
- * Simple injector singleton that also registers instances configured using weak references.
- */
-@Priority(0)
-public final class DefaultConfigurationInjector implements ConfigurationInjector {
-
- private final Map<Class<?>, ConfiguredType> configuredTypes = new ConcurrentHashMap<>();
-
- private static final Logger LOG = Logger.getLogger(DefaultConfigurationInjector.class.getName());
-
- private boolean autoConfigureEnabled = true;
-
- /**
- * Extract the configuration annotation config and registers it per class, for later reuse.
- *
- * @param type the type to be configured.
- * @return the configured type registered.
- */
- public ConfiguredType registerType(Class<?> type) {
- ConfiguredType confType = configuredTypes.get(type);
- if (confType == null) {
- if(!isConfigAnnotated(type) && !autoConfigureEnabled){
- return null;
- }
- confType = new ConfiguredTypeImpl(type);
- configuredTypes.put(type, confType);
- InjectionHelper.sendConfigurationEvent(confType);
- }
- return confType;
- }
-
- /**
- * If set also non annotated instances can be configured or created as templates.
- * @return true, if autoConfigureEnabled.
- */
- public boolean isAutoConfigureEnabled(){
- return autoConfigureEnabled;
- }
-
- /**
- * Setting to true enables also configuration/templating of non annotated classes or
- * interfaces.
- * @param enabled true enables also configuration/templating of
- */
- public void setAutoConfigureEnabled(boolean enabled){
- this.autoConfigureEnabled = enabled;
- }
-
- /**
- * CHecks if type is eligible for configuration injection.
- * @param type the target type, not null.
- * @return true, if the type, a method or field has Tamaya config annotation on it.
- */
- private boolean isConfigAnnotated(Class<?> type) {
- if(type.getClass().isAnnotationPresent(ConfigDefaultSections.class)){
- return true;
- }
- for (Field f : type.getDeclaredFields()) {
- if (f.isAnnotationPresent(NoConfig.class) || f.isAnnotationPresent(Config.class)) {
- return true;
- }
- }
- for (Method m : type.getDeclaredMethods()) {
- if (m.isAnnotationPresent(NoConfig.class) || m.isAnnotationPresent(Config.class)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Configured the current instance and reigsterd necessary listener to forward config change events as
- * defined by the current annotations in place.
- *
- * @param instance the instance to be configured
- */
- @Override
- public <T> T configure(T instance) {
- return configure(instance, ConfigurationProvider.getConfiguration());
- }
-
- /**
- * Configured the current instance and reigsterd necessary listener to forward config change events as
- * defined by the current annotations in place.
- *
- * @param instance the instance to be configured
- * @param config the target configuration, not null.
- */
- @Override
- public <T> T configure(T instance, Configuration config) {
- Class<?> type = Objects.requireNonNull(instance).getClass();
- ConfiguredType configuredType = registerType(type);
- if(configuredType!=null){
- configuredType.configure(instance, config);
- }else{
- LOG.info("Instance passed is not configurable: " + instance);
- }
- return instance;
- }
-
- /**
- * Create a template implementting the annotated methods based on current configuration data.
- *
- * @param templateType the type of the template to be created.
- */
- @Override
- public <T> T createTemplate(Class<T> templateType) {
- return createTemplate(templateType, ConfigurationProvider.getConfiguration());
- }
-
- /**
- * Create a template implementting the annotated methods based on current configuration data.
- *
- * @param templateType the type of the template to be created.
- * @param config the target configuration, not null.
- */
- @Override
- public <T> T createTemplate(Class<T> templateType, Configuration config) {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- if(cl==null){
- cl = this.getClass().getClassLoader();
- }
- return templateType.cast(Proxy.newProxyInstance(cl, new Class[]{ConfiguredItemSupplier.class, Objects.requireNonNull(templateType)},
- new ConfigTemplateInvocationHandler(templateType)));
- }
-
- @Override
- public <T> ConfiguredItemSupplier<T> getConfiguredSupplier(final ConfiguredItemSupplier<T> supplier) {
- return getConfiguredSupplier(supplier, ConfigurationProvider.getConfiguration());
- }
-
- @Override
- public <T> ConfiguredItemSupplier<T> getConfiguredSupplier(final ConfiguredItemSupplier<T> supplier, final Configuration config) {
- return new ConfiguredItemSupplier<T>() {
- public T get() {
- return configure(supplier.get(), config);
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/DefaultDynamicValue.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/DefaultDynamicValue.java b/modules/injection/src/main/java/org/apache/tamaya/inject/internal/DefaultDynamicValue.java
deleted file mode 100644
index 2f051b3..0000000
--- a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/DefaultDynamicValue.java
+++ /dev/null
@@ -1,498 +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.inject.internal;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.inject.api.BaseDynamicValue;
-import org.apache.tamaya.inject.api.DynamicValue;
-import org.apache.tamaya.inject.api.InjectionUtils;
-import org.apache.tamaya.inject.api.LoadPolicy;
-import org.apache.tamaya.inject.api.UpdatePolicy;
-import org.apache.tamaya.inject.api.WithPropertyConverter;
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.lang.ref.WeakReference;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Objects;
-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 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.
- * <h3>Implementation Details</h3>
- * This class is
- * <ul>
- * <li>Serializable, when also the item stored is serializable</li>
- * <li>Thread safe</li>
- * </ul>
- *
- * @param <T> The type of the value.
- */
-final class DefaultDynamicValue<T> extends BaseDynamicValue<T> {
-
- private static final long serialVersionUID = -2071172847144537443L;
-
- /**
- * The property name of the entry.
- */
- private final String propertyName;
- /**
- * The keys to be resolved.
- */
- private final String[] keys;
- /**
- * Back reference to the base configuration instance. This reference is used reevalaute the given property and
- * compare the result with the previous value after a configuration change was triggered.
- */
- private final Configuration configuration;
- /**
- * The target type of the property used to lookup a matching {@link PropertyConverter}.
- * If null, {@code propertyConverter} is set and used instead.
- */
- private final TypeLiteral<T> targetType;
- /**
- * The property converter to be applied, may be null. In the ladder case targetType is not null.
- */
- private final PropertyConverter<T> propertyConverter;
- /**
- * Policy that defines how new values are applied, be default it is applied initially once, but never updated
- * anymore.
- */
- private UpdatePolicy updatePolicy;
- /**
- * Load policy.
- */
- private final LoadPolicy loadPolicy;
-
- /**
- * The current value, never null.
- */
- private transient T value;
- /**
- * The new value, or null.
- */
- private transient Object[] newValue;
- /**
- * List of listeners that listen for changes.
- */
- private transient WeakList<PropertyChangeListener> listeners;
-
- /**
- * Constructor.
- *
- * @param propertyName the name of the fields' property/method.
- * @param keys the keys of the property, not null.
- * @param configuration the configuration, not null.
- * @param targetType the target type, not null.
- * @param propertyConverter the optional converter to be used.
- */
- private DefaultDynamicValue(String propertyName, Configuration configuration, TypeLiteral<T> targetType,
- PropertyConverter<T> propertyConverter, List<String> keys, LoadPolicy loadPolicy,
- UpdatePolicy updatePolicy) {
- this.propertyName = Objects.requireNonNull(propertyName);
- this.keys = keys.toArray(new String[keys.size()]);
- this.configuration = Objects.requireNonNull(configuration);
- this.propertyConverter = propertyConverter;
- this.targetType = targetType;
- this.loadPolicy = Objects.requireNonNull(loadPolicy);
- this.updatePolicy = Objects.requireNonNull(updatePolicy);
- if(loadPolicy == LoadPolicy.INITIAL){
- this.value = evaluateValue();
- }
- }
-
- public static DynamicValue of(Field annotatedField, Configuration configuration) {
- return of(annotatedField, configuration, LoadPolicy.ALWAYS, UpdatePolicy.IMMEDEATE);
- }
-
- public static DynamicValue of(Field annotatedField, Configuration configuration, LoadPolicy loadPolicy) {
- return of(annotatedField, configuration, loadPolicy, UpdatePolicy.IMMEDEATE);
- }
-
- public static DynamicValue of(Field annotatedField, Configuration configuration, UpdatePolicy updatePolicy) {
- return of(annotatedField, configuration, LoadPolicy.ALWAYS, updatePolicy);
- }
-
- public static DynamicValue of(Field annotatedField, Configuration configuration, LoadPolicy loadPolicy, UpdatePolicy updatePolicy) {
- // Check for adapter/filter
- Type targetType = annotatedField.getGenericType();
- if (targetType == null) {
- throw new ConfigException("Failed to evaluate target type for " + annotatedField.getDeclaringClass().getName()
- + '.' + annotatedField.getName());
- }
- if (targetType instanceof ParameterizedType) {
- ParameterizedType pt = (ParameterizedType) targetType;
- Type[] types = pt.getActualTypeArguments();
- if (types.length != 1) {
- throw new ConfigException("Failed to evaluate target type for " + annotatedField.getDeclaringClass().getName()
- + '.' + annotatedField.getName());
- }
- targetType = types[0];
- }
- PropertyConverter<?> propertyConverter = null;
- WithPropertyConverter annot = annotatedField.getAnnotation(WithPropertyConverter.class);
- if (annot != null) {
- try {
- propertyConverter = annot.value().newInstance();
- } catch (Exception e) {
- throw new ConfigException("Failed to instantiate annotated PropertyConverter on " +
- annotatedField.getDeclaringClass().getName()
- + '.' + annotatedField.getName(), e);
- }
- }
- List<String> keys = InjectionUtils.getKeys(annotatedField);
- return new DefaultDynamicValue(annotatedField.getName(), configuration,
- TypeLiteral.of(targetType), propertyConverter, keys, loadPolicy, updatePolicy);
- }
-
- public static DynamicValue of(Method method, Configuration configuration) {
- return of(method, configuration, LoadPolicy.ALWAYS, UpdatePolicy.IMMEDEATE);
- }
-
- public static DynamicValue of(Method method, Configuration configuration, UpdatePolicy updatePolicy) {
- return of(method, configuration, LoadPolicy.ALWAYS, updatePolicy);
- }
-
- public static DynamicValue of(Method method, Configuration configuration, LoadPolicy loadPolicy) {
- return of(method, configuration, loadPolicy, UpdatePolicy.IMMEDEATE);
- }
-
- public static DynamicValue of(Method method, Configuration configuration, LoadPolicy loadPolicy, UpdatePolicy updatePolicy) {
- // Check for adapter/filter
- Type targetType = method.getGenericReturnType();
- if (targetType == null) {
- throw new ConfigException("Failed to evaluate target type for " + method.getDeclaringClass()
- .getName() + '.' + method.getName());
- }
- if (targetType instanceof ParameterizedType) {
- ParameterizedType pt = (ParameterizedType) targetType;
- Type[] types = pt.getActualTypeArguments();
- if (types.length != 1) {
- throw new ConfigException("Failed to evaluate target type for " + method.getDeclaringClass()
- .getName() + '.' + method.getName());
- }
- targetType = types[0];
- }
- PropertyConverter<Object> propertyConverter = null;
- WithPropertyConverter annot = method.getAnnotation(WithPropertyConverter.class);
- if (annot != null) {
- try {
- propertyConverter = (PropertyConverter<Object>) annot.value().newInstance();
- } catch (Exception e) {
- throw new ConfigException("Failed to instantiate annotated PropertyConverter on " +
- method.getDeclaringClass().getName()
- + '.' + method.getName(), e);
- }
- }
- return new DefaultDynamicValue<>(method.getName(),
- configuration, TypeLiteral.of(targetType), propertyConverter, InjectionUtils.getKeys(method),
- loadPolicy, updatePolicy);
- }
-
-
- /**
- * Commits a new value that has not been committed yet, make it the new value of the instance. On change any
- * registered listeners will be triggered.
- */
- public void commit() {
- T oldValue = value;
- value = newValue==null?null:(T)newValue[0];
- newValue = null;
- informListeners(oldValue, value);
- }
-
- private void informListeners(T value, T newValue) {
- synchronized (this) {
- PropertyChangeEvent evt = new PropertyChangeEvent(this, propertyName, value,
- newValue);
- if (listeners != null) {
- for (PropertyChangeListener consumer : listeners.get()) {
- consumer.propertyChange(evt);
- }
- }
- }
- }
-
- /**
- * Discards a new value that was published. No listeners will be informed.
- */
- public void discard() {
- newValue = null;
- }
-
-
- /**
- * Access the {@link UpdatePolicy} used for updating this value.
- *
- * @return the update policy, never null.
- */
- public UpdatePolicy getUpdatePolicy() {
- return updatePolicy;
- }
-
- /**
- * Sets a new {@link UpdatePolicy}.
- *
- * @param updatePolicy the new policy, not null.
- */
- public void setUpdatePolicy(UpdatePolicy updatePolicy) {
- this.updatePolicy = Objects.requireNonNull(updatePolicy);
- }
-
- /**
- * Add a listener to be called as weak reference, when this value has been changed.
- *
- * @param l the listener, not null
- */
- public void addListener(PropertyChangeListener l) {
- if (listeners == null) {
- listeners = new WeakList<>();
- }
- listeners.add(l);
- }
-
- /**
- * Removes a listener to be called, when this value has been changed.
- *
- * @param l the listner to be removed, not null
- */
- public void removeListener(PropertyChangeListener l) {
- if (listeners != null) {
- listeners.remove(l);
- }
- }
-
- /**
- * If a value is present in this {@code DynamicValue}, returns the value,
- * otherwise throws {@code ConfigException}.
- *
- * @return the non-null value held by this {@code Optional}
- * @throws ConfigException if there is no value present
- * @see DefaultDynamicValue#isPresent()
- */
- public T get() {
- T newLocalValue;
- if(loadPolicy!=LoadPolicy.INITIAL) {
- newLocalValue = evaluateValue();
- if (this.value == null) {
- this.value = newLocalValue;
- }
- if(!Objects.equals(this.value, newLocalValue)){
- switch (updatePolicy){
- case IMMEDEATE:
- commit();
- break;
- case EXPLCIT:
- this.newValue = new Object[]{newLocalValue};
- break;
- case LOG_ONLY:
- informListeners(this.value, newLocalValue);
- this.newValue = null;
- break;
- case NEVER:
- this.newValue = null;
- break;
- default:
- this.newValue = null;
- break;
- }
- }
- }
- return value;
- }
-
- /**
- * Method to check for and apply a new value. Depending on the {@link UpdatePolicy}
- * the value is immediately or deferred visible (or it may even be ignored completely).
- *
- * @return true, if a new value has been detected. The value may not be visible depending on the current
- * {@link UpdatePolicy} in place.
- */
- public boolean updateValue() {
- if(this.value==null && this.newValue==null){
- this.value = evaluateValue();
- return false;
- }
- T newValue = evaluateValue();
- if (Objects.equals(newValue, this.value)) {
- return false;
- }
- switch (this.updatePolicy) {
- case LOG_ONLY:
- Logger.getLogger(getClass().getName()).info("Discard change on " + this + ", newValue=" + newValue);
- informListeners(value, newValue);
- this.newValue = null;
- break;
- case NEVER:
- this.newValue = null;
- break;
- case EXPLCIT:
- case IMMEDEATE:
- default:
- this.newValue = new Object[]{newValue};
- commit();
- break;
- }
- return true;
- }
-
- /**
- * Evaluates the current value dynamically from the underlying configuration.
- *
- * @return the current actual value, or null.
- */
- public T evaluateValue() {
- T value = null;
-
- for (String key : keys) {
- ConversionContext ctx = new ConversionContext.Builder(key, targetType).build();
- if (propertyConverter == null) {
- value = configuration.get(key, targetType);
- } else {
- String source = configuration.get(key);
- value = propertyConverter.convert(source, ctx);
- }
-
- if (value != null) {
- break;
- }
- }
-
- return value;
- }
-
- /**
- * Access a new value that has not yet been committed.
- *
- * @return the uncommitted new value, or null.
- */
- public T getNewValue() {
- T nv = newValue==null?null:(T)newValue[0];
- if (nv != null) {
- return nv;
- }
- return null;
- }
-
-
- /**
- * Serialization implementation that strips away the non serializable Optional part.
- *
- * @param oos the output stream
- * @throws IOException if serialization fails.
- */
- private void writeObject(ObjectOutputStream oos) throws IOException {
- oos.writeObject(getUpdatePolicy());
- oos.writeObject(get());
- }
-
- /**
- * Reads an instance from the input stream.
- *
- * @param ois the object input stream
- * @throws IOException if deserialization fails.
- * @throws ClassNotFoundException
- */
- private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
- this.updatePolicy = (UpdatePolicy) ois.readObject();
- if (isPresent()) {
- this.value = (T) ois.readObject();
- }
- newValue = null;
- }
-
-
- /**
- * Simple helper that allows keeping the listeners registered as weak references, hereby avoiding any
- * memory leaks.
- *
- * @param <I> the type
- */
- private class WeakList<I> {
- final List<WeakReference<I>> refs = new LinkedList<>();
-
- /**
- * Adds a new instance.
- *
- * @param t the new instance, not null.
- */
- void add(I t) {
- refs.add(new WeakReference<>(t));
- }
-
- /**
- * Removes a instance.
- *
- * @param t the instance to be removed.
- */
- void remove(I t) {
- synchronized (refs) {
- for (Iterator<WeakReference<I>> iterator = refs.iterator(); iterator.hasNext(); ) {
- WeakReference<I> ref = iterator.next();
- I instance = ref.get();
- if (instance == null || instance == t) {
- iterator.remove();
- break;
- }
- }
- }
- }
-
-
- /**
- * Access a list (copy) of the current instances that were not discarded by the GC.
- *
- * @return the list of accessible items.
- */
- public List<I> get() {
- synchronized (refs) {
- List<I> res = new ArrayList<>();
- for (Iterator<WeakReference<I>> iterator = refs.iterator(); iterator.hasNext(); ) {
- WeakReference<I> ref = iterator.next();
- I instance = ref.get();
- if (instance == null) {
- iterator.remove();
- } else {
- res.add(instance);
- }
- }
- return res;
- }
- }
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/InjectionHelper.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/InjectionHelper.java b/modules/injection/src/main/java/org/apache/tamaya/inject/internal/InjectionHelper.java
deleted file mode 100644
index 305a660..0000000
--- a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/InjectionHelper.java
+++ /dev/null
@@ -1,244 +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.inject.internal;
-
-import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.Field;
-import java.lang.reflect.Member;
-import java.lang.reflect.Method;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.events.ConfigEventManager;
-import org.apache.tamaya.events.spi.BaseConfigEvent;
-import org.apache.tamaya.inject.api.Config;
-import org.apache.tamaya.inject.api.ConfigDefaultSections;
-import org.apache.tamaya.inject.api.InjectionUtils;
-import org.apache.tamaya.inject.api.WithPropertyConverter;
-import org.apache.tamaya.inject.spi.ConfiguredType;
-import org.apache.tamaya.resolver.spi.ExpressionEvaluator;
-import org.apache.tamaya.spi.ConfigurationContext;
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-import org.apache.tamaya.spi.ServiceContextManager;
-
-
-/**
- * Utility class containing several aspects used in this module.
- */
-@SuppressWarnings("unchecked")
-final class InjectionHelper {
-
- private static final Logger LOG = Logger.getLogger(InjectionHelper.class.getName());
-
- private static final boolean RESOLUTION_MODULE_LOADED = checkResolutionModuleLoaded();
-
- private static final boolean EVENTS_AVAILABLE = checkForEvents();
-
- private static boolean checkForEvents() {
- try{
- Class.forName("org.apache.tamaya.events.FrozenConfiguration");
- LOG.info("Detected tamaya-events is loaded, will trigger ConfigEvents...");
- return true;
- } catch(Exception e){
- LOG.info("Detected tamaya-events not found, will not trigger any ConfigEvents...");
- return false;
- }
- }
-
- private static boolean checkResolutionModuleLoaded() {
- try {
- Class.forName("org.apache.tamaya.resolver.internal.DefaultExpressionEvaluator");
- return true;
- } catch (ClassNotFoundException e) {
- return false;
- }
- }
-
- private InjectionHelper() {
- }
-
- /**
- * Internally evaluated the current valid configuration keys based on the given annotations present.
- * @param method the method
- * @return the keys to be returned, or null.
- */
- public static String getConfigValue(Method method, Configuration config) {
- return getConfigValue(method, null, config);
- }
-
- /**
- * Internally evaluated the current valid configuration keys based on the given annotations present.
- * @param method the method
- * @param retKey the array to return the key found, or null.
- * @return the keys to be returned, or null.
- */
- public static String getConfigValue(Method method, String[] retKey, Configuration config) {
- ConfigDefaultSections areasAnnot = method.getDeclaringClass().getAnnotation(ConfigDefaultSections.class);
- return getConfigValueInternal(method, areasAnnot, retKey, config);
- }
-
- /**
- * Internally evaluated the current valid configuration keys based on the given annotations present.
- * @param field the field
- * @return the keys to be returned, or null.
- */
- public static String getConfigValue(Field field, Configuration config) {
- return getConfigValue(field, null, config);
- }
-
- /**
- * Internally evaluated the current valid configuration keys based on the given annotations present.
- * @param field the field
- * @param retKey the array to return the key found, or null.
- * @return the keys to be returned, or null.
- */
- public static String getConfigValue(Field field, String[] retKey, Configuration config) {
- ConfigDefaultSections areasAnnot = field.getDeclaringClass().getAnnotation(ConfigDefaultSections.class);
- return getConfigValueInternal(field, areasAnnot, retKey, config);
- }
-
- /**
- * Internally evaluated the current valid configuration keys based on the given annotations present.
- *
- * @return the keys to be returned, or null.
- */
- private static String getConfigValueInternal(AnnotatedElement element, ConfigDefaultSections areasAnnot, String[] retKey, Configuration config) {
- Config prop = element.getAnnotation(Config.class);
- List<String> keys;
- if (prop == null) {
- keys = InjectionUtils.evaluateKeys((Member) element, areasAnnot);
- } else {
- keys = InjectionUtils.evaluateKeys((Member) element, areasAnnot, prop);
- }
- String configValue = evaluteConfigValue(keys, retKey, config);
- if (configValue == null) {
- if(prop==null || prop.defaultValue().isEmpty()){
- return null;
- }
- return prop.defaultValue();
- }
- return configValue;
- }
-
-
- private static String evaluteConfigValue(List<String> keys, String[] retKey, Configuration config) {
- String configValue = null;
- for (String key : keys) {
- configValue = config.get(key);
- if (configValue != null) {
- if(retKey!=null && retKey.length>0){
- retKey[0] = key;
- }
- break;
- }
- }
- return configValue;
- }
-
-
- @SuppressWarnings("rawtypes")
- public static <T> T adaptValue(AnnotatedElement element, TypeLiteral<T> targetType, String key, String configValue) {
- // Check for adapter/filter
- T adaptedValue = null;
- WithPropertyConverter converterAnnot = element.getAnnotation(WithPropertyConverter.class);
- Class<? extends PropertyConverter<T>> converterType;
- if (converterAnnot != null) {
- converterType = (Class<? extends PropertyConverter<T>>) converterAnnot.value();
- if (!converterType.getName().equals(WithPropertyConverter.class.getName())) {
- try {
- // TODO cache here...
- ConversionContext ctx = new ConversionContext.Builder(key,targetType)
- .setAnnotatedElement(element).build();
-
- PropertyConverter<T> converter = PropertyConverter.class.cast(converterType.newInstance());
- adaptedValue = converter.convert(configValue, ctx);
- } catch (Exception e) {
- LOG.log(Level.SEVERE, "Failed to convert using explicit PropertyConverter on " + element +
- ", trying default conversion.", e);
- }
- }
- }
- if (adaptedValue != null) {
- return adaptedValue;
- }
- if (String.class == targetType.getType()) {
- return (T) configValue;
- } else{
- if(configValue==null) {
- return null;
- }
- ConfigurationContext configContext = ConfigurationProvider.getConfiguration().getContext();
- List<PropertyConverter<T>> converters = configContext
- .getPropertyConverters(targetType);
- ConversionContext ctx = new ConversionContext.Builder(ConfigurationProvider.getConfiguration(),
- configContext, key, targetType).setAnnotatedElement(element).build();
- for (PropertyConverter<T> converter : converters) {
- adaptedValue = converter.convert(configValue, ctx);
- if (adaptedValue != null) {
- return adaptedValue;
- }
- }
- }
- throw new ConfigException("Non convertible property type: " + element);
- }
-
- /**
- * Method that allows to statically check, if the resolver module is loaded. If the module is loaded
- * value expressions are automatically forwarded to the resolver module for resolution.
- *
- * @return true, if the resolver module is on the classpath.
- */
- public static boolean isResolutionModuleLoaded() {
- return RESOLUTION_MODULE_LOADED;
- }
-
- /**
- * Evaluates the given expression.
- *
- * @param expression the expression, not null.
- * @return the evaluated expression.
- */
- public static String evaluateValue(String expression) {
- if (!RESOLUTION_MODULE_LOADED) {
- return expression;
- }
- ExpressionEvaluator evaluator = ServiceContextManager.getServiceContext().getService(ExpressionEvaluator.class);
- if (evaluator != null) {
- return evaluator.evaluateExpression("<injection>", expression, true);
- }
- return expression;
- }
-
- /**
- * This method distributes the configuration event, if the Tamaya event module is accessible.
- * When Tamaya events are not available, the call simply returns.
- * @param event the event to be distributed, not null.
- */
- static void sendConfigurationEvent(ConfiguredType event) {
- if(EVENTS_AVAILABLE){
- ConfigEventManager.fireEvent(new BaseConfigEvent<ConfiguredType>(event, ConfiguredType.class) {});
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/Utils.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/Utils.java b/modules/injection/src/main/java/org/apache/tamaya/inject/internal/Utils.java
deleted file mode 100644
index 2c08467..0000000
--- a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/Utils.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.inject.internal;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Utility class simplifying some implementation aspects.
- * Created by Anatole on 11.11.2014.
- */
-@SuppressWarnings("unchecked")
-public final class Utils {
-
- private static final Logger LOG = Logger.getLogger(Utils.class.getName());
-
- private Utils() {
- }
-
- /**
- * Utility method to read out repeatable annotations.
- *
- * @param annotated the annotated instance.
- * @param repeatableAnnotation the repeatable annotation type
- * @param annotationContainer the container annotation type
- * @param <T> the repeatable annotation type
- * @param <R> the repeatable container annotation type
- * @return a list with the annotations found (could be empty, but never null).
- */
- public static <T extends Annotation, R extends Annotation> Collection<T>
- getAnnotations(AnnotatedElement annotated,
- Class<T> repeatableAnnotation,
- Class<R> annotationContainer) {
- List<T> result = new ArrayList<>();
- R containerAnnot = annotated.getAnnotation(annotationContainer);
- if (containerAnnot != null) {
- Method valueMethod;
- try {
- valueMethod = annotationContainer.getMethod("keys");
- result.addAll(Arrays.asList((T[]) valueMethod.invoke(containerAnnot)));
- } catch (Exception e) {
- LOG.log(Level.SEVERE, "Failed to evaluate repeatable annotation.", e);
- }
- } else {
- T annot = annotated.getAnnotation(repeatableAnnotation);
- if (annot != null) {
- result.add(annot);
- }
- }
- return result;
- }
-
- /**
- * Utility method to read out repeatable annotations.
- *
- * @param annotated the annotated instance.
- * @param repeatableAnnotation the repeatable annotation type
- * @param annotationContainer the container annotation type
- * @param <T> the repeatable annotation type
- * @param <R> the repeatable container annotation type
- * @return a list with the annotations found (could be empty, but never null).
- */
- public static <T extends Annotation, R extends Annotation> Collection<T>
- getAnnotations(AccessibleObject annotated,
- Class<T> repeatableAnnotation,
- Class<R> annotationContainer) {
- List<T> result = new ArrayList<>();
- R containerAnnot = annotated.getAnnotation(annotationContainer);
- if (containerAnnot != null) {
- Method valueMethod;
- try {
- valueMethod = annotationContainer.getMethod("keys");
- result.addAll(Arrays.asList((T[]) valueMethod.invoke(containerAnnot)));
- } catch (Exception e) {
- LOG.log(Level.SEVERE, "Failed to evaluate repeatable annotation.", e);
- }
- } else {
- T annot = annotated.getAnnotation(repeatableAnnotation);
- if (annot != null) {
- result.add(annot);
- }
- }
- return result;
- }
-
- /**
- * Utility method to read out repeatable annotations.
- *
- * @param annotationType the annotation type.
- * @param objects the accessible objects to be looked up
- * @param <T> the repeatable annotation type
- * @return a list with the annotations found (could be empty, but never null).
- */
- public static <T extends Annotation> T getAnnotation(
- Class<T> annotationType, AnnotatedElement... objects) {
- for (AnnotatedElement obj : objects) {
- T annot = obj.getAnnotation(annotationType);
- if (annot != null) {
- return annot;
- }
- }
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/package-info.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/package-info.java b/modules/injection/src/main/java/org/apache/tamaya/inject/internal/package-info.java
deleted file mode 100644
index 55e8cf6..0000000
--- a/modules/injection/src/main/java/org/apache/tamaya/inject/internal/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-/**
- * This package provides default implementation of a purely SE based injection mechanism.
- */
-package org.apache.tamaya.inject.internal;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/injection/src/main/java/org/apache/tamaya/inject/package-info.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/java/org/apache/tamaya/inject/package-info.java b/modules/injection/src/main/java/org/apache/tamaya/inject/package-info.java
deleted file mode 100644
index 4119248..0000000
--- a/modules/injection/src/main/java/org/apache/tamaya/inject/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-/**
- * Main SE based injection API.
- */
-package org.apache.tamaya.inject;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/injection/src/main/resources/META-INF/services/org.apache.tamaya.inject.ConfigurationInjector
----------------------------------------------------------------------
diff --git a/modules/injection/src/main/resources/META-INF/services/org.apache.tamaya.inject.ConfigurationInjector b/modules/injection/src/main/resources/META-INF/services/org.apache.tamaya.inject.ConfigurationInjector
deleted file mode 100644
index 7204749..0000000
--- a/modules/injection/src/main/resources/META-INF/services/org.apache.tamaya.inject.ConfigurationInjector
+++ /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.inject.internal.DefaultConfigurationInjector
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/injection/src/test/java/annottext/AnnotatedConfigBean.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/test/java/annottext/AnnotatedConfigBean.java b/modules/injection/src/test/java/annottext/AnnotatedConfigBean.java
deleted file mode 100644
index 3420977..0000000
--- a/modules/injection/src/test/java/annottext/AnnotatedConfigBean.java
+++ /dev/null
@@ -1,78 +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 annottext;
-
-import org.apache.tamaya.inject.api.DynamicValue;
-import org.apache.tamaya.inject.api.NoConfig;
-import org.apache.tamaya.inject.api.Config;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * An example showing some basic annotations, using an interface to be proxied by the
- * configuration system, nevertheless extending the overall Configuration interface.
- * Created by Anatole on 15.02.14.
- */
-public class AnnotatedConfigBean {
-
- @Config(value = {"foo.bar.myprop", "mp", "common.testdata.myProperty"}, defaultValue = "ET")
- // @ConfigLoadPolicy(listener = MyListener.class)
- public String myParameter;
-
- @Config("simple_value")
- public String simpleValue;
-
- @Config
- String anotherValue;
-
- @Config("host.name")
- private String hostName;
-
- @Config("host.name")
- private DynamicValue<String> dynamicHostname;
-
- @NoConfig
- public String javaVersion;
-
- public String getAnotherValue(){
- return anotherValue;
- }
-
- public String getHostName(){
- return hostName;
- }
-
- public DynamicValue<String> getDynamicValue(){
- return dynamicHostname;
- }
-
- @NoConfig
- private List<String> events = new ArrayList<>();
-
- // verify we don't try to inject final fields
- public static final String CONSTANT = "a constant";
-
-
- @Config("java.version")
- void setJavaVersion(String version){
- this.javaVersion = version;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/injection/src/test/java/annottext/AnnotatedConfigTemplate.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/test/java/annottext/AnnotatedConfigTemplate.java b/modules/injection/src/test/java/annottext/AnnotatedConfigTemplate.java
deleted file mode 100644
index 8c6d692..0000000
--- a/modules/injection/src/test/java/annottext/AnnotatedConfigTemplate.java
+++ /dev/null
@@ -1,47 +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 annottext;
-
-import org.apache.tamaya.inject.api.DynamicValue;
-import org.apache.tamaya.inject.api.Config;
-
-/**
- * An example showing some basic annotations, using an interface to be proxied by the
- * configuration system.
- * Created by Anatole on 15.02.14.
- */
-public interface AnnotatedConfigTemplate {
-
- @Config(value = {"foo.bar.myprop", "mp","common.testdata.myProperty"}, defaultValue = "ET")
- // @ConfigLoadPolicy(listener = MyListener.class)
- String myParameter();
-
- @Config("simple_value")
- String simpleValue();
-
- @Config
- String simplestValue();
-
- @Config("host.name")
- String hostName();
-
- @Config("host.name")
- DynamicValue<String> getDynamicValue();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/injection/src/test/java/annottext/NonAnnotatedConfigBean.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/test/java/annottext/NonAnnotatedConfigBean.java b/modules/injection/src/test/java/annottext/NonAnnotatedConfigBean.java
deleted file mode 100644
index 87f8be7..0000000
--- a/modules/injection/src/test/java/annottext/NonAnnotatedConfigBean.java
+++ /dev/null
@@ -1,45 +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 annottext;
-
-import org.apache.tamaya.inject.api.Config;
-import org.apache.tamaya.inject.api.DynamicValue;
-import org.apache.tamaya.inject.api.NoConfig;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * An example showing some basic annotations, using an interface to be proxied by the
- * configuration system, nevertheless extending the overall Configuration interface.
- * Created by Anatole on 15.02.14.
- */
-public class NonAnnotatedConfigBean {
-
- public String simple_value = "Should be overridden!";
-
- public String fieldKey;
-
- public String classFieldKey = "Foo";
-
- public String fullKey;
-
- public String test2 = "This is not set.";
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/injection/src/test/java/org/apache/tamaya/inject/TamayaInjectionTest.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/test/java/org/apache/tamaya/inject/TamayaInjectionTest.java b/modules/injection/src/test/java/org/apache/tamaya/inject/TamayaInjectionTest.java
deleted file mode 100644
index d5a26c1..0000000
--- a/modules/injection/src/test/java/org/apache/tamaya/inject/TamayaInjectionTest.java
+++ /dev/null
@@ -1,87 +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.inject;
-
-import annottext.AnnotatedConfigBean;
-import annottext.AnnotatedConfigTemplate;
-import annottext.NonAnnotatedConfigBean;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-/**
- * Created by Anatole on 12.01.2015.
- */
-public class TamayaInjectionTest {
-
- @Test
- public void testInjectionNonAnnotatedClass(){
- assertNotNull(ConfigurationInjection.getConfigurationInjector());
- NonAnnotatedConfigBean testInstance = new NonAnnotatedConfigBean();
- assertEquals(testInstance.simple_value, "Should be overridden!");
- assertEquals(testInstance.classFieldKey, "Foo");
- assertEquals(testInstance.fieldKey, null);
- assertEquals(testInstance.fullKey, null);
- assertEquals(testInstance.test2, "This is not set.");
- ConfigurationInjection.getConfigurationInjector().configure(testInstance);
- assertEquals(testInstance.simple_value, "aSimpleValue");
- assertEquals(testInstance.classFieldKey, "Class-Field-Value");
- assertEquals(testInstance.fieldKey, "Field-Value");
- assertEquals(testInstance.fullKey, "Fullkey-Value");
- assertEquals(testInstance.test2, "This is not set.");
- }
-
- @Test
- public void testInjectionClass(){
- assertNotNull(ConfigurationInjection.getConfigurationInjector());
- AnnotatedConfigBean testInstance = new AnnotatedConfigBean();
- assertEquals(testInstance.getHostName(), null);
- assertEquals(testInstance.getAnotherValue(), null);
- assertEquals(testInstance.myParameter, null);
- assertEquals(testInstance.simpleValue, null);
- ConfigurationInjection.getConfigurationInjector().configure(testInstance);
- assertEquals(testInstance.getHostName(), "tamaya01.incubator.apache.org");
- assertEquals(testInstance.getAnotherValue(), "HALLO!");
- assertEquals(testInstance.myParameter, "ET");
- assertEquals(testInstance.simpleValue, "aSimpleValue");
- assertNotNull(testInstance.getDynamicValue());
- assertTrue(testInstance.getDynamicValue().isPresent());
- assertEquals(testInstance.getDynamicValue().get(), "tamaya01.incubator.apache.org");
- assertEquals(testInstance.getHostName(), testInstance.getDynamicValue().get());
- assertEquals(testInstance.javaVersion, System.getProperty("java.version"));
- }
-
- @Test
- public void testConfigTemplate(){
- assertNotNull(ConfigurationInjection.getConfigurationInjector());
- AnnotatedConfigTemplate testInstance = ConfigurationInjection.getConfigurationInjector()
- .createTemplate(AnnotatedConfigTemplate.class);
- assertEquals(testInstance.hostName(), "tamaya01.incubator.apache.org");
- assertEquals(testInstance.myParameter(), "ET");
- assertEquals(testInstance.simpleValue(), "aSimpleValue");
- assertNotNull(testInstance.getDynamicValue());
- assertTrue(testInstance.getDynamicValue().isPresent());
- assertEquals(testInstance.getDynamicValue().get(), "tamaya01.incubator.apache.org");
- assertEquals(testInstance.hostName(), testInstance.getDynamicValue().get());
-// assertEquals(testInstance.simplestValue(), "HALLO!");
- }
-
-}
[07/24] incubator-tamaya git commit: Removed all modules from the
main repository. They will be reborn in separate ASF repository.
Posted by pl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/main/java/org/apache/tamaya/model/spi/SectionModel.java
----------------------------------------------------------------------
diff --git a/modules/model/src/main/java/org/apache/tamaya/model/spi/SectionModel.java b/modules/model/src/main/java/org/apache/tamaya/model/spi/SectionModel.java
deleted file mode 100644
index de0b398..0000000
--- a/modules/model/src/main/java/org/apache/tamaya/model/spi/SectionModel.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.model.spi;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.model.ConfigModel;
-import org.apache.tamaya.model.ModelTarget;
-import org.apache.tamaya.model.Validation;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-
-/**
- * Default configuration Model for a configuration section.
- */
-public class SectionModel extends GroupModel {
-
- /**
- * Creates a new builder.
- * @param owner owner, not null.
- * @param name the section name.
- * @return a new builder instance.
- */
- public static Builder builder(String owner, String name){
- return new Builder(owner, name);
- }
-
- /**
- * Creates a section validation for the given section.
- * @param owner owner, not null.
- * @param name the fully qualified section name
- * @param required flag, if the section is required to be present.
- * @return the ConfigModel instance
- */
- public static ConfigModel of(String owner, String name, boolean required){
- return new Builder(owner, name).setRequired(required).build();
- }
-
- /**
- * Creates a section validation for the given section.
- * @param owner owner, not null.
- * @param name the fully qualified section name
- * @param required flag, if the section is required to be present.
- * @param configModels additional configModels
- * @return a new builder, never null.
- */
- public static ConfigModel of(String owner, String name, boolean required, ConfigModel... configModels){
- return new Builder(owner, name).setRequired(required).addValidations(configModels).build();
- }
-
- /**
- * Internal constructor.
- * @param builder the builder, not null.
- */
- protected SectionModel(Builder builder) {
- super(builder.owner, builder.name, builder.childConfigModels);
- }
-
- @Override
- public ModelTarget getType(){
- return ModelTarget.Section;
- }
-
- @Override
- public Collection<Validation> validate(Configuration config) {
- Map<String,String> map = config.getProperties();
- String lookupKey = getName() + '.';
- boolean present = false;
- for(String key:map.keySet()){
- if(key.startsWith("_")){
- continue;
- }
- if(key.startsWith(lookupKey)){
- present = true;
- break;
- }
- }
- List<Validation> result = new ArrayList<>(1);
- if(isRequired() && !present) {
- result.add(Validation.ofMissing(this));
- }
- result.addAll(super.validate(config));
- return result;
- }
-
- @Override
- public String toString() {
- StringBuilder b = new StringBuilder();
- b.append(getType()).append(": ").append(getName());
- if(isRequired()) {
- b.append(", required: " ).append(isRequired());
- }
- for(ConfigModel val:getValidations()){
- b.append(", ").append(val.toString());
- }
- return b.toString();
- }
-
- /**
- * Builder for setting up a AreaConfigModel instance.
- */
- public static class Builder{
- /** The section owner. */
- private String owner;
- /** The section name. */
- private String name;
- /** The optional description. */
- private String description;
- /** The required flag. */
- private boolean required;
- /** The (optional) custom validations.*/
- private final List<ConfigModel> childConfigModels = new ArrayList<>();
-
- /**
- * Creates a new Builder.
- * @param owner owner, not null.
- * @param sectionName the section name, not null.
- */
- public Builder(String owner, String sectionName){
- this.owner = Objects.requireNonNull(owner);
- this.name = Objects.requireNonNull(sectionName);
- }
-
- /**
- * Add configModels.
- * @param configModels the configModels, not null.
- * @return the Builder for chaining.
- */
- public Builder addValidations(ConfigModel... configModels){
- this.childConfigModels.addAll(Arrays.asList(configModels));
- return this;
- }
-
- /**
- * Add configModels.
- * @param configModels the configModels, not null.
- * @return the Builder for chaining.
- */
- public Builder addValidations(Collection<ConfigModel> configModels){
- this.childConfigModels.addAll(configModels);
- return this;
- }
-
- /**
- * Sets the required flag.
- * @param required zhe flag.
- * @return the Builder for chaining.
- */
- public Builder setRequired(boolean required){
- this.required = required;
- return this;
- }
-
- /**
- * Set the )optional) description.
- * @param description the description.
- * @return the Builder for chaining.
- */
- public Builder setDescription(String description){
- this.description = description;
- return this;
- }
-
- /**
- * Set the section name
- * @param name the section name, not null.
- * @return the Builder for chaining.
- */
- public Builder setName(String name){
- this.name = Objects.requireNonNull(name);
- return this;
- }
-
- /**
- * Build a new ConfigModel instance.
- * @return the new ConfigModel instance, not null.
- */
- public ConfigModel build(){
- return new SectionModel(this);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/main/resources/META-INF/configmodel.properties
----------------------------------------------------------------------
diff --git a/modules/model/src/main/resources/META-INF/configmodel.properties b/modules/model/src/main/resources/META-INF/configmodel.properties
deleted file mode 100644
index 3381a09..0000000
--- a/modules/model/src/main/resources/META-INF/configmodel.properties
+++ /dev/null
@@ -1,35 +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.
-#
-# Contains definitions for default system property areas.
-_awt.model.target=Section
-_awt.model.transitive=true
-_file.model.target=Section
-_file.model.transitive=true
-_java.model.target=Section
-_java.model.transitive=true
-_line.model.target=Section
-_line.model.transitive=true
-_os.model.target=Section
-_os.model.transitive=true
-_path.model.target=Section
-_path.model.transitive=true
-_sun.model.target=Section
-_sun.model.transitive=true
-_user.model.target=Section
-_user.model.transitive=true
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/main/resources/META-INF/services/org.apache.tamaya.events.ConfigEventListener
----------------------------------------------------------------------
diff --git a/modules/model/src/main/resources/META-INF/services/org.apache.tamaya.events.ConfigEventListener b/modules/model/src/main/resources/META-INF/services/org.apache.tamaya.events.ConfigEventListener
deleted file mode 100644
index e8b12e9..0000000
--- a/modules/model/src/main/resources/META-INF/services/org.apache.tamaya.events.ConfigEventListener
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy current the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-org.apache.tamaya.model.internal.ConfiguredTypeEventsModelPopulator
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/main/resources/META-INF/services/org.apache.tamaya.model.spi.ConfigDocumentationMBean
----------------------------------------------------------------------
diff --git a/modules/model/src/main/resources/META-INF/services/org.apache.tamaya.model.spi.ConfigDocumentationMBean b/modules/model/src/main/resources/META-INF/services/org.apache.tamaya.model.spi.ConfigDocumentationMBean
deleted file mode 100644
index 05c3d02..0000000
--- a/modules/model/src/main/resources/META-INF/services/org.apache.tamaya.model.spi.ConfigDocumentationMBean
+++ /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.model.internal.ConfigDocumentationBean
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/main/resources/META-INF/services/org.apache.tamaya.model.spi.ConfigUsageStatsSpi
----------------------------------------------------------------------
diff --git a/modules/model/src/main/resources/META-INF/services/org.apache.tamaya.model.spi.ConfigUsageStatsSpi b/modules/model/src/main/resources/META-INF/services/org.apache.tamaya.model.spi.ConfigUsageStatsSpi
deleted file mode 100644
index 92299da..0000000
--- a/modules/model/src/main/resources/META-INF/services/org.apache.tamaya.model.spi.ConfigUsageStatsSpi
+++ /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.model.internal.DefaultConfigUsageStats
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/main/resources/META-INF/services/org.apache.tamaya.model.spi.ModelProviderSpi
----------------------------------------------------------------------
diff --git a/modules/model/src/main/resources/META-INF/services/org.apache.tamaya.model.spi.ModelProviderSpi b/modules/model/src/main/resources/META-INF/services/org.apache.tamaya.model.spi.ModelProviderSpi
deleted file mode 100644
index b394c17..0000000
--- a/modules/model/src/main/resources/META-INF/services/org.apache.tamaya.model.spi.ModelProviderSpi
+++ /dev/null
@@ -1,22 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy 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.model.internal.ConfiguredPropertiesModelProviderSpi
-org.apache.tamaya.model.internal.ConfiguredInlineModelProviderSpi
-org.apache.tamaya.model.internal.ConfiguredResourcesModelProviderSpi
-org.apache.tamaya.model.internal.ConfiguredTypeEventsModelProvider
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter
----------------------------------------------------------------------
diff --git a/modules/model/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter b/modules/model/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter
deleted file mode 100644
index 04cec4a..0000000
--- a/modules/model/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter
+++ /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.model.internal.UsageTrackerFilter
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/test/java/org/apache/tamaya/model/ConfigModelProviderTest.java
----------------------------------------------------------------------
diff --git a/modules/model/src/test/java/org/apache/tamaya/model/ConfigModelProviderTest.java b/modules/model/src/test/java/org/apache/tamaya/model/ConfigModelProviderTest.java
deleted file mode 100644
index d45376d..0000000
--- a/modules/model/src/test/java/org/apache/tamaya/model/ConfigModelProviderTest.java
+++ /dev/null
@@ -1,68 +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.model;
-
-import org.apache.tamaya.model.spi.SectionModel;
-import org.apache.tamaya.model.spi.ParameterModel;
-import org.apache.tamaya.model.spi.GroupModel;
-import org.apache.tamaya.model.spi.ModelProviderSpi;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-
-/**
- * Created by Anatole on 09.08.2015.
- */
-public class ConfigModelProviderTest implements ModelProviderSpi {
-
- private List<ConfigModel> configModels = new ArrayList<>(1);
-
- public ConfigModelProviderTest(){
- configModels.add(new TestConfigModel());
- configModels = Collections.unmodifiableList(configModels);
- }
-
- public Collection<ConfigModel> getConfigModels() {
- return configModels;
- }
-
- private static final class TestConfigModel extends GroupModel {
-
- public TestConfigModel(){
- super("TestConfigModel", "TestConfig", new SectionModel.Builder("TestConfigModel",
- "a.test.existing").setRequired(true).build(),
- ParameterModel.of("TestConfigModel", "a.test.existing.aParam", true),
- ParameterModel.of("TestConfigModel", "a.test.existing.optionalParam"),
- ParameterModel.of("TestConfigModel", "a.test.existing.aABCParam", false, "[ABC].*"),
- new SectionModel.Builder("TestConfigModel", "a.test.notexisting").setRequired(true).build(),
- ParameterModel.of("TestConfigModel", "a.test.notexisting.aParam", true),
- ParameterModel.of("TestConfigModel", "a.test.notexisting.optionalParam"),
- ParameterModel.of("TestConfigModel", "a.test.existing.aABCParam2", false, "[ABC].*"));
- }
- @Override
- public String getName() {
- return "TestConfigConfigModel";
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/test/java/org/apache/tamaya/model/ConfigUsageStatsTest.java
----------------------------------------------------------------------
diff --git a/modules/model/src/test/java/org/apache/tamaya/model/ConfigUsageStatsTest.java b/modules/model/src/test/java/org/apache/tamaya/model/ConfigUsageStatsTest.java
deleted file mode 100644
index 5059786..0000000
--- a/modules/model/src/test/java/org/apache/tamaya/model/ConfigUsageStatsTest.java
+++ /dev/null
@@ -1,114 +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.model;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.model.spi.GroupModel;
-import org.apache.tamaya.model.spi.ModelProviderSpi;
-import org.apache.tamaya.model.spi.ParameterModel;
-import org.apache.tamaya.model.spi.SectionModel;
-import org.junit.Test;
-import test.model.TestConfigAccessor;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-import static org.junit.Assert.*;
-
-/**
- * Created by Anatole on 09.08.2015.
- */
-public class ConfigUsageStatsTest implements ModelProviderSpi {
-
- private List<ConfigModel> configModels = new ArrayList<>(1);
-
- public ConfigUsageStatsTest(){
- configModels.add(new TestConfigModel());
- configModels = Collections.unmodifiableList(configModels);
- }
-
- public Collection<ConfigModel> getConfigModels() {
- return configModels;
- }
-
- private static final class TestConfigModel extends GroupModel {
-
- public TestConfigModel(){
- super("TestConfigModel", "TestConfig", new SectionModel.Builder("TestConfigModel",
- "a.test.existing").setRequired(true).build(),
- ParameterModel.of("TestConfigModel", "a.test.existing.aParam", true),
- ParameterModel.of("TestConfigModel", "a.test.existing.optionalParam"),
- ParameterModel.of("TestConfigModel", "a.test.existing.aABCParam", false, "[ABC].*"),
- new SectionModel.Builder("TestConfigModel", "a.test.notexisting").setRequired(true).build(),
- ParameterModel.of("TestConfigModel", "a.test.notexisting.aParam", true),
- ParameterModel.of("TestConfigModel", "a.test.notexisting.optionalParam"),
- ParameterModel.of("TestConfigModel", "a.test.existing.aABCParam2", false, "[ABC].*"));
- }
- @Override
- public String getName() {
- return "TestConfigConfigModel";
- }
-
- }
-
- @Test
- public void testUsageWhenEnabled(){
- ConfigUsageStats.enableUsageTracking(true);
- TestConfigAccessor.readConfiguration();
- Configuration config = ConfigurationProvider.getConfiguration();
- String info = ConfigUsageStats.getUsageInfo();
- assertFalse(info.contains("java.version"));
- assertNotNull(info);
- config = TestConfigAccessor.readConfiguration();
- config.getProperties();
- TestConfigAccessor.readProperty(config, "java.locale");
- TestConfigAccessor.readProperty(config, "java.version");
- TestConfigAccessor.readProperty(config, "java.version");
- config.get("java.version");
- info = ConfigUsageStats.getUsageInfo();
- System.out.println(info);
- assertTrue(info.contains("java.version"));
- assertNotNull(info);
- ConfigUsageStats.enableUsageTracking(false);
- }
-
- @Test
- public void testUsageWhenDisabled(){
- ConfigUsageStats.enableUsageTracking(false);
- ConfigUsageStats.clearUsageStats();
- TestConfigAccessor.readConfiguration();
- Configuration config = ConfigurationProvider.getConfiguration();
- String info = ConfigUsageStats.getUsageInfo();
- assertNotNull(info);
- assertFalse(info.contains("java.version"));
- config = TestConfigAccessor.readConfiguration();
- config.getProperties();
- TestConfigAccessor.readProperty(config, "java.locale");
- TestConfigAccessor.readProperty(config, "java.version");
- TestConfigAccessor.readProperty(config, "java.version");
- config.get("java.version");
- info = ConfigUsageStats.getUsageInfo();
- assertFalse(info.contains("java.version"));
- assertNotNull(info);
- ConfigUsageStats.enableUsageTracking(false);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/test/java/org/apache/tamaya/model/ValidationTests.java
----------------------------------------------------------------------
diff --git a/modules/model/src/test/java/org/apache/tamaya/model/ValidationTests.java b/modules/model/src/test/java/org/apache/tamaya/model/ValidationTests.java
deleted file mode 100644
index de4f76f..0000000
--- a/modules/model/src/test/java/org/apache/tamaya/model/ValidationTests.java
+++ /dev/null
@@ -1,52 +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.model;
-
-import org.junit.Test;
-
-/**
- * Created by Anatole on 10.08.2015.
- */
-public class ValidationTests {
-
- @Test
- public void testDefaults(){
- System.err.println(ConfigModelManager.validate());
- }
-
- @Test
- public void testAllValidations(){
- System.err.println(ConfigModelManager.getModels());
- }
-
- @Test
- public void testConfigInfo(){
- System.err.println(ConfigModelManager.getConfigInfoText());
- }
-
- @Test
- public void testAllValidationsInclUndefined(){
- System.err.println("Including UNDEFINED: \n" + ConfigModelManager.validate(true));
- }
-
- @Test
- public void testModels(){
- System.err.println("MODELS: " +ConfigModelManager.getModels());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/test/java/org/apache/tamaya/model/internal/ConfigDocumentationBeanTest.java
----------------------------------------------------------------------
diff --git a/modules/model/src/test/java/org/apache/tamaya/model/internal/ConfigDocumentationBeanTest.java b/modules/model/src/test/java/org/apache/tamaya/model/internal/ConfigDocumentationBeanTest.java
deleted file mode 100644
index e791417..0000000
--- a/modules/model/src/test/java/org/apache/tamaya/model/internal/ConfigDocumentationBeanTest.java
+++ /dev/null
@@ -1,108 +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.model.internal;
-
-import org.apache.tamaya.model.ModelTarget;
-import org.junit.Test;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-/**
- * Created by Anatole on 19.08.2015.
- */
-public class ConfigDocumentationBeanTest {
-
- private final ConfigDocumentationBean mbean = new ConfigDocumentationBean();
-
- @Test
- public void testValidate_NoUnknowns() throws Exception {
- String results = mbean.validate(false);
- assertNotNull(results);
- assertFalse(results.trim().isEmpty());
- assertTrue(results.contains("\"target\":\"Parameter\""));
- assertTrue(results.contains("\"result\":\"MISSING\""));
- assertFalse(results.contains("\"description\":\"Undefined key: "));
- assertFalse(results.contains(" \"result\":\"UNDEFINED\""));
- }
-
- @Test
- public void testValidate_WithUnknowns() throws Exception {
- String results = mbean.validate(true);
- assertNotNull(results);
- assertFalse(results.trim().isEmpty());
- // test transitive excludes of default sys properties
- assertFalse(results.contains("\"name\":\"java"));
- assertFalse(results.contains("\"name\":\"sun."));
- assertFalse(results.contains("\"name\":\"file."));
- // test others
- assertTrue(results.contains("\"target\":\"Parameter\""));
- assertTrue(results.contains("\"target\":\"Section\""));
- assertTrue(results.contains("\"result\":\"MISSING\""));
- assertTrue(results.contains("\"description\":\"Undefined key: "));
- assertTrue(results.contains(" \"result\":\"UNDEFINED\""));
- }
-
- @Test
- public void testGetConfigurationModel() throws Exception {
- String results = mbean.getConfigurationModel();
- assertNotNull(results);
- assertFalse(results.trim().isEmpty());
- assertTrue(results.contains("\"target\":\"Parameter\""));
- assertTrue(results.contains("\"name\":\"MyNumber\""));
- assertTrue(results.contains("\"name\":\"a.b.c\""));
- assertTrue(results.contains("\"required\":true"));
- }
-
- @Test
- public void testGetConfigurationModel_WithSection() throws Exception {
- String results = mbean.getConfigurationModel(ModelTarget.Parameter);
- assertNotNull(results);
- assertFalse(results.trim().isEmpty());
- assertTrue(results.contains("\"target\":\"Parameter\""));
- assertFalse(results.contains("\"target\":\"Section\""));
- assertTrue(results.contains("\"required\":true"));
- }
-
- @Test
- public void testFindConfigurationModels() throws Exception {
- String results = mbean.findConfigurationModels("a");
- assertNotNull(results);
- assertFalse(results.trim().isEmpty());
- assertFalse(results.contains("\"target\":\"Parameter\""));
- assertTrue(results.contains("\"target\":\"Section\""));
- }
-
- @Test
- public void testFindValidationModels() throws Exception {
- String results = mbean.findValidationModels("a", ModelTarget.Section);
- assertNotNull(results);
- assertFalse(results.trim().isEmpty());
- assertFalse(results.contains("\"target\":\"Parameter\""));
- assertTrue(results.contains("\"target\":\"Section\""));
- System.out.println(results);
- }
-
- @Test
- public void testToString() throws Exception {
- String toString = mbean.toString();
- System.out.println(toString);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/test/java/test/model/TestConfigAccessor.java
----------------------------------------------------------------------
diff --git a/modules/model/src/test/java/test/model/TestConfigAccessor.java b/modules/model/src/test/java/test/model/TestConfigAccessor.java
deleted file mode 100644
index 498d2b6..0000000
--- a/modules/model/src/test/java/test/model/TestConfigAccessor.java
+++ /dev/null
@@ -1,45 +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 test.model;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-
-import java.util.Map;
-
-/**
- * Created by atsticks on 30.04.16.
- */
-public final class TestConfigAccessor {
-
- private TestConfigAccessor(){}
-
- public static Map<String,String> readAllProperties(){
- return ConfigurationProvider.getConfiguration()
- .getProperties();
- }
-
- public static Configuration readConfiguration(){
- return ConfigurationProvider.getConfiguration();
- }
-
- public static String readProperty(Configuration config, String key){
- return config.get(key);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/test/resources/META-INF/configmodel.properties
----------------------------------------------------------------------
diff --git a/modules/model/src/test/resources/META-INF/configmodel.properties b/modules/model/src/test/resources/META-INF/configmodel.properties
deleted file mode 100644
index a7956dc..0000000
--- a/modules/model/src/test/resources/META-INF/configmodel.properties
+++ /dev/null
@@ -1,96 +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.
-#
-
-###################################################################################
-# Example of a configuration metamodel expressed via properties.
-####################################################################################
-
-# Metamodel information
-_model.provider=ConfigModel Extension
-
-# reusable parameter definition, referenceable as MyNumber
-_MyNumber.model.target=Parameter
-_MyNumber.model.type=Integer
-_MyNumber.model.description=a (reusable) number type parameter (optional)
-
-####################################################################################
-# Description of Configuration Sections (minimal, can be extended by other modules).
-# By default its interpreted as a section !
-####################################################################################
-
-# a (section)
-_a.model.target=Section
-_a.params2.model.target=Parameter
-_a.params2.model.type=String
-_a.params2.model.required=true
-_a.params2.model.description=a required parameter
-
-_a.paramInt.model.target=Parameter
-_a.paramInt.model.type=ref:MyNumber
-_a.paramInt.model.description=an optional parameter (default)
-
-_a._number.model.target=Parameter
-_a._number.model.type=Integer
-_a._number.model.deprecated=true
-_a._number.model.mappedTo=a.paramInt
-
-# a.b.c (section)
-_a.b.c.model.target=Section
-_a.b.c.model.description=Just a test section
-
-# a.b.c.aRequiredSection (section)
-_a.b.c.aRequiredSection.model.target=Section
-_a.b.c.aRequiredSection.model.required=true
-_a.b.c.aRequiredSection.model.description=A section containing required parameters is called a required section.\
- Sections can also explicitly be defined to be required, but without\
- specifying the paramteres to be contained.,
-
-# a.b.c.aRequiredSection.subsection (section)
-_a.b.c.aRequiredSection.subsection.model.target=Section
-
-_a.b.c.aRequiredSection.subsection.param0.model.model.target=Parameter
-_a.b.c.aRequiredSection.subsection.param0.type=String
-_a.b.c.aRequiredSection.subsection.param0.model.description=a minmally documented String parameter
-# A minmal String parameter
-_a.b.c.aRequiredSection.subsection.param00.model.target=Parameter
-_a.b.c.aRequiredSection.subsection.param00.model.type=String
-
-# a.b.c.aRequiredSection.subsection (section)
-_a.b.c.aRequiredSection.subsection.param1.model.target=Parameter
-_a.b.c.aRequiredSection.subsection.param1.model.type = String
-_a.b.c.aRequiredSection.subsection.param1.model.required = true
-_a.b.c.aRequiredSection.subsection.intParam.model.target=Parameter
-_a.b.c.aRequiredSection.subsection.intParam.model.type = Integer
-_a.b.c.aRequiredSection.subsection.intParam.model.description=an optional parameter (default)
-
-# a.b.c.aRequiredSection.nonempty-subsection (section)
-_a.b.c.aRequiredSection.nonempty-subsection.model.target=Section
-_a.b.c.aRequiredSection.nonempty-subsection.model.required=true
-
-# a.b.c.aRequiredSection.optional-subsection (section)
-_a.b.c.aRequiredSection.optional-subsection.model.target=Section
-
-# a.b.c.aValidatedSection (section)
-_a.b.c.aValidatedSection.model.target=Section
-_a.b.c.aValidatedSection.model.description=A validated section.
-_a.b.c.aValidatedSection.model.validator=org.apache.tamaya.model.TestValidator
-
-
-
-
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/test/resources/META-INF/javaconfiguration.properties
----------------------------------------------------------------------
diff --git a/modules/model/src/test/resources/META-INF/javaconfiguration.properties b/modules/model/src/test/resources/META-INF/javaconfiguration.properties
deleted file mode 100644
index b0b8c22..0000000
--- a/modules/model/src/test/resources/META-INF/javaconfiguration.properties
+++ /dev/null
@@ -1,22 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy 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.
-#
-a.test.existing.aParam=existingValue
-a.test.existing.optionalParam=optionalValue
-a.test.existing.aABCParam=ABCparam
-a.test.existing.aABCParam2=MMM
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/test/resources/META-INF/services/org.apache.tamaya.model.spi.ModelProviderSpi
----------------------------------------------------------------------
diff --git a/modules/model/src/test/resources/META-INF/services/org.apache.tamaya.model.spi.ModelProviderSpi b/modules/model/src/test/resources/META-INF/services/org.apache.tamaya.model.spi.ModelProviderSpi
deleted file mode 100644
index 9b29fda..0000000
--- a/modules/model/src/test/resources/META-INF/services/org.apache.tamaya.model.spi.ModelProviderSpi
+++ /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.model.ConfigModelProviderTest
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/test/resources/examples/configmodel.ini
----------------------------------------------------------------------
diff --git a/modules/model/src/test/resources/examples/configmodel.ini b/modules/model/src/test/resources/examples/configmodel.ini
deleted file mode 100644
index 0e10cc1..0000000
--- a/modules/model/src/test/resources/examples/configmodel.ini
+++ /dev/null
@@ -1,76 +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.
-#
-
-###################################################################################
-# Example of a configuration metamodel expressed via ini(tm).
-####################################################################################
-
-####################################################################################
-# Description of Configuration Sections (minimal, can be extended by other modules).
-# By default its interpreted as a section !
-####################################################################################
-[_a.model]
-class = Section
-params2.type = String
-params2.required = true
-params2.description = "a required parameter"
-paramInt.ref = MyNumber
-paramInt.description = "an optional parameter (default)"
-_number.type = Integer
-_number.deprecated = true
-_number.mappedTo = "a.paramInt"
-
-[_a.b.c.model]
-class = Section
-description = Just a test section
-
-[_a.b.c.aRequiredSection.model]
-class = Section
-required = true
-description = A section containing required parameters is called a required section.\
- Sections can also explicitly be defined to be required, but without\
- specifying the paramteres to be contained.,
-
-[_a.b.c.aRequiredSection.subsection.model]
-class = Section
-param0.type = String
-param0.description = "a minmally documented String parameter"
-# A minmal String parameter
-param00.type = String
-# description is optional
-param1.type = String
-param1.required = true
-intParam.type = Integer
-intParam.description = "an optional parameter (default)"
-
-[_a.b.c.aRequiredSection.nonempty-subsection.model]
-class = Section
-required = true
-
-[_a.b.c.aRequiredSection.optional-subsection.model]
-class = Section
-
-[_a.b.c.aValidatedSection.model]
-class = Section
-description = "A configModel section."
-configModels = org.apache.tamaya.model.TestValidator?max=3
-
-
-
-
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/test/resources/examples/configmodel.json
----------------------------------------------------------------------
diff --git a/modules/model/src/test/resources/examples/configmodel.json b/modules/model/src/test/resources/examples/configmodel.json
deleted file mode 100644
index 529f26e..0000000
--- a/modules/model/src/test/resources/examples/configmodel.json
+++ /dev/null
@@ -1,108 +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.
-*/
-
-//##################################################################################
-// Example of a configuration metamodel expressed via YAML(tm).
-// Structure is shown through indentation (one or more spaces).
-// Sequence items are denoted by a dash,
-// key value pairs within a map are separated by a colon.
-//##################################################################################
-
-//##################################################################################
-// Metamodel information
-//##################################################################################
-{
- "_model": {
- "provider": "ConfigModel Extension",
- // reusable parameter definition
- },
- "_MyNumber.model": {
- "class": "Parameter",
- "type": "Integer",
- "template": true,
- "description": "an (reusable) number type parameter (optional)"
- },
- //##################################################################################
- // Description of Configuration Sections (minimal, can be extended by other modules).
- //##################################################################################
- "_a.model": {
- "class": "Section",
- // required, default is parameter!
- },
- "_a.params2.model": {
- "required": true,
- "description": "a required parameter"
- },
- "_a.paramInt.model": {
- // references a shared parameter definition.
- "ref": "MyNumber",
- "description": "an optional parameter (default)"
- },
- "_a.number.model": {
- "type": "Integer",
- "deprecated": true,
- // references a deprecated parameter, now mapped to 'a.paramInt'.
- "mappedto": "a.paramInt"
- },
- "_a.b.c.model": {
- "class": "Section",
- "description": "Just a test section."
- // a subsection, directly configured as child element.
- },
- "_a.b.c.aRequiredSection.model": {
- "class": "Section",
- "required": true,
- "description": "A section containing required parameters is called a required section."
- },
- // a subsection, configured in its own section.
- "_a.b.c.aRequiredSection.subsection.model": {
- "class": "Section"
- }
- "_a.b.c.param0-model": {
- "type": "String",
- "description": "a minimally documented String parameter"
- },
- // A minimally defined String parameter
- "_a.b.c.param00": {},
- "_a.b.c.param1": {
- "type": "String",
- "required": true,
- "description": "a required parameter"
- },
- "_a.b.c.intParam": {
- "type": "Integer",
- "required": true,
- "description": "an optional parameter (default)"
- },
- "_a.b.c.aRequiredSection.nonempty-subsection.model": {
- "class": "Section",
- "required": true
- },
- "_a.b.c.aRequiredSection.optional-subsection.model": {
- "class": "Section"
- },
- "_a.b.c.aRequiredSection.aValidatedSection.model": {
- "class": "Section",
- "description": "A validated section.",
- "validations": "org.apache.tamaya.model.validation.MaxItemValidator?max=3"
- }
- }
-}
-
-
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/test/resources/examples/configmodel.properties
----------------------------------------------------------------------
diff --git a/modules/model/src/test/resources/examples/configmodel.properties b/modules/model/src/test/resources/examples/configmodel.properties
deleted file mode 100644
index b61695b..0000000
--- a/modules/model/src/test/resources/examples/configmodel.properties
+++ /dev/null
@@ -1,96 +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.
-#
-
-###################################################################################
-# Example of a configuration metamodel expressed via properties.
-####################################################################################
-
-# Metamodel information
-_model.provider=ConfigModel Extension
-
-# reusable parameter definition, referenceable as MyNumber
-_MyNumber.model.class=Parameter
-_MyNumber.model.type=Integer
-_MyNumber.model.description=a (reusable) number type parameter (optional)
-
-####################################################################################
-# Description of Configuration Sections (minimal, can be extended by other modules).
-# By default its interpreted as a section !
-####################################################################################
-
-# a (section)
-_a.model.class=Section
-_a.params2.model.class=Parameter
-_a.params2.model.type=String
-_a.params2.model.required=true
-_a.params2.model.description=a required parameter
-
-_a.paramInt.model.class=Parameter
-_a.paramInt.model.type=ref:MyNumber
-_a.paramInt.model.description=an optional parameter (default)
-
-_a._number.model.class=Parameter
-_a._number.model.type=Integer
-_a._number.model.deprecated=true
-_a._number.model.mappedTo=a.paramInt
-
-# a.b.c (section)
-_a.b.c.class=Section
-_a.b.c.description=Just a test section
-
-# a.b.c.aRequiredSection (section)
-_a.b.c.aRequiredSection.model.class=Section
-_a.b.c.aRequiredSection.model.required=true
-_a.b.c.aRequiredSection.model.description=A section containing required parameters is called a required section.\
- Sections can also explicitly be defined to be required, but without\
- specifying the paramteres to be contained.,
-
-# a.b.c.aRequiredSection.subsection (section)
-_a.b.c.aRequiredSection.model.subsection.class=Section
-
-_a.b.c.aRequiredSection.subsection.param0.model.class=Parameter
-_a.b.c.aRequiredSection.subsection.param0.model.type=String
-_a.b.c.aRequiredSection.subsection.param0.model.description=a minmally documented String parameter
-# A minmal String parameter
-_a.b.c.aRequiredSection.subsection.param00.model.class=Parameter
-_a.b.c.aRequiredSection.subsection.param00.model.type=String
-
-# a.b.c.aRequiredSection.subsection (section)
-_a.b.c.aRequiredSection.subsection.param1.model.class=Parameter
-_a.b.c.aRequiredSection.subsection.param1.model.type = String
-_a.b.c.aRequiredSection.subsection.param1.model.required = true
-_a.b.c.aRequiredSection.subsection.intParam.model.class=Parameter
-_a.b.c.aRequiredSection.subsection.intParam.model.type = Integer
-_a.b.c.aRequiredSection.subsection.intParam.model.description=an optional parameter (default)
-
-# a.b.c.aRequiredSection.nonempty-subsection (section)
-_a.b.c.aRequiredSection.nonempty-subsection.model.class=Section
-_a.b.c.aRequiredSection.nonempty-subsection.model.required=true
-
-# a.b.c.aRequiredSection.optional-subsection (section)
-_a.b.c.aRequiredSection.optional-subsection.model.class=Section
-
-# a.b.c.aValidatedSection (section)
-_a.b.c.aValidatedSection.model.class=Section
-_a.b.c.aValidatedSection.model.description=A validated section.
-_a.b.c.aValidatedSection.model.configModels=org.apache.tamaya.model.TestValidator
-
-
-
-
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/test/resources/examples/configmodel.xml
----------------------------------------------------------------------
diff --git a/modules/model/src/test/resources/examples/configmodel.xml b/modules/model/src/test/resources/examples/configmodel.xml
deleted file mode 100644
index f23f783..0000000
--- a/modules/model/src/test/resources/examples/configmodel.xml
+++ /dev/null
@@ -1,97 +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.
--->
-
-<!--################################################################################
-# Example of a configuration metamodel expressed via YAML(tm).
-# Structure is shown through indentation (one or more spaces).
-# Sequence items are denoted by a dash,
-# key value pairs within a map are separated by a colon.
-#################################################################################-->
-
-<!--################################################################################
-# Metamodel information
-#################################################################################-->
-
-<configuration>
- <section name="{model}" __provider="ConfigModel Extension" version="1.0" __release-date="2001-01-23"
- author="Anatole Tresch">
- <!-- model-format>alternate format reader type</model-format -->
- <__description>Late afternoon is best.
- Backup contact is Nancy.
- </__description>
-
- <!--################################################################################
- # Description of Configuration Sections (minimal, can be extended by other modules).
- #################################################################################-->
- <section name="a">
- <param name="params">
- <type>String</type>
- <required>true</required>
- <description>a required parameter</description>
- </param>
- <param name="paramInt">
- <ref>MyNumber</ref>
- <required>true</required>
- <description>an optional parameter (default)</description>
- </param>
- <param name="_number">
- <type>Integer</type>
- <deprecated>true</deprecated>
- <mappedto>a.paramInt</mappedto>
- </param>
- <section name="b.c">
- <description>Just a test section.</description>
- <section name="aRequiredSection">
- <description>A section containing required parameters is called a required section.
- Sections can also explicitly be defined to be required, but without
- specifying the paramteres to be contained.
- </description>
- </section>
- </section>
- </section>
-
- <section name="a.b.c.aRequiredSection.subsection">
- <param name="param0" type="String">a minmally documented String parameter</param>
- <!-- # A minmally defined String parameter -->
- <param name="param00">
- <type>String</type>
- </param>
- <param name="param1">
- <type>String</type>
- <required>true</required>
- <description>a required parameter</description>description>
- </param>
- <param name="intParam">
- <type>Integer</type>
- <description>an optional parameter (default)</description>
- </param>
- <section name="b.c">
- <description>Just a test section.</description>
- </section>
- </section>
- <section name="a.b.c.aRequiredSection.nonempty-subsection">
- <required>true</required>
- </section>
- <section name="a.b.c.aRequiredSection.optional-subsection"/>
- <section name="a.b.c.aRequiredSection.aValidatedSection">
- <configModels>org.apache.tamaya.model.configModel.MaxItemValidator?max=3"</configModels>
- <description>A configModel section.</description>
- </section>
- </section>
-</configuration>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/model/src/test/resources/examples/configmodel.yaml
----------------------------------------------------------------------
diff --git a/modules/model/src/test/resources/examples/configmodel.yaml b/modules/model/src/test/resources/examples/configmodel.yaml
deleted file mode 100644
index 041c801..0000000
--- a/modules/model/src/test/resources/examples/configmodel.yaml
+++ /dev/null
@@ -1,106 +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.
-#
-
-##################################################################################
-# Example of a configuration metamodel expressed via YAML(tm).
-# Structure is shown through indentation (one or more spaces).
-# Sequence items are denoted by a dash,
-# key value pairs within a map are separated by a colon.
-####################################################################################
-
-####################################################################################
-# Metamodel information
-####################################################################################
-{model}: {
- __name : 'testmodel',
- __provider : 'ValidationProviderSpi Extension',
- __version : '1.0',
- __release-date : 2001-01-23,
- __author : 'Anatole Tresch',
- # model-format: 'alternate format reader type'
- __description: >
- Late afternoon is best.
- Backup contact is Nancy.
-}
-
-####################################################################################
-# Description of Configuration Sections (minimal, can be extended by other modules).
-####################################################################################
----
-{model}.a.params2: {
- type : 'String',
- required : true,
- description : 'a required parameter',
- paramInt: 'Integer', 'an optional parameter (default)',
-}
----
-{model}.a.paramInt: {
- type : 'Integer',
- description : 'an optional parameter (default)',
-}
----
-{model}.a.b.c: {
- description: 'Just a test section.'
-}
----
-{model}.a.b.c.aRequiredSection: {
- required: true,
- description: |
- A section containing required parameters is called a required section.
- Sections can also explicitly be defined to be required, but without
- specifying the paramteres to be contained.,
-}
----
-{model}.a.b.c.aRequiredSection.subsection: {
- param0: {
- type: 'String',
- description: 'a minmally documented String parameter}'
- }, ,
- param00:{
- type: 'String' # A minmally defined String parameter
- },
- param1: {
- tpye: 'String',
- required: true,
- description: 'a required parameter'
- },
- intParam: {
- type: 'Integer',
- description: 'an optional parameter (default)'
- }
-}
-...
-
----
-{model}.a.b.c.aRequiredSection.nonempty-subsection: {
- required: true
-}
-...
-
----
-{model}.a.b.c.aRequiredSection.optional-subsection: {}
-...
-
----
-{model}.a.b.c.aRequiredSection.aValidatedSection: {
- description: 'A configModel section.',
- configModels: 'org.apache.tamaya.model.configModel.MaxItemValidator?max=3'
-}
-
-
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/mutable-config/pom.xml
----------------------------------------------------------------------
diff --git a/modules/mutable-config/pom.xml b/modules/mutable-config/pom.xml
deleted file mode 100644
index 8f0204d..0000000
--- a/modules/mutable-config/pom.xml
+++ /dev/null
@@ -1,83 +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.
--->
-<project xmlns="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">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-extensions</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
-
- <artifactId>tamaya-mutable-config</artifactId>
- <name>Apache Tamaya Modules - Mutable Configuration Support</name>
- <description>This module provides abstraction, if your scenario needs to actively change configuration entries
- and write changes back to some property sources, files etc.</description>
- <packaging>bundle</packaging>
-
- <properties>
- <jdkVersion>1.7</jdkVersion>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-spisupport</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-core</artifactId>
- <version>${project.version}</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>java-hamcrest</artifactId>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.tamaya.mutableconfig
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/ChangePropagationPolicy.java
----------------------------------------------------------------------
diff --git a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/ChangePropagationPolicy.java b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/ChangePropagationPolicy.java
deleted file mode 100644
index 5378166..0000000
--- a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/ChangePropagationPolicy.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.mutableconfig;
-
-import org.apache.tamaya.mutableconfig.spi.ConfigChangeRequest;
-import org.apache.tamaya.spi.PropertySource;
-
-import java.util.Collection;
-
-/**
- * Policy that defines how changes are applied to the available
- * {@link org.apache.tamaya.mutableconfig.spi.MutablePropertySource} instances, e.g.
- * <ul>
- * <li><b>ALL: </b>Changes are propagated to all {@link org.apache.tamaya.mutableconfig.spi.MutablePropertySource}
- * instances in order of significance. This means that a key added, updated or removed in each instance, if the key
- * is writable/removable.</li>
- * <li><b>SIGNIFICANT_ONLY: </b>A change (creation, update) is only applied, if
- * <ol>
- * <li>the value is not provided by a more significant read-only property source.</li>
- * <li>there is no more significant writable property source, which supports writing a g iven key.</li>
- * </ol>
- * In other words a added or updated value is written exactly once to the most significant
- * writable property source, which accepts a given key. Otherwise the change is discarded.</li>
- * <li><b>NONE: </b>Do not apply any changes.</li>
- * </ul>
- */
-public interface ChangePropagationPolicy {
-
- /**
- * Method being called when a multiple key/value pairs are added or updated.
- * @param propertySources the property sources, including readable property sources of the current configuration,
- * never null.
- * @param configChange the configuration change, not null.
- */
- void applyChange(ConfigChangeRequest configChange, Collection<PropertySource> propertySources);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/MutableConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/MutableConfiguration.java b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/MutableConfiguration.java
deleted file mode 100644
index 451769e..0000000
--- a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/MutableConfiguration.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.mutableconfig;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.mutableconfig.spi.ConfigChangeRequest;
-
-import java.util.Collection;
-import java.util.Map;
-
-
-/**
- * This interface extends the Configuration interface hereby adding methods to change configuration entries.
- * Hereby not all configuration entries are necessarily mutable, since some entries may be read from non
- * mutable areas of configuration. Of course, it is always possible to add a mutable shadow layer on top of all
- * property sources to persist/control any changes applied. The exact management and storage persistence algorithm
- * should be transparent.
- *
- * As a consequence clients should first check, using the corresponding methods, if entries can be added/updated or
- * removed.
- *
- * This class should only used in a single threaded context, though all methods inherited from {@link Configuration}
- * must be thread-safe. Methods handling configuration changes are expected to be used in a single threaded environment
- * only. For multi-threaded us create a new instance of {@link MutableConfiguration} for each thread.
- */
-public interface MutableConfiguration extends Configuration {
-
- /**
- * Storesd the changes. After a commit the change is not editable anymore. All changes applied will be written to
- * the corresponding configuration backend.
- *
- * NOTE that changes applied must not necessarily be visible in the current {@link Configuration} instance,
- * since visibility of changes also depends on the ordinals set on the {@link org.apache.tamaya.spi.PropertySource}s
- * configured.
- * @throws org.apache.tamaya.ConfigException if the request already has been committed or cancelled, or the commit fails.
- */
- void store();
-
- /**
- * Access the current configuration change context, built up on all the change context of the participating
- * {@link org.apache.tamaya.mutableconfig.spi.MutablePropertySource} instances.
- * @return the colleted changes as one single config change for the current transaction, or null, if no transaction
- * is active.
- */
- ConfigChangeRequest getConfigChangeRequest();
-
- /**
- * Access the active {@link ChangePropagationPolicy}.This policy controls how configuration changes are written/published
- * to the known {@link org.apache.tamaya.mutableconfig.spi.MutablePropertySource} instances of a {@link Configuration}.
- * @return he active {@link ChangePropagationPolicy}, never null.
- */
- ChangePropagationPolicy getChangePropagationPolicy();
-
- /**
- * Sets a property.
- *
- * @param key the property's key, not null.
- * @param value the property's value, not null.
- * @return the former property value, or null.
- * @throws org.apache.tamaya.ConfigException if the key/value cannot be added, or the request is read-only.
- */
- MutableConfiguration put(String key, String value);
-
- /**
- * Puts all given configuration entries. This method should check that all given properties are
- * basically removable, as defined by #isWritable. If any of the passed keys is not writable during this initial
- * check, the operation should not perform any configuration changes and throw a
- * {@link org.apache.tamaya.ConfigException}. If errors occur afterwards, when the properties are effectively
- * written back to the backends, the errors should be collected and returned as part of the ConfigException
- * payload. Nevertheless the operation should in that case remove all entries as far as possible and abort the
- * writing operation.
- *
- * @param properties the properties tobe written, not null.
- * @return the config change request
- * @throws org.apache.tamaya.ConfigException if any of the given properties could not be written, or the request
- * is read-only.
- */
- MutableConfiguration putAll(Map<String, String> properties);
-
- /**
- * Removes all given configuration entries. This method should check that all given properties are
- * basically removable, as defined by #isRemovable. If any of the passed keys is not removable during this initial
- * check, the operation should not perform any configuration changes and throw a
- * {@link org.apache.tamaya.ConfigException}. If errors
- * occur afterwards, when the properties are effectively written back to the backends, the errors should be
- * collected and returned as part of the ConfigException payload. Nevertheless the operation should in that case
- * remove all entries as far as possible and abort the writing operation.
- *
- * @param keys the property's keys to be removedProperties, not null.
- * @return the config change request
- * @throws org.apache.tamaya.ConfigException if any of the given keys could not be removedProperties, or the
- * request is read-only.
- */
- MutableConfiguration remove(Collection<String> keys);
-
- /**
- * Removes all given configuration entries. This method should check that all given properties are
- * basically removable, as defined by #isRemovable. If any of the passed keys is not removable during this initial
- * check, the operation should not perform any configuration changes and throw a {@link org.apache.tamaya.ConfigException}. If errors
- * occur afterwards, when the properties are effectively written back to the backends, the errors should be
- * collected and returned as part of the ConfigException payload. Nevertheless the operation should in that case
- * remove all entries as far as possible and abort the writing operation.
- *
- * @param keys the property's keys to be removedProperties, not null.
- * @return the config change request
- * @throws org.apache.tamaya.ConfigException if any of the given keys could not be removedProperties, or the request is read-only.
- */
- MutableConfiguration remove(String... keys);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/MutableConfigurationProvider.java
----------------------------------------------------------------------
diff --git a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/MutableConfigurationProvider.java b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/MutableConfigurationProvider.java
deleted file mode 100644
index c2cd20e..0000000
--- a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/MutableConfigurationProvider.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.mutableconfig;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.mutableconfig.spi.ConfigChangeRequest;
-import org.apache.tamaya.mutableconfig.spi.MutableConfigurationProviderSpi;
-import org.apache.tamaya.mutableconfig.spi.MutablePropertySource;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.ServiceContextManager;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.logging.Logger;
-
-
-/**
- * Accessor for creating {@link MutableConfiguration} instances to change configuration and commit changes.
- */
-public final class MutableConfigurationProvider {
-
- private static final Logger LOG = Logger.getLogger(MutableConfigurationProvider.class.getName());
- /**
- * URIs used by this query instance to identify the backends to use for write operations.
- */
- private static MutableConfigurationProviderSpi mutableConfigurationProviderSpi = loadSpi();
-
- /**
- * SPI loader method.
- * @throws ConfigException if loading fails.
- * @return the SPI, never null.
- */
- private static MutableConfigurationProviderSpi loadSpi() {
- try{
- return ServiceContextManager.getServiceContext().getService(
- MutableConfigurationProviderSpi.class) ;
- } catch(Exception e){
- throw new ConfigException("Failed to initialize MutableConfigurationProviderSpi - " +
- "mutable configuration support.");
- }
- }
-
-
- /** Singleton constructor. */
- private MutableConfigurationProvider(){}
-
- /**
- * Creates a new {@link MutableConfiguration} for the given default configuration, using all
- * {@link MutablePropertySource} instances found in its context and {@code autoCommit = false}.
- *
- * @return a new MutableConfiguration instance
- */
- public static MutableConfiguration createMutableConfiguration(){
- return mutableConfigurationProviderSpi.createMutableConfiguration(
- ConfigurationProvider.getConfiguration(), getApplyMostSignificantOnlyChangePolicy());
- }
-
- /**
- * Creates a new {@link MutableConfiguration} for the given default configuration, using all
- * {@link MutablePropertySource} instances found in its context and {@code autoCommit = false}.
- * @param changePropgationPolicy policy that defines how a change is written back and which property
- * sources are finally eligible for a write operation.
- * @return a new MutableConfiguration instance, with the given change policy active.
- */
- public static MutableConfiguration createMutableConfiguration(ChangePropagationPolicy changePropgationPolicy){
- return mutableConfigurationProviderSpi.createMutableConfiguration(
- ConfigurationProvider.getConfiguration(), changePropgationPolicy);
- }
-
-
- /**
- * Creates a new {@link MutableConfiguration} for the given configuration, using all
- * {@link MutablePropertySource} instances found in its context and {@code MOST_SIGNIFICANT_ONLY_POLICY}
- * configuration writing policy.
- *
- * @param configuration the configuration to use to write the changes/config.
- * @return a new MutableConfiguration instance
- */
- public static MutableConfiguration createMutableConfiguration(Configuration configuration){
- return createMutableConfiguration(configuration, MOST_SIGNIFICANT_ONLY_POLICY);
- }
-
- /**
- * Creates a new {@link MutableConfiguration} for the given configuration, using all
- * {@link MutablePropertySource} instances found in its context and {@code ALL_POLICY}
- * configuration writing policy.
- *
- * @param configuration the configuration to use to write the changes/config.
- * @param changePropagationPolicy the configuration writing policy.
- * @return a new MutableConfiguration instance
- */
- public static MutableConfiguration createMutableConfiguration(Configuration configuration, ChangePropagationPolicy changePropagationPolicy){
- return mutableConfigurationProviderSpi.createMutableConfiguration(configuration, changePropagationPolicy);
- }
-
- /**
- * This propagation policy writes through all changes to all mutable property sources, where applicable.
- * This is also the default policy.
- * @return default all policy.
- */
- public static ChangePropagationPolicy getApplyAllChangePolicy(){
- return ALL_POLICY;
- }
-
- /**
- * This propagation policy writes changes only once to the most significant property source, where a change is
- * applicable.
- * @return a corresponding {@link ChangePropagationPolicy} implementation, never null.
- */
- public static ChangePropagationPolicy getApplyMostSignificantOnlyChangePolicy(){
- return MOST_SIGNIFICANT_ONLY_POLICY;
- }
-
- /**
- * This propagation policy writes changes only once to the most significant property source, where a change is
- * applicable.
- * @param propertySourceNames the names of the mutable property sources to be considered for writing any changes to.
- * @return a corresponding {@link ChangePropagationPolicy} implementation, never null.
- */
- public static ChangePropagationPolicy getApplySelectiveChangePolicy(String... propertySourceNames){
- return new SelectiveChangeApplyPolicy(propertySourceNames);
- }
-
- /**
- * This propagation policy writes changes only once to the most significant property source, where a change is
- * applicable.
- * @return a corresponding {@link ChangePropagationPolicy} implementation, never null.
- */
- public static ChangePropagationPolicy getApplyNonePolicy(){
- return NONE_POLICY;
- }
-
- /**
- * This propagation policy writes through all changes to all mutable property sources, where applicable.
- */
- private static final ChangePropagationPolicy ALL_POLICY = new ChangePropagationPolicy() {
- @Override
- public void applyChange(ConfigChangeRequest change, Collection<PropertySource> propertySources) {
- for(PropertySource propertySource: propertySources){
- if(propertySource instanceof MutablePropertySource){
- MutablePropertySource target = (MutablePropertySource)propertySource;
- try{
- target.applyChange(change);
- }catch(ConfigException e){
- LOG.warning("Failed to store changes '"+change+"' not applicable to "+target.getName()
- +"("+target.getClass().getName()+").");
- }
- }
- }
- }
-
- };
-
- /**
- * This propagation policy writes changes only once to the most significant property source, where a change is
- * applicable.
- */
- private static final ChangePropagationPolicy MOST_SIGNIFICANT_ONLY_POLICY = new ChangePropagationPolicy() {
- @Override
- public void applyChange(ConfigChangeRequest change, Collection<PropertySource> propertySources) {
- for(PropertySource propertySource: propertySources){
- if(propertySource instanceof MutablePropertySource){
- MutablePropertySource target = (MutablePropertySource)propertySource;
- try{
- target.applyChange(change);
- }catch(ConfigException e){
- LOG.warning("Failed to store changes '"+change+"' not applicable to "+target.getName()
- +"("+target.getClass().getName()+").");
- }
- break;
- }
- }
- }
-
- };
-
- /**
- * This propagation policy writes changes only once to the most significant property source, where a change is
- * applicable.
- */
- private static final ChangePropagationPolicy NONE_POLICY = new ChangePropagationPolicy() {
- @Override
- public void applyChange(ConfigChangeRequest change, Collection<PropertySource> propertySources) {
- LOG.warning("Cannot store changes '"+change+"': prohibited by change policy (read-only).");
- }
- };
-
- /**
- * This propagation policy writes through all changes to all mutable property sources, where applicable.
- */
- private static final class SelectiveChangeApplyPolicy implements ChangePropagationPolicy {
-
- private Set<String> propertySourceNames = new HashSet<>();
-
- SelectiveChangeApplyPolicy(String... propertySourceNames){
- this.propertySourceNames.addAll(Arrays.asList(propertySourceNames));
- }
-
- @Override
- public void applyChange(ConfigChangeRequest change, Collection<PropertySource> propertySources) {
- for(PropertySource propertySource: propertySources){
- if(propertySource instanceof MutablePropertySource){
- if(this.propertySourceNames.contains(propertySource.getName())) {
- MutablePropertySource target = (MutablePropertySource) propertySource;
- try{
- target.applyChange(change);
- }catch(ConfigException e){
- LOG.warning("Failed to store changes '"+change+"' not applicable to "+target.getName()
- +"("+target.getClass().getName()+").");
- }
- break;
- }
- }
- }
- }
- };
-
-
-}
[11/24] incubator-tamaya git commit: Removed all modules from the
main repository. They will be reborn in separate ASF repository.
Posted by pl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/consul/src/main/java/org/apache/tamaya/consul/ConsulPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/integration/consul/src/main/java/org/apache/tamaya/consul/ConsulPropertySource.java b/modules/integration/consul/src/main/java/org/apache/tamaya/consul/ConsulPropertySource.java
deleted file mode 100644
index 89c903b..0000000
--- a/modules/integration/consul/src/main/java/org/apache/tamaya/consul/ConsulPropertySource.java
+++ /dev/null
@@ -1,198 +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.consul;
-
-import com.fasterxml.jackson.databind.deser.Deserializers;
-import com.google.common.base.Optional;
-import com.google.common.net.HostAndPort;
-import com.orbitz.consul.Consul;
-import com.orbitz.consul.KeyValueClient;
-import com.orbitz.consul.model.kv.Value;
-import org.apache.tamaya.mutableconfig.spi.ConfigChangeRequest;
-import org.apache.tamaya.mutableconfig.spi.MutablePropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-import org.apache.tamaya.spi.PropertyValueBuilder;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Propertysource that is reading configuration from a configured consul endpoint. Setting
- * {@code consul.prefix} as system property maps the consul based onfiguration
- * to this prefix namespace. Consul servers are configured as {@code consul.urls} system or environment property.
- */
-public class ConsulPropertySource extends Deserializers.Base
-implements MutablePropertySource{
- private static final Logger LOG = Logger.getLogger(ConsulPropertySource.class.getName());
-
- private String prefix = System.getProperty("tamaya.consul.prefix", "");
-
-
- @Override
- public int getOrdinal() {
- PropertyValue configuredOrdinal = get(TAMAYA_ORDINAL);
- if(configuredOrdinal!=null){
- try{
- return Integer.parseInt(configuredOrdinal.getValue());
- } catch(Exception e){
- Logger.getLogger(getClass().getName()).log(Level.WARNING,
- "Configured Ordinal is not an int number: " + configuredOrdinal, e);
- }
- }
- return getDefaultOrdinal();
- }
-
- /**
- * Returns the default ordinal used, when no ordinal is set, or the ordinal was not parseable to an int value.
- * @return the default ordinal used, by default 1000.
- */
- public int getDefaultOrdinal(){
- return 1000;
- }
-
- @Override
- public String getName() {
- return "consul";
- }
-
- @Override
- public PropertyValue get(String key) {
- // check prefix, if key does not start with it, it is not part of our name space
- // if so, the prefix part must be removedProperties, so etcd can resolve without it
- if(!key.startsWith(prefix)){
- return null;
- } else{
- key = key.substring(prefix.length());
- }
- String reqKey = key;
- if(key.startsWith("_")){
- reqKey = key.substring(1);
- if(reqKey.endsWith(".createdIndex")){
- reqKey = reqKey.substring(0,reqKey.length()-".createdIndex".length());
- } else if(reqKey.endsWith(".modifiedIndex")){
- reqKey = reqKey.substring(0,reqKey.length()-".modifiedIndex".length());
- } else if(reqKey.endsWith(".ttl")){
- reqKey = reqKey.substring(0,reqKey.length()-".ttl".length());
- } else if(reqKey.endsWith(".expiration")){
- reqKey = reqKey.substring(0,reqKey.length()-".expiration".length());
- } else if(reqKey.endsWith(".source")){
- reqKey = reqKey.substring(0,reqKey.length()-".source".length());
- }
- }
- for(HostAndPort hostAndPort: ConsulBackends.getConsulBackends()){
- try{
- Consul consul = Consul.builder().withHostAndPort(hostAndPort).build();
- KeyValueClient kvClient = consul.keyValueClient();
- Optional<Value> valueOpt = kvClient.getValue(reqKey);
- if(!valueOpt.isPresent()) {
- LOG.log(Level.FINE, "key not found in consul: " + reqKey);
- }else{
- // No repfix mapping necessary here, since we only access/return the value...
- Value value = valueOpt.get();
- Map<String,String> props = new HashMap<>();
- props.put(reqKey+".createIndex", String.valueOf(value.getCreateIndex()));
- props.put(reqKey+".modifyIndex", String.valueOf(value.getModifyIndex()));
- props.put(reqKey+".lockIndex", String.valueOf(value.getLockIndex()));
- props.put(reqKey+".flags", String.valueOf(value.getFlags()));
- return new PropertyValueBuilder(key, value.getValue().get(), getName()).setContextData(props).build();
- }
- } catch(Exception e){
- LOG.log(Level.FINE, "etcd access failed on " + hostAndPort + ", trying next...", e);
- }
- }
- return null;
- }
-
- @Override
- public Map<String, String> getProperties() {
-// for(HostAndPort hostAndPort: ConsulBackends.getConsulBackends()){
-// try{
-// Consul consul = Consul.builder().withHostAndPort(hostAndPort).build();
-// KeyValueClient kvClient = consul.keyValueClient();
-// Optional<Value> valueOpt = kvClient.getValue(reqKey);
-// try{
-// Map<String, String> props = kvClient.getProperties("");
-// if(!props.containsKey("_ERROR")) {
-// return mapPrefix(props);
-// } else{
-// LOG.log(Level.FINE, "consul error on " + hostAndPort + ": " + props.get("_ERROR"));
-// }
-// } catch(Exception e){
-// LOG.log(Level.FINE, "consul access failed on " + hostAndPort + ", trying next...", e);
-// }
-// } catch(Exception e){
-// LOG.log(Level.FINE, "etcd access failed on " + hostAndPort + ", trying next...", e);
-// }
-// }
- return Collections.emptyMap();
- }
-
- private Map<String, String> mapPrefix(Map<String, String> props) {
- if(prefix.isEmpty()){
- return props;
- }
- Map<String,String> map = new HashMap<>();
- for(Map.Entry<String,String> entry:props.entrySet()){
- if(entry.getKey().startsWith("_")){
- map.put("_" + prefix + entry.getKey().substring(1), entry.getValue());
- } else{
- map.put(prefix+ entry.getKey(), entry.getValue());
- }
- }
- return map;
- }
-
- @Override
- public boolean isScannable() {
- return false;
- }
-
- @Override
- public void applyChange(ConfigChangeRequest configChange) {
- for(HostAndPort hostAndPort: ConsulBackends.getConsulBackends()){
- try{
- Consul consul = Consul.builder().withHostAndPort(hostAndPort).build();
- KeyValueClient kvClient = consul.keyValueClient();
-
- for(String k: configChange.getRemovedProperties()){
- try{
- kvClient.deleteKey(k);
- } catch(Exception e){
- LOG.info("Failed to remove key from consul: " + k);
- }
- }
- for(Map.Entry<String,String> en:configChange.getAddedProperties().entrySet()){
- String key = en.getKey();
- try{
- kvClient.putValue(key,en.getValue());
- }catch(Exception e) {
- LOG.info("Failed to add key to consul: " + en.getKey() + "=" + en.getValue());
- }
- }
- // success: stop here
- break;
- } catch(Exception e){
- LOG.log(Level.FINE, "consul access failed on " + hostAndPort + ", trying next...", e);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/consul/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
----------------------------------------------------------------------
diff --git a/modules/integration/consul/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySource b/modules/integration/consul/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
deleted file mode 100644
index 4996059..0000000
--- a/modules/integration/consul/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
+++ /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.consul.ConsulPropertySource
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/consul/src/test/java/org/apache/tamaya/etcd/ConsulPropertySourceTest.java
----------------------------------------------------------------------
diff --git a/modules/integration/consul/src/test/java/org/apache/tamaya/etcd/ConsulPropertySourceTest.java b/modules/integration/consul/src/test/java/org/apache/tamaya/etcd/ConsulPropertySourceTest.java
deleted file mode 100644
index 415fb38..0000000
--- a/modules/integration/consul/src/test/java/org/apache/tamaya/etcd/ConsulPropertySourceTest.java
+++ /dev/null
@@ -1,75 +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.etcd;
-
-import org.apache.tamaya.consul.ConsulPropertySource;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.util.Map;
-
-import static org.junit.Assert.*;
-import static org.junit.Assert.assertEquals;
-
-/**
- * Created by atsticks on 07.01.16.
- */
-public class ConsulPropertySourceTest {
-
- private final ConsulPropertySource propertySource = new ConsulPropertySource();
-
- @BeforeClass
- public static void setup(){
- System.setProperty("consul.urls", "http://127.0.0.1:8300");
- }
-
- @Test
- public void testGetOrdinal() throws Exception {
- assertEquals(propertySource.getOrdinal(), 1000);
- }
-
- @Test
- public void testGetDefaultOrdinal() throws Exception {
- assertEquals(propertySource.getDefaultOrdinal(), 1000);
- }
-
- @Test
- public void testGetName() throws Exception {
- assertEquals("consul", propertySource.getName());
- }
-
- @Test
- public void testGet() throws Exception {
- Map<String,String> props = propertySource.getProperties();
- for(Map.Entry<String,String> en:props.entrySet()){
- assertNotNull("Key not found: " + en.getKey(), propertySource.get(en.getKey()));
- }
- }
-
- @Test
- public void testGetProperties() throws Exception {
- Map<String,String> props = propertySource.getProperties();
- assertNotNull(props);
- }
-
- @Test
- public void testIsScannable() throws Exception {
- assertFalse(propertySource.isScannable());
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/consul/src/test/java/org/apache/tamaya/etcd/ConsulWriteTest.java
----------------------------------------------------------------------
diff --git a/modules/integration/consul/src/test/java/org/apache/tamaya/etcd/ConsulWriteTest.java b/modules/integration/consul/src/test/java/org/apache/tamaya/etcd/ConsulWriteTest.java
deleted file mode 100644
index ec930b9..0000000
--- a/modules/integration/consul/src/test/java/org/apache/tamaya/etcd/ConsulWriteTest.java
+++ /dev/null
@@ -1,80 +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.etcd;
-
-import com.google.common.net.HostAndPort;
-import org.apache.tamaya.consul.ConsulPropertySource;
-import org.apache.tamaya.mutableconfig.spi.ConfigChangeRequest;
-import org.junit.BeforeClass;
-
-import java.net.MalformedURLException;
-import java.net.URISyntaxException;
-import java.util.Map;
-import java.util.UUID;
-
-import static org.junit.Assert.*;
-
-/**
- * Tests for th consul backend integration for writing to the consul backend.
- */
-public class ConsulWriteTest {
-
- private static HostAndPort accessor;
- static boolean execute = false;
- private static ConsulPropertySource propertySource;
-
- @BeforeClass
- public static void setup() throws MalformedURLException, URISyntaxException {
- System.setProperty("consul.urls", "http://127.0.0.1:8300");
- accessor = HostAndPort.fromString("127.0.0.1:8500");
- propertySource = new ConsulPropertySource();
- }
-
- @org.junit.Test
- public void testSetNormal() throws Exception {
- if (!execute) return;
- String taID = UUID.randomUUID().toString();
- ConfigChangeRequest request = new ConfigChangeRequest("testSetNormal");
- request.put(taID, "testSetNormal");
- propertySource.applyChange(request);
- }
-
-
- @org.junit.Test
- public void testDelete() throws Exception {
- if(!execute)return;
- String taID = UUID.randomUUID().toString();
- ConfigChangeRequest request = new ConfigChangeRequest("testDelete");
- request.put(taID, "testDelete");
- propertySource.applyChange(request);
- assertEquals(propertySource.get("testDelete").getValue(), taID.toString());
- assertNotNull(propertySource.get("_testDelete.createdIndex"));
- request = new ConfigChangeRequest("testDelete2");
- request.remove("testDelete");
- propertySource.applyChange(request);
- assertNull(propertySource.get("testDelete"));
- }
-
- @org.junit.Test
- public void testGetProperties() throws Exception {
- if(!execute)return;
- Map<String,String> result = propertySource.getProperties();
- assertTrue(result.isEmpty());
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/etcd/pom.xml
----------------------------------------------------------------------
diff --git a/modules/integration/etcd/pom.xml b/modules/integration/etcd/pom.xml
deleted file mode 100644
index 7520822..0000000
--- a/modules/integration/etcd/pom.xml
+++ /dev/null
@@ -1,110 +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.
--->
-<project xmlns="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">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-integration</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
- </parent>
-
- <artifactId>tamaya-etcd</artifactId>
- <name>Apache Tamaya Integration - etcd</name>
- <packaging>bundle</packaging>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.jacoco</groupId>
- <artifactId>jacoco-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>prepare-agent</id>
- <goals>
- <goal>prepare-agent</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.tamaya.etcd
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>java-hamcrest</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-core</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-functions</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient-osgi</artifactId>
- <version>4.5.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-json_1.0_spec</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.johnzon</groupId>
- <artifactId>johnzon-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-mutable-config</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- <optional>true</optional>
- </dependency>
- </dependencies>
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/etcd/src/main/java/org/apache/tamaya/etcd/EtcdAccessor.java
----------------------------------------------------------------------
diff --git a/modules/integration/etcd/src/main/java/org/apache/tamaya/etcd/EtcdAccessor.java b/modules/integration/etcd/src/main/java/org/apache/tamaya/etcd/EtcdAccessor.java
deleted file mode 100644
index 4feccfa..0000000
--- a/modules/integration/etcd/src/main/java/org/apache/tamaya/etcd/EtcdAccessor.java
+++ /dev/null
@@ -1,520 +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.etcd;
-
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.json.Json;
-import javax.json.JsonArray;
-import javax.json.JsonObject;
-import javax.json.JsonReader;
-import javax.json.JsonReaderFactory;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpStatus;
-import org.apache.http.NameValuePair;
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.client.entity.UrlEncodedFormEntity;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpDelete;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.message.BasicNameValuePair;
-import org.apache.http.util.EntityUtils;
-
-/**
- * Accessor for reading to or writing from an etcd endpoint.
- */
-public class EtcdAccessor {
-
- private static final Logger LOG = Logger.getLogger(EtcdAccessor.class.getName());
-
- /**
- * Timeout in seconds.
- */
- private int timeout = 2;
- /**
- * Timeout in seconds.
- */
- private final int socketTimeout = 1000;
- /**
- * Timeout in seconds.
- */
- private final int connectTimeout = 1000;
-
- /**
- * Property that make Johnzon accept commentc.
- */
- public static final String JOHNZON_SUPPORTS_COMMENTS_PROP = "org.apache.johnzon.supports-comments";
- /**
- * The JSON reader factory used.
- */
- private final JsonReaderFactory readerFactory = initReaderFactory();
-
- /**
- * Initializes the factory to be used for creating readers.
- */
- private JsonReaderFactory initReaderFactory() {
- final Map<String, Object> config = new HashMap<>();
- config.put(JOHNZON_SUPPORTS_COMMENTS_PROP, true);
- return Json.createReaderFactory(config);
- }
-
- /**
- * The base server url.
- */
- private final String serverURL;
- /**
- * The http client.
- */
- private final CloseableHttpClient httpclient = HttpClients.createDefault();
-
- /**
- * Creates a new instance with the basic access url.
- *
- * @param server server url, e.g. {@code http://127.0.0.1:4001}, not null.
- */
- public EtcdAccessor(String server) {
- this(server, 2);
- }
-
- public EtcdAccessor(String server, int timeout) {
- this.timeout = timeout;
- if (server.endsWith("/")) {
- serverURL = server.substring(0, server.length() - 1);
- } else {
- serverURL = server;
- }
-
- }
-
- /**
- * Get the etcd server version.
- *
- * @return the etcd server version, never null.
- */
- public String getVersion() {
- String version = "<ERROR>";
- try {
- final CloseableHttpClient httpclient = HttpClients.createDefault();
- final HttpGet httpGet = new HttpGet(serverURL + "/version");
- httpGet.setConfig(RequestConfig.copy(RequestConfig.DEFAULT).setSocketTimeout(socketTimeout)
- .setConnectTimeout(timeout).build());
- try (CloseableHttpResponse response = httpclient.execute(httpGet)) {
- if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
- final HttpEntity entity = response.getEntity();
- // and ensure it is fully consumed
- version = EntityUtils.toString(entity);
- EntityUtils.consume(entity);
- }
- }
- return version;
- } catch (final Exception e) {
- LOG.log(Level.INFO, "Error getting etcd version from: " + serverURL, e);
- }
- return version;
- }
-
- /**
- * Ask etcd for a single key, value pair. Hereby the response returned from
- * etcd:
- *
- * <pre>
- * {
- * "action": "get",
- * "node": {
- * "createdIndex": 2,
- * "key": "/message",
- * "modifiedIndex": 2,
- * "value": "Hello world"
- * }
- * }
- * </pre>
- *
- * is mapped to:
- *
- * <pre>
- * key=value
- * _key.source=[etcd]http://127.0.0.1:4001
- * _key.createdIndex=12
- * _key.modifiedIndex=34
- * _key.ttl=300
- * _key.expiration=...
- * </pre>
- *
- * @param key the requested key
- * @return the mapped result, including meta-entries.
- */
- public Map<String, String> get(String key) {
- final Map<String, String> result = new HashMap<>();
- try {
- final HttpGet httpGet = new HttpGet(serverURL + "/v2/keys/" + key);
- httpGet.setConfig(RequestConfig.copy(RequestConfig.DEFAULT).setSocketTimeout(socketTimeout)
- .setConnectionRequestTimeout(timeout).setConnectTimeout(connectTimeout).build());
- try (CloseableHttpResponse response = httpclient.execute(httpGet)) {
- if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
- final HttpEntity entity = response.getEntity();
- final JsonReader reader = readerFactory
- .createReader(new StringReader(EntityUtils.toString(entity)));
- final JsonObject o = reader.readObject();
- final JsonObject node = o.getJsonObject("node");
- if (node.containsKey("value")) {
- result.put(key, node.getString("value"));
- result.put("_" + key + ".source", "[etcd]" + serverURL);
- }
- if (node.containsKey("createdIndex")) {
- result.put("_" + key + ".createdIndex", String.valueOf(node.getInt("createdIndex")));
- }
- if (node.containsKey("modifiedIndex")) {
- result.put("_" + key + ".modifiedIndex", String.valueOf(node.getInt("modifiedIndex")));
- }
- if (node.containsKey("expiration")) {
- result.put("_" + key + ".expiration", String.valueOf(node.getString("expiration")));
- }
- if (node.containsKey("ttl")) {
- result.put("_" + key + ".ttl", String.valueOf(node.getInt("ttl")));
- }
- EntityUtils.consume(entity);
- } else {
- result.put("_" + key + ".NOT_FOUND.target", "[etcd]" + serverURL);
- }
- }
- } catch (final Exception e) {
- LOG.log(Level.INFO, "Error reading key '" + key + "' from etcd: " + serverURL, e);
- result.put("_ERROR", "Error reading key '" + key + "' from etcd: " + serverURL + ": " + e.toString());
- }
- return result;
- }
-
- /**
- * Creates/updates an entry in etcd without any ttl set.
- *
- * @param key the property key, not null
- * @param value the value to be set
- * @return the result map as described above.
- * @see #set(String, String, Integer)
- */
- public Map<String, String> set(String key, String value) {
- return set(key, value, null);
- }
-
- /**
- * Creates/updates an entry in etcd. The response as follows:
- *
- * <pre>
- * {
- * "action": "set",
- * "node": {
- * "createdIndex": 3,
- * "key": "/message",
- * "modifiedIndex": 3,
- * "value": "Hello etcd"
- * },
- * "prevNode": {
- * "createdIndex": 2,
- * "key": "/message",
- * "value": "Hello world",
- * "modifiedIndex": 2
- * }
- * }
- * </pre>
- *
- * is mapped to:
- *
- * <pre>
- * key=value
- * _key.source=[etcd]http://127.0.0.1:4001
- * _key.createdIndex=12
- * _key.modifiedIndex=34
- * _key.ttl=300
- * _key.expiry=...
- * // optional
- * _key.prevNode.createdIndex=12
- * _key.prevNode.modifiedIndex=34
- * _key.prevNode.ttl=300
- * _key.prevNode.expiration=...
- * </pre>
- *
- * @param key the property key, not null
- * @param value the value to be set
- * @param ttlSeconds the ttl in seconds (optional)
- * @return the result map as described above.
- */
- public Map<String, String> set(String key, String value, Integer ttlSeconds) {
- final Map<String, String> result = new HashMap<>();
- try {
- final HttpPut put = new HttpPut(serverURL + "/v2/keys/" + key);
- put.setConfig(RequestConfig.copy(RequestConfig.DEFAULT).setSocketTimeout(socketTimeout)
- .setConnectionRequestTimeout(timeout).setConnectTimeout(connectTimeout).build());
- final List<NameValuePair> nvps = new ArrayList<>();
- nvps.add(new BasicNameValuePair("value", value));
- if (ttlSeconds != null) {
- nvps.add(new BasicNameValuePair("ttl", ttlSeconds.toString()));
- }
- put.setEntity(new UrlEncodedFormEntity(nvps));
- try (CloseableHttpResponse response = httpclient.execute(put)) {
- if (response.getStatusLine().getStatusCode() == HttpStatus.SC_CREATED
- || response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
- final HttpEntity entity = response.getEntity();
- final JsonReader reader = readerFactory
- .createReader(new StringReader(EntityUtils.toString(entity)));
- final JsonObject o = reader.readObject();
- final JsonObject node = o.getJsonObject("node");
- if (node.containsKey("createdIndex")) {
- result.put("_" + key + ".createdIndex", String.valueOf(node.getInt("createdIndex")));
- }
- if (node.containsKey("modifiedIndex")) {
- result.put("_" + key + ".modifiedIndex", String.valueOf(node.getInt("modifiedIndex")));
- }
- if (node.containsKey("expiration")) {
- result.put("_" + key + ".expiration", String.valueOf(node.getString("expiration")));
- }
- if (node.containsKey("ttl")) {
- result.put("_" + key + ".ttl", String.valueOf(node.getInt("ttl")));
- }
- result.put(key, node.getString("value"));
- result.put("_" + key + ".source", "[etcd]" + serverURL);
- parsePrevNode(key, result, node);
- EntityUtils.consume(entity);
- }
- }
- } catch (final Exception e) {
- LOG.log(Level.INFO, "Error writing to etcd: " + serverURL, e);
- result.put("_ERROR", "Error writing '" + key + "' to etcd: " + serverURL + ": " + e.toString());
- }
- return result;
- }
-
- /**
- * Deletes a given key. The response is as follows:
- *
- * <pre>
- * _key.source=[etcd]http://127.0.0.1:4001
- * _key.createdIndex=12
- * _key.modifiedIndex=34
- * _key.ttl=300
- * _key.expiry=...
- * // optional
- * _key.prevNode.createdIndex=12
- * _key.prevNode.modifiedIndex=34
- * _key.prevNode.ttl=300
- * _key.prevNode.expiration=...
- * _key.prevNode.value=...
- * </pre>
- *
- * @param key the key to be deleted.
- * @return the response mpas as described above.
- */
- public Map<String, String> delete(String key) {
- final Map<String, String> result = new HashMap<>();
- try {
- final HttpDelete delete = new HttpDelete(serverURL + "/v2/keys/" + key);
- delete.setConfig(RequestConfig.copy(RequestConfig.DEFAULT).setSocketTimeout(socketTimeout)
- .setConnectionRequestTimeout(timeout).setConnectTimeout(connectTimeout).build());
- try (CloseableHttpResponse response = httpclient.execute(delete)) {
- if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
- final HttpEntity entity = response.getEntity();
- final JsonReader reader = readerFactory
- .createReader(new StringReader(EntityUtils.toString(entity)));
- final JsonObject o = reader.readObject();
- final JsonObject node = o.getJsonObject("node");
- if (node.containsKey("createdIndex")) {
- result.put("_" + key + ".createdIndex", String.valueOf(node.getInt("createdIndex")));
- }
- if (node.containsKey("modifiedIndex")) {
- result.put("_" + key + ".modifiedIndex", String.valueOf(node.getInt("modifiedIndex")));
- }
- if (node.containsKey("expiration")) {
- result.put("_" + key + ".expiration", String.valueOf(node.getString("expiration")));
- }
- if (node.containsKey("ttl")) {
- result.put("_" + key + ".ttl", String.valueOf(node.getInt("ttl")));
- }
- parsePrevNode(key, result, o);
- EntityUtils.consume(entity);
- }
- }
- } catch (final Exception e) {
- LOG.log(Level.INFO, "Error deleting key '" + key + "' from etcd: " + serverURL, e);
- result.put("_ERROR", "Error deleting '" + key + "' from etcd: " + serverURL + ": " + e.toString());
- }
- return result;
- }
-
- private static void parsePrevNode(String key, Map<String, String> result, JsonObject o) {
- if (o.containsKey("prevNode")) {
- final JsonObject prevNode = o.getJsonObject("prevNode");
- if (prevNode.containsKey("createdIndex")) {
- result.put("_" + key + ".prevNode.createdIndex",
- String.valueOf(prevNode.getInt("createdIndex")));
- }
- if (prevNode.containsKey("modifiedIndex")) {
- result.put("_" + key + ".prevNode.modifiedIndex",
- String.valueOf(prevNode.getInt("modifiedIndex")));
- }
- if (prevNode.containsKey("expiration")) {
- result.put("_" + key + ".prevNode.expiration",
- String.valueOf(prevNode.getString("expiration")));
- }
- if (prevNode.containsKey("ttl")) {
- result.put("_" + key + ".prevNode.ttl", String.valueOf(prevNode.getInt("ttl")));
- }
- result.put("_" + key + ".prevNode.value", prevNode.getString("value"));
- }
- }
-
- /**
- * Get all properties for the given directory key recursively.
- *
- * @param directory the directory entry
- * @return the properties and its metadata
- * @see #getProperties(String, boolean)
- */
- public Map<String, String> getProperties(String directory) {
- return getProperties(directory, true);
- }
-
- /**
- * Access all properties. The response of:
- *
- * <pre>
- * {
- * "action": "get",
- * "node": {
- * "key": "/",
- * "dir": true,
- * "nodes": [
- * {
- * "key": "/foo_dir",
- * "dir": true,
- * "modifiedIndex": 2,
- * "createdIndex": 2
- * },
- * {
- * "key": "/foo",
- * "value": "two",
- * "modifiedIndex": 1,
- * "createdIndex": 1
- * }
- * ]
- * }
- * }
- * </pre>
- *
- * is mapped to a regular Tamaya properties map as follows:
- *
- * <pre>
- * key1=myvalue
- * _key1.source=[etcd]http://127.0.0.1:4001
- * _key1.createdIndex=12
- * _key1.modifiedIndex=34
- * _key1.ttl=300
- * _key1.expiration=...
- *
- * key2=myvaluexxx
- * _key2.source=[etcd]http://127.0.0.1:4001
- * _key2.createdIndex=12
- *
- * key3=val3
- * _key3.source=[etcd]http://127.0.0.1:4001
- * _key3.createdIndex=12
- * _key3.modifiedIndex=2
- * </pre>
- *
- * @param directory remote directory to query.
- * @param recursive allows to set if querying is performed recursively
- * @return all properties read from the remote server.
- */
- public Map<String, String> getProperties(String directory, boolean recursive) {
- final Map<String, String> result = new HashMap<>();
- try {
- final HttpGet get = new HttpGet(serverURL + "/v2/keys/" + directory + "?recursive=" + recursive);
- get.setConfig(RequestConfig.copy(RequestConfig.DEFAULT).setSocketTimeout(socketTimeout)
- .setConnectionRequestTimeout(timeout).setConnectTimeout(connectTimeout).build());
- try (CloseableHttpResponse response = httpclient.execute(get)) {
-
- if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
- final HttpEntity entity = response.getEntity();
- final JsonReader reader = readerFactory.createReader(new StringReader(EntityUtils.toString(entity)));
- final JsonObject o = reader.readObject();
- final JsonObject node = o.getJsonObject("node");
- if (node != null) {
- addNodes(result, node);
- }
- EntityUtils.consume(entity);
- }
- }
- } catch (final Exception e) {
- LOG.log(Level.INFO, "Error reading properties for '" + directory + "' from etcd: " + serverURL, e);
- result.put("_ERROR",
- "Error reading properties for '" + directory + "' from etcd: " + serverURL + ": " + e.toString());
- }
- return result;
- }
-
- /**
- * Recursively read out all key/values from this etcd JSON array.
- *
- * @param result map with key, values and metadata.
- * @param node the node to parse.
- */
- private void addNodes(Map<String, String> result, JsonObject node) {
- if (!node.containsKey("dir") || "false".equals(node.get("dir").toString())) {
- final String key = node.getString("key").substring(1);
- result.put(key, node.getString("value"));
- if (node.containsKey("createdIndex")) {
- result.put("_" + key + ".createdIndex", String.valueOf(node.getInt("createdIndex")));
- }
- if (node.containsKey("modifiedIndex")) {
- result.put("_" + key + ".modifiedIndex", String.valueOf(node.getInt("modifiedIndex")));
- }
- if (node.containsKey("expiration")) {
- result.put("_" + key + ".expiration", String.valueOf(node.getString("expiration")));
- }
- if (node.containsKey("ttl")) {
- result.put("_" + key + ".ttl", String.valueOf(node.getInt("ttl")));
- }
- result.put("_" + key + ".source", "[etcd]" + serverURL);
- } else {
- final JsonArray nodes = node.getJsonArray("nodes");
- if (nodes != null) {
- for (int i = 0; i < nodes.size(); i++) {
- addNodes(result, nodes.getJsonObject(i));
- }
- }
- }
- }
-
- /**
- * Access the server root URL used by this accessor.
- *
- * @return the server root URL.
- */
- public String getUrl() {
- return serverURL;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/etcd/src/main/java/org/apache/tamaya/etcd/EtcdBackends.java
----------------------------------------------------------------------
diff --git a/modules/integration/etcd/src/main/java/org/apache/tamaya/etcd/EtcdBackends.java b/modules/integration/etcd/src/main/java/org/apache/tamaya/etcd/EtcdBackends.java
deleted file mode 100644
index a0c0703..0000000
--- a/modules/integration/etcd/src/main/java/org/apache/tamaya/etcd/EtcdBackends.java
+++ /dev/null
@@ -1,65 +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.etcd;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Singleton that reads and stores the current etcd setup, especially the possible URLs to be used.
- */
-public final class EtcdBackends {
-
- private static final Logger LOG = Logger.getLogger(EtcdBackends.class.getName());
- private static List<EtcdAccessor> etcdBackends = new ArrayList<>();
-
- static{
- int timeout = 2;
- String val = System.getProperty("tamaya.etcd.timeout");
- if(val == null){
- val = System.getenv("tamaya.etcd.timeout");
- }
- if(val!=null){
- timeout = Integer.parseInt(val);
- }
- String serverURLs = System.getProperty("tamaya.etcd.server.urls");
- if(serverURLs==null){
- serverURLs = System.getenv("tamaya.etcd.server.urls");
- }
- if(serverURLs==null){
- serverURLs = "http://127.0.0.1:4001";
- }
- for(String url:serverURLs.split("\\,")) {
- try{
- etcdBackends.add(new EtcdAccessor(url.trim(), timeout));
- LOG.info("Using etcd endoint: " + url);
- } catch(Exception e){
- LOG.log(Level.SEVERE, "Error initializing etcd accessor for URL: " + url, e);
- }
- }
- }
-
- private EtcdBackends(){}
-
- public static List<EtcdAccessor> getEtcdBackends(){
- return etcdBackends;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/etcd/src/main/java/org/apache/tamaya/etcd/EtcdPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/integration/etcd/src/main/java/org/apache/tamaya/etcd/EtcdPropertySource.java b/modules/integration/etcd/src/main/java/org/apache/tamaya/etcd/EtcdPropertySource.java
deleted file mode 100644
index 5e129f7..0000000
--- a/modules/integration/etcd/src/main/java/org/apache/tamaya/etcd/EtcdPropertySource.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.etcd;
-
-import org.apache.tamaya.mutableconfig.spi.ConfigChangeRequest;
-import org.apache.tamaya.mutableconfig.spi.MutablePropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-import org.apache.tamaya.spi.PropertyValueBuilder;
-import org.apache.tamaya.spisupport.BasePropertySource;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Propertysource that is reading configuration from a configured etcd endpoint. Setting
- * {@code etcd.prefix} as system property maps the etcd based onfiguration
- * to this prefix namespace. Etcd servers are configured as {@code etcd.server.urls} system or environment property.
- * ETcd can be disabled by setting {@code tamaya.etcdprops.disable} either as env or system property.
- */
-public class EtcdPropertySource extends BasePropertySource
- implements MutablePropertySource{
- private static final Logger LOG = Logger.getLogger(EtcdPropertySource.class.getName());
-
- private String prefix = System.getProperty("tamaya.etcd.prefix", "");
-
- private final boolean disabled = evaluateDisabled();
-
- private boolean evaluateDisabled() {
- String value = System.getProperty("tamaya.etcdprops.disable");
- if(value==null){
- value = System.getenv("tamaya.etcdprops.disable");
- }
- if(value==null){
- return false;
- }
- return value.isEmpty() || Boolean.parseBoolean(value);
- }
-
- @Override
- public int getOrdinal() {
- PropertyValue configuredOrdinal = get(TAMAYA_ORDINAL);
- if(configuredOrdinal!=null){
- try{
- return Integer.parseInt(configuredOrdinal.getValue());
- } catch(Exception e){
- Logger.getLogger(getClass().getName()).log(Level.WARNING,
- "Configured Ordinal is not an int number: " + configuredOrdinal, e);
- }
- }
- return getDefaultOrdinal();
- }
-
- /**
- * Returns the default ordinal used, when no ordinal is set, or the ordinal was not parseable to an int value.
- * @return the default ordinal used, by default 0.
- */
- public int getDefaultOrdinal(){
- return 1000;
- }
-
- @Override
- public String getName() {
- return "etcd";
- }
-
- @Override
- public PropertyValue get(String key) {
- if(disabled){
- return null;
- }
- // check prefix, if key does not start with it, it is not part of our name space
- // if so, the prefix part must be removedProperties, so etcd can resolve without it
- if(!key.startsWith(prefix)){
- return null;
- } else{
- key = key.substring(prefix.length());
- }
- Map<String,String> props;
- String reqKey = key;
- if(key.startsWith("_")){
- reqKey = key.substring(1);
- if(reqKey.endsWith(".createdIndex")){
- reqKey = reqKey.substring(0,reqKey.length()-".createdIndex".length());
- } else if(reqKey.endsWith(".modifiedIndex")){
- reqKey = reqKey.substring(0,reqKey.length()-".modifiedIndex".length());
- } else if(reqKey.endsWith(".ttl")){
- reqKey = reqKey.substring(0,reqKey.length()-".ttl".length());
- } else if(reqKey.endsWith(".expiration")){
- reqKey = reqKey.substring(0,reqKey.length()-".expiration".length());
- } else if(reqKey.endsWith(".source")){
- reqKey = reqKey.substring(0,reqKey.length()-".source".length());
- }
- }
- for(EtcdAccessor accessor: EtcdBackends.getEtcdBackends()){
- try{
- props = accessor.get(reqKey);
- if(!props.containsKey("_ERROR")) {
- // No repfix mapping necessary here, since we only access/return the value...
- return new PropertyValueBuilder(key, props.get(reqKey), getName()).setContextData(props).build();
- } else{
- LOG.log(Level.FINE, "etcd error on " + accessor.getUrl() + ": " + props.get("_ERROR"));
- }
- } catch(Exception e){
- LOG.log(Level.FINE, "etcd access failed on " + accessor.getUrl() + ", trying next...", e);
- }
- }
- return null;
- }
-
- @Override
- public Map<String, String> getProperties() {
- if(disabled){
- return Collections.emptyMap();
- }
- if(!EtcdBackends.getEtcdBackends().isEmpty()){
- for(EtcdAccessor accessor: EtcdBackends.getEtcdBackends()){
- try{
- Map<String, String> props = accessor.getProperties("");
- if(!props.containsKey("_ERROR")) {
- return mapPrefix(props);
- } else{
- LOG.log(Level.FINE, "etcd error on " + accessor.getUrl() + ": " + props.get("_ERROR"));
- }
- } catch(Exception e){
- LOG.log(Level.FINE, "etcd access failed on " + accessor.getUrl() + ", trying next...", e);
- }
- }
- }
- return Collections.emptyMap();
- }
-
- private Map<String, String> mapPrefix(Map<String, String> props) {
- if(prefix.isEmpty()){
- return props;
- }
- Map<String,String> map = new HashMap<>();
- for(Map.Entry<String,String> entry:props.entrySet()){
- if(entry.getKey().startsWith("_")){
- map.put("_" + prefix + entry.getKey().substring(1), entry.getValue());
- } else{
- map.put(prefix+ entry.getKey(), entry.getValue());
- }
- }
- return map;
- }
-
- @Override
- public boolean isScannable() {
- return true;
- }
-
- @Override
- public void applyChange(ConfigChangeRequest configChange) {
- for(EtcdAccessor accessor: EtcdBackends.getEtcdBackends()){
- try{
- for(String k: configChange.getRemovedProperties()){
- Map<String,String> res = accessor.delete(k);
- if(res.get("_ERROR")!=null){
- LOG.info("Failed to remove key from etcd: " + k);
- }
- }
- for(Map.Entry<String,String> en:configChange.getAddedProperties().entrySet()){
- String key = en.getKey();
- Integer ttl = null;
- int index = en.getKey().indexOf('?');
- if(index>0){
- key = en.getKey().substring(0, index);
- String rawQuery = en.getKey().substring(index+1);
- String[] queries = rawQuery.split("&");
- for(String query:queries){
- if(query.contains("ttl")){
- int qIdx = query.indexOf('=');
- ttl = qIdx>0?Integer.parseInt(query.substring(qIdx+1).trim()):null;
- }
- }
- }
- Map<String,String> res = accessor.set(key, en.getValue(), ttl);
- if(res.get("_ERROR")!=null){
- LOG.info("Failed to add key to etcd: " + en.getKey() + "=" + en.getValue());
- }
- }
- // success, stop here
- break;
- } catch(Exception e){
- LOG.log(Level.FINE, "etcd access failed on " + accessor.getUrl() + ", trying next...", e);
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/etcd/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
----------------------------------------------------------------------
diff --git a/modules/integration/etcd/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySource b/modules/integration/etcd/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
deleted file mode 100644
index eb7958e..0000000
--- a/modules/integration/etcd/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
+++ /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.etcd.EtcdPropertySource
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/etcd/src/test/java/org/apache/tamaya/etcd/EtcdAccessorTest.java
----------------------------------------------------------------------
diff --git a/modules/integration/etcd/src/test/java/org/apache/tamaya/etcd/EtcdAccessorTest.java b/modules/integration/etcd/src/test/java/org/apache/tamaya/etcd/EtcdAccessorTest.java
deleted file mode 100644
index 80bd716..0000000
--- a/modules/integration/etcd/src/test/java/org/apache/tamaya/etcd/EtcdAccessorTest.java
+++ /dev/null
@@ -1,116 +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.etcd;
-
-import org.junit.BeforeClass;
-
-import java.net.MalformedURLException;
-import java.util.Map;
-import java.util.UUID;
-
-import static org.junit.Assert.*;
-
-/**
- * Tests for th etcd backend integration. You must have set a system property so, theses tests are executed, e.g.
- * {@code -Detcd.url=http://127.0.0.1:4001}.
- */
-public class EtcdAccessorTest {
-
- private static EtcdAccessor accessor;
- static boolean execute = false;
-
- @BeforeClass
- public static void setup() throws MalformedURLException {
- accessor = new EtcdAccessor("http://192.168.99.105:4001");
- if(!accessor.getVersion().contains("etcd")){
- System.out.println("Disabling etcd tests, etcd not accessible at: " + System.getProperty("etcd.server.urls"));
- System.out.println("Configure etcd with -Detcd.server.urls=http://<IP>:<PORT>");
- }
- else{
- execute = true;
- }
- }
-
- @org.junit.Test
- public void testGetVersion() throws Exception {
- if(!execute)return;
- assertEquals(accessor.getVersion(), "etcd 0.4.9");
- }
-
- @org.junit.Test
- public void testGet() throws Exception {
- if(!execute)return;
- Map<String,String> result = accessor.get("test1");
- assertNotNull(result);
- }
-
- @org.junit.Test
- public void testSetNormal() throws Exception {
- if(!execute)return;
- String value = UUID.randomUUID().toString();
- Map<String,String> result = accessor.set("testSetNormal", value);
- assertNull(result.get("_testSetNormal.ttl"));
- assertEquals(accessor.get("testSetNormal").get("testSetNormal"), value);
- }
-
- @org.junit.Test
- public void testSetNormal2() throws Exception {
- if(!execute)return;
- String value = UUID.randomUUID().toString();
- Map<String,String> result = accessor.set("testSetNormal2", value, null);
- assertNull(result.get("_testSetNormal2.ttl"));
- assertEquals(accessor.get("testSetNormal2").get("testSetNormal2"), value);
- }
-
- @org.junit.Test
- public void testSetWithTTL() throws Exception {
- if(!execute)return;
- String value = UUID.randomUUID().toString();
- Map<String,String> result = accessor.set("testSetWithTTL", value, 1);
- assertNotNull(result.get("_testSetWithTTL.ttl"));
- assertEquals(accessor.get("testSetWithTTL").get("testSetWithTTL"), value);
- Thread.sleep(2000L);
- result = accessor.get("testSetWithTTL");
- assertNull(result.get("testSetWithTTL"));
- }
-
-
- @org.junit.Test
- public void testDelete() throws Exception {
- if(!execute)return;
- String value = UUID.randomUUID().toString();
- Map<String,String> result = accessor.set("testDelete", value, null);
- assertEquals(accessor.get("testDelete").get("testDelete"), value);
- assertNotNull(result.get("_testDelete.createdIndex"));
- result = accessor.delete("testDelete");
- assertEquals(result.get("_testDelete.prevNode.value"),value);
- assertNull(accessor.get("testDelete").get("testDelete"));
- }
-
- @org.junit.Test
- public void testGetProperties() throws Exception {
- if(!execute)return;
- String value = UUID.randomUUID().toString();
- accessor.set("testGetProperties1", value);
- Map<String,String> result = accessor.getProperties("");
- assertNotNull(result);
- assertEquals(result.get("testGetProperties1"), value);
- assertNotNull(result.get("_testGetProperties1.createdIndex"));
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/etcd/src/test/java/org/apache/tamaya/etcd/EtcdPropertySourceTest.java
----------------------------------------------------------------------
diff --git a/modules/integration/etcd/src/test/java/org/apache/tamaya/etcd/EtcdPropertySourceTest.java b/modules/integration/etcd/src/test/java/org/apache/tamaya/etcd/EtcdPropertySourceTest.java
deleted file mode 100644
index 898a963..0000000
--- a/modules/integration/etcd/src/test/java/org/apache/tamaya/etcd/EtcdPropertySourceTest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.etcd;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.util.Map;
-
-import static org.junit.Assert.*;
-import static org.junit.Assert.assertEquals;
-
-/**
- * Created by atsticks on 07.01.16.
- */
-public class EtcdPropertySourceTest {
-
- private final EtcdPropertySource propertySource = new EtcdPropertySource();
-
- @BeforeClass
- public static void setup(){
- System.setProperty("etcd.server.urls", "http://8.8.8.8:4001,http://192.168.99.105:4001");
- }
-
- @Test
- public void testGetOrdinal() throws Exception {
- assertEquals(propertySource.getOrdinal(), 1000);
- }
-
- @Test
- public void testGetDefaultOrdinal() throws Exception {
- assertEquals(propertySource.getDefaultOrdinal(), 1000);
- }
-
- @Test
- public void testGetName() throws Exception {
- assertEquals("etcd", propertySource.getName());
- }
-
- @Test
- public void testGet() throws Exception {
- Map<String,String> props = propertySource.getProperties();
- for(Map.Entry<String,String> en:props.entrySet()){
- assertNotNull("Key not found: " + en.getKey(), propertySource.get(en.getKey()));
- }
- }
-
- @Test
- public void testGetProperties() throws Exception {
- Map<String,String> props = propertySource.getProperties();
- assertNotNull(props);
- }
-
- @Test
- public void testIsScannable() throws Exception {
- assertTrue(propertySource.isScannable());
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/osgi/pom.xml
----------------------------------------------------------------------
diff --git a/modules/integration/osgi/pom.xml b/modules/integration/osgi/pom.xml
deleted file mode 100644
index e57f395..0000000
--- a/modules/integration/osgi/pom.xml
+++ /dev/null
@@ -1,102 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="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">
-
- <!--
-
- 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.
- -->
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-integration</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
- </parent>
-
- <artifactId>tamaya-osgi</artifactId>
- <packaging>bundle</packaging>
- <name>Apache Tamaya Integration - OSGi Services :: Tamaya Config</name>
- <description>Tamaya Based OSGI Implementation of ConfigAdmin and Config Injection</description>
-
- <properties>
- <felix.plugin.version>2.5.4</felix.plugin.version>
- </properties>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <version>${felix.plugin.version}</version>
- <inherited>true</inherited>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-Activator>
- org.apache.tamaya.integration.osgi.Activator
- </Bundle-Activator>
- <Export-Service>
- org.osgi.service.cm.ConfigurationAdmin
- </Export-Service>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.configadmin</artifactId>
- <version>1.8.8</version>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- <version>6.0.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-functions</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-spisupport</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-injection</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>java-hamcrest</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- </dependencies>
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/osgi/src/main/java/org/apache/tamaya/integration/osgi/Activator.java
----------------------------------------------------------------------
diff --git a/modules/integration/osgi/src/main/java/org/apache/tamaya/integration/osgi/Activator.java b/modules/integration/osgi/src/main/java/org/apache/tamaya/integration/osgi/Activator.java
deleted file mode 100644
index 7425dfb..0000000
--- a/modules/integration/osgi/src/main/java/org/apache/tamaya/integration/osgi/Activator.java
+++ /dev/null
@@ -1,134 +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.integration.osgi;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.inject.ConfigurationInjection;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.cm.ConfigurationAdmin;
-import org.osgi.util.tracker.ServiceTracker;
-
-import java.util.Dictionary;
-import java.util.Hashtable;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Activator that registers the Tamaya based Service Class for {@link ConfigurationAdmin},
- * using a default service priority of {@code 0}. This behaviour is configurable based on OSGI properties:
- * <ul>
- * <li><p><b>org.tamaya.integration.osgi.cm.ranking, type: int</b> allows to configure the OSGI service ranking for
- * Tamaya based ConfigurationAdmin instance. The default ranking used is 10.</p></li>
- * <li><p><b>org.tamaya.integration.osgi.cm.override, type: boolean</b> allows to configure if Tamaya should
- * register its ConfigAdmin service. Default is true.</p></li>
- * </ul>
- */
-public class Activator implements BundleActivator {
-
- private static final String SERVICE_RANKING_PROP = "org.tamaya.integration.osgi.cm.ranking";
-
- private static final String SERVICE_OVERRIDE_PROP = "org.tamaya.integration.osgi.cm.override";
-
- private static final String SERVICE_INJECT_PROP = "org.tamaya.integration.osgi.cm.inject";
-
- private static final Integer DEFAULT_RANKING = 10;
-
- private static final Logger LOG = Logger.getLogger(Activator.class.getName());
-
- private ServiceRegistration<ConfigurationAdmin> registration;
-
- private ServiceTracker<Object, Object> injectionTracker;
-
- @Override
- public void start(BundleContext context) throws Exception {
- String val = context.getProperty(SERVICE_OVERRIDE_PROP);
- if(val == null || Boolean.parseBoolean(val)){
- Dictionary<String, Object> props = new Hashtable<>();
- String ranking = context.getProperty(SERVICE_RANKING_PROP);
- if (ranking == null) {
- props.put(Constants.SERVICE_RANKING, DEFAULT_RANKING);
- } else {
- props.put(Constants.SERVICE_RANKING, Integer.valueOf(ranking));
- }
- TamayaConfigAdminImpl cm = new TamayaConfigAdminImpl(context);
- registration = context.registerService(ConfigurationAdmin.class, cm, props);
- }
-
- // register injection mechanisms, if not configured otherwise
- val = context.getProperty(SERVICE_INJECT_PROP);
- if(val == null || Boolean.parseBoolean(val)){
- injectionTracker = new ServiceTracker<Object, Object>(context, Object.class, null) {
- @Override
- public Object addingService(ServiceReference<Object> reference) {
- Object service = context.getService(reference);
- Object pidObj = reference.getProperty(Constants.SERVICE_PID);
- if (pidObj instanceof String) {
- String pid = (String) pidObj;
- ConfigurationAdmin configAdmin = null;
- ServiceReference<ConfigurationAdmin> adminRef =
- context.getServiceReference(ConfigurationAdmin.class);
- if(adminRef!=null){
- configAdmin = context.getService(adminRef);
- }
- try {
- Configuration targetConfig = null;
- if(configAdmin != null){
- org.osgi.service.cm.Configuration osgiConfig = configAdmin.getConfiguration(pid);
- if(osgiConfig!=null){
- targetConfig = new OSGIEnhancedConfiguration(osgiConfig);
- }
- }
- if(targetConfig==null){
- targetConfig = ConfigurationProvider.getConfiguration();
- }
- ConfigurationInjection.getConfigurationInjector().configure(service, targetConfig);
- } catch (Exception e) {
- LOG.log(Level.WARNING, "Error configuring Service: " + service, e);
- }
- } else {
- LOG.log(Level.SEVERE, "Unsupported pid: " + pidObj);
- }
- return service;
- }
-
- @Override
- public void removedService(ServiceReference<Object> reference, Object service) {
- context.ungetService(reference);
- }
- };
- injectionTracker.open();
- }
- }
-
- @Override
- public void stop(BundleContext context) throws Exception {
- if (registration != null) {
- registration.unregister();
- }
- if(injectionTracker!=null){
- injectionTracker.close();
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/osgi/src/main/java/org/apache/tamaya/integration/osgi/OSGIConfigRootMapper.java
----------------------------------------------------------------------
diff --git a/modules/integration/osgi/src/main/java/org/apache/tamaya/integration/osgi/OSGIConfigRootMapper.java b/modules/integration/osgi/src/main/java/org/apache/tamaya/integration/osgi/OSGIConfigRootMapper.java
deleted file mode 100644
index 836df8b..0000000
--- a/modules/integration/osgi/src/main/java/org/apache/tamaya/integration/osgi/OSGIConfigRootMapper.java
+++ /dev/null
@@ -1,36 +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.integration.osgi;
-
-/**
- * Mapping function for mapping Tamaya configuration sections to OSGI pids.
- */
-public interface OSGIConfigRootMapper {
-
- /**
- * Map the given OSGI pid to a corresponding configuration section in Tamaya. Es an example (and this is also the
- * default implemented) a configuration mapping for {@code pid/factoryPid==myBundle} could be {@code [bundle:myBundle]}.
- * This mapping is used as a prefix when collecting the corresponding entries for the OSGI configuration.
- * @param pid the OSGI pid, or null
- * @param factoryPid the OSGI factoryPid, or null
- * @return return the corresponding config root section. For ommitting any root section simply return an empty
- * String.
- */
- String getTamayaConfigRoot(String pid, String factoryPid);
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/osgi/src/main/java/org/apache/tamaya/integration/osgi/OSGIEnhancedConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/integration/osgi/src/main/java/org/apache/tamaya/integration/osgi/OSGIEnhancedConfiguration.java b/modules/integration/osgi/src/main/java/org/apache/tamaya/integration/osgi/OSGIEnhancedConfiguration.java
deleted file mode 100644
index 5e813af..0000000
--- a/modules/integration/osgi/src/main/java/org/apache/tamaya/integration/osgi/OSGIEnhancedConfiguration.java
+++ /dev/null
@@ -1,117 +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.integration.osgi;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spisupport.BasePropertySource;
-import org.apache.tamaya.spisupport.DefaultConfiguration;
-import org.apache.tamaya.spisupport.DefaultConfigurationContext;
-
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-
-/**
- * Configuration object that also reflects the values provided by the OSGI ConfigAdmin Configuration.
- * Similar to other tamaya areas adding a tamaya.ordinal into the corresponding OSGI configuration for
- * a pif/factoryPid allows to control the ordinal/priority of the OSGI configuration related to other
- * configured Tamaya Property Sources. Overall the configuration evaluation for Tamaya follows the
- * same rules, with the difference that each bunldle owns its own ConfigAdmin based part. From
- * Tamaya, the granularity depends on the implementation of the ConfigurationProviderSpi. By default
- * Tamaya configuration is managed as a global resource/config tree, wheres bundle specific sections are
- * selected only.
- */
-public class OSGIEnhancedConfiguration extends DefaultConfiguration{
- /** The default ordinal used for the OSGI config, */
- private static final int OSGI_DEFAULT_ORDINAL = 0;
-
- /**
- * Constructor.
- *
- * @param osgiConfiguration The OSGI configuration found.
- */
- public OSGIEnhancedConfiguration(org.osgi.service.cm.Configuration osgiConfiguration) {
- super(new OSGIConfigurationContext(osgiConfiguration));
- }
-
- /**
- * Class that models a Tamaya ConfigurationContext, which implicitly contains the bundle specific
- * Configuration wrapped into a Tamaya PropertySource.
- */
- private static final class OSGIConfigurationContext extends DefaultConfigurationContext{
- private OSGIPropertySource osgiPropertySource;
-
- public OSGIConfigurationContext(org.osgi.service.cm.Configuration osgiConfiguration){
- if(osgiConfiguration!=null) {
- this.osgiPropertySource = new OSGIPropertySource(osgiConfiguration);
- }
- }
-
- @Override
- public List<PropertySource> getPropertySources() {
- List<PropertySource> sources = super.getPropertySources();
- if(osgiPropertySource!=null){
- sources.add(osgiPropertySource);
- }
- return sources;
- }
- }
-
- /**
- * Tamaya PropertySource providing the values from an OSGI Configuration.
- */
- private static final class OSGIPropertySource extends BasePropertySource{
-
- private final org.osgi.service.cm.Configuration osgiConfiguration;
-
- public OSGIPropertySource(org.osgi.service.cm.Configuration osgiConfiguration){
- this.osgiConfiguration = Objects.requireNonNull(osgiConfiguration);
- }
-
- @Override
- public int getDefaultOrdinal() {
- String val = System.getProperty("osgi.defaultOrdinal");
- if(val!=null){
- return Integer.parseInt(val.trim());
- }
- return OSGI_DEFAULT_ORDINAL;
- }
-
- @Override
- public String getName() {
- return "OSGIConfig:pid="+
- (osgiConfiguration.getPid()!=null?osgiConfiguration.getPid():osgiConfiguration.getFactoryPid());
- }
-
- @Override
- public Map<String, String> getProperties() {
- Map<String, String> map = new HashMap<>();
- Dictionary<String,Object> dict = osgiConfiguration.getProperties();
- Enumeration<String> keys = dict.keys();
- while(keys.hasMoreElements()){
- String key = keys.nextElement();
- map.put(key,String.valueOf(dict.get(key)));
- }
- return map;
- }
- }
-}
[17/24] incubator-tamaya git commit: Removed all modules from the
main repository. They will be reborn in separate ASF repository.
Posted by pl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/formats/src/test/java/org/apache/tamaya/format/FlattenedDefaultPropertySourceTest.java
----------------------------------------------------------------------
diff --git a/modules/formats/src/test/java/org/apache/tamaya/format/FlattenedDefaultPropertySourceTest.java b/modules/formats/src/test/java/org/apache/tamaya/format/FlattenedDefaultPropertySourceTest.java
deleted file mode 100644
index adc94f6..0000000
--- a/modules/formats/src/test/java/org/apache/tamaya/format/FlattenedDefaultPropertySourceTest.java
+++ /dev/null
@@ -1,98 +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.format;
-
-import org.apache.tamaya.format.formats.PropertiesFormat;
-import org.apache.tamaya.spi.PropertySource;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
-/**
- * Tests for {@link org.apache.tamaya.format.FlattenedDefaultPropertySource}.
- */
-public class FlattenedDefaultPropertySourceTest {
-
- @Test
- public void testGetName() throws Exception {
- FlattenedDefaultPropertySource ps = new FlattenedDefaultPropertySource(createConfigurationData("test1"));
- assertEquals("test1", ps.getName());
- }
-
- private ConfigurationData createConfigurationData(String sourceName) {
- return ConfigurationDataBuilder.of(sourceName, new PropertiesFormat())
- .addProperty("a", "aValue").addSectionProperty("section1", "sectionKey1", "sectionValue11")
- .addSections("section1", "section12")
- .addSectionProperty("section2", "sectionKey1", "sectionValue21").build();
- }
-
- private ConfigurationData createConfigurationData(String sourceName, int ordinal) {
- return ConfigurationDataBuilder.of(sourceName, new PropertiesFormat())
- .addProperty("a", "aValue").addSectionProperty("section1", "sectionKey1", "sectionValue11")
- .addSections("section1", "section12").addProperty(PropertySource.TAMAYA_ORDINAL, String.valueOf(ordinal))
- .addSectionProperty("section2", "sectionKey1", "sectionValue21").build();
- }
-
- private ConfigurationData createConfigurationDataNoDefault(String sourceName) {
- return ConfigurationDataBuilder.of(sourceName, new PropertiesFormat())
- .addSectionProperty("section1", "sectionKey1", "sectionValue11")
- .addSections("section1", "section12")
- .addSectionProperty("section2", "sectionKey1", "sectionValue21").build();
- }
-
- @Test
- public void testGetOrdinal() throws Exception {
- FlattenedDefaultPropertySource ps = new FlattenedDefaultPropertySource(createConfigurationData("test1", 11));
- assertEquals(11, ps.getOrdinal());
- }
-
- @Test
- public void testGet() throws Exception {
- FlattenedDefaultPropertySource ps = new FlattenedDefaultPropertySource(createConfigurationData("test2"));
- assertEquals("aValue", ps.get("a").get("a"));
- assertNotNull(ps.get("section1.sectionKey1").get("section1.sectionKey1"));
- assertNotNull(ps.get("section2.sectionKey1").get("section2.sectionKey1"));
- assertNull(ps.get("sectionKey1"));
- ps = new FlattenedDefaultPropertySource(createConfigurationDataNoDefault("test2"));
- assertEquals("sectionValue11", ps.get("section1.sectionKey1").get("section1.sectionKey1"));
- assertEquals("sectionValue21", ps.get("section2.sectionKey1").get("section2.sectionKey1"));
- assertNull(ps.get("a"));
- assertNull(ps.get("section1"));
- }
-
- @Test
- public void testGetProperties() throws Exception {
- FlattenedDefaultPropertySource ps = new FlattenedDefaultPropertySource(createConfigurationData("test3"));
- assertNotNull(ps.getProperties());
- assertEquals("aValue", ps.getProperties().get("a"));
- assertNotNull(ps.getProperties().get("section1.sectionKey1"));
- assertNotNull(ps.getProperties().get("section2.sectionKey1"));
- assertNull(ps.getProperties().get("section1.sectionKey2"));
- assertNull(ps.getProperties().get("section2.sectionKey2"));
- assertNull(ps.getProperties().get("sectionKey1"));
- assertNull(ps.getProperties().get("sectionKey2"));
- ps = new FlattenedDefaultPropertySource(createConfigurationDataNoDefault("test3"));
- assertNotNull(ps.getProperties());
- assertEquals("sectionValue11", ps.getProperties().get("section1.sectionKey1"));
- assertEquals("sectionValue21", ps.getProperties().get("section2.sectionKey1"));
- assertNull(ps.get("section1"));
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/formats/src/test/java/org/apache/tamaya/format/InputStreamFactoryTest.java
----------------------------------------------------------------------
diff --git a/modules/formats/src/test/java/org/apache/tamaya/format/InputStreamFactoryTest.java b/modules/formats/src/test/java/org/apache/tamaya/format/InputStreamFactoryTest.java
deleted file mode 100644
index c05da09..0000000
--- a/modules/formats/src/test/java/org/apache/tamaya/format/InputStreamFactoryTest.java
+++ /dev/null
@@ -1,145 +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.format;
-
-import org.junit.Test;
-import org.mockito.ArgumentCaptor;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-
-public class InputStreamFactoryTest {
-
- @Test(expected = NullPointerException.class)
- public void ctorEnforcesNonNullOriginal() throws IOException {
- new InputStreamFactory(null);
- }
-
- @Test
- public void givenStreamIsClosedInTryWithResourcesConstruct() throws Exception {
- InputStream stream = mock(InputStream.class);
- doReturn(34).when(stream).read();
-
- InputStreamFactory factory = new InputStreamFactory(stream);
- verify(stream).close();
- for (int i = 0; i < 100; i++) {
- try (InputStream in = factory.createInputStream()) {
- in.read();
- }
- }
- verify(stream).close();
- }
-
- @Test
- public void callToReadIsNotForwardedCallToWrapped() throws IOException {
- InputStream stream = new ByteArrayInputStream(new byte[]{1, 2, 3, 4});
- InputStreamFactory closer = new InputStreamFactory(stream);
- byte[] byteArray = new byte[4];
- for (int i = 0; i < 100; i++) {
- InputStream is = closer.createInputStream();
- assertThat(is.read(byteArray), equalTo(4));
- }
- }
-
-
- @Test
- public void callToSkipIsForwardedToWrapped() throws IOException {
- InputStream stream = new ByteArrayInputStream(new byte[]{1, 2, 3, 4});
- InputStreamFactory closer = new InputStreamFactory(stream);
- for (int i = 0; i < 100; i++) {
- InputStream is = closer.createInputStream();
- assertThat(is.skip(2L), equalTo(2L));
- }
- }
-
-
- @Test
- public void callToAvailableIsNotForwardedToWrapped() throws IOException {
- InputStream stream = new ByteArrayInputStream(new byte[]{1, 2, 3, 4});
- InputStreamFactory closer = new InputStreamFactory(stream);
- for (int i = 0; i < 100; i++) {
- InputStream is = closer.createInputStream();
- assertThat(is.available(), equalTo(4));
- }
- }
-
- @Test
- public void callToCloseIsNotForwardedToWrapped() throws IOException {
- InputStream stream = new ByteArrayInputStream(new byte[]{1, 2, 3, 4});
- InputStreamFactory closer = new InputStreamFactory(stream);
- for (int i = 0; i < 100; i++) {
- InputStream is = closer.createInputStream();
- is.close();
- }
- }
-
- @Test
- public void callToMarkIsNotForwardedToWrapped() throws IOException {
-// ArgumentCaptor<Integer> captor = ArgumentCaptor.forClass(Integer.class);
- InputStream stream = new ByteArrayInputStream(new byte[]{1, 2, 3, 4});
- InputStreamFactory closer = new InputStreamFactory(stream);
- for (int i = 0; i < 100; i++) {
- InputStream is = closer.createInputStream();
- is.mark(2);
- }
- }
-
-
- @Test
- public void callToResetIsNotForwardedToWrapped() throws IOException {
- InputStream stream = new ByteArrayInputStream(new byte[]{1, 2, 3, 4});
- InputStreamFactory closer = new InputStreamFactory(stream);
- for (int i = 0; i < 100; i++) {
- InputStream is = closer.createInputStream();
- is.reset();
- }
- }
-
- @Test
- public void callToMarkSupportedIsNotForwardedToWrapped() throws IOException {
- InputStream stream = new ByteArrayInputStream(new byte[]{1, 2, 3, 4});
- InputStreamFactory closer = new InputStreamFactory(stream);
- for (int i = 0; i < 100; i++) {
- InputStream is = closer.createInputStream();
- assertThat(is.markSupported(), is(true));
- }
- }
-
- @Test
- public void callToReadIsForwardedToWrapped() throws IOException {
- InputStream stream = new ByteArrayInputStream(new byte[]{1, 2, 3, 4});
- InputStreamFactory closer = new InputStreamFactory(stream);
- for (int i = 0; i < 100; i++) {
- InputStream is = closer.createInputStream();
- assertThat(is.read(), equalTo(1));
- assertThat(is.read(), equalTo(2));
- assertThat(is.read(), equalTo(3));
- assertThat(is.read(), equalTo(4));
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/formats/src/test/resources/Test.ini
----------------------------------------------------------------------
diff --git a/modules/formats/src/test/resources/Test.ini b/modules/formats/src/test/resources/Test.ini
deleted file mode 100644
index 906a1e6..0000000
--- a/modules/formats/src/test/resources/Test.ini
+++ /dev/null
@@ -1,26 +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.
-#
-
-aGeneralEntry=blabla
-
-[MySection1]
-sectionEntry1=value1
-
-[MySection2]
-sectionEntry2=value2
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/formats/src/test/resources/Test.properties
----------------------------------------------------------------------
diff --git a/modules/formats/src/test/resources/Test.properties b/modules/formats/src/test/resources/Test.properties
deleted file mode 100644
index ced544b..0000000
--- a/modules/formats/src/test/resources/Test.properties
+++ /dev/null
@@ -1,21 +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.
-#
-aGeneralEntry=blabla
-MySection1.sectionEntry1=value1
-MySection2.sectionEntry2=value2
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/functions/pom.xml
----------------------------------------------------------------------
diff --git a/modules/functions/pom.xml b/modules/functions/pom.xml
deleted file mode 100644
index 88d95e4..0000000
--- a/modules/functions/pom.xml
+++ /dev/null
@@ -1,79 +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.
--->
-<project xmlns="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">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-extensions</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
-
- <artifactId>tamaya-functions</artifactId>
- <name>Apache Tamaya Modules - Common Functional Extensions</name>
- <packaging>bundle</packaging>
-
- <properties>
- <jdkVersion>1.7</jdkVersion>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <!-- Test scope only, do not create a code dependency! -->
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-core</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>java-hamcrest</artifactId>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.tamaya.functions
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/functions/src/main/java/org/apache/tamaya/functions/CombinedConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/CombinedConfiguration.java b/modules/functions/src/main/java/org/apache/tamaya/functions/CombinedConfiguration.java
deleted file mode 100644
index 8a479e9..0000000
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/CombinedConfiguration.java
+++ /dev/null
@@ -1,146 +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.functions;
-
-import org.apache.tamaya.ConfigOperator;
-import org.apache.tamaya.ConfigQuery;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.spi.ConfigurationContext;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Combines a set of child configurations to a new one, by overriding the first entries with result from
- * later instances.
- */
-class CombinedConfiguration implements Configuration{
- /** The name of the new configuration. */
- private final String name;
- /** The configuration's in evaluation order. Instances with higher indices override results with lower ones. */
- private final Configuration[] configurations;
-
- /**
- * Creates a combined configuration instance.
- * @param configName the name of the new config.
- * @param configs the configurations hereby instances with higher indices override results with lower ones.
- */
- public CombinedConfiguration(String configName, Configuration... configs){
- this.name = configName;
- this.configurations =configs.clone();
- }
-
- @Override
- public String get(String key) {
- String curValue = null;
- for(Configuration config: configurations){
- String value = config.get(key);
- if(value!=null){
- curValue = value;
- }
- }
- return curValue;
- }
-
- @Override
- public String getOrDefault(String key, String defaultValue) {
- String val = get(key);
- if(val==null){
- return defaultValue;
- }
- return val;
- }
-
- @Override
- public <T> T getOrDefault(String key, Class<T> type, T defaultValue) {
- T val = get(key, type);
- if(val==null){
- return defaultValue;
- }
- return val;
- }
-
- @Override
- public <T> T get(String key, Class<T> type) {
- T curValue = null;
- for(Configuration config: configurations){
- T value = config.get(key, type);
- if(value!=null){
- curValue = value;
- }
- }
- return curValue;
- }
-
- @Override
- public <T> T get(String key, TypeLiteral<T> type) {
- T curValue = null;
- for(Configuration config: configurations){
- T value = config.get(key, type);
- if(value!=null){
- curValue = value;
- }
- }
- return curValue;
- }
-
- @Override
- public <T> T getOrDefault(String key, TypeLiteral<T> type, T defaultValue) {
- T val = get(key, type);
- if(val==null){
- return defaultValue;
- }
- return val;
- }
-
- @Override
- public Map<String, String> getProperties() {
- Map<String, String> result = new HashMap<>();
- for(Configuration ps:configurations){
- result.putAll(ps.getProperties());
- }
- return result;
- }
-
- @Override
- public Configuration with(ConfigOperator operator) {
- return operator.operate(this);
- }
-
- @Override
- public <T> T query(ConfigQuery<T> query) {
- return query.query(this);
- }
-
- @Override
- public ConfigurationContext getContext() {
- // TODO thjink on combining the participating contexts...
- return configurations[0].getContext();
- }
-
- @Override
- public String toString() {
- return "CombinedConfiguration{" +
- "name='" + name + '\'' +
- ", configurations=" + Arrays.toString(configurations) +
- '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/functions/src/main/java/org/apache/tamaya/functions/ConfigWrappingPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/ConfigWrappingPropertySource.java b/modules/functions/src/main/java/org/apache/tamaya/functions/ConfigWrappingPropertySource.java
deleted file mode 100644
index 83a628a..0000000
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/ConfigWrappingPropertySource.java
+++ /dev/null
@@ -1,80 +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.functions;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-
-import java.util.Map;
-import java.util.Objects;
-
-/**
- * PropertySource that wraps a Configuration instance.
- */
-final class ConfigWrappingPropertySource implements PropertySource {
- /** The property source name. */
- private final String name;
- /** The ordinal. */
- private final int ordinal;
- /** The wrapped config. */
- private final Configuration config;
-
- /**
- * Constructor.
- * @param name the property source name, not null.
- * @param ordinal ths ordinal
- * @param config the wrapped config, not null.
- */
- public ConfigWrappingPropertySource(String name, int ordinal, Configuration config){
- this.name = Objects.requireNonNull(name);
- this.ordinal = ordinal;
- this.config = Objects.requireNonNull(config);
- }
-
- @Override
- public int getOrdinal() {
- return ordinal;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public PropertyValue get(String key) {
- return PropertyValue.of(key, config.get(key), getName());
- }
-
- @Override
- public Map<String, String> getProperties() {
- return config.getProperties();
- }
-
- @Override
- public boolean isScannable() {
- return true;
- }
-
- @Override
- public String toString(){
- return "ConfigWrappingPropertySource(name="+name+", ordinal="+ordinal+", config="+config+")";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/functions/src/main/java/org/apache/tamaya/functions/ConfigurationFunctions.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/ConfigurationFunctions.java b/modules/functions/src/main/java/org/apache/tamaya/functions/ConfigurationFunctions.java
deleted file mode 100644
index 6dd0427..0000000
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/ConfigurationFunctions.java
+++ /dev/null
@@ -1,662 +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.functions;
-
-import org.apache.tamaya.ConfigOperator;
-import org.apache.tamaya.ConfigQuery;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.spi.ConfigurationContext;
-import org.apache.tamaya.spi.ConfigurationContextBuilder;
-import org.apache.tamaya.spi.PropertyConverter;
-import org.apache.tamaya.spi.PropertyFilter;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValueCombinationPolicy;
-
-import java.net.Inet4Address;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.TreeSet;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Accessor that provides useful functions along with configuration.
- */
-public final class ConfigurationFunctions {
-
- /**
- * The Logger used.
- */
- private static final Logger LOG = Logger.getLogger(ConfigurationFunctions.class.getName());
-
- /**
- * Implementation of an empty propertySource.
- */
- private static final Configuration EMPTY_CONFIGURATION = new Configuration() {
-
- @Override
- public String get(String key) {
- return null;
- }
-
- @Override
- public String getOrDefault(String key, String defaultValue) {
- return defaultValue;
- }
-
- @Override
- public <T> T getOrDefault(String key, Class<T> type, T defaultValue) {
- return defaultValue;
- }
-
- @Override
- public <T> T get(String key, Class<T> type) {
- return null;
- }
-
- @Override
- public <T> T get(String key, TypeLiteral<T> type) {
- return null;
- }
-
- @Override
- public <T> T getOrDefault(String key, TypeLiteral<T> type, T defaultValue) {
- return defaultValue;
- }
-
- @Override
- public Map<String, String> getProperties() {
- return Collections.emptyMap();
- }
-
- @Override
- public Configuration with(ConfigOperator operator) {
- return operator.operate(this);
- }
-
- @Override
- public <T> T query(ConfigQuery<T> query) {
- return query.query(this);
- }
-
- @Override
- public ConfigurationContext getContext() {
- return EMPTY_CONFIGURATION_CONTEXT;
- }
-
- @Override
- public String toString(){
- return "Configuration<empty>";
- }
- };
-
- private static final ConfigurationContext EMPTY_CONFIGURATION_CONTEXT = new ConfigurationContext() {
- @Override
- public void addPropertySources(PropertySource... propertySourcesToAdd) {
- // ignore
- }
-
- @Override
- public List<PropertySource> getPropertySources() {
- return Collections.emptyList();
- }
-
- @Override
- public <T> void addPropertyConverter(TypeLiteral<T> typeToConvert, PropertyConverter<T> propertyConverter) {
- // ignore
- }
-
- @Override
- public Map<TypeLiteral<?>, List<PropertyConverter<?>>> getPropertyConverters() {
- return Collections.emptyMap();
- }
-
- @Override
- public <T> List<PropertyConverter<T>> getPropertyConverters(TypeLiteral<T> type) {
- return Collections.emptyList();
- }
-
- @Override
- public List<PropertyFilter> getPropertyFilters() {
- return Collections.emptyList();
- }
-
- @Override
- public PropertyValueCombinationPolicy getPropertyValueCombinationPolicy() {
- return PropertyValueCombinationPolicy.DEFAULT_OVERRIDING_COLLECTOR;
- }
-
- @Override
- public ConfigurationContextBuilder toBuilder() {
- throw new UnsupportedOperationException("Cannot build from ConfigurationContext.EMPTY.");
- }
-
- @Override
- public String toString(){
- return "ConfigurationContext.EMPTY";
- }
- };
-
- /**
- * Private singleton constructor.
- */
- private ConfigurationFunctions() {
- }
-
- /**
- * Creates a ConfigOperator that creates a Configuration containing only keys
- * that are selected by the given {@link PropertyMatcher}.
- *
- * @param filter the filter, not null
- * @return the section configuration, with the areaKey stripped away.
- */
- public static ConfigOperator filter(final PropertyMatcher filter) {
- return new ConfigOperator() {
- @Override
- public Configuration operate(Configuration config) {
- return new FilteredConfiguration(config, filter, "FilterClass: " + filter.getClass().getName());
- }
- };
- }
-
- /**
- * Creates a ConfigOperator that creates a Configuration with keys mapped as
- * defined by the given keyMapper.
- *
- * @param keyMapper the keyMapper, not null
- * @return the section configuration, with the areaKey stripped away.
- */
- public static ConfigOperator map(final KeyMapper keyMapper) {
- return new ConfigOperator() {
- @Override
- public Configuration operate(Configuration config) {
- return new MappedConfiguration(config, keyMapper, null);
- }
- };
- }
-
- /**
- * Creates a ConfigOperator that creates a Configuration containing only keys
- * that are contained in the given section (non recursive). Hereby
- * the section key is stripped away fromMap the resulting key.
- *
- * @param areaKey the section key, not null
- * @return the section configuration, with the areaKey stripped away.
- */
- public static ConfigOperator section(String areaKey) {
- return section(areaKey, false);
- }
-
- /**
- * Creates a ConfigOperator that creates a Configuration containing only keys
- * that are contained in the given section (non recursive).
- *
- * @param areaKey the section key, not null
- * @param stripKeys if set to true, the section key is stripped away fromMap the resulting key.
- * @return the section configuration, with the areaKey stripped away.
- */
- public static ConfigOperator section(final String areaKey, final boolean stripKeys) {
- return new ConfigOperator() {
- @Override
- public Configuration operate(Configuration config) {
- Configuration filtered = new FilteredConfiguration(config,
- new PropertyMatcher() {
- @Override
- public boolean test(String k, String v) {
- return isKeyInSection(k, areaKey);
- }
- }, "section: " + areaKey);
- if (stripKeys) {
- return new MappedConfiguration(filtered, new KeyMapper(){
- @Override
- public String mapKey(String key) {
- if(key.startsWith(areaKey)) {
- return key.substring(areaKey.length());
- }
- return null;
- }
- }, "stripped");
- }
- return filtered;
- }
- };
- }
-
- /**
- * Calculates the current section key and compares it with the given key.
- *
- * @param key the fully qualified entry key, not null
- * @param sectionKey the section key, not null
- * @return true, if the entry is exact in this section
- */
- public static boolean isKeyInSection(String key, String sectionKey) {
- return key.startsWith(sectionKey);
- }
-
- /**
- * Calculates the current section key and compares it with the given section keys.
- *
- * @param key the fully qualified entry key, not null
- * @param sectionKeys the section keys, not null
- * @return true, if the entry is exact in this section
- */
- public static boolean isKeyInSections(String key, String... sectionKeys) {
- for (String areaKey : sectionKeys) {
- if (isKeyInSection(key, areaKey)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Return a query to evaluate the set with all fully qualifies section names. This method should return the sections as accurate as possible,
- * but may not provide a complete set of sections that are finally accessible, especially when the underlying storage
- * does not support key iteration.
- *
- * @return s set with all sections, never {@code null}.
- */
- public static ConfigQuery<Set<String>> sections() {
- return new ConfigQuery<Set<String>>() {
- @Override
- public Set<String> query(Configuration config) {
- final Set<String> areas = new TreeSet<>();
- for (String s : config.getProperties().keySet()) {
- int index = s.lastIndexOf('.');
- if (index > 0) {
- areas.add(s.substring(0, index));
- }
- }
- return areas;
- }
- };
- }
-
- /**
- * Return a query to evaluate the set with all fully qualified section names, containing the transitive closure also including all
- * subarea names, regardless if properties are accessible or not. This method should return the sections as accurate
- * as possible, but may not provide a complete set of sections that are finally accessible, especially when the
- * underlying storage does not support key iteration.
- *
- * @return s set with all transitive sections, never {@code null}.
- */
- public static ConfigQuery<Set<String>> transitiveSections() {
- return new ConfigQuery<Set<String>>() {
- @Override
- public Set<String> query(Configuration config) {
- final Set<String> transitiveAreas = new TreeSet<>();
- for (String s : config.query(sections())) {
- transitiveAreas.add(s);
- int index = s.lastIndexOf('.');
- while (index > 0) {
- s = s.substring(0, index);
- transitiveAreas.add(s);
- index = s.lastIndexOf('.');
- }
- }
- return transitiveAreas;
- }
- };
- }
-
- /**
- * Return a query to evaluate the set with all fully qualified section names, containing only the
- * sections that match the predicate and have properties attached. This method should return the sections as accurate as possible,
- * but may not provide a complete set of sections that are finally accessible, especially when the underlying storage
- * does not support key iteration.
- *
- * @param predicate A predicate to deternine, which sections should be returned, not {@code null}.
- * @return s set with all sections, never {@code null}.
- */
- public static ConfigQuery<Set<String>> sections(final Predicate<String> predicate) {
- return new ConfigQuery<Set<String>>() {
- @Override
- public Set<String> query(Configuration config) {
- Set<String> result = new TreeSet<>();
- for (String s : sections().query(config)) {
- if (predicate.test(s)) {
- result.add(s);
- }
- }
- return result;
- }
- };
-
- }
-
- /**
- * Return a query to evaluate the set with all fully qualified section names, containing the transitive closure also including all
- * subarea names, regardless if properties are accessible or not. This method should return the sections as accurate as possible,
- * but may not provide a complete set of sections that are finally accessible, especially when the underlying storage
- * does not support key iteration.
- *
- * @param predicate A predicate to deternine, which sections should be returned, not {@code null}.
- * @return s set with all transitive sections, never {@code null}.
- */
- public static ConfigQuery<Set<String>> transitiveSections(final Predicate<String> predicate) {
- return new ConfigQuery<Set<String>>() {
- @Override
- public Set<String> query(Configuration config) {
- Set<String> result = new TreeSet<>();
- for (String s : transitiveSections().query(config)) {
- if (predicate.test(s)) {
- result.add(s);
- }
- }
- return result;
- }
- };
- }
-
- /**
- * Creates a ConfigOperator that creates a Configuration containing only keys
- * that are contained in the given section (recursive).
- *
- * @param sectionKeys the section keys, not null
- * @return the section configuration, with the areaKey stripped away.
- */
- public static ConfigOperator sectionsRecursive(String... sectionKeys) {
- return sectionRecursive(false, sectionKeys);
- }
-
- /**
- * Creates a Configuration that creates a new instance using the configuration instances provided. Hereby
- * values from higher instances override previous values..
- *
- * @param configName the new config name
- * @param configs the configs to be combined. The entries of the first config are overwritten
- * by entries of the later instances.
- * @return the resulting configuration instance.
- */
- public static Configuration combine(String configName, Configuration... configs) {
- return new CombinedConfiguration(configName, configs);
- }
-
- /**
- * Creates a {@link PropertySource}, based on the given {@link Configuration}. The keys and propertx map
- * are dynamically calculated, so the returned PropertySource is a real dynamic wrapper.
- * @param name the name of the property source, not null.
- * @param ordinal ordinal of the property source.
- * @param config the config to be mapped, not null.
- * @return a property source wrapping the configuration.
- */
- public static PropertySource propertySourceFrom(final String name, final int ordinal, final Configuration config){
- return new ConfigWrappingPropertySource(name, ordinal, config);
- }
-
- /**
- * Creates a ConfigOperator that creates a Configuration containing only keys
- * that are contained in the given section (recursive).
- *
- * @param sectionKeys the section keys, not null
- * @param stripKeys if set to true, the section key is stripped away fromMap the resulting key.
- * @return the section configuration, with the areaKey stripped away.
- */
- public static ConfigOperator sectionRecursive(final boolean stripKeys, final String... sectionKeys) {
- return new ConfigOperator() {
- @Override
- public Configuration operate(Configuration config) {
- Configuration filtered = new FilteredConfiguration(config, new PropertyMatcher() {
- @Override
- public boolean test(final String k, String v) {
- return isKeyInSections(k, sectionKeys);
- }
- }, "sections: " + Arrays.toString(sectionKeys));
- if (stripKeys) {
- return new MappedConfiguration(filtered, new KeyMapper() {
- @Override
- public String mapKey(String key) {
- return PropertySourceFunctions.stripSectionKeys(key, sectionKeys);
- }
- }, "stripped");
- }
- return filtered;
- }
- };
- }
-
- /**
- * Creates a ConfigQuery that creates a JSON formatted ouitput of all properties in the given configuration.
- *
- * @return the given query.
- */
- public static ConfigQuery<String> jsonInfo() {
- return jsonInfo(null);
- }
-
- /**
- * Creates a ConfigQuery that creates a JSON formatted ouitput of all properties in the given configuration.
- *
- * @param info the additional information attributes to be added to the output, e.g. the original request
- * parameters.
- * @return the given query.
- */
- public static ConfigQuery<String> jsonInfo(final Map<String, String> info) {
- return new ConfigQuery<String>() {
- @Override
- public String query(Configuration config) {
- Map<String, String> props = new TreeMap<>(config.getProperties());
- props.put("__timestamp", String.valueOf(System.currentTimeMillis()));
- if(info!=null) {
- for (Map.Entry<String, String> en : info.entrySet()) {
- props.put("__" + escape(en.getKey()), escape(en.getValue()));
- }
- }
- StringBuilder builder = new StringBuilder(400).append("{\n");
- for (Map.Entry<String, String> en : props.entrySet()) {
- builder.append(" \"").append(escape(en.getKey())).append("\": \"" )
- .append(escape(en.getValue())).append("\",\n");
- }
- if(builder.toString().endsWith(",\n")){
- builder.setLength(builder.length()-2);
- builder.append('\n');
- }
- builder.append("}\n");
- return builder.toString();
- }
- };
- }
-
- /**
- * Creates a ConfigQuery that creates a XML formatted ouitput of all properties in the given configuration.
- *
- * @return the given query.
- */
- public static ConfigQuery<String> xmlInfo() {
- return xmlInfo(null);
- }
-
- /**
- * Creates a ConfigQuery that creates a XML formatted ouitput of all properties in the given configuration.
- *
- * @param info the additional information attributes to be added to the output, e.g. the original request
- * parameters.
- * @return the given query.
- */
- public static ConfigQuery<String> xmlInfo(final Map<String, String> info) {
- return new ConfigQuery<String>() {
- @Override
- public String query(Configuration config) {
- Map<String, String> props = new TreeMap<>(config.getProperties());
- props.put("__timestamp", String.valueOf(System.currentTimeMillis()));
- if(info!=null) {
- for (Map.Entry<String, String> en : info.entrySet()) {
- props.put("__" + escape(en.getKey()), escape(en.getValue()));
- }
- }
- StringBuilder builder = new StringBuilder(400);
- builder.append("<configuration>\n");
- for (Map.Entry<String, String> en : props.entrySet()) {
- builder.append(" <entry key=\"" + escape(en.getKey()) + "\">" + escape(en.getValue()) + "</entry>\n");
- }
- builder.append("</configuration>\n");
- return builder.toString();
- }
- };
- }
-
- /**
- * Creates a ConfigQuery that creates a plain text formatted output of all properties in the given configuration.
- *
- * @return the given query.
- */
- public static ConfigQuery<String> textInfo() {
- return textInfo(null);
- }
-
- /**
- * Creates a ConfigQuery that creates a plain text formatted output of all properties in the given configuration.
- * @param info configuration values to use for filtering.
- * @return the given query.
- */
- public static ConfigQuery<String> textInfo(final Map<String, String> info) {
- return new ConfigQuery<String>() {
- @Override
- public String query(Configuration config) {
- Map<String, String> props = new TreeMap<>(config.getProperties());
- props.put("__timestamp", String.valueOf(System.currentTimeMillis()));
- if(info!=null) {
- for (Map.Entry<String, String> en : info.entrySet()) {
- props.put("__" + escape(en.getKey()), escape(en.getValue()));
- }
- }
- StringBuilder builder = new StringBuilder(400).append("Configuration:\n");
- for (Map.Entry<String, String> en : props.entrySet()) {
- builder.append(" " + escape(en.getKey()) + ": " + escape(en.getValue()).replace("\n", "\n ") + ",\n");
- }
- if(builder.toString().endsWith(",\n")){
- builder.setLength(builder.length() - 2);
- }
- builder.append("\n");
- return builder.toString();
- }
- };
- }
-
- /**
- * Creates a ConfigOperator that adds the given items.
- * @param items the items to be added/replaced.
- * @param override if true, all items existing are overridden by the new ones passed.
- * @return the ConfigOperator, never null.
- */
- public static ConfigOperator addItems(final Map<String,Object> items, final boolean override){
- return new ConfigOperator() {
- @Override
- public Configuration operate(Configuration config) {
- return new EnrichedConfiguration(config,items, override);
- }
- };
- }
-
- /**
- * Creates an operator that adds items to the instance.
- * @param items the items, not null.
- * @return the operator, never null.
- */
- public static ConfigOperator addItems(Map<String,Object> items){
- return addItems(items, false);
- }
-
- /**
- * Creates an operator that replaces the given items.
- * @param items the items.
- * @return the operator for replacing the items.
- */
- public static ConfigOperator replaceItems(Map<String,Object> items){
- return addItems(items, true);
- }
-
- /**
- * Creates a ConfigQuery that creates a html formatted ouitput of all properties in the given configuration.
- *
- * @return the given query.
- */
- public static ConfigQuery<String> htmlInfo() {
- return htmlInfo(null);
- }
-
- /**
- * Creates a ConfigQuery that creates a html formatted ouitput of all properties in the given configuration.
- * @param info configuration values to use for filtering.
- * @return the given query.
- */
- public static ConfigQuery<String> htmlInfo(final Map<String, String> info) {
- return new ConfigQuery<String>() {
- @Override
- public String query(Configuration config) {
- StringBuilder builder = new StringBuilder();
- addHeader(builder);
- builder.append("<pre>\n").append(textInfo(info).query(config)).append("</pre>\n");
- addFooter(builder);
- return builder.toString();
- }
- };
- }
-
- private static void addFooter(StringBuilder b) {
- b.append("</body>\n</html>\n");
- }
-
- private static void addHeader(StringBuilder b) {
- String host = "unknown";
- try {
- host = Inet4Address.getLocalHost().getHostName();
- } catch (Exception e) {
- LOG.log(Level.INFO, "Failed to lookup hostname.", e);
- }
- b.append("<html>\n<head><title>System Configuration</title></head>\n" +
- "<body>\n" +
- "<h1>System Configuration</h1>\n" +
- "<p>This view shows the system configuration of " + host + " at " + new Date() + ".</p>");
-
- }
-
- /**
- * Replaces new lines, returns, tabs and '"' with escaped variants.
- *
- * @param text the input text, not null
- * @return the escaped text.
- */
- private static String escape(String text) {
- return text.replace("\t", "\\t").replace("\"", "\\\"");
- }
-
- /**
- * Accesses an empty {@link Configuration}.
- * @return an empty {@link Configuration}, never null.
- */
- public static Configuration emptyConfiguration(){
- return EMPTY_CONFIGURATION;
- }
-
- /**
- * Accesses an empty {@link ConfigurationContext}.
- * @return an empty {@link ConfigurationContext}, never null.
- */
- public static ConfigurationContext emptyConfigurationContext(){
- return EMPTY_CONFIGURATION_CONTEXT;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/functions/src/main/java/org/apache/tamaya/functions/EnrichedConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/EnrichedConfiguration.java b/modules/functions/src/main/java/org/apache/tamaya/functions/EnrichedConfiguration.java
deleted file mode 100644
index 7969563..0000000
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/EnrichedConfiguration.java
+++ /dev/null
@@ -1,159 +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.functions;
-
-import org.apache.tamaya.ConfigOperator;
-import org.apache.tamaya.ConfigQuery;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.spi.ConfigurationContext;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-
-/**
- * Configuration, that has values added or overridden.
- */
-class EnrichedConfiguration implements Configuration {
-
- private final Configuration baseConfiguration;
-
- private final Map<String, Object> addedProperties = new HashMap<>();
-
- private final boolean overriding;
-
- /**
- * Constructor.
- *
- * @param configuration the base config, not null.
- * @param properties the properties to be added, not null.
- * @param overriding true, if existing keys should be overriden, or config should be extended only.
- */
- EnrichedConfiguration(Configuration configuration, Map<String, Object> properties, boolean overriding) {
- this.baseConfiguration = Objects.requireNonNull(configuration);
- this.addedProperties.putAll(addedProperties);
- this.overriding = overriding;
- }
-
- @Override
- public String get(String key) {
- if (overriding) {
- Object val = addedProperties.get(key);
- if (val != null) {
- return val.toString();
- }
- return baseConfiguration.get(key);
- }
- String val = baseConfiguration.get(key);
- if (val != null) {
- return val;
- }
- Object val2 = addedProperties.get(key);
- if (val2 != null) {
- return val2.toString();
- }
- return null;
- }
-
- @Override
- public String getOrDefault(String key, String defaultValue) {
- String val = get(key);
- if (val == null) {
- return defaultValue;
- }
- return val;
- }
-
- @Override
- public <T> T getOrDefault(String key, Class<T> type, T defaultValue) {
- T val = get(key, type);
- if (val == null) {
- return defaultValue;
- }
- return val;
- }
-
- @Override
- public <T> T get(String key, Class<T> type) {
- return (T) get(key, TypeLiteral.of(type));
- }
-
- @Override
- public <T> T get(String key, TypeLiteral<T> type) {
- if (overriding) {
- Object val = addedProperties.get(key);
- if (val != null && type.getRawType().isAssignableFrom(val.getClass())) {
- return (T) val;
- }
- return baseConfiguration.get(key, type);
- }
- T val = baseConfiguration.get(key, type);
- if (val != null) {
- return val;
- }
- Object val2 = addedProperties.get(key);
- if (val2 != null && type.getRawType().isAssignableFrom(val2.getClass())) {
- return (T) val2;
- }
- return null;
- }
-
- @Override
- public <T> T getOrDefault(String key, TypeLiteral<T> type, T defaultValue) {
- T val = get(key, type);
- if (val == null) {
- return defaultValue;
- }
- return val;
- }
-
- @Override
- public Map<String, String> getProperties() {
- Map<String, String> allProps = new HashMap<>();
- if (overriding) {
- allProps.putAll(baseConfiguration.getProperties());
- for (Map.Entry<String, Object> en : addedProperties.entrySet()) {
- allProps.put(en.getKey(), en.getValue().toString());
- }
- } else {
- for (Map.Entry<String, Object> en : addedProperties.entrySet()) {
- allProps.put(en.getKey(), en.getValue().toString());
- }
- allProps.putAll(baseConfiguration.getProperties());
- }
- return allProps;
- }
-
- @Override
- public Configuration with(ConfigOperator operator) {
- return operator.operate(this);
- }
-
- @Override
- public <T> T query(ConfigQuery<T> query) {
- return query.query(this);
- }
-
- @Override
- public ConfigurationContext getContext() {
- return baseConfiguration.getContext();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/functions/src/main/java/org/apache/tamaya/functions/EnrichedPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/EnrichedPropertySource.java b/modules/functions/src/main/java/org/apache/tamaya/functions/EnrichedPropertySource.java
deleted file mode 100644
index de48fa8..0000000
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/EnrichedPropertySource.java
+++ /dev/null
@@ -1,97 +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.functions;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-
-/**
- * PropertySource, that has values added or overridden.
- */
-class EnrichedPropertySource implements PropertySource {
-
- private final PropertySource basePropertySource;
-
- private final Map<String, String> addedProperties;
-
- private final boolean overriding;
-
- /**
- * Constructor.
- *
- * @param propertySource the base property source, not null.
- * @param properties the properties to be added.
- * @param overriding flag if existing properties are overridden.
- */
- EnrichedPropertySource(PropertySource propertySource, Map<String, String> properties, boolean overriding) {
- this.basePropertySource = Objects.requireNonNull(propertySource);
- this.addedProperties = Objects.requireNonNull(properties);
- this.overriding = overriding;
- }
-
-
- @Override
- public int getOrdinal() {
- return basePropertySource.getOrdinal();
- }
-
- @Override
- public String getName() {
- return basePropertySource.getName();
- }
-
- @Override
- public PropertyValue get(String key) {
- if (overriding) {
- String val = addedProperties.get(key);
- if (val != null) {
- return PropertyValue.of(key, val, getName());
- }
- return basePropertySource.get(key);
- }
- PropertyValue val = basePropertySource.get(key);
- if (val != null) {
- return val;
- }
- return PropertyValue.of(key, addedProperties.get(key), getName());
-
- }
-
- @Override
- public Map<String, String> getProperties() {
- Map<String, String> allProps;
- if (overriding) {
- allProps = new HashMap<>(basePropertySource.getProperties());
- allProps.putAll(addedProperties);
- } else {
- allProps = new HashMap<>(addedProperties);
- allProps.putAll(basePropertySource.getProperties());
- }
- return allProps;
- }
-
- @Override
- public boolean isScannable() {
- return basePropertySource.isScannable();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/functions/src/main/java/org/apache/tamaya/functions/FilteredConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/FilteredConfiguration.java b/modules/functions/src/main/java/org/apache/tamaya/functions/FilteredConfiguration.java
deleted file mode 100644
index e8acaaa..0000000
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/FilteredConfiguration.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.functions;
-
-import org.apache.tamaya.ConfigOperator;
-import org.apache.tamaya.ConfigQuery;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.spi.ConfigurationContext;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-
-/**
- * Configuration that filters part of the entries defined by a matcher predicate.
- */
-class FilteredConfiguration implements Configuration {
-
- private final Configuration baseConfiguration;
- private final PropertyMatcher matcher;
- private final String filterType;
-
- FilteredConfiguration(Configuration baseConfiguration, PropertyMatcher matcher, String filterType) {
- this.baseConfiguration = Objects.requireNonNull(baseConfiguration);
- this.matcher = Objects.requireNonNull(matcher);
- this.filterType = filterType!=null?filterType:this.matcher.toString();
- }
-
- @Override
- public String get(String key) {
- return get(key, String.class);
- }
-
- @Override
- public String getOrDefault(String key, String defaultValue) {
- String val = get(key);
- if(val==null){
- return defaultValue;
- }
- return val;
- }
-
- @Override
- public <T> T getOrDefault(String key, Class<T> type, T defaultValue) {
- T val = get(key, type);
- if(val==null){
- return defaultValue;
- }
- return val;
- }
-
- @Override
- public <T> T get(String key, Class<T> type) {
- return (T)get(key, TypeLiteral.of(type));
- }
-
- @Override
- public <T> T get(String key, TypeLiteral<T> type) {
- String value = baseConfiguration.get(key);
- if (matcher.test(key, value)) {
- return baseConfiguration.get(key, type);
- }
- return null;
- }
-
- @Override
- public <T> T getOrDefault(String key, TypeLiteral<T> type, T defaultValue) {
- T val = get(key, type);
- if(val==null){
- return defaultValue;
- }
- return val;
- }
-
- @Override
- public Map<String, String> getProperties() {
- Map<String, String> result = new HashMap<>();
- for(Map.Entry<String,String> en:baseConfiguration.getProperties().entrySet()){
- if(matcher.test(en.getKey(), en.getValue())){
- result.put(en.getKey(), en.getValue());
- }
- }
- return result;
- }
-
- @Override
- public Configuration with(ConfigOperator operator) {
- return null;
- }
-
- @Override
- public <T> T query(ConfigQuery<T> query) {
- return query.query(this);
- }
-
- @Override
- public ConfigurationContext getContext() {
- return baseConfiguration.getContext();
- }
-
- @Override
- public String toString() {
- return "FilteredConfiguration{" +
- "baseConfiguration=" + baseConfiguration +
- ", matcher=" + filterType +
- '}';
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/functions/src/main/java/org/apache/tamaya/functions/FilteredPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/FilteredPropertySource.java b/modules/functions/src/main/java/org/apache/tamaya/functions/FilteredPropertySource.java
deleted file mode 100644
index 7eccdee..0000000
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/FilteredPropertySource.java
+++ /dev/null
@@ -1,84 +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.functions;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-
-/**
- * PropertySource that on the fly filters out part of the key/values of the underlying PropertySource.
- */
-class FilteredPropertySource implements PropertySource {
-
- private final PropertySource baseSource;
- private final Predicate<String> filter;
-
- /**
- * Creates a new instance
- * @param baseSource the underlying PropertySource
- * @param filter the filter to be applied.
- */
- public FilteredPropertySource(PropertySource baseSource, Predicate<String> filter){
- this.baseSource = Objects.requireNonNull(baseSource);
- this.filter = Objects.requireNonNull(filter);
- }
-
- @Override
- public int getOrdinal(){
- return baseSource.getOrdinal();
- }
-
- @Override
- public String getName() {
- return baseSource.getName();
- }
-
- @Override
- public PropertyValue get(String key) {
- return PropertyValue.of(key, getProperties().get(key), getName());
- }
-
- @Override
- public Map<String,String> getProperties(){
- final Map<String,String> result = new HashMap<>();
- for(Map.Entry<String,String> en: this.baseSource.getProperties().entrySet()) {
- if (filter.test(en.getKey())) {
- result.put(en.getKey(), en.getValue());
- }
- }
- return result;
- }
-
- @Override
- public boolean isScannable() {
- return baseSource.isScannable();
- }
-
- @Override
- public String toString() {
- return "FilteredPropertySource{" +
- "baseSource=" + baseSource +
- ", filter=" + filter +
- '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/functions/src/main/java/org/apache/tamaya/functions/KeyMapper.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/KeyMapper.java b/modules/functions/src/main/java/org/apache/tamaya/functions/KeyMapper.java
deleted file mode 100644
index 2666c1b..0000000
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/KeyMapper.java
+++ /dev/null
@@ -1,37 +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.functions;
-
-/**
- * Represents a function that maps a key of a property entry to another key (or removes it
- * if mapped to null).
- *
- */
-//@FunctionalInterface
-public interface KeyMapper {
-
- /**
- * Maps a property key to another key.
- * @param key the fproperty key, not null
- * @return the new key, returning null, removes the entry.
- */
- String mapKey(String key);
-
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/functions/src/main/java/org/apache/tamaya/functions/MappedConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/MappedConfiguration.java b/modules/functions/src/main/java/org/apache/tamaya/functions/MappedConfiguration.java
deleted file mode 100644
index b93b9ca..0000000
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/MappedConfiguration.java
+++ /dev/null
@@ -1,132 +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.functions;
-
-import org.apache.tamaya.ConfigOperator;
-import org.apache.tamaya.ConfigQuery;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.spi.ConfigurationContext;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-import java.util.logging.Logger;
-
-
-/**
- * Configuration that filters part of the entries defined by a filter predicate.
- */
-class MappedConfiguration implements Configuration {
-
- private static final Logger LOG = Logger.getLogger(MappedConfiguration.class.getName());
- private final Configuration baseConfiguration;
- private final KeyMapper keyMapper;
- private final String mapType;
-
- MappedConfiguration(Configuration baseConfiguration, KeyMapper keyMapper, String mapType) {
- this.baseConfiguration = Objects.requireNonNull(baseConfiguration);
- this.keyMapper = Objects.requireNonNull(keyMapper);
- this.mapType = mapType!=null?mapType:this.keyMapper.toString();
- }
-
- @Override
- public String get(String key) {
- return get(key, String.class);
- }
-
- @Override
- public String getOrDefault(String key, String defaultValue) {
- String val = get(key);
- if(val==null){
- return defaultValue;
- }
- return val;
- }
-
- @Override
- public <T> T getOrDefault(String key, Class<T> type, T defaultValue) {
- T val = get(key, type);
- if(val==null){
- return defaultValue;
- }
- return val;
- }
-
- @Override
- public <T> T get(String key, Class<T> type) {
- return (T)get(key, TypeLiteral.of(type));
- }
-
- @Override
- public <T> T get(String key, TypeLiteral<T> type) {
- String targetKey = keyMapper.mapKey(key);
- if (targetKey != null) {
- return baseConfiguration.get(targetKey, type);
- }
- LOG.finest("Configuration property hidden by KeyMapper, key="+key+", mapper="+keyMapper+", config="+this);
- return null;
- }
-
- @Override
- public <T> T getOrDefault(String key, TypeLiteral<T> type, T defaultValue) {
- T val = get(key, type);
- if(val==null){
- return defaultValue;
- }
- return val;
- }
-
- @Override
- public Map<String, String> getProperties() {
- Map<String, String> baseProps = baseConfiguration.getProperties();
- Map<String, String> props = new HashMap<>(baseProps.size());
- for(Map.Entry<String,String> en:baseProps.entrySet()){
- String targetKey = keyMapper.mapKey(en.getKey());
- if (targetKey != null) {
- props.put(targetKey, en.getValue());
- }
- }
- return props;
- }
-
- @Override
- public Configuration with(ConfigOperator operator) {
- return operator.operate(this);
- }
-
- @Override
- public <T> T query(ConfigQuery<T> query) {
- return query.query(this);
- }
-
- @Override
- public ConfigurationContext getContext() {
- return baseConfiguration.getContext();
- }
-
- @Override
- public String toString() {
- return "FilteredConfiguration{" +
- "baseConfiguration=" + baseConfiguration +
- ", mapping=" + mapType +
- '}';
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/functions/src/main/java/org/apache/tamaya/functions/MappedPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/MappedPropertySource.java b/modules/functions/src/main/java/org/apache/tamaya/functions/MappedPropertySource.java
deleted file mode 100644
index 3f85f53..0000000
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/MappedPropertySource.java
+++ /dev/null
@@ -1,88 +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.functions;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-
-/**
- * PropertySource implementation that maps certain parts (defined by an {@code UnaryOperator<String>}) to alternate sections.
- */
-class MappedPropertySource implements PropertySource {
-
- private static final long serialVersionUID = 8690637705511432083L;
-
- /**
- * The mapping operator.
- */
- private final KeyMapper keyMapper;
- /**
- * The base configuration.
- */
- private final PropertySource propertySource;
-
- /**
- * Creates a new instance.
- *
- * @param config the base configuration, not null
- * @param keyMapper The mapping operator, not null
- */
- public MappedPropertySource(PropertySource config, KeyMapper keyMapper) {
- this.propertySource = Objects.requireNonNull(config);
- this.keyMapper = Objects.requireNonNull(keyMapper);
- }
-
- @Override
- public int getOrdinal() {
- return this.propertySource.getOrdinal();
- }
-
- @Override
- public String getName() {
- return this.propertySource.getName() + "[mapped]";
- }
-
- @Override
- public Map<String, String> getProperties() {
- Map<String, String> result = new HashMap<>();
- Map<String, String> map = this.propertySource.getProperties();
- for (Map.Entry<String, String> en : map.entrySet()) {
- String targetKey = keyMapper.mapKey(en.getKey());
- if (targetKey != null) {
- result.put(targetKey, en.getValue());
- }
- }
- return result;
- }
-
- @Override
- public boolean isScannable() {
- return propertySource.isScannable();
- }
-
- @Override
- public PropertyValue get(String key) {
- return PropertyValue.of(key, getProperties().get(key), getName());
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/functions/src/main/java/org/apache/tamaya/functions/Predicate.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/Predicate.java b/modules/functions/src/main/java/org/apache/tamaya/functions/Predicate.java
deleted file mode 100644
index 3061746..0000000
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/Predicate.java
+++ /dev/null
@@ -1,42 +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.functions;
-
-/**
- * Represents a predicate (boolean-valued function) of one argument.
- *
- * <p>This is a <a href="package-summary.html">functional interface</a>
- * whose functional method is {@link #test(Object)}.
- *
- * @param <T> the type of the input to the predicate
- */
-//@FunctionalInterface
-public interface Predicate<T> {
-
- /**
- * Evaluates this predicate on the given argument.
- *
- * @param t the input argument
- * @return {@code true} if the input argument matches the predicate,
- * otherwise {@code false}
- */
- boolean test(T t);
-
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/functions/src/main/java/org/apache/tamaya/functions/PropertyMapper.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/PropertyMapper.java b/modules/functions/src/main/java/org/apache/tamaya/functions/PropertyMapper.java
deleted file mode 100644
index dc5bd30..0000000
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/PropertyMapper.java
+++ /dev/null
@@ -1,36 +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.functions;
-
-/**
- * This is a simple functional interface, used for mapping properties.
- * It can be used as functional interface in Java 8.
- */
-//@FunctionalInterface
-public interface PropertyMapper {
-
- /**
- * Maps the given key/value to another value.
- * @param key the key, not null.
- * @param value the value, not null.
- * @return the new value, not null.
- */
- String mapProperty(String key, String value);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/functions/src/main/java/org/apache/tamaya/functions/PropertyMatcher.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/PropertyMatcher.java b/modules/functions/src/main/java/org/apache/tamaya/functions/PropertyMatcher.java
deleted file mode 100644
index 45d44ee..0000000
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/PropertyMatcher.java
+++ /dev/null
@@ -1,38 +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.functions;
-
-/**
- * Represents a selector predicate for selecting configuration properties.
- * This can be used as a functional interface in Java 8.
- */
-//@FunctionalInterface
-public interface PropertyMatcher {
-
- /**
- * Evaluates this predicate on the given arguments.
- *
- * @param key the key, not null
- * @param value the value, not null
- * @return {@code true} if the entry should match the predicate
- */
- boolean test(String key, String value);
-
-}
-
[13/24] incubator-tamaya git commit: Removed all modules from the
main repository. They will be reborn in separate ASF repository.
Posted by pl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/PropertyConverterManager.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/PropertyConverterManager.java b/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/PropertyConverterManager.java
deleted file mode 100644
index e0e35f7..0000000
--- a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/PropertyConverterManager.java
+++ /dev/null
@@ -1,427 +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.integration.cdi;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-import org.apache.tamaya.spi.ServiceContextManager;
-
-import javax.enterprise.inject.Vetoed;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.lang.reflect.Type;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-import java.util.logging.Logger;
-
-/**
- * Manager that deals with {@link PropertyConverter} instances.
- * This class is thread-safe.
- */
-@Vetoed
-public class PropertyConverterManager {
- /**
- * The logger used.
- */
- private static final Logger LOG = Logger.getLogger(PropertyConverterManager.class.getName());
- /**
- * The registered converters.
- */
- private final Map<TypeLiteral<?>, List<PropertyConverter<?>>> converters = new ConcurrentHashMap<>();
- /**
- * The transitive converters.
- */
- private final Map<TypeLiteral<?>, List<PropertyConverter<?>>> transitiveConverters = new ConcurrentHashMap<>();
- /**
- * The lock used.
- */
- private final ReadWriteLock lock = new ReentrantReadWriteLock();
-
- private static final Comparator<Object> PRIORITY_COMPARATOR = new Comparator<Object>() {
-
- @Override
- public int compare(Object o1, Object o2) {
- int prio = CDIAwareServiceContext.getPriority(o1) - CDIAwareServiceContext.getPriority(o2);
- if (prio < 0) {
- return 1;
- } else if (prio > 0) {
- return -1;
- } else {
- return o1.getClass().getSimpleName().compareTo(o2.getClass().getSimpleName());
- }
- }
- };
-
- /**
- * Constructor.
- */
- public PropertyConverterManager() {
- initConverters();
- }
-
- /**
- * Registers the default converters provided out of the box.
- */
- protected void initConverters() {
- for (PropertyConverter conv : ServiceContextManager.getServiceContext().getServices(PropertyConverter.class)) {
- Type type = TypeLiteral.getGenericInterfaceTypeParameters(conv.getClass(), PropertyConverter.class)[0];
- register(TypeLiteral.of(type), conv);
- }
- }
-
- /**
- * Registers a ew converter instance.
- *
- * @param targetType the target type, not null.
- * @param converter the converter, not null.
- * @param <T> the type.
- */
- public <T> void register(TypeLiteral<T> targetType, PropertyConverter<T> converter) {
- Objects.requireNonNull(converter);
- Lock writeLock = lock.writeLock();
- try {
- writeLock.lock();
- List converters = List.class.cast(this.converters.get(targetType));
- List<PropertyConverter<?>> newConverters = new ArrayList<>();
- if (converters != null) {
- newConverters.addAll(converters);
- }
- newConverters.add(converter);
- Collections.sort(newConverters, PRIORITY_COMPARATOR);
- this.converters.put(targetType, Collections.unmodifiableList(newConverters));
- // evaluate transitive closure for all inherited supertypes and implemented interfaces
- // direct implemented interfaces
- for (Class<?> ifaceType : targetType.getRawType().getInterfaces()) {
- converters = List.class.cast(this.transitiveConverters.get(TypeLiteral.of(ifaceType)));
- newConverters = new ArrayList<>();
- if (converters != null) {
- newConverters.addAll(converters);
- }
- newConverters.add(converter);
- Collections.sort(newConverters, PRIORITY_COMPARATOR);
- this.transitiveConverters.put(TypeLiteral.of(ifaceType), Collections.unmodifiableList(newConverters));
- }
- Class<?> superClass = targetType.getRawType().getSuperclass();
- while (superClass != null && !superClass.equals(Object.class)) {
- converters = List.class.cast(this.transitiveConverters.get(TypeLiteral.of(superClass)));
- newConverters = new ArrayList<>();
- if (converters != null) {
- newConverters.addAll(converters);
- }
- newConverters.add(converter);
- Collections.sort(newConverters, PRIORITY_COMPARATOR);
- this.transitiveConverters.put(TypeLiteral.of(superClass), Collections.unmodifiableList(newConverters));
- for (Class<?> ifaceType : superClass.getInterfaces()) {
- converters = List.class.cast(this.transitiveConverters.get(TypeLiteral.of(ifaceType)));
- newConverters = new ArrayList<>();
- if (converters != null) {
- newConverters.addAll(converters);
- }
- newConverters.add(converter);
- Collections.sort(newConverters, PRIORITY_COMPARATOR);
- this.transitiveConverters.put(TypeLiteral.of(ifaceType), Collections.unmodifiableList(newConverters));
- }
- superClass = superClass.getSuperclass();
- }
- } finally {
- writeLock.unlock();
- }
- }
-
- /**
- * Allows to evaluate if a given target type is supported.
- *
- * @param targetType the target type, not null.
- * @return true, if a converter for the given type is registered, or a default one can be created.
- */
- public boolean isTargetTypeSupported(TypeLiteral<?> targetType) {
- if (converters.containsKey(targetType) || transitiveConverters.containsKey(targetType)) {
- return true;
- }
- return createDefaultPropertyConverter(targetType) != null;
- }
-
- /**
- * Get a map of all property converters currently registered. This will not contain the converters that
- * may be created, when an instance is adapted, which provides a String constructor or compatible
- * factory methods taking a single String instance.
- *
- * @return the current map of instantiated and registered converters.
- * @see #createDefaultPropertyConverter(TypeLiteral)
- */
- public Map<TypeLiteral<?>, List<PropertyConverter<?>>> getPropertyConverters() {
- Lock readLock = lock.readLock();
- try {
- readLock.lock();
- return new HashMap<>(this.converters);
- } finally {
- readLock.unlock();
- }
- }
-
- /**
- * <p>Get the list of all current registered converters for the given target type.
- * If not converters are registered, they component tries to create and register a dynamic
- * converter based on String costructor or static factory methods available.</p>
- *
- * <p>The converters provided are of the following type and returned in the following order:</p>
- * <ul>
- * <li>Converters mapped explicitly to the required target type are returned first, ordered
- * by decreasing priority. This means, if explicit converters are registered these are used
- * primarly for converting a value.</li>
- * <li>The target type of each explicitly registered converter also can be transitively mapped to
- * 1) all directly implemented interfaces, 2) all its superclasses (except Object), 3) all the interfaces
- * implemented by its superclasses. These groups of transitive converters is returned similarly in the
- * order as mentioned, whereas also here a priority based decreasing ordering is applied.</li>
- * <li>java.lang wrapper classes and native types are automatically mapped.</li>
- * <li>If no explicit converters are registered, for Enum types a default implementation is provided that
- * compares the configuration values with the different enum members defined (cases sensitive mapping).</li>
- * </ul>
- *
- * <p>So given that list above directly registered mappings always are tried first, before any transitive mapping
- * should be used. Also in all cases @Priority annotations are honored for ordering of the converters in place.
- * Transitive conversion is supported for all directly implemented interfaces (including inherited ones) and
- * the inheritance hierarchy (exception Object). Super interfaces of implemented interfaces are ignored.</p>
- *
- *
- * @param targetType the target type, not null.
- * @param <T> the type class
- * @return the ordered list of converters (may be empty for not convertible types).
- * @see #createDefaultPropertyConverter(TypeLiteral)
- */
- public <T> List<PropertyConverter<T>> getPropertyConverters(TypeLiteral<T> targetType) {
- Lock readLock = lock.readLock();
- List<PropertyConverter<T>> converterList = new ArrayList<>();
- List<PropertyConverter<T>> converters;
- // direct mapped converters
- try {
- readLock.lock();
- converters = List.class.cast(this.converters.get(targetType));
- } finally {
- readLock.unlock();
- }
- if (converters != null) {
- converterList.addAll(converters);
- }
- // transitive converter
- try {
- readLock.lock();
- converters = List.class.cast(this.transitiveConverters.get(targetType));
- } finally {
- readLock.unlock();
- }
- if (converters != null) {
- converterList.addAll(converters);
- }
- // handling of java.lang wrapper classes
- TypeLiteral<T> boxedType = mapBoxedType(targetType);
- if (boxedType != null) {
- try {
- readLock.lock();
- converters = List.class.cast(this.converters.get(boxedType));
- } finally {
- readLock.unlock();
- }
- if (converters != null) {
- converterList.addAll(converters);
- }
- }
- if (converterList.isEmpty()) {
- // adding any converters created on the fly, e.g. for enum types.
- PropertyConverter<T> defaultConverter = createDefaultPropertyConverter(targetType);
- if (defaultConverter != null) {
- register(targetType, defaultConverter);
- try {
- readLock.lock();
- converters = List.class.cast(this.converters.get(targetType));
- } finally {
- readLock.unlock();
- }
- }
- if (converters != null) {
- converterList.addAll(converters);
- }
- }
- return converterList;
- }
-
- /**
- * Maps native types to the corresponding boxed types.
- *
- * @param targetType the native type.
- * @param <T> the type
- * @return the boxed type, or null.
- */
- private <T> TypeLiteral<T> mapBoxedType(TypeLiteral<T> targetType) {
- Type parameterType = targetType.getType();
- if (parameterType == int.class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Integer.class));
- }
- if (parameterType == short.class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Short.class));
- }
- if (parameterType == byte.class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Byte.class));
- }
- if (parameterType == long.class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Long.class));
- }
- if (parameterType == boolean.class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Boolean.class));
- }
- if (parameterType == char.class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Character.class));
- }
- if (parameterType == float.class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Float.class));
- }
- if (parameterType == double.class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Double.class));
- }
- if (parameterType == int[].class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Integer[].class));
- }
- if (parameterType == short[].class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Short[].class));
- }
- if (parameterType == byte[].class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Byte[].class));
- }
- if (parameterType == long[].class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Long[].class));
- }
- if (parameterType == boolean.class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Boolean.class));
- }
- if (parameterType == char[].class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Character[].class));
- }
- if (parameterType == float[].class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Float[].class));
- }
- if (parameterType == double[].class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Double[].class));
- }
- return null;
- }
-
- /**
- * Creates a dynamic PropertyConverter for the given target type.
- *
- * @param targetType the target type
- * @param <T> the type class
- * @return a new converter, or null.
- */
- protected <T> PropertyConverter<T> createDefaultPropertyConverter(final TypeLiteral<T> targetType) {
- if (Enum.class.isAssignableFrom(targetType.getRawType())) {
- return new EnumConverter<>(targetType.getRawType());
- }
- PropertyConverter<T> converter = null;
- final Method factoryMethod = getFactoryMethod(targetType.getRawType(), "of", "valueOf", "instanceOf", "getInstance", "from", "fromString", "parse");
- if (factoryMethod != null) {
- converter = new PropertyConverter<T>() {
- @Override
- public T convert(String value, ConversionContext context) {
- context.addSupportedFormats(PropertyConverter.class, "static T of(String)", "static T valueOf(String)",
- "static T getInstance(String)", "static T from(String)",
- "static T fromString(String)", "static T parse(String)");
- try {
- if (!Modifier.isStatic(factoryMethod.getModifiers())) {
- throw new ConfigException(factoryMethod.toGenericString() +
- " is not a static method. Only static " +
- "methods can be used as factory methods.");
- }
- AccessController.doPrivileged(new PrivilegedAction<Object>() {
- @Override
- public Object run() {
- factoryMethod.setAccessible(true);
- return null;
- }
- });
- Object invoke = factoryMethod.invoke(null, value);
- return targetType.getRawType().cast(invoke);
- } catch (Exception e) {
- throw new ConfigException("Failed to decode '" + value + "'", e);
- }
- }
- };
- }
- if (converter == null) {
- try {
- final Constructor<T> constr = targetType.getRawType().getDeclaredConstructor(String.class);
- converter = new PropertyConverter<T>() {
- @Override
- public T convert(String value, ConversionContext context) {
- context.addSupportedFormats(PropertyConverter.class, "new T(String)");
- try {
- AccessController.doPrivileged(new PrivilegedAction<Object>() {
- @Override
- public Object run() {
- constr.setAccessible(true);
- return null;
- }
- });
- return constr.newInstance(value);
- } catch (Exception e) {
- throw new ConfigException("Failed to decode '" + value + "'", e);
- }
- }
- };
- } catch (Exception e) {
- LOG.finest("Failed to construct instance of type: " + targetType.getRawType().getName() + ": " + e);
- }
- }
- return converter;
- }
-
- /**
- * Tries to evaluate a factory method that can be used to create an instance based on a String.
- *
- * @param type the target type
- * @param methodNames the possible static method names
- * @return the first method found, or null.
- */
- private Method getFactoryMethod(Class<?> type, String... methodNames) {
- Method m;
- for (String name : methodNames) {
- try {
- m = type.getDeclaredMethod(name, String.class);
- return m;
- } catch (NoSuchMethodException | RuntimeException e) {
- LOG.finest("No such factory method found on type: " + type.getName() + ", methodName: " + name);
- }
- }
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/SEInjectorCDIExtension.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/SEInjectorCDIExtension.java b/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/SEInjectorCDIExtension.java
deleted file mode 100644
index 86e95b0..0000000
--- a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/SEInjectorCDIExtension.java
+++ /dev/null
@@ -1,112 +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.integration.cdi;
-
-
-import org.apache.tamaya.inject.ConfigurationInjection;
-import org.apache.tamaya.inject.api.Config;
-import org.apache.tamaya.inject.api.ConfigDefaultSections;
-
-import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.Vetoed;
-import javax.enterprise.inject.spi.AnnotatedType;
-import javax.enterprise.inject.spi.Extension;
-import javax.enterprise.inject.spi.InjectionPoint;
-import javax.enterprise.inject.spi.InjectionTarget;
-import javax.enterprise.inject.spi.ProcessInjectionTarget;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.Set;
-
-/**
- * CDI portable extension that integrates {@link org.apache.tamaya.inject.ConfigurationInjector}
- * with CDI by adding configuration features to CDI (config enable CDI beans).
- */
-@Vetoed
-public final class SEInjectorCDIExtension implements Extension {
-
- /**
- * Method that injects the values into any configured fields, by wrapping the given
- * InjectionTarget.
- * @param pit the injection target
- * @param <T> the target type
- */
- public <T> void initializeConfiguredFields(final @Observes ProcessInjectionTarget<T> pit) {
- final AnnotatedType<T> at = pit.getAnnotatedType();
- if (!isConfigured(at.getJavaClass())) {
- return;
- }
- final InjectionTarget<T> it = pit.getInjectionTarget();
- InjectionTarget<T> wrapped = new InjectionTarget<T>() {
- @Override
- public void inject(T instance, CreationalContext<T> ctx) {
- it.inject(instance, ctx);
- ConfigurationInjection.getConfigurationInjector().configure(instance);
- }
-
- @Override
- public void postConstruct(T instance) {
- it.postConstruct(instance);
- }
-
- @Override
- public void preDestroy(T instance) {
- it.dispose(instance);
- }
-
- @Override
- public void dispose(T instance) {
- it.dispose(instance);
- }
-
- @Override
- public Set<InjectionPoint> getInjectionPoints() {
- return it.getInjectionPoints();
- }
-
- @Override
- public T produce(CreationalContext<T> ctx) {
- return it.produce(ctx);
- }
- };
- pit.setInjectionTarget(wrapped);
- }
-
- private boolean isConfigured(Class type) {
- if (type.getAnnotation(ConfigDefaultSections.class) != null) {
- return true;
- }
- // if no class level annotation is there we might have field level annotations only
- for (Field field : type.getDeclaredFields()) {
- if (field.isAnnotationPresent(Config.class)) {
- return true;
- }
- }
- // if no class level annotation is there we might have method level annotations only
- for (Method method : type.getDeclaredMethods()) {
- if(method.isAnnotationPresent(Config.class)) {
- return true;
- }
- }
- return false;
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/ServiceLoaderServiceContext.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/ServiceLoaderServiceContext.java b/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/ServiceLoaderServiceContext.java
deleted file mode 100644
index 5171d91..0000000
--- a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/ServiceLoaderServiceContext.java
+++ /dev/null
@@ -1,151 +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.integration.cdi;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.spi.ServiceContext;
-
-import javax.annotation.Priority;
-import java.text.MessageFormat;
-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 ServiceLoader} to load the services required.
- */
-final class ServiceLoaderServiceContext implements ServiceContext {
- /**
- * List current services loaded, per class.
- */
- private final ConcurrentHashMap<Class<?>, List<Object>> servicesLoaded = new ConcurrentHashMap<>();
- /**
- * Singletons.
- */
- private final Map<Class<?>, Object> singletons = new ConcurrentHashMap<>();
-
- @Override
- public <T> T getService(Class<T> serviceType) {
- Object cached = singletons.get(serviceType);
- if (cached == null) {
- Collection<T> services = getServices(serviceType);
- if (services.isEmpty()) {
- cached = null;
- } else {
- cached = getServiceWithHighestPriority(services, serviceType);
- }
- if(cached!=null) {
- singletons.put(serviceType, cached);
- }
- }
- return serviceType.cast(cached);
- }
-
- /**
- * Loads and registers services.
- *
- * @param <T> the concrete type.
- * @param serviceType The service type.
- * @return the items found, never {@code null}.
- */
- @Override
- public <T> List<T> getServices(final Class<T> serviceType) {
- List<T> found = (List<T>) servicesLoaded.get(serviceType);
- if (found != null) {
- return found;
- }
- List<T> services = new ArrayList<>();
- try {
- for (T t : ServiceLoader.load(serviceType)) {
- services.add(t);
- }
- services = Collections.unmodifiableList(services);
- } catch (Exception e) {
- Logger.getLogger(ServiceLoaderServiceContext.class.getName()).log(Level.WARNING,
- "Error loading services current type " + serviceType, e);
- }
- final List<T> previousServices = List.class.cast(servicesLoaded.putIfAbsent(serviceType, (List<Object>) services));
- return previousServices != null ? previousServices : services;
- }
-
- /**
- * Checks the given instance for a @Priority annotation. If present the annotation's value s evaluated. If no such
- * annotation is present, a default priority is returned (1);
- * @param o the instance, not null.
- * @return a priority, by default 1.
- */
- public static int getPriority(Object o){
- int prio = 1; //X TODO discuss default priority
- Priority priority = o.getClass().getAnnotation(Priority.class);
- if (priority != null) {
- prio = priority.value();
- }
- return prio;
- }
-
- /**
- * @param services to scan
- * @param <T> type of the service
- *
- * @return the service with the highest {@link Priority#value()}
- *
- * @throws ConfigException if there are multiple service implementations with the maximum priority
- */
- private <T> T getServiceWithHighestPriority(Collection<T> services, Class<T> serviceType) {
-
- // we do not need the priority stuff if the list contains only one element
- if (services.size() == 1) {
- return services.iterator().next();
- }
-
- Integer highestPriority = null;
- int highestPriorityServiceCount = 0;
- T highestService = null;
-
- for (T service : services) {
- int prio = getPriority(service);
- 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}: {3}",
- highestPriorityServiceCount,
- serviceType.getName(),
- highestPriority,
- services));
- }
-
- return highestService;
- }
-
- @Override
- public int ordinal() {
- return 1;
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/TamayaCDIIntegration.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/TamayaCDIIntegration.java b/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/TamayaCDIIntegration.java
deleted file mode 100644
index 3f62039..0000000
--- a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/TamayaCDIIntegration.java
+++ /dev/null
@@ -1,52 +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.integration.cdi;
-
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.spi.AfterDeploymentValidation;
-import javax.enterprise.inject.spi.BeanManager;
-import javax.enterprise.inject.spi.Extension;
-
-/**
- * Tamaya main integration with CDI, storing the BeanManager reference for implementation, where no
- * JNDI is available or {@code java:comp/env/BeanManager} is not set correctly.
- */
-public class TamayaCDIIntegration implements Extension {
- /** The BeanManager references stored. */
- private static BeanManager beanManager;
-
- /**
- * Initializes the current BeanManager with the instance passed.
- * @param validation the event
- * @param beanManager the BeanManager instance
- */
- @SuppressWarnings("all")
- public void initBeanManager(@Observes AfterDeploymentValidation validation, BeanManager beanManager){
- TamayaCDIIntegration.beanManager = beanManager;
- }
-
- /**
- * Get the current {@link BeanManager} instance.
- * @return the currently used bean manager.
- */
- public static BeanManager getBeanManager(){
- return beanManager;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/TamayaConfigProvider.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/TamayaConfigProvider.java b/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/TamayaConfigProvider.java
deleted file mode 100644
index f2763e5..0000000
--- a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/TamayaConfigProvider.java
+++ /dev/null
@@ -1,54 +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.integration.cdi;
-
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.spi.ConfigurationContext;
-import org.apache.tamaya.spi.ConfigurationContextBuilder;
-import org.apache.tamaya.spisupport.DefaultConfiguration;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.enterprise.inject.Produces;
-import javax.inject.Singleton;
-
-/**
- * Tamaya main integreation with CDI (singleton) serving producers for Configuration, ConfigurationContext and
- * ConfigurationContextBuilder.
- */
-@Singleton
-public class TamayaConfigProvider{
-
- @Produces
- @ApplicationScoped
- public Configuration getConfiguration(ConfigurationContext context){
- return new DefaultConfiguration(context);
- }
-
- @Produces @ApplicationScoped
- public ConfigurationContext getConfigurationContext(){
- return new DefaultConfigurationContext();
- }
-
- @Produces
- public ConfigurationContextBuilder getConfigurationContextBuilder(){
- return new DefaultConfigurationContextBuilder();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/config/ConfiguredVetoExtension.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/config/ConfiguredVetoExtension.java b/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/config/ConfiguredVetoExtension.java
deleted file mode 100644
index f90998d..0000000
--- a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/config/ConfiguredVetoExtension.java
+++ /dev/null
@@ -1,42 +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.integration.cdi.config;
-
-import org.apache.tamaya.ConfigurationProvider;
-
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.spi.ProcessAnnotatedType;
-
-/**
- * CDI Extension that can be used to veto on beans by configuring the fully qualified class names (as regex expression)
- * under {@code javax.enterprise.inject.vetoed}. Multiple expression can be added as comma separated values.
- */
-public class ConfiguredVetoExtension {
-
- public void observesBean(@Observes ProcessAnnotatedType<?> type){
- String vetoedTypesVal = ConfigurationProvider.getConfiguration().get("javax.enterprise.inject.vetoed");
- String[] vetoedTypes = vetoedTypesVal.split(",");
- for(String typeExpr:vetoedTypes){
- if(type.getAnnotatedType().getJavaClass().getName().matches(typeExpr)){
- type.veto();
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi-se/src/main/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/modules/integration/cdi-se/src/main/resources/META-INF/beans.xml b/modules/integration/cdi-se/src/main/resources/META-INF/beans.xml
deleted file mode 100644
index adee378..0000000
--- a/modules/integration/cdi-se/src/main/resources/META-INF/beans.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-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.
--->
-<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://jboss.org/schema/cdi/beans_1_0.xsd">
-
-</beans>
-
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi-se/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
----------------------------------------------------------------------
diff --git a/modules/integration/cdi-se/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension b/modules/integration/cdi-se/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
deleted file mode 100644
index 8580a42..0000000
--- a/modules/integration/cdi-se/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
+++ /dev/null
@@ -1,20 +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.integration.cdi.TamayaCDIIntegration
-org.apache.tamaya.integration.cdi.SEInjectorCDIExtension
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi-se/src/main/resources/META-INF/services/org.apache.tamaya.spi.ServiceContext
----------------------------------------------------------------------
diff --git a/modules/integration/cdi-se/src/main/resources/META-INF/services/org.apache.tamaya.spi.ServiceContext b/modules/integration/cdi-se/src/main/resources/META-INF/services/org.apache.tamaya.spi.ServiceContext
deleted file mode 100644
index 4fe7e01..0000000
--- a/modules/integration/cdi-se/src/main/resources/META-INF/services/org.apache.tamaya.spi.ServiceContext
+++ /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.integration.cdi.CDIAwareServiceContext
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/ConfiguredClass.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/ConfiguredClass.java b/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/ConfiguredClass.java
deleted file mode 100644
index 9d920bc..0000000
--- a/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/ConfiguredClass.java
+++ /dev/null
@@ -1,112 +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.integration.cdi;
-
-import org.apache.tamaya.inject.api.Config;
-
-import java.math.BigDecimal;
-
-import javax.inject.Singleton;
-
-/**
- * Class to be loaded from CDI to ensure fields are correctly configured using CDI injection mechanisms.
- */
-@Singleton
-public class ConfiguredClass{
-
- @Config
- private String testProperty;
-
- @Config(value = {"a.b.c.key1","a.b.c.key2","a.b.c.key3"}, defaultValue = "The current \\${JAVA_HOME} env property is ${env:JAVA_HOME}.")
- String value1;
-
- @Config({"foo","a.b.c.key2"})
- private String value2;
-
- @Config(defaultValue = "N/A")
- private String runtimeVersion;
-
- @Config(defaultValue = "${sys:java.version}")
- private String javaVersion2;
-
- @Config(defaultValue = "5")
- private Integer int1;
-
- @Config
- private int int2;
-
- @Config
- private boolean booleanT;
-
- @Config("BD")
- private BigDecimal bigNumber;
-
- @Config("double1")
- private double doubleValue;
-
- public String getTestProperty() {
- return testProperty;
- }
-
- public String getValue1() {
- return value1;
- }
-
- public String getValue2() {
- return value2;
- }
-
- public String getRuntimeVersion() {
- return runtimeVersion;
- }
-
- public String getJavaVersion2() {
- return javaVersion2;
- }
-
- public Integer getInt1() {
- return int1;
- }
-
- public int getInt2() {
- return int2;
- }
-
- public boolean isBooleanT() {
- return booleanT;
- }
-
- public BigDecimal getBigNumber() {
- return bigNumber;
- }
-
- public double getDoubleValue() {
- return doubleValue;
- }
-
- @Override
- public String toString(){
- return super.toString() + ": testProperty="+testProperty+", value1="+value1+", value2="+value2
- +", int1="+int1+", int2="+int2+", booleanT="+booleanT+", bigNumber="+bigNumber
- +", runtimeVersion="+runtimeVersion+", javaVersion2="+javaVersion2;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/ConfiguredTest.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/ConfiguredTest.java b/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/ConfiguredTest.java
deleted file mode 100644
index 69e8ef9..0000000
--- a/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/ConfiguredTest.java
+++ /dev/null
@@ -1,83 +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.integration.cdi;
-
-import org.apache.deltaspike.testcontrol.api.TestControl;
-import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
-import org.hamcrest.MatcherAssert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.enterprise.inject.spi.CDI;
-import javax.inject.Singleton;
-
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-/**
- * Tests for CDI integration.
- */
-@RunWith(CdiTestRunner.class)
-@TestControl(startScopes = {ApplicationScoped.class, Singleton.class})
-public class ConfiguredTest{
-
- @Test
- public void test_Configuration_is_injected_correctly(){
- ConfiguredClass item = CDI.current().select(ConfiguredClass.class).get();
- System.out.println("********************************************");
- System.out.println(item);
- System.out.println("********************************************");
- double actual = 1234.5678;
- MatcherAssert.assertThat(item.getDoubleValue(), is(actual));
- }
-
- @Test
- public void test_Default_injections_are_accessible(){
- InjectedClass injectedClass = CDI.current().select(InjectedClass.class).get();
- System.out.println("********************************************");
- System.out.println(injectedClass);
- System.out.println("********************************************");
- assertNotNull(injectedClass.builder1);
- assertNotNull(injectedClass.builder2);
- assertNotNull(injectedClass.config);
- assertNotNull(injectedClass.configContext);
- }
-
- @Test
- public void test_Injected_builders_are_notSame(){
- InjectedClass injectedClass = CDI.current().select(InjectedClass.class).get();
- assertTrue(injectedClass.builder1 != injectedClass.builder2);
- }
-
- @Test
- public void test_Injected_configs_are_same(){
- InjectedClass injectedClass = CDI.current().select(InjectedClass.class).get();
- assertTrue(injectedClass.config == injectedClass.config2);
- }
-
- @Test
- public void test_Injected_configContexts_are_same(){
- InjectedClass injectedClass = CDI.current().select(InjectedClass.class).get();
- assertTrue(injectedClass.configContext == injectedClass.configContext2);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/InjectedClass.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/InjectedClass.java b/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/InjectedClass.java
deleted file mode 100644
index 9b7bd23..0000000
--- a/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/InjectedClass.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy 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.integration.cdi;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.spi.ConfigurationContext;
-import org.apache.tamaya.spi.ConfigurationContextBuilder;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-/**
- * Class loaded by CDI to test correct injection of Configuration API artifacts.
- */
-@Singleton
-public class InjectedClass {
-
- @Inject
- Configuration config;
-
- @Inject
- Configuration config2;
-
- @Inject
- ConfigurationContext configContext;
-
- @Inject
- ConfigurationContext configContext2;
-
- @Inject
- ConfigurationContextBuilder builder1;
-
- @Inject
- ConfigurationContextBuilder builder2;
-
- @Override
- public String toString() {
- return "InjectedClass{" +
- "config=" + config +
- ", configContext=" + configContext +
- ", builder1=" + builder1 +
- ", builder2=" + builder2 +
- '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/cfg/ProvidedPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/cfg/ProvidedPropertySource.java b/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/cfg/ProvidedPropertySource.java
deleted file mode 100644
index f7e3c6d..0000000
--- a/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/cfg/ProvidedPropertySource.java
+++ /dev/null
@@ -1,67 +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.integration.cdi.cfg;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-
-import javax.enterprise.inject.Vetoed;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Created by Anatole on 17.09.2015.
- */
-@Vetoed
-class ProvidedPropertySource implements PropertySource{
-
- final Map<String,String> config = new HashMap<>();
-
- public ProvidedPropertySource(){
- config.put("a.b.c.key3", "keys current a.b.c.key3");
- config.put("a.b.c.key4", "keys current a.b.c.key4");
- config.put("{meta}source.type:"+getClass().getName(), "PropertySourceProvider");
- }
-
- @Override
- public int getOrdinal() {
- return 10;
- }
-
- @Override
- public String getName() {
- return getClass().getName();
- }
-
- @Override
- public PropertyValue get(String key) {
- return PropertyValue.of(key, config.get(key), getName());
- }
-
- @Override
- public Map<String, String> getProperties() {
- return config;
- }
-
- @Override
- public boolean isScannable() {
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/cfg/TestConfigProvider.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/cfg/TestConfigProvider.java b/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/cfg/TestConfigProvider.java
deleted file mode 100644
index 7b89fba..0000000
--- a/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/cfg/TestConfigProvider.java
+++ /dev/null
@@ -1,45 +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.integration.cdi.cfg;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertySourceProvider;
-
-import javax.enterprise.context.ApplicationScoped;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * Created by Anatole on 29.09.2014.
- */
-@ApplicationScoped
-public class TestConfigProvider implements PropertySourceProvider {
-
- private List<PropertySource> configs = new ArrayList<>();
-
- public TestConfigProvider(){
- configs.add(new ProvidedPropertySource());
- }
-
- @Override
- public Collection<PropertySource> getPropertySources() {
- return configs;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/cfg/TestPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/cfg/TestPropertySource.java b/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/cfg/TestPropertySource.java
deleted file mode 100644
index 75c55ca..0000000
--- a/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/cfg/TestPropertySource.java
+++ /dev/null
@@ -1,79 +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.integration.cdi.cfg;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-
-import javax.inject.Singleton;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Created by Anatole on 17.09.2015.
- */
-@Singleton
-public class TestPropertySource implements PropertySource{
-
- final Map<String,String> config = new HashMap<>();
-
- public TestPropertySource(){
- config.put("a.b.c.key1", "keys current a.b.c.key1");
- config.put("a.b.c.key2", "keys current a.b.c.key2");
- config.put("a.b.key3", "keys current a.b.key3");
- config.put("a.b.key4", "keys current a.b.key4");
- config.put("a.key5", "keys current a.key5");
- config.put("a.key6", "keys current a.key6");
- config.put("int1", "123456");
- config.put("int2", "111222");
- config.put("testProperty", "testPropertyValue!");
- config.put("booleanT", "true");
- config.put("double1", "1234.5678");
- config.put("BD", "123456789123456789123456789123456789.123456789123456789123456789123456789");
- config.put("testProperty", "keys current testProperty");
- config.put("runtimeVersion", "${java.version}");
- config.put("{meta}source.type:"+getClass().getName(), "PropertySource");
- }
-
- @Override
- public int getOrdinal() {
- return 10;
- }
-
- @Override
- public String getName() {
- return getClass().getName();
- }
-
- @Override
- public PropertyValue get(String key) {
- return PropertyValue.of(key, config.get(key), getName());
- }
-
- @Override
- public Map<String, String> getProperties() {
- return config;
- }
-
- @Override
- public boolean isScannable() {
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi-se/src/test/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/modules/integration/cdi-se/src/test/resources/META-INF/beans.xml b/modules/integration/cdi-se/src/test/resources/META-INF/beans.xml
deleted file mode 100644
index adee378..0000000
--- a/modules/integration/cdi-se/src/test/resources/META-INF/beans.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-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.
--->
-<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://jboss.org/schema/cdi/beans_1_0.xsd">
-
-</beans>
-
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi-se/src/test/resources/META-INF/javaconfiguration.properties
----------------------------------------------------------------------
diff --git a/modules/integration/cdi-se/src/test/resources/META-INF/javaconfiguration.properties b/modules/integration/cdi-se/src/test/resources/META-INF/javaconfiguration.properties
deleted file mode 100644
index 362ce0b..0000000
--- a/modules/integration/cdi-se/src/test/resources/META-INF/javaconfiguration.properties
+++ /dev/null
@@ -1,20 +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.
-#
-double1=1234.5678
-int2=13
-booleanT=y
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi/pom.xml
----------------------------------------------------------------------
diff --git a/modules/integration/cdi/pom.xml b/modules/integration/cdi/pom.xml
deleted file mode 100644
index 34481f6..0000000
--- a/modules/integration/cdi/pom.xml
+++ /dev/null
@@ -1,224 +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.
--->
-<project xmlns="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">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-integration</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
- </parent>
-
- <artifactId>tamaya-cdi</artifactId>
- <name>Apache Tamaya Integration - CDI (Java EE)</name>
- <packaging>bundle</packaging>
-
- <properties>
- <owb.version>1.6.2</owb.version>
- <weld.version>2.2.7.Final</weld.version>
- <geronimo-jcdi-1.1-spec.version>1.0</geronimo-jcdi-1.1-spec.version>
- <geronimo-interceptor-1.2-spec.version>1.0</geronimo-interceptor-1.2-spec.version>
- <geronimo-atinject-1.0-spec.version>1.0</geronimo-atinject-1.0-spec.version>
- <bval.version>0.5</bval.version>
- <ds.version>1.1.0</ds.version>
- <javaee-api.version>6.0-6</javaee-api.version>
- <openejb.version>4.7.1</openejb.version>
- <tomee.version>1.7.1</tomee.version>
- </properties>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.jacoco</groupId>
- <artifactId>jacoco-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>prepare-agent</id>
- <goals>
- <goal>prepare-agent</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.tamaya.integration.cdi
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-injection-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>java-hamcrest</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-core</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-api</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.openejb</groupId>
- <artifactId>javaee-api</artifactId>
- <version>${javaee-api.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.tomitribe</groupId>
- <artifactId>tomitribe-util</artifactId>
- <version>1.1.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.openejb</groupId>
- <artifactId>openejb-core</artifactId>
- <version>${openejb.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-jcdi_1.1_spec</artifactId>
- <version>${geronimo-jcdi-1.1-spec.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.deltaspike.modules</groupId>
- <artifactId>deltaspike-test-control-module-api</artifactId>
- <version>${ds.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.deltaspike.modules</groupId>
- <artifactId>deltaspike-test-control-module-impl</artifactId>
- <version>${ds.version}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
- <profiles>
- <!--<profile>-->
- <!--<id>OWB</id>-->
- <!--<!– there is an issue with this profile:-->
- <!--java.lang.NoClassDefFoundError: org/apache/webbeans/event/EventMetadata-->
- <!--–>-->
- <!--<activation>-->
- <!--<activeByDefault>false</activeByDefault>-->
- <!--</activation>-->
- <!--<dependencies>-->
- <!--<!– OWB specific dependencies–>-->
- <!--<dependency>-->
- <!--<groupId>org.apache.geronimo.specs</groupId>-->
- <!--<artifactId>geronimo-atinject_1.0_spec</artifactId>-->
- <!--<version>${geronimo-atinject-1.0-spec.version}</version>-->
- <!--</dependency>-->
- <!--<dependency>-->
- <!--<groupId>org.apache.geronimo.specs</groupId>-->
- <!--<artifactId>geronimo-interceptor_1.2_spec</artifactId>-->
- <!--<version>${geronimo-interceptor-1.2-spec.version}</version>-->
- <!--<scope>test</scope>-->
- <!--</dependency>-->
- <!--<dependency>-->
- <!--<groupId>org.apache.geronimo.specs</groupId>-->
- <!--<artifactId>geronimo-annotation_1.2_spec</artifactId>-->
- <!--<version>1.0</version>-->
- <!--<scope>test</scope>-->
- <!--</dependency>-->
- <!--<dependency>-->
- <!--<groupId>org.apache.geronimo.specs</groupId>-->
- <!--<artifactId>geronimo-el_2.2_spec</artifactId>-->
- <!--<version>1.0.2</version>-->
- <!--</dependency>-->
-
- <!--<dependency>-->
- <!--<groupId>org.apache.openwebbeans</groupId>-->
- <!--<artifactId>openwebbeans-impl</artifactId>-->
- <!--<version>${owb.version}</version>-->
- <!--</dependency>-->
- <!--<dependency>-->
- <!--<groupId>org.apache.openwebbeans</groupId>-->
- <!--<artifactId>openwebbeans-spi</artifactId>-->
- <!--<version>${owb.version}</version>-->
- <!--</dependency>-->
- <!--<dependency>-->
- <!--<groupId>org.apache.openwebbeans</groupId>-->
- <!--<artifactId>openwebbeans-resource</artifactId>-->
- <!--<version>${owb.version}</version>-->
- <!--</dependency>-->
-
- <!--<dependency>-->
- <!--<groupId>org.apache.bval</groupId>-->
- <!--<artifactId>bval-jsr303</artifactId>-->
- <!--<version>${bval.version}</version>-->
- <!--<scope>test</scope>-->
- <!--</dependency>-->
- <!--<dependency>-->
- <!--<groupId>org.apache.deltaspike.cdictrl</groupId>-->
- <!--<artifactId>deltaspike-cdictrl-owb</artifactId>-->
- <!--<version>${ds.version}</version>-->
- <!--<scope>test</scope>-->
- <!--</dependency>-->
- <!--</dependencies>-->
- <!--</profile>-->
- <profile>
- <id>Weld</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
- <dependencies>
- <dependency>
- <groupId>org.jboss.weld.se</groupId>
- <artifactId>weld-se</artifactId>
- <version>${weld.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.deltaspike.cdictrl</groupId>
- <artifactId>deltaspike-cdictrl-weld</artifactId>
- <version>${ds.version}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
- </profile>
- </profiles>
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi/src/main/java/org/apache/tamaya/integration/cdi/CDIConfiguredField.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi/src/main/java/org/apache/tamaya/integration/cdi/CDIConfiguredField.java b/modules/integration/cdi/src/main/java/org/apache/tamaya/integration/cdi/CDIConfiguredField.java
deleted file mode 100644
index fa826f5..0000000
--- a/modules/integration/cdi/src/main/java/org/apache/tamaya/integration/cdi/CDIConfiguredField.java
+++ /dev/null
@@ -1,77 +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.integration.cdi;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.inject.spi.ConfiguredField;
-
-import javax.enterprise.inject.spi.InjectionPoint;
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * CDI implementation for event publishing of configured instances.
- */
-class CDIConfiguredField implements ConfiguredField{
-
- private final Field field;
- private List<String> keys = new ArrayList<>();
-
- CDIConfiguredField(InjectionPoint injectionPoint, List<String> keys){
- this.field = (Field)injectionPoint.getMember();
- this.keys.addAll(keys);
- this.keys = Collections.unmodifiableList(this.keys);
- }
-
- @Override
- public Class<?> getType() {
- return field.getType();
- }
-
- @Override
- public Collection<String> getConfiguredKeys() {
- return keys;
- }
-
- @Override
- public Field getAnnotatedField() {
- return field;
- }
-
- @Override
- public String getName() {
- return field.getName();
- }
-
- @Override
- public String getSignature() {
- return getName()+':'+field.getType().getName();
- }
-
- @Override
- public void configure(Object instance, Configuration config) {
- throw new UnsupportedOperationException("Use CDI annotations for configuration injection.");
- }
-
- @Override
- public String toString() {
- return "CDIConfiguredField["+getSignature()+']';
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi/src/main/java/org/apache/tamaya/integration/cdi/CDIConfiguredMethod.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi/src/main/java/org/apache/tamaya/integration/cdi/CDIConfiguredMethod.java b/modules/integration/cdi/src/main/java/org/apache/tamaya/integration/cdi/CDIConfiguredMethod.java
deleted file mode 100644
index ed8019a..0000000
--- a/modules/integration/cdi/src/main/java/org/apache/tamaya/integration/cdi/CDIConfiguredMethod.java
+++ /dev/null
@@ -1,77 +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.integration.cdi;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.inject.spi.ConfiguredMethod;
-
-import javax.enterprise.inject.spi.InjectionPoint;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * Implementation of a configured methods for CDI module.
- */
-public class CDIConfiguredMethod implements ConfiguredMethod{
-
- private final Method method;
- private List<String> keys = new ArrayList<>();
-
- CDIConfiguredMethod(InjectionPoint injectionPoint, List<String> keys){
- this.method = (Method)injectionPoint.getMember();
- this.keys.addAll(keys);
- this.keys = Collections.unmodifiableList(this.keys);
- }
-
- @Override
- public Collection<String> getConfiguredKeys() {
- return keys;
- }
-
- @Override
- public Class<?>[] getParameterTypes() {
- return method.getParameterTypes();
- }
-
- @Override
- public Method getAnnotatedMethod() {
- return method;
- }
-
- @Override
- public String getName() {
- return method.getName();
- }
-
- @Override
- public String getSignature() {
- return null;
- }
-
- @Override
- public void configure(Object instance, Configuration config) {
- throw new UnsupportedOperationException("Use CDI annotations for configuration injection.");
- }
-
- @Override
- public String toString() {
- return "CDIConfiguredMethod["+getSignature()+']';
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi/src/main/java/org/apache/tamaya/integration/cdi/CDIConfiguredType.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi/src/main/java/org/apache/tamaya/integration/cdi/CDIConfiguredType.java b/modules/integration/cdi/src/main/java/org/apache/tamaya/integration/cdi/CDIConfiguredType.java
deleted file mode 100644
index c677065..0000000
--- a/modules/integration/cdi/src/main/java/org/apache/tamaya/integration/cdi/CDIConfiguredType.java
+++ /dev/null
@@ -1,94 +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.integration.cdi;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.inject.spi.ConfiguredField;
-import org.apache.tamaya.inject.spi.ConfiguredMethod;
-import org.apache.tamaya.inject.spi.ConfiguredType;
-
-import javax.enterprise.inject.spi.InjectionPoint;
-import java.lang.reflect.Field;
-import java.lang.reflect.Member;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Objects;
-
-/**
- * Event published for items configured by CDI extensions. This is for example used by the documentation module
- * to automatically track the configuration endpoints for documentation.
- */
-class CDIConfiguredType implements ConfiguredType{
-
- private final Class<?> type;
- private final List<CDIConfiguredMethod> methods = new ArrayList<>();
- private final List<CDIConfiguredField> fields = new ArrayList<>();
-
- public CDIConfiguredType(Class<?> type){
- this.type = Objects.requireNonNull(type);
- }
-
- @Override
- public Class getType() {
- return type;
- }
-
- @Override
- public String getName() {
- return type.getName();
- }
-
- @Override
- public Collection<ConfiguredField> getConfiguredFields() {
- return null;
- }
-
- @Override
- public Collection<ConfiguredMethod> getConfiguredMethods() {
- return null;
- }
-
- @Override
- public void configure(Object instance, Configuration config) {
- throw new UnsupportedOperationException("Use CDI annotations for configuration injection.");
- }
-
- /**
- * Used to build up during injection point processing.
- * @param injectionPoint the CDI injection ppint, not null.
- * @param keys the possible config keys, in order of precedence, not null.
- */
- void addConfiguredMember(InjectionPoint injectionPoint, List<String> keys) {
- Member member = injectionPoint.getMember();
- if(member instanceof Field){
- this.fields.add(new CDIConfiguredField(injectionPoint, keys));
- } else if(member instanceof Method){
- this.methods.add(new CDIConfiguredMethod(injectionPoint, keys));
- }
- }
-
- @Override
- public String toString() {
- return "CDIConfiguredType{" +
- "type=" + type +
- ", methods=" + methods +
- ", fields=" + fields +
- '}';
- }
-}
[23/24] incubator-tamaya git commit: Removed all modules from the
main repository. They will be reborn in separate ASF repository.
Posted by pl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/builder/src/test/java/org/apache/tamaya/builder/ConfigurationBuilderTest.java
----------------------------------------------------------------------
diff --git a/modules/builder/src/test/java/org/apache/tamaya/builder/ConfigurationBuilderTest.java b/modules/builder/src/test/java/org/apache/tamaya/builder/ConfigurationBuilderTest.java
deleted file mode 100644
index 07a72c5..0000000
--- a/modules/builder/src/test/java/org/apache/tamaya/builder/ConfigurationBuilderTest.java
+++ /dev/null
@@ -1,907 +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.builder;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.builder.util.types.CustomTypeA;
-import org.apache.tamaya.builder.util.types.CustomTypeB;
-import org.apache.tamaya.builder.util.types.CustomTypeC;
-import org.apache.tamaya.spi.*;
-import org.hamcrest.CoreMatchers;
-import org.hamcrest.Matchers;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.mockito.Mockito;
-
-
-import java.io.IOException;
-import java.net.URL;
-
-import static java.util.Arrays.asList;
-import static org.apache.tamaya.builder.util.mockito.NotMockedAnswer.NOT_MOCKED_ANSWER;
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.CALLS_REAL_METHODS;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-
-
-public class ConfigurationBuilderTest {
-
- @Test
- public void buildCanBuildEmptyConfiguration() {
- ConfigurationBuilder builder = new ConfigurationBuilder();
-
- Configuration config = builder.build();
-
- assertThat(config, notNullValue());
- }
-
- @Test(expected = IllegalStateException.class)
- public void buildCanBeCalledOnlyOnce() {
- ConfigurationBuilder builder = new ConfigurationBuilder();
-
- builder.build();
- builder.build();
- }
-
- /*********************************************************************
- * Tests for adding P r o p e r t y S o u r c e s
- */
-
- @Test(expected = NullPointerException.class)
- public void addPropertySourcesDoesNotAcceptNullValue() {
- ConfigurationBuilder builder = new ConfigurationBuilder();
-
- builder.addPropertySources((PropertySource[])null);
- }
-
- @Test(expected = IllegalStateException.class)
- public void propertySourceCanNotBeAddedAfterBuildingTheConfiguration() {
- PropertySource first = mock(PropertySource.class, NOT_MOCKED_ANSWER);
-
- doReturn("first").when(first).getName();
- doReturn(100).when(first).getOrdinal();
-
- ConfigurationBuilder builder = new ConfigurationBuilder().addPropertySources(first);
-
- builder.build();
-
- PropertySource second = mock(PropertySource.class, NOT_MOCKED_ANSWER);
-
- doReturn("second").when(first).getName();
-
- builder.addPropertySources(second);
- }
-
- @Test
- public void singleAddedPropertySourceIsUsed() {
- PropertySource source = mock(PropertySource.class, NOT_MOCKED_ANSWER);
-
- doReturn("one").when(source).getName();
- doReturn(PropertyValue.of("keyOfA","a", "test")).when(source).get("keyOfA");
- doReturn(100).when(source).getOrdinal();
-
- ConfigurationBuilder builder = new ConfigurationBuilder().addPropertySources(source);
-
- Configuration config = builder.build();
-
- String valueOfA = config.get("keyOfA");
-
- assertThat(valueOfA, notNullValue());
- assertThat(valueOfA, equalTo("a"));
- }
-
- @Test
- public void twoAddedPropertySourcesAreUsed() {
- PropertySource sourceOne = mock(PropertySource.class, NOT_MOCKED_ANSWER);
-
- doReturn("one").when(sourceOne).getName();
- doReturn(PropertyValue.of("keyOfA","b", "test")).when(sourceOne).get("keyOfA");
- doReturn(10).when(sourceOne).getOrdinal();
-
- PropertySource sourceTwo = mock(PropertySource.class, NOT_MOCKED_ANSWER);
- doReturn("two").when(sourceTwo).getName();
- doReturn(PropertyValue.of("keyOfA","a", "test")).when(sourceTwo).get("keyOfA");
- doReturn(10).when(sourceTwo).getOrdinal();
-
- ConfigurationBuilder builder = new ConfigurationBuilder().addPropertySources(sourceOne)
- .addPropertySources(sourceTwo);
-
- Configuration config = builder.build();
-
- String valueOfA = config.get("keyOfA");
-
- assertThat(valueOfA, notNullValue());
- assertThat(valueOfA, equalTo("a"));
- }
-
- @Ignore
- @Test(expected = ConfigException.class)
- public void twoPropertySourcesSamePrioritySameKey() {
- PropertySource sourceOne = mock(PropertySource.class, NOT_MOCKED_ANSWER);
-
- doReturn("one").when(sourceOne).getName();
- doReturn("b").when(sourceOne).get("keyOfA");
- doReturn(20).when(sourceOne).getOrdinal();
-
- PropertySource sourceTwo = mock(PropertySource.class, NOT_MOCKED_ANSWER);
- doReturn("two").when(sourceTwo).getName();
- doReturn("a").when(sourceTwo).get("keyOfA");
- doReturn(20).when(sourceTwo).getOrdinal();
-
- ConfigurationBuilder builder = new ConfigurationBuilder().addPropertySources(sourceOne)
- .addPropertySources(sourceTwo);
-
- Configuration config = builder.build();
-
- config.get("keyOfA");
- }
-
- @Test
- public void twoPropertySourcesDiffPrioritySameKeyLowerAddedFirst() {
- PropertySource sourceOne = mock(PropertySource.class, NOT_MOCKED_ANSWER);
-
- doReturn("one").when(sourceOne).getName();
- doReturn(PropertyValue.of("keyOfA","b", "test")).when(sourceOne).get("keyOfA");
- doReturn(10).when(sourceOne).getOrdinal();
-
- PropertySource sourceTwo = mock(PropertySource.class, NOT_MOCKED_ANSWER);
- doReturn("two").when(sourceTwo).getName();
- doReturn(PropertyValue.of("keyOfA","a", "test")).when(sourceTwo).get("keyOfA");
- doReturn(20).when(sourceTwo).getOrdinal();
-
- ConfigurationBuilder builder = new ConfigurationBuilder().addPropertySources(sourceOne)
- .addPropertySources(sourceTwo);
-
- Configuration config = builder.build();
-
- String valueOfA = config.get("keyOfA");
-
- assertThat(valueOfA, notNullValue());
- assertThat(valueOfA, equalTo("a"));
- }
-
- @Test
- public void twoPropertySourcesDiffPrioritySameKeyHigherAddedFirst() {
- PropertySource sourceOne = mock(PropertySource.class, NOT_MOCKED_ANSWER);
-
- doReturn("one").when(sourceOne).getName();
- doReturn(PropertyValue.of("keyOfA","b", "test")).when(sourceOne).get("keyOfA");
- doReturn(30).when(sourceOne).getOrdinal();
-
- PropertySource sourceTwo = mock(PropertySource.class, NOT_MOCKED_ANSWER);
- doReturn("two").when(sourceTwo).getName();
- doReturn(PropertyValue.of("keyOfA","a", "test")).when(sourceTwo).get("keyOfA");
- doReturn(20).when(sourceTwo).getOrdinal();
-
- ConfigurationBuilder builder = new ConfigurationBuilder().addPropertySources(sourceOne, sourceTwo);
-
- Configuration config = builder.build();
-
- String valueOfA = config.get("keyOfA");
-
- assertThat(valueOfA, notNullValue());
- assertThat(valueOfA, equalTo("b"));
- }
-
- @Test
- public void consecutiveCallsToAddPropertySourceArePossible() {
- PropertySource sourceOne = mock(PropertySource.class, NOT_MOCKED_ANSWER);
-
- doReturn("one").when(sourceOne).getName();
- doReturn(null).when(sourceOne).get(anyString());
- doReturn(PropertyValue.of("b","b", "test")).when(sourceOne).get("b");
- doReturn(30).when(sourceOne).getOrdinal();
-
- PropertySource sourceTwo = mock(PropertySource.class, NOT_MOCKED_ANSWER);
- doReturn("two").when(sourceTwo).getName();
- doReturn(null).when(sourceTwo).get(anyString());
- doReturn(PropertyValue.of("a","a", "test")).when(sourceTwo).get("a");
- doReturn(30).when(sourceTwo).getOrdinal();
-
- ConfigurationBuilder builder = new ConfigurationBuilder().addPropertySources(sourceOne)
- .addPropertySources(sourceTwo);
-
- Configuration config = builder.build();
-
- assertThat(config.get("b"), equalTo("b"));
- assertThat(config.get("a"), equalTo("a"));
- }
-
- @Test
- public void addMultiplePropertySourcesWhereOneIsNull() {
- PropertySource sourceOne = mock(PropertySource.class, NOT_MOCKED_ANSWER);
-
- doReturn("one").when(sourceOne).getName();
- doReturn(null).when(sourceOne).get(anyString());
- doReturn(PropertyValue.of("b","b", "test")).when(sourceOne).get("b");
- doReturn(30).when(sourceOne).getOrdinal();
-
- PropertySource sourceTwo = mock(PropertySource.class, NOT_MOCKED_ANSWER);
- doReturn("two").when(sourceTwo).getName();
- doReturn(null).when(sourceTwo).get(anyString());
- doReturn(PropertyValue.of("a","a", "test")).when(sourceTwo).get("a");
- doReturn(30).when(sourceTwo).getOrdinal();
-
- ConfigurationBuilder builder = new ConfigurationBuilder().addPropertySources(sourceOne, null, sourceTwo);
-
- Configuration config = builder.build();
-
- assertThat(config.get("b"), equalTo("b"));
- assertThat(config.get("a"), equalTo("a"));
- }
-
- /**
- * ******************************************************************
- * Tests for adding P r o p e r t y C o n v e r t e r
- */
-
- @Test(expected = NullPointerException.class)
- public void canNotAddNullPropertyConverter() {
- ConfigurationBuilder builder = new ConfigurationBuilder();
-
- builder.addPropertyConverter(TypeLiteral.of(CustomTypeA.class), null);
- }
-
- @Test(expected = NullPointerException.class)
- public void canNotAddNullTypeLiteralButPropertyConverter() {
- ConfigurationBuilder builder = new ConfigurationBuilder();
- builder.addPropertyConverter((TypeLiteral)null,
- new PropertyConverter() {
- @Override
- public CustomTypeA convert(final String prop, ConversionContext context) {
- return new CustomTypeA(prop, prop);
- }
- });
- }
-
- @Test
- public void addedPropertyConverterWithTypeLiteralIsUsedByConfiguration() {
- PropertySource source = mock(PropertySource.class, NOT_MOCKED_ANSWER);
-
- doReturn("source").when(source).getName();
- doReturn(PropertyValue.of("key","A", "test")).when(source).get("key");
- doReturn(100).when(source).getOrdinal();
-
- ConfigurationBuilder builder = new ConfigurationBuilder();
-
- builder.addPropertyConverter(TypeLiteral.of(CustomTypeA.class),
- new PropertyConverter() {
- @Override
- public CustomTypeA convert(final String prop, ConversionContext context) {
- return new CustomTypeA(prop, prop);
- }
- });
- builder.addPropertySources(source);
-
- Configuration config = builder.build();
-
- Object resultRaw = config.get("key", CustomTypeA.class);
-
- assertThat(resultRaw, CoreMatchers.notNullValue());
-
- CustomTypeA result = (CustomTypeA)resultRaw;
-
- assertThat(result.getName(), equalTo("AA"));
- }
-
- @Test
- public void addedPropertyConverterWithClassIsUsedByConfiguration() {
- PropertySource source = mock(PropertySource.class, NOT_MOCKED_ANSWER);
-
- doReturn("source").when(source).getName();
- doReturn(PropertyValue.of("key","A", "test")).when(source).get("key");
- doReturn(100).when(source).getOrdinal();
-
- ConfigurationBuilder builder = new ConfigurationBuilder();
-
- builder.addPropertyConverter(TypeLiteral.of(CustomTypeA.class),
- new PropertyConverter() {
- @Override
- public CustomTypeA convert(final String prop, ConversionContext context) {
- return new CustomTypeA(prop, prop);
- }
- });
- builder.addPropertySources(source);
-
- Configuration config = builder.build();
-
- Object resultRaw = config.get("key", CustomTypeA.class);
-
- assertThat(resultRaw, CoreMatchers.notNullValue());
-
- CustomTypeA result = (CustomTypeA)resultRaw;
-
- assertThat(result.getName(), equalTo("AA"));
- }
-
- @Test
- public void canGetAndConvertPropertyViaOfMethod() {
- PropertySource source = mock(PropertySource.class, NOT_MOCKED_ANSWER);
-
- doReturn("source").when(source).getName();
- doReturn(PropertyValue.of("key","A", "test")).when(source).get("key");
- doReturn(100).when(source).getOrdinal();
-
- ConfigurationBuilder builder = new ConfigurationBuilder();
-
- builder.addPropertySources(source);
-
- Configuration config = builder.build();
-
- Object resultRaw = config.get("key", CustomTypeB.class);
-
- assertThat(resultRaw, CoreMatchers.notNullValue());
-
- CustomTypeB result = (CustomTypeB)resultRaw;
-
- assertThat(result.getName(), equalTo("A"));
- }
-
- /*********************************************************************
- * Tests for adding P r o p e r t y F i l t e r
- */
-
- @Test(expected = NullPointerException.class)
- public void canNotAddNullAsPropertyFilter() {
- ConfigurationBuilder builder = new ConfigurationBuilder();
- builder.addPropertyFilters((PropertyFilter[])null);
- }
-
- @Test
- public void canAddNonSPIPropertyFilter() {
- PropertySource source = mock(PropertySource.class, NOT_MOCKED_ANSWER);
-
- doReturn(PropertyValue.of("key","M", "test")).when(source).get("key");
- doReturn("source").when(source).getName();
-
- ConfigurationBuilder builder = new ConfigurationBuilder();
-
- Configuration config = builder.addPropertySources(source)
- .addPropertyFilters(new TestANonSPIPropertyFilter())
- .build();
-
- String property = config.get("key");
-
- assertThat(property, CoreMatchers.notNullValue());
- assertThat(property, CoreMatchers.containsString("ABC"));
- }
-
- @Test
- public void canAddNonSPIPropertyFiltersViaConsecutiveCalls() {
- PropertySource source = mock(PropertySource.class, NOT_MOCKED_ANSWER);
-
- doReturn(PropertyValue.of("key","M", "test")).when(source).get("key");
- doReturn("source").when(source).getName();
-
- ConfigurationBuilder builder = new ConfigurationBuilder();
-
- Configuration config = builder.addPropertySources(source)
- .addPropertyFilters(new TestANonSPIPropertyFilter())
- .addPropertyFilters(new TestBNonSPIPropertyFilter())
- .build();
-
- String property = config.get("key");
-
- assertThat(property, CoreMatchers.notNullValue());
- assertThat(property, CoreMatchers.containsString("ABC"));
- assertThat(property, CoreMatchers.containsString("XYZ"));
- }
-
- @Test
- public void canAddMultipleNonSPIPropertyFiltersWhileOneIsNull() {
- PropertySource source = mock(PropertySource.class, NOT_MOCKED_ANSWER);
-
- doReturn(PropertyValue.of("key","M", "test")).when(source).get("key");
- doReturn("source").when(source).getName();
-
- ConfigurationBuilder builder = new ConfigurationBuilder();
-
- Configuration config = builder.addPropertySources(source)
- .addPropertyFilters(new TestANonSPIPropertyFilter(),
- null,
- new TestBNonSPIPropertyFilter())
- .build();
-
- String property = config.get("key");
-
- assertThat(property, CoreMatchers.notNullValue());
- assertThat(property, CoreMatchers.containsString("ABC"));
- assertThat(property, CoreMatchers.containsString("XYZ"));
- }
-
- @Test
- public void overhandedNullPropertyFilterIsSafelyHandled() {
- PropertySource source = mock(PropertySource.class, NOT_MOCKED_ANSWER);
-
- doReturn(PropertyValue.of("key","M", "test")).when(source).get("key");
- doReturn("source").when(source).getName();
-
- ConfigurationBuilder builder = new ConfigurationBuilder();
-
- Configuration config = builder.addPropertySources(source)
- .addPropertyFilters((PropertyFilter)null) // The cast is needed!
- .addPropertyFilters(new TestBNonSPIPropertyFilter())
- .build();
-
- String property = config.get("key");
-
- assertThat(property, CoreMatchers.notNullValue());
- assertThat(property, CoreMatchers.containsString("XYZ"));
- }
-
- @Test
- public void canAddMultipleNonSPIPropertyFilter() {
- PropertySource source = mock(PropertySource.class, NOT_MOCKED_ANSWER);
-
- doReturn(PropertyValue.of("key","M", "test")).when(source).get("key");
- doReturn("source").when(source).getName();
-
- ConfigurationBuilder builder = new ConfigurationBuilder();
-
- Configuration config = builder.addPropertySources(source)
- .addPropertyFilters(new TestANonSPIPropertyFilter(),
- new TestBNonSPIPropertyFilter())
- .build();
-
- String property = config.get("key");
-
- assertThat(property, CoreMatchers.notNullValue());
- assertThat(property, CoreMatchers.containsString("ABC"));
- assertThat(property, CoreMatchers.containsString("XYZ"));
- }
-
- /*********************************************************************
- * Tests for adding
- * P r o p e r t y S o u r c e P r o v i d e r s
- */
-
- @Test
- public void handlesSafelyPropertyProviderReturningNullInsteadOfPropertySource() {
- PropertySourceProvider nullReturning = mock(PropertySourceProvider.class, NOT_MOCKED_ANSWER);
-
- doReturn(asList((PropertySource)null)).when(nullReturning).getPropertySources();
-
- ConfigurationBuilder builder = new ConfigurationBuilder();
-
- Configuration config = builder.addPropertySourceProviders(new TestPropertySourceProviderB(),
- nullReturning,
- new TestPropertySourceProvider())
- .build();
-
- assertThat(config.get("tpsp_a"), Matchers.equalTo("A"));
- assertThat(config.get("tpsp_b"), Matchers.equalTo("B"));
- assertThat(config.get("tpsp_x"), Matchers.equalTo("X"));
- assertThat(config.get("tpsp_y"), Matchers.equalTo("Y"));
-
- verify(nullReturning).getPropertySources();
- }
-
- @Test(expected = NullPointerException.class)
- public void cannotAddNullAsPropertyProvider() {
- new ConfigurationBuilder().addPropertySourceProviders((PropertySourceProvider[])null);
- }
-
- @Test
- public void canAddMultipleNonSPIPropertySourceProviders() {
- ConfigurationBuilder builder = new ConfigurationBuilder();
-
- Configuration config = builder.addPropertySourceProviders(new TestPropertySourceProviderB(),
- new TestPropertySourceProvider())
- .build();
-
- assertThat(config.get("tpsp_a"), Matchers.equalTo("A"));
- assertThat(config.get("tpsp_b"), Matchers.equalTo("B"));
- assertThat(config.get("tpsp_x"), Matchers.equalTo("X"));
- assertThat(config.get("tpsp_y"), Matchers.equalTo("Y"));
- }
-
- @Test
- public void canAddMultipleNonSPIPropertySourceProvidersWhileOfOfThemIsNull() {
- ConfigurationBuilder builder = new ConfigurationBuilder();
-
- Configuration config = builder.addPropertySourceProviders(new TestPropertySourceProviderB(), null,
- new TestPropertySourceProvider())
- .build();
-
- assertThat(config.get("tpsp_a"), Matchers.equalTo("A"));
- assertThat(config.get("tpsp_b"), Matchers.equalTo("B"));
- assertThat(config.get("tpsp_x"), Matchers.equalTo("X"));
- assertThat(config.get("tpsp_y"), Matchers.equalTo("Y"));
- }
-
-
- /*
- * Tests for adding
- * P r o p e r t y V a l u e C o m b i n a t i o n P o l i c y
- */
-
- // @todo TAYAMA-60 Write more tests
-
- /*********************************************************************
- * Tests for enabling and disabling of automatic loading of
- * P r o p e r t y S o u r c e s
- */
-
- @Test
- public void enablingOfProvidedPropertySourceServiceProvidersIsOk() {
- ConfigurationBuilder builder = new ConfigurationBuilder();
-
- builder.disableProvidedPropertyConverters()
- .enableProvidedPropertyConverters();
-
- assertThat(builder.isPropertyConverterLoadingEnabled(), is(true));
- }
-
- @Test
- public void disablingOfProvidedPropertySourceServiceProvidersIsOk() {
- ConfigurationBuilder builder = new ConfigurationBuilder();
-
- builder.enableProvidedPropertyConverters()
- .disableProvidedPropertyConverters();
-
- assertThat(builder.isPropertyConverterLoadingEnabled(), is(false));
- }
-
- @Test(expected = ConfigException.class)
- public void loadingOrPropertyConvertersCanBeDisabled() {
- PropertySource source = mock(PropertySource.class, NOT_MOCKED_ANSWER);
-
- doReturn("source").when(source).getName();
- doReturn(PropertyValue.of("key","A", "test")).when(source).get("key");
- doReturn(100).when(source).getOrdinal();
-
- ConfigurationBuilder builder = new ConfigurationBuilder().addPropertySources(source)
- .enableProvidedPropertyConverters()
- .disableProvidedPropertyConverters();
-
- Configuration config = builder.build();
-
- config.get("key", CustomTypeC.class);
- }
-
- @Test
- public void loadingOfPropertyConvertersCanBeEnabled() {
- PropertySource source = mock(PropertySource.class, NOT_MOCKED_ANSWER);
-
- doReturn("source").when(source).getName();
- doReturn(PropertyValue.of("key","A", "test")).when(source).get("key");
- doReturn(100).when(source).getOrdinal();
-
- ConfigurationBuilder builder = new ConfigurationBuilder().addPropertySources(source)
- .disableProvidedPropertyConverters()
- .enableProvidedPropertyConverters();
-
- Configuration config = builder.build();
-
- CustomTypeC result = config.get("key", CustomTypeC.class);
-
- assertThat(result, notNullValue());
- assertThat(result.getValue(), equalTo("A"));
- }
-
- /*********************************************************************
- * Tests for enabling and disabling of automatic loading of
- * P r o p e r t y S o u r c e s
- */
-
- @Test
- public void enablingOfPropertySourceLoadingIsOk() {
- ConfigurationBuilder builder = new ConfigurationBuilder();
-
- builder.disableProvidedPropertySources()
- .enableProvidedPropertySources();
-
- assertThat(builder.isPropertySourcesLoadingEnabled(), is(true));
- }
-
- @Test
- public void disablingPropertySourceLoadingIsOk() {
- ConfigurationBuilder builder = new ConfigurationBuilder();
-
- builder.enableProvidedPropertySources()
- .disableProvidedPropertySources();
-
- assertThat(builder.isPropertySourcesLoadingEnabled(), is(false));
- }
-
- @Test
- public void loadingOfPropertySourcesCanBeEnabled() {
- ConfigurationBuilder builder = new ConfigurationBuilder();
-
- Configuration config = builder.disableProvidedPropertySources()
- .enableProvidedPropertySources()
- .build();
-
-
- assertThat(builder.isPropertySourcesLoadingEnabled(), is(true));
- assertThat(config.get("tps_a"), Matchers.equalTo("A"));
- }
-
- @Test
- public void loadingOfPropertySourcesCanBeDisabled() {
- ConfigurationBuilder builder = new ConfigurationBuilder();
-
- Configuration config = builder.enableProvidedPropertySources()
- .disableProvidedPropertySources()
- .build();
-
-
- assertThat(builder.isPropertySourcesLoadingEnabled(), is(false));
- assertThat(config.get("tps_c"), Matchers.nullValue());
- }
-
- /*********************************************************************
- * Tests for enabling and disabling of automatic loading of
- * P r o p e r t y F i l t e r s
- */
-
- @Test
- public void enablingOfPropertyFiltersLoadingIsOk() {
- PropertySource source = mock(PropertySource.class, NOT_MOCKED_ANSWER);
-
- doReturn("source").when(source).getName();
- doReturn(PropertyValue.of("key","A", "test")).when(source).get("key");
- doReturn(100).when(source).getOrdinal();
-
- ConfigurationBuilder builder = new ConfigurationBuilder();
-
- Configuration config = builder.disableProvidedPropertyFilters()
- .enabledProvidedPropertyFilters()
- .addPropertySources(source)
- .build();
-
- String property = config.get("key");
-
- assertThat(property, CoreMatchers.notNullValue());
- assertThat(property, Matchers.equalTo("AinBerlin"));
- }
-
- @Test
- public void disablingOfPropertyFiltersLoadingIsOk() {
- ConfigurationBuilder builder = new ConfigurationBuilder();
-
- builder.enabledProvidedPropertyFilters()
- .disableProvidedPropertyFilters();
-
- assertThat(builder.isPropertyFilterLoadingEnabled(), is(false));
- }
-
- @Test
- public void loadingOfPropertyFiltersCanBeDisabled() {
- ConfigurationBuilder builder = new ConfigurationBuilder();
-
- builder.disableProvidedPropertyFilters()
- .enabledProvidedPropertyFilters();
-
- assertThat(builder.isPropertyFilterLoadingEnabled(), is(true));
- }
-
- @Test
- public void loadingOfPropertyFiltersCanBeEnabled() {
- PropertySource source = mock(PropertySource.class, NOT_MOCKED_ANSWER);
-
- doReturn("source").when(source).getName();
- doReturn(PropertyValue.of("key","A", "test")).when(source).get("key");
- doReturn(100).when(source).getOrdinal();
-
- ConfigurationBuilder builder = new ConfigurationBuilder();
-
- Configuration config = builder.enabledProvidedPropertyFilters()
- .disableProvidedPropertyFilters()
- .addPropertySources(source)
- .build();
-
- String property = config.get("key");
-
- assertThat(property, CoreMatchers.notNullValue());
- assertThat(property, Matchers.equalTo("A"));
- }
-
- /*********************************************************************
- * Tests for enabling and disabling of automatic loading of
- * P r o p e r t y S o u r c e P r o v i d e r s
- */
-
- @Test
- public void disablingOfPropertySourceProvidersIsOk() {
- ConfigurationBuilder builder = new ConfigurationBuilder();
-
- builder.enableProvidedPropertySourceProviders()
- .disableProvidedPropertySourceProviders()
- .build();
-
- assertThat(builder.isPropertySourceProvidersLoadingEnabled(), is(false));
- }
-
- @Test
- public void enablingOfPropertySourceProvidersIsOk() {
-
- ConfigurationBuilder builder = new ConfigurationBuilder();
-
- builder.disableProvidedPropertySourceProviders()
- .enableProvidedPropertySourceProviders()
- .build();
-
- assertThat(builder.isPropertySourceProvidersLoadingEnabled(), is(true));
- }
-
- @Test
- public void loadingOfPropertySourceProvidersCanBeEnabled() {
- ConfigurationBuilder builder = new ConfigurationBuilder();
-
- Configuration config = builder.disableProvidedPropertySourceProviders()
- .enableProvidedPropertySourceProviders()
- .build();
-
- assertThat(builder.isPropertySourceProvidersLoadingEnabled(), is(true));
- assertThat(config.get("tpsp_x"), Matchers.equalTo("X"));
- assertThat(config.get("tpsp_y"), Matchers.equalTo("Y"));
- }
-
- @Test
- public void loadingOfPropertySourceProvidersCanBeDisabled() {
- ConfigurationBuilder builder = new ConfigurationBuilder();
-
- Configuration config = builder.enableProvidedPropertySourceProviders()
- .disableProvidedPropertySourceProviders()
- .build();
-
- assertThat(builder.isPropertySourceProvidersLoadingEnabled(), is(false));
- assertThat(config.get("tpsp_x"), nullValue());
- assertThat(config.get("tpsp_x"), nullValue());
- }
-
- @Test(expected = ConfigException.class)
- public void ioExceptionIsTurnedInConfigExceptionWhenLoadingResourceViaURL() throws Exception {
- URL resource = this.getClass().getResource("/configfiles/json/simple.json");
-
- assertThat(resource, CoreMatchers.notNullValue());
-
- ConfigurationBuilder builder = mock(ConfigurationBuilder.class, CALLS_REAL_METHODS);
-
- doThrow(IOException.class).when(builder).getConfigurationDataFromURL(Mockito.eq(resource));
-
- builder.addPropertySource(resource).build();
- }
-
- /*********************************************************************
- * Tests for loading resources via URL (as String)
- */
-
- @Test(expected = ConfigException.class)
- public void tryToLoadOneUnsupportedPropertySourceViaStringURL() {
- URL resource = this.getClass().getResource("/configfiles/other/simple.oml");
-
- assertThat(resource, CoreMatchers.notNullValue());
-
- ConfigurationBuilder builder = new ConfigurationBuilder();
-
- builder.addPropertySources(resource.toString()).build();
- }
-
- @Test
- public void loadOneJSONPropertySourceViaStringURL() {
- URL resource = this.getClass().getResource("/configfiles/json/simple.json");
-
- assertThat(resource, CoreMatchers.notNullValue());
-
- ConfigurationBuilder builder = new ConfigurationBuilder();
-
- Configuration config = builder.addPropertySources(resource.toString())
- .build();
-
- assertThat(config, CoreMatchers.notNullValue());
- assertThat(config.get("a"), equalTo("A"));
- assertThat(config.get("b"), equalTo("B"));
- }
-
- @Test
- public void loadMultipleJSONPropertySourceViaStringURL() {
- URL first = this.getClass().getResource("/configfiles/json/first.json");
- URL second = this.getClass().getResource("/configfiles/json/second.json");
- URL third = this.getClass().getResource("/configfiles/json/third.json");
-
- assertThat(first, CoreMatchers.notNullValue());
- assertThat(second, CoreMatchers.notNullValue());
- assertThat(third, CoreMatchers.notNullValue());
-
- ConfigurationBuilder builder = new ConfigurationBuilder();
-
- Configuration config = builder.addPropertySources(first.toString(), second.toString(),
- null, third.toString())
- .build();
-
- assertThat(config, CoreMatchers.notNullValue());
-
- // from first.json
- assertThat(config.get("d"), equalTo("D"));
- assertThat(config.get("e"), equalTo("E"));
-
- // from second.json
- assertThat(config.get("m"), equalTo("M"));
- assertThat(config.get("n"), equalTo("N"));
-
- // from thrid.json
- assertThat(config.get("p"), equalTo("P"));
- assertThat(config.get("q"), equalTo("Q"));
- }
-
- /**
- * ******************************************************************
- * Tests for loading resources via URL (as URL object)
- */
-
- @Test
- public void loadOneJSONPropertySourceViaURL() {
- URL resource = this.getClass().getResource("/configfiles/json/simple.json");
-
- assertThat(resource, CoreMatchers.notNullValue());
-
- ConfigurationBuilder builder = new ConfigurationBuilder();
-
- Configuration config = builder.addPropertySource(resource)
- .build();
-
- assertThat(config, CoreMatchers.notNullValue());
- assertThat(config.get("a"), equalTo("A"));
- assertThat(config.get("b"), equalTo("B"));
- }
-
- @Test
- public void loadMultipleJSONPropertySourceViaURL() {
- URL first = this.getClass().getResource("/configfiles/json/first.json");
- URL second = this.getClass().getResource("/configfiles/json/second.json");
- URL third = this.getClass().getResource("/configfiles/json/third.json");
-
- assertThat(first, CoreMatchers.notNullValue());
- assertThat(second, CoreMatchers.notNullValue());
- assertThat(third, CoreMatchers.notNullValue());
-
- ConfigurationBuilder builder = new ConfigurationBuilder();
-
- Configuration config = builder.addPropertySources(first, second,
- null, third)
- .build();
-
- assertThat(config, CoreMatchers.notNullValue());
-
- // from first.json
- assertThat(config.get("d"), equalTo("D"));
- assertThat(config.get("e"), equalTo("E"));
-
- // from second.json
- assertThat(config.get("m"), equalTo("M"));
- assertThat(config.get("n"), equalTo("N"));
-
- // from thrid.json
- assertThat(config.get("p"), equalTo("P"));
- assertThat(config.get("q"), equalTo("Q"));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/builder/src/test/java/org/apache/tamaya/builder/TestANonSPIPropertyFilter.java
----------------------------------------------------------------------
diff --git a/modules/builder/src/test/java/org/apache/tamaya/builder/TestANonSPIPropertyFilter.java b/modules/builder/src/test/java/org/apache/tamaya/builder/TestANonSPIPropertyFilter.java
deleted file mode 100644
index 896e0bc..0000000
--- a/modules/builder/src/test/java/org/apache/tamaya/builder/TestANonSPIPropertyFilter.java
+++ /dev/null
@@ -1,35 +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.builder;
-
-import org.apache.tamaya.spi.FilterContext;
-import org.apache.tamaya.spi.PropertyFilter;
-
-public class TestANonSPIPropertyFilter implements PropertyFilter {
- @Override
- public String filterProperty(String value, FilterContext context) {
- String result = value;
-
- if (!result.contains(("ABC"))) {
- result = value + "ABC";
- }
-
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/builder/src/test/java/org/apache/tamaya/builder/TestBNonSPIPropertyFilter.java
----------------------------------------------------------------------
diff --git a/modules/builder/src/test/java/org/apache/tamaya/builder/TestBNonSPIPropertyFilter.java b/modules/builder/src/test/java/org/apache/tamaya/builder/TestBNonSPIPropertyFilter.java
deleted file mode 100644
index a9c0ac2..0000000
--- a/modules/builder/src/test/java/org/apache/tamaya/builder/TestBNonSPIPropertyFilter.java
+++ /dev/null
@@ -1,35 +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.builder;
-
-import org.apache.tamaya.spi.FilterContext;
-import org.apache.tamaya.spi.PropertyFilter;
-
-public class TestBNonSPIPropertyFilter implements PropertyFilter {
- @Override
- public String filterProperty(String value, FilterContext context) {
- String result = value;
-
- if (!result.contains(("XYZ"))) {
- result = value + "XYZ";
- }
-
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/builder/src/test/java/org/apache/tamaya/builder/TestPropertyFilter.java
----------------------------------------------------------------------
diff --git a/modules/builder/src/test/java/org/apache/tamaya/builder/TestPropertyFilter.java b/modules/builder/src/test/java/org/apache/tamaya/builder/TestPropertyFilter.java
deleted file mode 100644
index e22fca8..0000000
--- a/modules/builder/src/test/java/org/apache/tamaya/builder/TestPropertyFilter.java
+++ /dev/null
@@ -1,35 +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.builder;
-
-import org.apache.tamaya.spi.FilterContext;
-import org.apache.tamaya.spi.PropertyFilter;
-
-public class TestPropertyFilter implements PropertyFilter {
- @Override
- public String filterProperty(String value, FilterContext context) {
- String result = value;
-
- if (!result.contains(("inBerlin"))) {
- result = value + "inBerlin";
- }
-
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/builder/src/test/java/org/apache/tamaya/builder/TestPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/builder/src/test/java/org/apache/tamaya/builder/TestPropertySource.java b/modules/builder/src/test/java/org/apache/tamaya/builder/TestPropertySource.java
deleted file mode 100644
index f1ebfea..0000000
--- a/modules/builder/src/test/java/org/apache/tamaya/builder/TestPropertySource.java
+++ /dev/null
@@ -1,59 +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.builder;
-
-import org.apache.tamaya.core.propertysource.BasePropertySource;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-
-import java.util.Collections;
-import java.util.Hashtable;
-import java.util.Map;
-
-public class TestPropertySource extends BasePropertySource
-{
- private Map<String, String> properties;
-
- {
- properties = new Hashtable<>(3);
- properties.put("tps_a", "A");
- properties.put("tps_b", "B");
- properties.put("tps_c", "C");
- }
-
- @Override
- public int getOrdinal() {
- return 456;
- }
-
- @Override
- public String getName() {
- return "TestPropertySource";
- }
-
- @Override
- public PropertyValue get(String key) {
- return PropertyValue.of(key, getProperties().get(key), getName());
- }
-
- @Override
- public Map<String, String> getProperties() {
- return Collections.unmodifiableMap(properties);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/builder/src/test/java/org/apache/tamaya/builder/TestPropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/modules/builder/src/test/java/org/apache/tamaya/builder/TestPropertySourceProvider.java b/modules/builder/src/test/java/org/apache/tamaya/builder/TestPropertySourceProvider.java
deleted file mode 100644
index 5a2f400..0000000
--- a/modules/builder/src/test/java/org/apache/tamaya/builder/TestPropertySourceProvider.java
+++ /dev/null
@@ -1,91 +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.builder;
-
-import org.apache.tamaya.core.propertysource.BasePropertySource;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertySourceProvider;
-import org.apache.tamaya.spi.PropertyValue;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-
-public class TestPropertySourceProvider
- implements PropertySourceProvider
-{
- @Override
- public Collection<PropertySource> getPropertySources() {
- ArrayList<PropertySource> sources = new ArrayList<>(2);
-
- sources.add(new XProvidingPropertySource());
- sources.add(new YProvidingPropertySource());
-
- return sources;
- }
-
- private class YProvidingPropertySource extends BasePropertySource {
- private Map<String, String> props = Collections.singletonMap("tpsp_x", "X");
-
- @Override
- public int getOrdinal() {
- return 100;
- }
-
- @Override
- public String getName() {
- return "YProvidingPropertySource";
- }
-
- @Override
- public PropertyValue get(String key) {
- return PropertyValue.of(key, getProperties().get(key), getName());
- }
-
- @Override
- public Map<String, String> getProperties() {
- return props;
- }
- }
-
- private class XProvidingPropertySource extends BasePropertySource {
- private Map<String, String> props = Collections.singletonMap("tpsp_y", "Y");
-
- @Override
- public Map<String, String> getProperties() {
- return props;
- }
-
- @Override
- public PropertyValue get(String key) {
- return PropertyValue.of(key, getProperties().get(key), getName());
- }
-
- @Override
- public int getOrdinal() {
- return 100;
- }
-
- @Override
- public String getName() {
- return "XProvidingPropertySource";
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/builder/src/test/java/org/apache/tamaya/builder/TestPropertySourceProviderB.java
----------------------------------------------------------------------
diff --git a/modules/builder/src/test/java/org/apache/tamaya/builder/TestPropertySourceProviderB.java b/modules/builder/src/test/java/org/apache/tamaya/builder/TestPropertySourceProviderB.java
deleted file mode 100644
index 9cfe725..0000000
--- a/modules/builder/src/test/java/org/apache/tamaya/builder/TestPropertySourceProviderB.java
+++ /dev/null
@@ -1,91 +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.builder;
-
-import org.apache.tamaya.core.propertysource.BasePropertySource;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertySourceProvider;
-import org.apache.tamaya.spi.PropertyValue;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-
-public class TestPropertySourceProviderB
- implements PropertySourceProvider
-{
- @Override
- public Collection<PropertySource> getPropertySources() {
- ArrayList<PropertySource> sources = new ArrayList<>(2);
-
- sources.add(new AProvidingPropertySource());
- sources.add(new BProvidingPropertySource());
-
- return sources;
- }
-
- private class BProvidingPropertySource extends BasePropertySource {
- private Map<String, String> props = Collections.singletonMap("tpsp_b", "B");
-
- @Override
- public int getOrdinal() {
- return 100;
- }
-
- @Override
- public String getName() {
- return "BProvidingPropertySource";
- }
-
- @Override
- public PropertyValue get(String key) {
- return PropertyValue.of(key,getProperties().get(key), getName());
- }
-
- @Override
- public Map<String, String> getProperties() {
- return props;
- }
- }
-
- private class AProvidingPropertySource extends BasePropertySource {
- private Map<String, String> props = Collections.singletonMap("tpsp_a", "A");
-
- @Override
- public Map<String, String> getProperties() {
- return props;
- }
-
- @Override
- public PropertyValue get(String key) {
- return PropertyValue.of(key, getProperties().get(key), getName());
- }
-
- @Override
- public int getOrdinal() {
- return 100;
- }
-
- @Override
- public String getName() {
- return "AProvidingPropertySource";
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/builder/src/test/java/org/apache/tamaya/builder/util/mockito/NotMockedAnswer.java
----------------------------------------------------------------------
diff --git a/modules/builder/src/test/java/org/apache/tamaya/builder/util/mockito/NotMockedAnswer.java b/modules/builder/src/test/java/org/apache/tamaya/builder/util/mockito/NotMockedAnswer.java
deleted file mode 100644
index 3188d85..0000000
--- a/modules/builder/src/test/java/org/apache/tamaya/builder/util/mockito/NotMockedAnswer.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.builder.util.mockito;
-
-import org.mockito.exceptions.base.MockitoException;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-
-import java.io.Serializable;
-
-// @todo This is a duplicated class
-public class NotMockedAnswer implements Answer<Object>, Serializable {
- public final static NotMockedAnswer NOT_MOCKED_ANSWER = new NotMockedAnswer();
-
- private NotMockedAnswer() {
- }
-
- @Override
- public Object answer(InvocationOnMock invocation) throws Throwable {
- if("toString".equals(invocation.getMethod().getName())){
- return "Some "+invocation.getMethod().getDeclaringClass().getName();
- }
- StringBuilder msgBuilder = new StringBuilder();
-
- msgBuilder.append("Invocation of method not mocked: ")
- .append(invocation.getMethod().toGenericString());
-
- if (invocation.getArguments().length > 0) {
- msgBuilder.append(" Supplied arguments: ");
-
- for (int i = 0; i < invocation.getArguments().length; i++) {
- msgBuilder.append(invocation.getArguments()[i]);
-
- if (i - 1 < invocation.getArguments().length) {
- msgBuilder.append(", ");
- }
- }
- }
- throw new MockitoException(msgBuilder.toString());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/builder/src/test/java/org/apache/tamaya/builder/util/types/CustomTypeA.java
----------------------------------------------------------------------
diff --git a/modules/builder/src/test/java/org/apache/tamaya/builder/util/types/CustomTypeA.java b/modules/builder/src/test/java/org/apache/tamaya/builder/util/types/CustomTypeA.java
deleted file mode 100644
index 89b2f5b..0000000
--- a/modules/builder/src/test/java/org/apache/tamaya/builder/util/types/CustomTypeA.java
+++ /dev/null
@@ -1,34 +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.builder.util.types;
-
-/**
- * Custom type with two argument constructor.
- */
-public class CustomTypeA {
- private String name;
-
- public CustomTypeA(String name, String other) {
- this.name = name + other;
- }
-
- public String getName() {
- return name;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/builder/src/test/java/org/apache/tamaya/builder/util/types/CustomTypeB.java
----------------------------------------------------------------------
diff --git a/modules/builder/src/test/java/org/apache/tamaya/builder/util/types/CustomTypeB.java b/modules/builder/src/test/java/org/apache/tamaya/builder/util/types/CustomTypeB.java
deleted file mode 100644
index f7f4d99..0000000
--- a/modules/builder/src/test/java/org/apache/tamaya/builder/util/types/CustomTypeB.java
+++ /dev/null
@@ -1,39 +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.builder.util.types;
-
-/**
- * Custom type with factory method
- * {@link org.apache.tamaya.builder.util.types.CustomTypeB#of(String)}
- */
-public class CustomTypeB {
- private String name;
-
- private CustomTypeB(String value) {
- this.name = value;
- }
-
- public String getName() {
- return name;
- }
-
- public static CustomTypeB of(String source) {
- return new CustomTypeB(source);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/builder/src/test/java/org/apache/tamaya/builder/util/types/CustomTypeC.java
----------------------------------------------------------------------
diff --git a/modules/builder/src/test/java/org/apache/tamaya/builder/util/types/CustomTypeC.java b/modules/builder/src/test/java/org/apache/tamaya/builder/util/types/CustomTypeC.java
deleted file mode 100644
index da9ce56..0000000
--- a/modules/builder/src/test/java/org/apache/tamaya/builder/util/types/CustomTypeC.java
+++ /dev/null
@@ -1,36 +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.builder.util.types;
-
-public class CustomTypeC {
- private String value;
-
-
- public CustomTypeC(String in, @SuppressWarnings("unused") int iHideThisConstructorForTamaya) {
- value = in;
- }
-
- public String getValue() {
- return value;
- }
-
- public static CustomTypeC produceFrom(String in) {
- return new CustomTypeC(in, -1);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/builder/src/test/java/org/apache/tamaya/builder/util/types/CustomTypeCPropertyConverter.java
----------------------------------------------------------------------
diff --git a/modules/builder/src/test/java/org/apache/tamaya/builder/util/types/CustomTypeCPropertyConverter.java b/modules/builder/src/test/java/org/apache/tamaya/builder/util/types/CustomTypeCPropertyConverter.java
deleted file mode 100644
index 9e56613..0000000
--- a/modules/builder/src/test/java/org/apache/tamaya/builder/util/types/CustomTypeCPropertyConverter.java
+++ /dev/null
@@ -1,29 +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.builder.util.types;
-
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-public class CustomTypeCPropertyConverter implements PropertyConverter<org.apache.tamaya.builder.util.types.CustomTypeC> {
- @Override
- public org.apache.tamaya.builder.util.types.CustomTypeC convert(String value, ConversionContext context) {
- return org.apache.tamaya.builder.util.types.CustomTypeC.produceFrom(value);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/builder/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter
----------------------------------------------------------------------
diff --git a/modules/builder/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter b/modules/builder/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter
deleted file mode 100644
index b9e0d44..0000000
--- a/modules/builder/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter
+++ /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.builder.util.types.CustomTypeCPropertyConverter
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/builder/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter
----------------------------------------------------------------------
diff --git a/modules/builder/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter b/modules/builder/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter
deleted file mode 100644
index f35e9c5..0000000
--- a/modules/builder/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter
+++ /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.builder.TestPropertyFilter
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/builder/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
----------------------------------------------------------------------
diff --git a/modules/builder/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource b/modules/builder/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
deleted file mode 100644
index 8b07205..0000000
--- a/modules/builder/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
+++ /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.builder.TestPropertySource
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/builder/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider
----------------------------------------------------------------------
diff --git a/modules/builder/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider b/modules/builder/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider
deleted file mode 100644
index 9a19ea0..0000000
--- a/modules/builder/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider
+++ /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.builder.TestPropertySourceProvider
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/builder/src/test/resources/configfiles/json/first.json
----------------------------------------------------------------------
diff --git a/modules/builder/src/test/resources/configfiles/json/first.json b/modules/builder/src/test/resources/configfiles/json/first.json
deleted file mode 100644
index 822cf6e..0000000
--- a/modules/builder/src/test/resources/configfiles/json/first.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "d": "D",
- "e": "E"
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/builder/src/test/resources/configfiles/json/second.json
----------------------------------------------------------------------
diff --git a/modules/builder/src/test/resources/configfiles/json/second.json b/modules/builder/src/test/resources/configfiles/json/second.json
deleted file mode 100644
index e2c7778..0000000
--- a/modules/builder/src/test/resources/configfiles/json/second.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "m": "M",
- "n": "N"
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/builder/src/test/resources/configfiles/json/simple.json
----------------------------------------------------------------------
diff --git a/modules/builder/src/test/resources/configfiles/json/simple.json b/modules/builder/src/test/resources/configfiles/json/simple.json
deleted file mode 100644
index 0cab2ae..0000000
--- a/modules/builder/src/test/resources/configfiles/json/simple.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "a": "A",
- "b": "B"
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/builder/src/test/resources/configfiles/json/third.json
----------------------------------------------------------------------
diff --git a/modules/builder/src/test/resources/configfiles/json/third.json b/modules/builder/src/test/resources/configfiles/json/third.json
deleted file mode 100644
index 6b62b96..0000000
--- a/modules/builder/src/test/resources/configfiles/json/third.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "p": "P",
- "q": "Q"
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/builder/src/test/resources/configfiles/other/simple.oml
----------------------------------------------------------------------
diff --git a/modules/builder/src/test/resources/configfiles/other/simple.oml b/modules/builder/src/test/resources/configfiles/other/simple.oml
deleted file mode 100644
index 494dba3..0000000
--- a/modules/builder/src/test/resources/configfiles/other/simple.oml
+++ /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.
-#
-Key:=Value
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/classloader-support/pom.xml
----------------------------------------------------------------------
diff --git a/modules/classloader-support/pom.xml b/modules/classloader-support/pom.xml
deleted file mode 100644
index adea1d3..0000000
--- a/modules/classloader-support/pom.xml
+++ /dev/null
@@ -1,74 +0,0 @@
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy 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.
--->
-<project xmlns="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">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-extensions</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
-
- <artifactId>tamaya-classloader-support</artifactId>
- <name>Apache Tamaya Modules - Classloader Support</name>
- <description>Apache Tamaya Classloader Support registers a ConfigurationContext that leverages
- classloader hierarchies. Also visibility of features and components is aligned with the
- corresponding hierarchy of classloaders.</description>
- <packaging>bundle</packaging>
-
- <properties>
- <jdkVersion>1.7</jdkVersion>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-spisupport</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.tamaya.clsupport
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/classloader-support/src/main/java/org/apache/tamaya/clsupport/AbstractClassloaderAwareItemLoader.java
----------------------------------------------------------------------
diff --git a/modules/classloader-support/src/main/java/org/apache/tamaya/clsupport/AbstractClassloaderAwareItemLoader.java b/modules/classloader-support/src/main/java/org/apache/tamaya/clsupport/AbstractClassloaderAwareItemLoader.java
deleted file mode 100644
index 0145d1f..0000000
--- a/modules/classloader-support/src/main/java/org/apache/tamaya/clsupport/AbstractClassloaderAwareItemLoader.java
+++ /dev/null
@@ -1,268 +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.clsupport;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-
-/**
- * <p>This class implements an abstract base class, which basically provides a loading mechanism that supports
- * loading and managing resources along the classloader hierarchies individually. It ensures resources are loaded
- * and stored related to the each target classloader within the hierarchy individually. Additionally it enables
- * mechanisms to ensure an item T is not loaded multiple times, when traversing up the classloader hierarchy.</p>
- *
- * <p>Finally classloaders are not stored by reference by this class, to ensure they still can be garbage collected.
- * Instead this class uses the fully qualified class name of the loader and the corresponsing hashCode as returned
- * by {@link Objects#hashCode(Object)}.</p>
- *
- * @param <T> the managed item type.
- */
-public abstract class AbstractClassloaderAwareItemLoader<T> {
- /**
- * The logger used.
- */
- private static final Logger LOG = Logger.getLogger(AbstractClassloaderAwareItemLoader.class.getName());
- /**
- * The items managed, related to their classloader.
- */
- private final Map<String, T> items = new ConcurrentHashMap<>();
-
- /**
- * Creates a new instance, using the current Thread context classloader, or - if null - the classloader that
- * loaded this class for initially initializing the loader instance.
- */
- public AbstractClassloaderAwareItemLoader() {
- this(getDefaultClassLoader());
- }
-
- /**
- * Creates a new instance, using the class loader given for initializing the resources loaded.
- *
- * @param classLoader the target top level classloader, not null.
- */
- public AbstractClassloaderAwareItemLoader(ClassLoader classLoader) {
- loadItems(classLoader);
- }
-
- /**
- * Loads the items for the given classloader and all its parent classloaders. This method will not update
- * the items already found for any class loader involved.
- *
- * @param classLoader the target top level classloader, not null.
- */
- public void loadItems(ClassLoader classLoader) {
- loadItems(classLoader, false);
- }
-
- /**
- * Loads the items for the given classloader and all its parent classloaders.
- *
- * @param classLoader the target top level classloader, not null.
- * @param update if set to true, resources not visible on former runs are added during this load.
- */
- public void loadItems(ClassLoader classLoader, boolean update) {
- this.items.clear();
- List<ClassLoader> cls = new ArrayList<>();
- cls.add(classLoader);
- ClassLoader cl = classLoader.getParent();
- while (cl != null) {
- cls.add(cl);
- cl = cl.getParent();
- }
- // Start with the parent classloader and then go up...
- for (int i = cls.size() - 1; i <= 0; i--) {
- ClassLoader curCL = cls.get(i);
- String clKey = getClassLoaderID(curCL);
- T itemFound = items.get(clKey);
- try {
- if (itemFound != null) {
- updateItem(itemFound, curCL);
- } else {
- items.put(clKey, createItem(curCL));
- }
- } catch (Exception e) {
- LOG.log(Level.SEVERE,
- "Error loading from classloader: " + curCL, e);
- }
- }
- }
-
- /**
- * Creates a new item for being stored linked with the given lassloader.
- *
- * @param classLoader the classloader, not null.
- * @return the new item loaded.
- */
- protected abstract T createItem(ClassLoader classLoader);
-
- /**
- * Creates a new item for being stored linked with the given lassloader.
- *
- * @param currentItemSet the current found ItemContainer instance to be updated.
- * @param classLoader the classloader, not null.
- */
- protected abstract void updateItem(T currentItemSet, ClassLoader classLoader);
-
- /**
- * Evaluates a String key for identfying a classloader instance, based on the loader class and its hashCode.
- * This prevents the storage of classloader references as keys and therefore enables classloaders not used anymore
- * to be garbage collected.
- *
- * @param classLoader {@link ClassLoader} to be identified, must not be {@code null}.
- * @return the unique key for the given classloader
- */
- public static String getClassLoaderID(ClassLoader classLoader) {
- return classLoader.getClass().getName() + Objects.hash(classLoader);
- }
-
- /**
- * Evaluates a String key for identfying a classloader instance, based on the loader class and its hashCode.
- * This prevents the storage of classloader references as keys and therefore enables classloaders not used anymore
- * to be garbage collected.
- *
- * @return the unique key for the current default classloader as returned by #getDefaultClassLoader.
- */
- public static String getClassLoaderID() {
- return getClassLoaderID(getDefaultClassLoader());
- }
-
- /**
- * Get all items valid for the current thread context class loader, or - if null - the classloader that loaded
- * this class.
- *
- * @return the items found, never null.
- */
- public Set<T> getItems() {
- return getItems(getDefaultClassLoader());
- }
-
- /**
- * Get all items found for the given classloader and all its parent classloaders.
- *
- * @param classLoader the target top level classloader, not null.
- * @return the items found, never null.
- */
- public Set<T> getItems(ClassLoader classLoader) {
- Set<T> result = new HashSet<>();
- ClassLoader cl = classLoader;
- while (cl != null) {
- T item = getItemNoParent(cl, true);
- result.add(item);
- cl = cl.getParent();
- }
- return result;
- }
-
- /**
- * Get all items valid for the parent class loader of the current thread context class loader, or - if null - the
- * parent of the classloader that loaded this class. This allows
- * to build a delta list of instances only visible on the target classloader given.
- *
- * @return the items found, never null.
- */
- public Set<T> getParentItems() {
- return getParentItems(getDefaultClassLoader());
- }
-
- /**
- * Get all items found for the parent of the given classloader and all its parent classloaders. This allows
- * to build a delta list of instances only visible on the target classloader given.
- *
- * @param classLoader the target top level classloader, not null.
- * @return the items found, never null.
- */
- public Set<T> getParentItems(ClassLoader classLoader) {
- Set<T> result = new HashSet<>();
- ClassLoader cl = classLoader.getParent();
- while (cl != null) {
- T item = getItemNoParent(cl, true);
- result.add(item);
- cl = cl.getParent();
- }
- return result;
- }
-
- /**
- * Return the item assigned to the current thread context class loader or - if null - the class that loaded
- * this class. If not yet loaded this method will NOT trigger a load.
- *
- * @return the item attached, or null.
- */
- public T getItemNoParent() {
- return getItemNoParent(getDefaultClassLoader(), false);
- }
-
- /**
- * Return the item assigned to the current thread context class loader or - if null - the class that loaded
- * this class.
- *
- * @param loadIfMissing Flag that allows to define if this method will trigger an item load, when no item is loaded
- * for the current class loader.
- * @return the item attached, or null.
- */
- public T getItemNoParent(boolean loadIfMissing) {
- return getItemNoParent(getDefaultClassLoader(), loadIfMissing);
- }
-
- /**
- * Return the item assigned to the current thread context class loader or - if null - the class that loaded
- * this class.
- *
- * @param classLoader the target top level classloader, not null.
- * @param loadIfMissing Flag that allows to define if this method will trigger an item load, when no item is loaded
- * for the current class loader.
- * @return the item attached, or null. If {@code loadIfMissing} is set to true, the result is normally not to be
- * expected to be null.
- */
- public T getItemNoParent(ClassLoader classLoader, boolean loadIfMissing) {
- String clKey = getClassLoaderID(classLoader);
- T item = items.get(clKey);
- if (item == null) {
- if (loadIfMissing) {
- item = createItem(classLoader);
- this.items.put(clKey, item);
- }
- }
- return item;
- }
-
-
- /**
- * Utility method that either returns the current thread context classloader or
- * - if not available - the classloader that loaded this class.
- * @return the default classloader to be used, if no explicit classloader has been passed.
- */
- public static ClassLoader getDefaultClassLoader() {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- if (cl == null) {
- cl = AbstractClassloaderAwareItemLoader.class.getClassLoader();
- }
- return cl;
- }
-
-
-}
[14/24] incubator-tamaya git commit: Removed all modules from the
main repository. They will be reborn in separate ASF repository.
Posted by pl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/injection/src/test/java/org/apache/tamaya/inject/TestPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/test/java/org/apache/tamaya/inject/TestPropertySource.java b/modules/injection/src/test/java/org/apache/tamaya/inject/TestPropertySource.java
deleted file mode 100644
index 0853fd1..0000000
--- a/modules/injection/src/test/java/org/apache/tamaya/inject/TestPropertySource.java
+++ /dev/null
@@ -1,68 +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.inject;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Created by Anatole on 12.01.2015.
- */
-public class TestPropertySource implements PropertySource {
-
- private Map<String,String> properties = new HashMap<>();
-
- public TestPropertySource(){
- properties.put("env.stage", "ET");
- properties.put("simple_value", "aSimpleValue");
- properties.put("host.name", "tamaya01.incubator.apache.org");
- properties.put("anotherValue", "HALLO!");
- properties.put("NonAnnotatedConfigBean.classFieldKey", "Class-Field-Value");
- properties.put("NonAnnotatedConfigBean.fieldKey", "Field-Value");
- properties.put("annottext.NonAnnotatedConfigBean.fullKey", "Fullkey-Value");
- }
-
- @Override
- public int getOrdinal() {
- return 0;
- }
-
- @Override
- public String getName() {
- return getClass().getName();
- }
-
- @Override
- public PropertyValue get(String key) {
- return PropertyValue.of(key,properties.get(key),getName());
- }
-
- @Override
- public Map<String, String> getProperties() {
- return properties;
- }
-
- @Override
- public boolean isScannable() {
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/injection/src/test/java/org/apache/tamaya/inject/internal/DefaultDynamicValueTest.java
----------------------------------------------------------------------
diff --git a/modules/injection/src/test/java/org/apache/tamaya/inject/internal/DefaultDynamicValueTest.java b/modules/injection/src/test/java/org/apache/tamaya/inject/internal/DefaultDynamicValueTest.java
deleted file mode 100644
index dd16f36..0000000
--- a/modules/injection/src/test/java/org/apache/tamaya/inject/internal/DefaultDynamicValueTest.java
+++ /dev/null
@@ -1,315 +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.inject.internal;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.builder.ConfigurationBuilder;
-import org.apache.tamaya.inject.api.ConfiguredItemSupplier;
-import org.apache.tamaya.inject.api.DynamicValue;
-import org.apache.tamaya.inject.api.Config;
-import org.apache.tamaya.inject.api.UpdatePolicy;
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-import org.junit.Test;
-
-import org.apache.tamaya.Configuration;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.junit.Assert.*;
-
-/**
- * Tests for {@link org.apache.tamaya.inject.internal.DefaultDynamicValue}.
- */
-public class DefaultDynamicValueTest {
-
- @Config("a")
- String myValue;
-
- @Config("a")
- String myValue2;
-
- @Config("a")
- void setterMethod(String value){
-
- }
-
- private PropertyChangeEvent event;
-
- private PropertyChangeListener consumer = new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- event = evt;
- }
- };
-
- private Map<String,String> properties = new HashMap<>();
- private Configuration config = new ConfigurationBuilder().addPropertySources(
- new PropertySource() {
- @Override
- public int getOrdinal() {
- return 0;
- }
-
- @Override
- public String getName() {
- return "test";
- }
-
- @Override
- public PropertyValue get(String key) {
- return PropertyValue.of(key,properties.get(key),getName());
- }
-
- @Override
- public Map<String, String> getProperties() {
- return properties;
- }
-
- @Override
- public boolean isScannable() {
- return false;
- }
- }
- ).build();
-
- @Test
- public void testOf_Field() throws Exception {
- DynamicValue val = DefaultDynamicValue.of(getClass().getDeclaredField("myValue"),
- ConfigurationProvider.getConfiguration());
- assertNotNull(val);
- }
-
- @Test
- public void testOf_Method() throws Exception {
- DynamicValue val = DefaultDynamicValue.of(getClass().getDeclaredMethod("setterMethod", String.class),
- config);
- assertNotNull(val);
- }
-
- @Test
- public void testCommitAndGet() throws Exception {
- properties.put("a","aValue");
- DynamicValue val = DefaultDynamicValue.of(getClass().getDeclaredField("myValue"),
- config);
- assertNotNull(val);
- assertEquals("aValue",val.evaluateValue());
- }
-
- @Test
- public void testCommitAndGets() throws Exception {
- properties.put("a","aValue");
- DynamicValue val = DefaultDynamicValue.of(getClass().getDeclaredField("myValue"),
- config);
- val.setUpdatePolicy(UpdatePolicy.EXPLCIT);
- assertNotNull(val);
- assertEquals("aValue",val.evaluateValue());
- // change config
- val.get();
- this.properties.put("a", "aValue2");
- assertTrue(val.updateValue());
- assertEquals("aValue2", val.commitAndGet());
- }
-
- @Test
- public void testCommit() throws Exception {
- properties.put("a", "aValue");
- DynamicValue val = DefaultDynamicValue.of(getClass().getDeclaredField("myValue"),
- config);
- val.setUpdatePolicy(UpdatePolicy.EXPLCIT);
- assertNotNull(val);
- assertEquals("aValue", val.evaluateValue());
- // change config
- val.get();
- this.properties.put("a", "aValue2");
- assertEquals("aValue2", val.evaluateValue());
- assertTrue(val.updateValue());
- val.commit();
- assertEquals("aValue2", val.get());
- }
-
- @Test
- public void testGetSetUpdatePolicy() throws Exception {
- DynamicValue val = DefaultDynamicValue.of(getClass().getDeclaredField("myValue"),
- config);
- for(UpdatePolicy pol: UpdatePolicy.values()) {
- val.setUpdatePolicy(pol);
- assertEquals(pol, val.getUpdatePolicy());
- }
- }
-
- @Test
- public void testAddRemoveListener() throws Exception {
- properties.put("a","aValue");
- DynamicValue val = DefaultDynamicValue.of(getClass().getDeclaredField("myValue"),
- config);
- val.setUpdatePolicy(UpdatePolicy.IMMEDEATE);
- val.addListener(consumer);
- // change config
- val.get();
- this.properties.put("a", "aValue2");
- val.get();
- assertNotNull(event);
- event = null;
- val.removeListener(consumer);
- this.properties.put("a", "aValue3");
- val.updateValue();
- assertNull(event);
- }
-
- @Test
- public void testGet() throws Exception {
- properties.put("a", "aValue");
- DynamicValue val = DefaultDynamicValue.of(getClass().getDeclaredField("myValue"),
- config);
- val.setUpdatePolicy(UpdatePolicy.IMMEDEATE);
- properties.put("a", "aValue2");
- val.updateValue();
- assertEquals("aValue2", val.get());
- }
-
- @Test
- public void testUpdateValue() throws Exception {
- properties.put("a","aValue");
- DynamicValue val = DefaultDynamicValue.of(getClass().getDeclaredField("myValue"),
- config);
- val.setUpdatePolicy(UpdatePolicy.EXPLCIT);
- assertNotNull(val.get());
- assertEquals("aValue", val.get());
- val.updateValue();
- assertEquals("aValue", val.get());
- val.setUpdatePolicy(UpdatePolicy.IMMEDEATE);
- val.updateValue();
- assertEquals("aValue",val.get());
- }
-
- @Test
- public void testEvaluateValue() throws Exception {
- properties.put("a","aValue");
- DynamicValue val = DefaultDynamicValue.of(getClass().getDeclaredField("myValue"),
- config);
- val.setUpdatePolicy(UpdatePolicy.EXPLCIT);
- assertNotNull(val.get());
- assertEquals("aValue",val.evaluateValue());
- properties.put("a", "aValue2");
- assertEquals("aValue2", val.evaluateValue());
- }
-
- @Test
- public void testGetNewValue() throws Exception {
- properties.put("a","aValue");
- DynamicValue val = DefaultDynamicValue.of(getClass().getDeclaredField("myValue"),
- config);
- val.setUpdatePolicy(UpdatePolicy.EXPLCIT);
- val.get();
- assertNull(val.getNewValue());
- properties.put("a", "aValue2");
- val.get();
- assertNotNull(val.getNewValue());
- assertEquals("aValue2", val.getNewValue());
- val.commit();
- assertNull(val.getNewValue());
- }
-
- @Test
- public void testIsPresent() throws Exception {
-
- }
-
- @Test
- public void testIfPresent() throws Exception {
- properties.put("a","aValue");
- DynamicValue val = DefaultDynamicValue.of(getClass().getDeclaredField("myValue"),
- config);
- val.setUpdatePolicy(UpdatePolicy.IMMEDEATE);
- assertTrue(val.isPresent());
- properties.remove("a");
- val.updateValue();
- assertFalse(val.isPresent());
- }
-
- @Test
- public void testOrElse() throws Exception {
- DynamicValue val = DefaultDynamicValue.of(getClass().getDeclaredField("myValue"),
- config);
- val.setUpdatePolicy(UpdatePolicy.IMMEDEATE);
- assertEquals("bla", val.orElse("bla"));
- properties.put("a","aValue");
- val.updateValue();
- assertEquals("aValue", val.orElse("bla"));
- }
-
- @Test
- public void testOrElseGet() throws Exception {
- DynamicValue val = DefaultDynamicValue.of(getClass().getDeclaredField("myValue"),
- config);
- val.setUpdatePolicy(UpdatePolicy.IMMEDEATE);
- assertEquals("bla", val.orElseGet(new ConfiguredItemSupplier() {
- @Override
- public Object get() {
- return "bla";
- }
- }));
- properties.put("a", "aValue");
- val.updateValue();
- assertEquals("aValue", val.orElseGet(new ConfiguredItemSupplier() {
- @Override
- public Object get() {
- return "bla";
- }
- }));
- }
-
- @Test(expected = ConfigException.class)
- public void testOrElseThrow() throws Throwable {
- DynamicValue val = DefaultDynamicValue.of(getClass().getDeclaredField("myValue"),
- config);
- val.setUpdatePolicy(UpdatePolicy.EXPLCIT);
- val.get();
- properties.put("a", "aValue");
- assertEquals("aValue", val.orElseThrow(new ConfiguredItemSupplier() {
- @Override
- public ConfigException get() {
- return new ConfigException("bla");
- }
- }));
- properties.remove("a");
- val.updateValue();
- assertEquals("aValue", val.orElseThrow(new ConfiguredItemSupplier() {
- @Override
- public ConfigException get() {
- return new ConfigException("bla");
- }
- }));
- }
-
- private static final class DoublicatingConverter implements PropertyConverter<String>{
-
- @Override
- public String convert(String value, ConversionContext context) {
- return value + value;
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/injection/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
----------------------------------------------------------------------
diff --git a/modules/injection/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource b/modules/injection/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
deleted file mode 100644
index 5dfb894..0000000
--- a/modules/injection/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
+++ /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.inject.TestPropertySource
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/camel/pom.xml
----------------------------------------------------------------------
diff --git a/modules/integration/camel/pom.xml b/modules/integration/camel/pom.xml
deleted file mode 100644
index b91ba8d..0000000
--- a/modules/integration/camel/pom.xml
+++ /dev/null
@@ -1,100 +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.
--->
-<project xmlns="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">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-integration</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
- </parent>
-
- <artifactId>tamaya-camel</artifactId>
- <name>Apache Tamaya Integration - Apache Camel</name>
- <packaging>bundle</packaging>
-
- <properties>
- <camel.version>2.17.0</camel.version>
- </properties>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.jacoco</groupId>
- <artifactId>jacoco-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>prepare-agent</id>
- <goals>
- <goal>prepare-agent</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.tamaya.integration.camel
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>java-hamcrest</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-core</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-functions</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-core</artifactId>
- <version>${camel.version}</version>
- <scope>provided</scope>
- </dependency>
- </dependencies>
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/camel/src/main/java/org/apache/tamaya/integration/camel/TamayaPropertiesComponent.java
----------------------------------------------------------------------
diff --git a/modules/integration/camel/src/main/java/org/apache/tamaya/integration/camel/TamayaPropertiesComponent.java b/modules/integration/camel/src/main/java/org/apache/tamaya/integration/camel/TamayaPropertiesComponent.java
deleted file mode 100644
index 8b776a5..0000000
--- a/modules/integration/camel/src/main/java/org/apache/tamaya/integration/camel/TamayaPropertiesComponent.java
+++ /dev/null
@@ -1,78 +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.integration.camel;
-
-import java.util.Properties;
-
-import org.apache.camel.component.properties.PropertiesComponent;
-import org.apache.tamaya.ConfigurationProvider;
-
-/**
- * Default Camel PropertiesComponent that additionally has cfg and tamaya prefixes configured for resolution of
- * entries from tamaya.
- */
-public class TamayaPropertiesComponent extends PropertiesComponent{
-
- /**
- * Constructor similar to parent.
- */
- public TamayaPropertiesComponent(){
- super();
- addFunction(new TamayaPropertyResolver("tamaya"));
- addFunction(new TamayaPropertyResolver("cfg"));
- setTamayaOverrides(true);
- }
-
- /**
- * Constructor similar to parent with additional locations.
- * @param locations additional locations for Camel.
- */
- public TamayaPropertiesComponent(String ... locations){
- super(locations);
- addFunction(new TamayaPropertyResolver("tamaya"));
- addFunction(new TamayaPropertyResolver("cfg"));
- setTamayaOverrides(true);
- }
-
- /**
- * Constructor similar to parent with only one location.
- * @param location addition location for Camel.
- */
- public TamayaPropertiesComponent(String location){
- super(location);
- addFunction(new TamayaPropertyResolver("tamaya"));
- addFunction(new TamayaPropertyResolver("cfg"));
- setTamayaOverrides(true);
- }
-
- /**
- * Apply the current Tamaya properties (configuration) as override properties evaluated first by camel before
- * evaluating other uris.
- * @param enabled flag to define if tamaya values override everything else.
- */
- public void setTamayaOverrides(boolean enabled){
- if(enabled){
- final Properties props = new Properties();
- props.putAll(ConfigurationProvider.getConfiguration().getProperties());
- setOverrideProperties(props);
- } else{
- setOverrideProperties(null);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/camel/src/main/java/org/apache/tamaya/integration/camel/TamayaPropertyResolver.java
----------------------------------------------------------------------
diff --git a/modules/integration/camel/src/main/java/org/apache/tamaya/integration/camel/TamayaPropertyResolver.java b/modules/integration/camel/src/main/java/org/apache/tamaya/integration/camel/TamayaPropertyResolver.java
deleted file mode 100644
index 6b6ada9..0000000
--- a/modules/integration/camel/src/main/java/org/apache/tamaya/integration/camel/TamayaPropertyResolver.java
+++ /dev/null
@@ -1,53 +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.integration.camel;
-
-import org.apache.camel.component.properties.PropertiesFunction;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-
-import java.util.Objects;
-
-
-/**
- * Implementation of the Camel Properties SPI using Tamaya configuration.
- */
-public class TamayaPropertyResolver implements PropertiesFunction{
-
- private final String prefix;
-
- /**
- * Creates a new instance.
- * @param configPrefix the prefix to be registered for explicit resolution by this resolver function, not null.
- */
- public TamayaPropertyResolver(String configPrefix){
- this.prefix = Objects.requireNonNull(configPrefix);
- }
-
- @Override
- public String getName() {
- return prefix;
- }
-
- @Override
- public String apply(String remainder) {
- Configuration config = ConfigurationProvider.getConfiguration();
- return config.get(remainder);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/camel/src/test/java/org/apache/tamaya/integration/camel/TamayaPropertyResolverTest.java
----------------------------------------------------------------------
diff --git a/modules/integration/camel/src/test/java/org/apache/tamaya/integration/camel/TamayaPropertyResolverTest.java b/modules/integration/camel/src/test/java/org/apache/tamaya/integration/camel/TamayaPropertyResolverTest.java
deleted file mode 100644
index 0cba47e..0000000
--- a/modules/integration/camel/src/test/java/org/apache/tamaya/integration/camel/TamayaPropertyResolverTest.java
+++ /dev/null
@@ -1,116 +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.integration.camel;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.builder.ProxyBuilder;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.impl.DefaultCamelContext;
-import org.apache.camel.model.RouteDefinition;
-import org.apache.camel.model.RoutesDefinition;
-import org.junit.Test;
-
-import java.io.InputStream;
-
-import static org.junit.Assert.*;
-
-/**
- * Tests for integration of Tamaya with Apache Camel using Java DSL and XML DSL.
- */
-public class TamayaPropertyResolverTest {
-
- @Test
- public void testJavaDSLWithCfgResolution() throws Exception {
- CamelContext camelContext = new DefaultCamelContext();
- camelContext.addComponent("properties", new TamayaPropertiesComponent());
- RouteBuilder builder = new RouteBuilder() {
- public void configure() {
- from("direct:hello").transform().simple("{{cfg:message}}");
- }
- };
- camelContext.addRoutes(builder);
- camelContext.start();
- // test configuration is injected right...
- Greeter proxy = new ProxyBuilder(camelContext).endpoint("direct:hello").build(Greeter.class);
- String greetMessage = proxy.greet();
- assertEquals("Good Bye from Apache Tamaya!", greetMessage);
- }
-
- @Test
- public void testJavaDSLWithTamayaResolution() throws Exception {
- CamelContext camelContext = new DefaultCamelContext();
- camelContext.addComponent("properties", new TamayaPropertiesComponent());
- RouteBuilder builder = new RouteBuilder() {
- public void configure() {
- from("direct:hello").transform().simple("{{tamaya:message}}");
- }
- };
- camelContext.addRoutes(builder);
- camelContext.start();
- // test configuration is injected right...
- Greeter proxy = new ProxyBuilder(camelContext).endpoint("direct:hello").build(Greeter.class);
- String greetMessage = proxy.greet();
- assertEquals("Good Bye from Apache Tamaya!", greetMessage);
- }
-
- @Test
- public void testJavaDSLWithOverrideActive() throws Exception {
- CamelContext camelContext = new DefaultCamelContext();
- TamayaPropertiesComponent props = new TamayaPropertiesComponent();
- props.setTamayaOverrides(true);
- camelContext.addComponent("properties", props);
- RouteBuilder builder = new RouteBuilder() {
- public void configure() {
- from("direct:hello").transform().simple("{{message}}");
- }
- };
- camelContext.addRoutes(builder);
- camelContext.start();
- // test configuration is injected right...
- Greeter proxy = new ProxyBuilder(camelContext).endpoint("direct:hello").build(Greeter.class);
- String greetMessage = proxy.greet();
- assertEquals("Good Bye from Apache Tamaya!", greetMessage);
- }
-
- @Test
- public void testXmlDSL() throws Exception {
- CamelContext camelContext = new DefaultCamelContext();
- // This is normally done by the Spring implemented registry, we keep it simple here...
- TamayaPropertiesComponent props = new TamayaPropertiesComponent();
- props.setTamayaOverrides(true);
- camelContext.addComponent("properties", props);
- // Read routes from XML DSL
- InputStream is = getClass().getResourceAsStream("/META-INF/routes.xml");
- RoutesDefinition routes = camelContext.loadRoutesDefinition(is);
- for(RouteDefinition def: routes.getRoutes()) {
- camelContext.addRouteDefinition(def);
- }
- camelContext.start();
- Greeter greeter = new ProxyBuilder(camelContext).endpoint("direct:hello1").build(Greeter.class);
- assertEquals("Good Bye from Apache Tamaya!", greeter.greet());
- greeter = new ProxyBuilder(camelContext).endpoint("direct:hello2").build(Greeter.class);
- assertEquals("Good Bye from Apache Tamaya!", greeter.greet());
- greeter = new ProxyBuilder(camelContext).endpoint("direct:hello3").build(Greeter.class);
- assertEquals("Good Bye from Apache Tamaya!", greeter.greet());
- }
-
- public interface Greeter {
- String greet();
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/camel/src/test/resources/META-INF/camelcontext.xml
----------------------------------------------------------------------
diff --git a/modules/integration/camel/src/test/resources/META-INF/camelcontext.xml b/modules/integration/camel/src/test/resources/META-INF/camelcontext.xml
deleted file mode 100644
index 6b99d3d..0000000
--- a/modules/integration/camel/src/test/resources/META-INF/camelcontext.xml
+++ /dev/null
@@ -1,52 +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.
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
- http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
- ">
-
- <!-- this is an included XML file where we only the the routeContext -->
- <routeContext id="myCoolRoutes" xmlns="http://camel.apache.org/schema/spring">
- <route id="r1">
- <from uri="direct:hello1"/>
- <transform>
- <simple>{{message}}</simple>
- </transform>
- </route>
- <route id="r2">
- <from uri="direct:hello2"/>
- <transform>
- <simple>{{cfg:message}}</simple>
- </transform>
- </route>
- <route id="r3">
- <from uri="direct:hello3"/>
- <transform>
- <simple>{{tamaya:message}}</simple>
- </transform>
- </route>
- </routeContext>
-
- <bean id="properties" class="org.apache.tamaya.integration.camel.TamayaPropertiesComponent">
- <property name="tamayaOverrides" value="true"/>
- </bean>
-
-</beans>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/camel/src/test/resources/META-INF/javaconfiguration.properties
----------------------------------------------------------------------
diff --git a/modules/integration/camel/src/test/resources/META-INF/javaconfiguration.properties b/modules/integration/camel/src/test/resources/META-INF/javaconfiguration.properties
deleted file mode 100644
index fbe9178..0000000
--- a/modules/integration/camel/src/test/resources/META-INF/javaconfiguration.properties
+++ /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.
-#
-message=Good Bye from Apache Tamaya!
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/camel/src/test/resources/META-INF/routes.xml
----------------------------------------------------------------------
diff --git a/modules/integration/camel/src/test/resources/META-INF/routes.xml b/modules/integration/camel/src/test/resources/META-INF/routes.xml
deleted file mode 100644
index 5ec3529..0000000
--- a/modules/integration/camel/src/test/resources/META-INF/routes.xml
+++ /dev/null
@@ -1,39 +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.
--->
-<routes xmlns="http://camel.apache.org/schema/spring">
- <description>Routes for testing.</description>
- <route>
- <from uri="direct:hello1"/>
- <transform>
- <simple>{{message}}</simple>
- </transform>
- </route>
- <route>
- <from uri="direct:hello2"/>
- <transform>
- <simple>{{cfg:message}}</simple>
- </transform>
- </route>
- <route>
- <from uri="direct:hello3"/>
- <transform>
- <simple>{{tamaya:message}}</simple>
- </transform>
- </route>
-</routes>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi-se/pom.xml
----------------------------------------------------------------------
diff --git a/modules/integration/cdi-se/pom.xml b/modules/integration/cdi-se/pom.xml
deleted file mode 100644
index bcaf441..0000000
--- a/modules/integration/cdi-se/pom.xml
+++ /dev/null
@@ -1,210 +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.
--->
-<project xmlns="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">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-integration</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
- </parent>
-
- <artifactId>tamaya-cdi-se</artifactId>
- <name>Apache Tamaya Integration - CDI (Using SE Injection)</name>
- <packaging>bundle</packaging>
-
- <properties>
- <owb.version>1.6.2</owb.version>
- <weld.version>2.2.7.Final</weld.version>
- <geronimo-jcdi-1.1-spec.version>1.0</geronimo-jcdi-1.1-spec.version>
- <geronimo-interceptor-1.2-spec.version>1.0</geronimo-interceptor-1.2-spec.version>
- <geronimo-atinject-1.0-spec.version>1.0</geronimo-atinject-1.0-spec.version>
- <bval.version>0.5</bval.version>
- <ds.version>1.1.0</ds.version>
- </properties>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.jacoco</groupId>
- <artifactId>jacoco-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>prepare-agent</id>
- <goals>
- <goal>prepare-agent</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.tamaya.integration.cdi.config
- </Export-Package>
- <Private-Package>
- org.apache.tamaya.integration.cdi.internal
- </Private-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>java-hamcrest</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-classloader-support</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-spisupport</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-core</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-api</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-injection</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-jcdi_1.1_spec</artifactId>
- <version>${geronimo-jcdi-1.1-spec.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.deltaspike.modules</groupId>
- <artifactId>deltaspike-test-control-module-api</artifactId>
- <version>${ds.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.deltaspike.modules</groupId>
- <artifactId>deltaspike-test-control-module-impl</artifactId>
- <version>${ds.version}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <profiles>
- <profile>
- <id>OWB</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
- <dependencies>
- <!-- OWB specific dependencies-->
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-atinject_1.0_spec</artifactId>
- <version>${geronimo-atinject-1.0-spec.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-interceptor_1.2_spec</artifactId>
- <version>${geronimo-interceptor-1.2-spec.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-annotation_1.2_spec</artifactId>
- <version>1.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-el_2.2_spec</artifactId>
- <version>1.0.2</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.openwebbeans</groupId>
- <artifactId>openwebbeans-impl</artifactId>
- <version>${owb.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.openwebbeans</groupId>
- <artifactId>openwebbeans-spi</artifactId>
- <version>${owb.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.openwebbeans</groupId>
- <artifactId>openwebbeans-resource</artifactId>
- <version>${owb.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.bval</groupId>
- <artifactId>bval-jsr303</artifactId>
- <version>${bval.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.deltaspike.cdictrl</groupId>
- <artifactId>deltaspike-cdictrl-owb</artifactId>
- <version>${ds.version}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
- </profile>
- <profile>
- <id>Weld</id>
- <dependencies>
- <dependency>
- <groupId>org.jboss.weld.se</groupId>
- <artifactId>weld-se</artifactId>
- <version>${weld.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.deltaspike.cdictrl</groupId>
- <artifactId>deltaspike-cdictrl-weld</artifactId>
- <version>${ds.version}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
- </profile>
- </profiles>
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/CDIAwareServiceContext.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/CDIAwareServiceContext.java b/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/CDIAwareServiceContext.java
deleted file mode 100644
index 566d00e..0000000
--- a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/CDIAwareServiceContext.java
+++ /dev/null
@@ -1,169 +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.integration.cdi;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.spi.ServiceContext;
-
-import javax.annotation.Priority;
-import javax.enterprise.inject.Instance;
-import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.BeanManager;
-import java.text.MessageFormat;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-
-/**
- * <p>This class implements a {@link ServiceContext}, which basically provides a similar loading mechanism as used
- * by the {@link java.util.ServiceLoader}. Whereas the {@link java.util.ServiceLoader} only loads configurations
- * and instances from one classloader, this loader manages configs found and the related instances for each
- * classloader along the classloader hierarchies individually. It ensures instances are loaded on the classloader
- * level, where they first are visible. Additionally it ensures the same configuration resource (and its
- * declared services) are loaded multiple times, when going up the classloader hierarchy.</p>
- *
- * <p>Finally classloaders are not stored by reference by this class, to ensure they still can be garbage collected.
- * Refer also the inherited parent class for further details.</p>
- *
- * <p>This class uses an ordinal of {@code 10}, so it overrides any default {@link ServiceContext} implementations
- * provided with the Tamaya core modules.</p>
- */
-public class CDIAwareServiceContext implements ServiceContext {
-
- /**
- * Singletons.
- */
- private final Map<Class<?>, Object> singletons = new ConcurrentHashMap<>();
-
- private ServiceContext defaultServiceContext = new ServiceLoaderServiceContext();
-
-
- @Override
- public <T> T getService(Class<T> serviceType) {
- Object cached = singletons.get(serviceType);
- if (cached == null) {
- Collection<T> services = getServices(serviceType);
- if (services.isEmpty()) {
- cached = null;
- } else {
- cached = getServiceWithHighestPriority(services, serviceType);
- }
- if(cached!=null) {
- singletons.put(serviceType, cached);
- }
- }
- return serviceType.cast(cached);
- }
-
- /**
- * Loads and registers services.
- *
- * @param <T> the concrete type.
- * @param serviceType The service type.
- * @return the items found, never {@code null}.
- */
- @Override
- public <T> List<T> getServices(final Class<T> serviceType) {
- List<T> found = defaultServiceContext.getServices(serviceType);
- BeanManager beanManager = TamayaCDIIntegration.getBeanManager();
- Instance<T> cdiInstances = null;
- if(beanManager!=null){
- Set<Bean<?>> instanceBeans = beanManager.getBeans(Instance.class);
- Bean<?> bean = instanceBeans.iterator().next();
- cdiInstances = (Instance<T>)beanManager.getReference(bean, Instance.class,
- beanManager.createCreationalContext(bean));
- }
- if(cdiInstances!=null){
- for(T t:cdiInstances.select(serviceType)){
- found.add(t);
- }
- }
- return found;
- }
-
- /**
- * Checks the given instance for a @Priority annotation. If present the annotation's value s evaluated. If no such
- * annotation is present, a default priority is returned (1);
- * @param o the instance, not null.
- * @return a priority, by default 1.
- */
- public static int getPriority(Object o){
- int prio = 1; //X TODO discuss default priority
- Priority priority = o.getClass().getAnnotation(Priority.class);
- if (priority != null) {
- prio = priority.value();
- }
- return prio;
- }
-
- /**
- * @param services to scan
- * @param <T> 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> T getServiceWithHighestPriority(Collection<T> services, Class<T> serviceType) {
-
- // we do not need the priority stuff if the list contains only one element
- if (services.size() == 1) {
- return services.iterator().next();
- }
-
- Integer highestPriority = null;
- int highestPriorityServiceCount = 0;
- T highestService = null;
-
- for (T service : services) {
- int prio = getPriority(service);
- 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}: {3}",
- highestPriorityServiceCount,
- serviceType.getName(),
- highestPriority,
- services));
- }
-
- return highestService;
- }
-
- /**
- * Returns ordinal of 20, overriding defaults as well as the inherited (internally used) CLAwareServiceContext
- * instance.
- * @return ordinal of 20.
- */
- @Override
- public int ordinal() {
- return 20;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/DefaultConfigurationContext.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/DefaultConfigurationContext.java b/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/DefaultConfigurationContext.java
deleted file mode 100644
index daffbef..0000000
--- a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/DefaultConfigurationContext.java
+++ /dev/null
@@ -1,286 +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.integration.cdi;
-
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.spi.ConfigurationContext;
-import org.apache.tamaya.spi.ConfigurationContextBuilder;
-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.PropertyValueCombinationPolicy;
-import org.apache.tamaya.spi.ServiceContextManager;
-
-import javax.annotation.Priority;
-import javax.enterprise.inject.Vetoed;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-import java.util.logging.Logger;
-
-/**
- * Default Implementation of a simple ConfigurationContext.
- */
-@SuppressWarnings("FieldCanBeLocal")
-@Vetoed
-public class DefaultConfigurationContext implements ConfigurationContext {
- /** The logger used. */
- private final static Logger LOG = Logger.getLogger(DefaultConfigurationContext.class.getName());
- /**
- * Cubcomponent handling {@link PropertyConverter} instances.
- */
- private final PropertyConverterManager propertyConverterManager = new PropertyConverterManager();
-
- /**
- * The current unmodifiable list of loaded {@link PropertySource} instances.
- */
- private List<PropertySource> immutablePropertySources;
-
- /**
- * The current unmodifiable list of loaded {@link PropertyFilter} instances.
- */
- private List<PropertyFilter> immutablePropertyFilters;
-
- /**
- * The overriding policy used when combining PropertySources registered to evalute the final configuration
- * values.
- */
- private PropertyValueCombinationPolicy propertyValueCombinationPolicy;
-
- /**
- * Lock for internal synchronization.
- */
- private final ReentrantReadWriteLock propertySourceLock = new ReentrantReadWriteLock();
-
- /** Comparator used for ordering property sources. */
- private final PropertySourceComparator propertySourceComparator = new PropertySourceComparator();
-
- /** Comparator used for ordering property filters. */
- private final PropertyFilterComparator propertyFilterComparator = new PropertyFilterComparator();
-
-
- /**
- * The first time the Configuration system gets invoked we do initialize
- * all our {@link PropertySource}s and
- * {@link PropertyFilter}s which are known at startup.
- */
- public DefaultConfigurationContext() {
- List<PropertySource> propertySources = new ArrayList<>();
-
- // first we load all PropertySources which got registered via java.util.ServiceLoader
- propertySources.addAll(ServiceContextManager.getServiceContext().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, new PropertySourceComparator());
-
- immutablePropertySources = Collections.unmodifiableList(propertySources);
- LOG.info("Registered " + immutablePropertySources.size() + " property sources: " +
- immutablePropertySources);
-
- // as next step we pick up the PropertyFilters pretty much the same way
- List<PropertyFilter> propertyFilters = new ArrayList<>();
- propertyFilters.addAll(ServiceContextManager.getServiceContext().getServices(PropertyFilter.class));
- Collections.sort(propertyFilters, new PropertyFilterComparator());
- immutablePropertyFilters = Collections.unmodifiableList(propertyFilters);
- LOG.info("Registered " + immutablePropertyFilters.size() + " property filters: " +
- immutablePropertyFilters);
-
- immutablePropertyFilters = Collections.unmodifiableList(propertyFilters);
- LOG.info("Registered " + immutablePropertyFilters.size() + " property filters: " +
- immutablePropertyFilters);
- propertyValueCombinationPolicy = ServiceContextManager.getServiceContext().getService(PropertyValueCombinationPolicy.class);
- if(propertyValueCombinationPolicy==null) {
- propertyValueCombinationPolicy = PropertyValueCombinationPolicy.DEFAULT_OVERRIDING_COLLECTOR;
- }
- LOG.info("Using PropertyValueCombinationPolicy: " + propertyValueCombinationPolicy);
- }
-
- DefaultConfigurationContext(DefaultConfigurationContextBuilder builder) {
- List<PropertySource> propertySources = new ArrayList<>();
- // first we load all PropertySources which got registered via java.util.ServiceLoader
- propertySources.addAll(builder.propertySources.values());
- // now sort them according to their ordinal values
- Collections.sort(propertySources, propertySourceComparator);
- immutablePropertySources = Collections.unmodifiableList(propertySources);
- LOG.info("Registered " + immutablePropertySources.size() + " property sources: " +
- immutablePropertySources);
-
- // as next step we pick up the PropertyFilters pretty much the same way
- List<PropertyFilter> propertyFilters = new ArrayList<>();
- propertyFilters.addAll(ServiceContextManager.getServiceContext().getServices(PropertyFilter.class));
- Collections.sort(propertyFilters, propertyFilterComparator);
- immutablePropertyFilters = Collections.unmodifiableList(propertyFilters);
- LOG.info("Registered " + immutablePropertyFilters.size() + " property filters: " +
- immutablePropertyFilters);
-
- propertyValueCombinationPolicy = ServiceContextManager.getServiceContext().getService(PropertyValueCombinationPolicy.class);
- if(propertyValueCombinationPolicy==null){
- propertyValueCombinationPolicy = PropertyValueCombinationPolicy.DEFAULT_OVERRIDING_COLLECTOR;
- }
- LOG.info("Using PropertyValueCombinationPolicy: " + propertyValueCombinationPolicy);
- }
-
-
-
- /**
- * Pick up all {@link PropertySourceProvider}s and return all the
- * {@link PropertySource}s they like to register.
- */
- private Collection<? extends PropertySource> evaluatePropertySourcesFromProviders() {
- List<PropertySource> propertySources = new ArrayList<>();
- Collection<PropertySourceProvider> propertySourceProviders = ServiceContextManager.getServiceContext().getServices(PropertySourceProvider.class);
- for (PropertySourceProvider propertySourceProvider : propertySourceProviders) {
- Collection<PropertySource> sources = propertySourceProvider.getPropertySources();
- LOG.finer("PropertySourceProvider " + propertySourceProvider.getClass().getName() +
- " provided the following property sources: " + sources);
- propertySources.addAll(sources);
- }
-
- return propertySources;
- }
-
- @Override
- public void addPropertySources(PropertySource... propertySourcesToAdd) {
- Lock writeLock = propertySourceLock.writeLock();
- try {
- writeLock.lock();
- List<PropertySource> newPropertySources = new ArrayList<>(this.immutablePropertySources);
- newPropertySources.addAll(Arrays.asList(propertySourcesToAdd));
- Collections.sort(newPropertySources, new PropertySourceComparator());
-
- this.immutablePropertySources = Collections.unmodifiableList(newPropertySources);
- } finally {
- writeLock.unlock();
- }
- }
-
- /**
- * Comparator used for ordering PropertySources.
- */
- private static class PropertySourceComparator implements Comparator<PropertySource>, Serializable {
-
- private static final long serialVersionUID = 1L;
-
- /**
- * Order property source reversely, the most important come first.
- *
- * @param source1 the first PropertySource
- * @param source2 the second PropertySource
- * @return the comparison result.
- */
- private int comparePropertySources(PropertySource source1, PropertySource source2) {
- if (source1.getOrdinal() < source2.getOrdinal()) {
- return -1;
- } else if (source1.getOrdinal() > source2.getOrdinal()) {
- return 1;
- } else {
- return source1.getClass().getName().compareTo(source2.getClass().getName());
- }
- }
-
- @Override
- public int compare(PropertySource source1, PropertySource source2) {
- return comparePropertySources(source1, source2);
- }
- }
-
- /**
- * Comparator used for ordering PropertyFilters.
- */
- private static class PropertyFilterComparator implements Comparator<PropertyFilter>, Serializable{
-
- private static final long serialVersionUID = 1L;
-
- /**
- * Compare 2 filters for ordering the filter chain.
- *
- * @param filter1 the first filter
- * @param filter2 the second filter
- * @return the comparison result
- */
- private int comparePropertyFilters(PropertyFilter filter1, PropertyFilter filter2) {
- Priority prio1 = filter1.getClass().getAnnotation(Priority.class);
- Priority prio2 = filter2.getClass().getAnnotation(Priority.class);
- int ord1 = prio1 != null ? prio1.value() : 0;
- int ord2 = prio2 != null ? prio2.value() : 0;
-
- if (ord1 < ord2) {
- return -1;
- } else if (ord1 > ord2) {
- return 1;
- } else {
- return filter1.getClass().getName().compareTo(filter2.getClass().getName());
- }
- }
-
- @Override
- public int compare(PropertyFilter filter1, PropertyFilter filter2) {
- return comparePropertyFilters(filter1, filter2);
- }
- }
-
- @Override
- public List<PropertySource> getPropertySources() {
- return immutablePropertySources;
- }
-
- @Override
- public <T> void addPropertyConverter(TypeLiteral<T> typeToConvert, PropertyConverter<T> propertyConverter) {
- propertyConverterManager.register(typeToConvert, propertyConverter);
- LOG.info("Added PropertyConverter: " + propertyConverter.getClass().getName());
- }
-
- @Override
- public Map<TypeLiteral<?>, List<PropertyConverter<?>>> getPropertyConverters() {
- return propertyConverterManager.getPropertyConverters();
- }
-
- @Override
- public <T> List<PropertyConverter<T>> getPropertyConverters(TypeLiteral<T> targetType) {
- return propertyConverterManager.getPropertyConverters(targetType);
- }
-
- @Override
- public List<PropertyFilter> getPropertyFilters() {
- return immutablePropertyFilters;
- }
-
- @Override
- public PropertyValueCombinationPolicy getPropertyValueCombinationPolicy(){
- return propertyValueCombinationPolicy;
- }
-
- @Override
- public ConfigurationContextBuilder toBuilder() {
- return ConfigurationProvider.getConfigurationContextBuilder().setContext(this);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/DefaultConfigurationContextBuilder.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/DefaultConfigurationContextBuilder.java b/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/DefaultConfigurationContextBuilder.java
deleted file mode 100644
index 3c6c0eb..0000000
--- a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/DefaultConfigurationContextBuilder.java
+++ /dev/null
@@ -1,152 +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.integration.cdi;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.spi.ConfigurationContext;
-import org.apache.tamaya.spi.ConfigurationContextBuilder;
-import org.apache.tamaya.spi.PropertyConverter;
-import org.apache.tamaya.spi.PropertyFilter;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValueCombinationPolicy;
-
-import javax.enterprise.inject.Vetoed;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-
-/**
- * Default implementation of {@link ConfigurationContextBuilder}.
- */
-@Vetoed
-public class DefaultConfigurationContextBuilder implements ConfigurationContextBuilder {
-
- final Map<String, PropertySource> propertySources = new HashMap<>();
- final List<PropertyFilter> propertyFilters = new ArrayList<>();
- final Map<TypeLiteral<?>, List<PropertyConverter<?>>> propertyConverters = new HashMap<>();
- PropertyValueCombinationPolicy combinationPolicy;
-
- @Override
- public ConfigurationContextBuilder setContext(ConfigurationContext context) {
- this.propertySources.clear();
- for(PropertySource ps:context.getPropertySources()) {
- this.propertySources.put(ps.getName(), ps);
- }
- this.propertyFilters.clear();
- this.propertyFilters.addAll(context.getPropertyFilters());
- this.propertyConverters.clear();
- this.propertyConverters.putAll(context.getPropertyConverters());
- this.combinationPolicy = context.getPropertyValueCombinationPolicy();
- return this;
- }
-
- @Override
- public ConfigurationContextBuilder addPropertySources(Collection<PropertySource> propertySourcesToAdd) {
- for(PropertySource ps:propertySourcesToAdd){
- if(this.propertySources.containsKey(ps.getName())){
- throw new ConfigException("Duplicate PropertySource: " + ps.getName());
- }
- }
- for(PropertySource ps:propertySourcesToAdd) {
- this.propertySources.put(ps.getName(), ps);
- }
- return this;
- }
-
- @Override
- public ConfigurationContextBuilder addPropertySources(PropertySource... propertySourcesToAdd) {
- return addPropertySources(Arrays.asList(propertySourcesToAdd));
- }
-
- @Override
- public ConfigurationContextBuilder removePropertySources(Collection<String> propertySourcesToRemove) {
- for(String key: propertySourcesToRemove){
- this.propertySources.remove(key);
- }
- return this;
- }
-
- @Override
- public ConfigurationContextBuilder removePropertySources(String... propertySourcesToRemove) {
- return removePropertySources(Arrays.asList(propertySourcesToRemove));
- }
-
- @Override
- public ConfigurationContextBuilder addPropertyFilters(Collection<PropertyFilter> filters) {
- this.propertyFilters.addAll(filters);
- return this;
- }
-
- @Override
- public ConfigurationContextBuilder addPropertyFilters(PropertyFilter... filters) {
- return addPropertyFilters(Arrays.asList(filters));
- }
-
- @Override
- public ConfigurationContextBuilder removePropertyFilters(Collection<PropertyFilter> filters) {
- this.propertyFilters.removeAll(filters);
- return this;
- }
-
- @Override
- public ConfigurationContextBuilder removePropertyFilters(PropertyFilter... filters) {
- return removePropertyFilters(Arrays.asList(filters));
- }
-
- @Override
- public <T> ConfigurationContextBuilder addPropertyConverter(TypeLiteral<T> typeToConvert, PropertyConverter<T> propertyConverter) {
- List<PropertyConverter<?>> converters = this.propertyConverters.get(typeToConvert);
- if(converters==null){
- converters = new ArrayList<>();
- this.propertyConverters.put(typeToConvert, converters);
- }
- return this;
- }
-
- @Override
- public ConfigurationContextBuilder removePropertyConverters(TypeLiteral<?> typeToConvert, PropertyConverter<?>... converters) {
- return removePropertyConverters(typeToConvert, Arrays.asList(converters));
- }
-
- @Override
- public ConfigurationContextBuilder removePropertyConverters(TypeLiteral<?> typeToConvert, Collection<PropertyConverter<?>> converters) {
- List<PropertyConverter<?>> existing = this.propertyConverters.get(typeToConvert);
- if(existing!=null) {
- existing.removeAll(converters);
- }
- return this;
- }
-
- @Override
- public ConfigurationContextBuilder setPropertyValueCombinationPolicy(PropertyValueCombinationPolicy policy) {
- this.combinationPolicy = Objects.requireNonNull(policy);
- return this;
- }
-
- @Override
- public ConfigurationContext build() {
- return new DefaultConfigurationContext(this);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/EnumConverter.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/EnumConverter.java b/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/EnumConverter.java
deleted file mode 100644
index d6ad1ba..0000000
--- a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/EnumConverter.java
+++ /dev/null
@@ -1,71 +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.integration.cdi;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-import javax.enterprise.inject.Vetoed;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.Locale;
-import java.util.Objects;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Converter, converting from String to tge given enum type.
- * @param <T> the enum type.
- */
-@Vetoed
-public class EnumConverter<T> implements PropertyConverter<T> {
- private final Logger LOG = Logger.getLogger(EnumConverter.class.getName());
- private Class<T> enumType;
- private Method factory;
-
- public EnumConverter(Class<T> enumType) {
- if (!Enum.class.isAssignableFrom(enumType)) {
- throw new IllegalArgumentException("Not an Enum: " + enumType.getName());
- }
- this.enumType = Objects.requireNonNull(enumType);
- try {
- this.factory = enumType.getMethod("valueOf", String.class);
- } catch (NoSuchMethodException e) {
- throw new ConfigException("Uncovertible enum type without valueOf method found, please provide a custom " +
- "PropertyConverter for: " + enumType.getName());
- }
- }
-
- @Override
- public T convert(String value, ConversionContext context) {
- context.addSupportedFormats(getClass(), "<enumValue>");
- try {
- return (T) factory.invoke(null, value);
- } catch (InvocationTargetException | IllegalAccessException e) {
- LOG.log(Level.FINEST, "Invalid enum value '" + value + "' for " + enumType.getName(), e);
- }
- try {
- return (T) factory.invoke(null, value.toUpperCase(Locale.ENGLISH));
- } catch (InvocationTargetException | IllegalAccessException e) {
- LOG.log(Level.FINEST, "Invalid enum value '" + value + "' for " + enumType.getName(), e);
- }
- return null;
- }
-}
[02/24] incubator-tamaya git commit: Removed all modules from the
main repository. They will be reborn in separate ASF repository.
Posted by pl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfiguration.java b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfiguration.java
deleted file mode 100644
index 52a0d11..0000000
--- a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfiguration.java
+++ /dev/null
@@ -1,228 +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.spisupport;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.ConfigOperator;
-import org.apache.tamaya.ConfigQuery;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.spi.ConfigurationContext;
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-import org.apache.tamaya.spi.PropertyValueCombinationPolicy;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Implementation of the Configuration API. This class uses the current {@link ConfigurationContext} to evaluate the
- * chain of {@link PropertySource} and {@link org.apache.tamaya.spi.PropertyFilter}
- * instance to evaluate the current Configuration.
- */
-public class DefaultConfiguration implements Configuration {
- /**
- * The logger.
- */
- private static final Logger LOG = Logger.getLogger(DefaultConfiguration.class.getName());
-
- /**
- * The current {@link ConfigurationContext} of the current instance.
- */
- private final ConfigurationContext configurationContext;
-
-
- /**
- * Constructor.
- * @param configurationContext The configuration Context to be used.
- */
- public DefaultConfiguration(ConfigurationContext configurationContext){
- this.configurationContext = Objects.requireNonNull(configurationContext);
- }
-
- /**
- * Get a given value, filtered with the context's filters as needed.
- * @param key the property's key, not null.
- * @return the filtered value, or null.
- */
- @Override
- public String get(String key) {
- PropertyValue configData = evaluteRawValue(key);
- if(configData==null){
- return null;
- }
- return PropertyFiltering.applyFilter(key, configData.getConfigEntries(), configurationContext);
- }
-
- /**
- * Evaluates the raw value using the context's PropertyValueCombinationPolicy.
- * @param key the key, not null.
- * @return the value, before filtering is applied.
- */
- protected PropertyValue evaluteRawValue(String key) {
- List<PropertySource> propertySources = configurationContext.getPropertySources();
- Map<String,String> unfilteredValue = null;
- PropertyValueCombinationPolicy combinationPolicy = this.configurationContext
- .getPropertyValueCombinationPolicy();
- for (PropertySource propertySource : propertySources) {
- unfilteredValue = combinationPolicy.collect(unfilteredValue, key, propertySource);
- }
- if(unfilteredValue==null){
- return null;
- }
- return PropertyValue.of(key, unfilteredValue.get(key), unfilteredValue.get("_"+key+".source"));
- }
-
-
- @Override
- public String getOrDefault(String key, String defaultValue) {
- String val = get(key);
- if(val==null){
- return defaultValue;
- }
- return val;
- }
-
- @Override
- public <T> T getOrDefault(String key, Class<T> type, T defaultValue) {
- T val = get(key, type);
- if(val==null){
- return defaultValue;
- }
- return val;
- }
-
- /**
- * Get the current properties, composed by the loaded {@link PropertySource} and filtered
- * by registered {@link org.apache.tamaya.spi.PropertyFilter}.
- *
- * @return the final properties.
- */
- @Override
- public Map<String, String> getProperties() {
- return PropertyFiltering.applyFilters(evaluateUnfilteredMap(), configurationContext);
- }
-
- /**
- * Evaluate all properties, but do not apply filtering on the output.
- * @return the unfiltered key, value map.
- */
- protected Map<String, String> evaluateUnfilteredMap() {
- List<PropertySource> propertySources = new ArrayList<>(configurationContext.getPropertySources());
- Collections.reverse(propertySources);
- Map<String, String> result = new HashMap<>();
- for (PropertySource propertySource : propertySources) {
- try {
- int origSize = result.size();
- Map<String, String> otherMap = propertySource.getProperties();
- LOG.log(Level.FINEST, null, "Overriding with properties from " + propertySource.getName());
- result.putAll(otherMap);
- LOG.log(Level.FINEST, null, "Handled properties from " + propertySource.getName() + "(new: " +
- (result.size() - origSize) + ", overrides: " + origSize + ", total: " + result.size());
- } catch (Exception e) {
- LOG.log(Level.SEVERE, "Error adding properties from PropertySource: " + propertySource + ", ignoring PropertySource.", e);
- }
- }
- return result;
- }
-
- /**
- * Accesses the current String value for the given key and tries to convert it
- * using the {@link PropertyConverter} instances provided by the current
- * {@link ConfigurationContext}.
- *
- * @param key the property's absolute, or relative path, e.g. @code
- * a/b/c/d.myProperty}.
- * @param type The target type required, not null.
- * @param <T> the value type
- * @return the converted value, never null.
- */
- @Override
- public <T> T get(String key, Class<T> type) {
- return get(key, (TypeLiteral<T>)TypeLiteral.of(type));
- }
-
- /**
- * Accesses the current String value for the given key and tries to convert it
- * using the {@link PropertyConverter} instances provided by the current
- * {@link ConfigurationContext}.
- *
- * @param key the property's absolute, or relative path, e.g. @code
- * a/b/c/d.myProperty}.
- * @param type The target type required, not null.
- * @param <T> the value type
- * @return the converted value, never null.
- */
- @Override
- public <T> T get(String key, TypeLiteral<T> type) {
- return convertValue(key, get(key), type);
- }
-
- protected <T> T convertValue(String key, String value, TypeLiteral<T> type) {
- if (value != null) {
- List<PropertyConverter<T>> converters = configurationContext.getPropertyConverters(type);
- ConversionContext context = new ConversionContext.Builder(this, configurationContext, key, type).build();
- for (PropertyConverter<T> converter : converters) {
- try {
- T t = converter.convert(value, context);
- if (t != null) {
- return t;
- }
- } catch (Exception e) {
- LOG.log(Level.FINEST, "PropertyConverter: " + converter + " failed to convert value: " + value, e);
- }
- }
- throw new ConfigException("Unparseable config value for type: " + type.getRawType().getName() + ": " + key +
- ", supported formats: "+context.getSupportedFormats());
- }
- return null;
- }
-
- @Override
- public <T> T getOrDefault(String key, TypeLiteral<T> type, T defaultValue) {
- T val = get(key, type);
- if(val==null){
- return defaultValue;
- }
- return val;
- }
-
- @Override
- public Configuration with(ConfigOperator operator) {
- return operator.operate(this);
- }
-
- @Override
- public <T> T query(ConfigQuery<T> query) {
- return query.query(this);
- }
-
- @Override
- public ConfigurationContext getContext() {
- return configurationContext;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigurationContext.java
----------------------------------------------------------------------
diff --git a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigurationContext.java b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigurationContext.java
deleted file mode 100644
index 76f254b..0000000
--- a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigurationContext.java
+++ /dev/null
@@ -1,256 +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.spisupport;
-
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.spi.ConfigurationContext;
-import org.apache.tamaya.spi.ConfigurationContextBuilder;
-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.PropertyValueCombinationPolicy;
-import org.apache.tamaya.spi.ServiceContextManager;
-
-import javax.annotation.Priority;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-import java.util.logging.Logger;
-
-/**
- * Default Implementation of a simple ConfigurationContext.
- */
-public class DefaultConfigurationContext implements ConfigurationContext {
- /** The logger used. */
- private final static Logger LOG = Logger.getLogger(DefaultConfigurationContext.class.getName());
- /**
- * Cubcomponent handling {@link PropertyConverter} instances.
- */
- private final PropertyConverterManager propertyConverterManager = new PropertyConverterManager();
-
- /**
- * The current unmodifiable list of loaded {@link PropertySource} instances.
- */
- private List<PropertySource> immutablePropertySources;
-
- /**
- * The current unmodifiable list of loaded {@link PropertyFilter} instances.
- */
- private List<PropertyFilter> immutablePropertyFilters;
-
- /**
- * The overriding policy used when combining PropertySources registered to evalute the final configuration
- * values.
- */
- private PropertyValueCombinationPolicy propertyValueCombinationPolicy;
-
- /**
- * Lock for internal synchronization.
- */
- private final ReentrantReadWriteLock propertySourceLock = new ReentrantReadWriteLock();
-
- /** Comparator used for ordering property sources. */
- private final PropertySourceComparator propertySourceComparator = new PropertySourceComparator();
-
- /** Comparator used for ordering property filters. */
- private final PropertyFilterComparator propertyFilterComparator = new PropertyFilterComparator();
-
-
- /**
- * The first time the Configuration system gets invoked we do initialize
- * all our {@link PropertySource}s and
- * {@link PropertyFilter}s which are known at startup.
- */
- public DefaultConfigurationContext() {
- List<PropertySource> propertySources = new ArrayList<>();
-
- // first we load all PropertySources which got registered via java.util.ServiceLoader
- propertySources.addAll(ServiceContextManager.getServiceContext().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, new PropertySourceComparator());
-
- immutablePropertySources = Collections.unmodifiableList(propertySources);
- LOG.info("Registered " + immutablePropertySources.size() + " property sources: " +
- immutablePropertySources);
-
- // as next step we pick up the PropertyFilters pretty much the same way
- List<PropertyFilter> propertyFilters = new ArrayList<>();
- propertyFilters.addAll(ServiceContextManager.getServiceContext().getServices(PropertyFilter.class));
- Collections.sort(propertyFilters, new PropertyFilterComparator());
- immutablePropertyFilters = Collections.unmodifiableList(propertyFilters);
- LOG.info("Registered " + immutablePropertyFilters.size() + " property filters: " +
- immutablePropertyFilters);
-
- immutablePropertyFilters = Collections.unmodifiableList(propertyFilters);
- LOG.info("Registered " + immutablePropertyFilters.size() + " property filters: " +
- immutablePropertyFilters);
- propertyValueCombinationPolicy = ServiceContextManager.getServiceContext().getService(PropertyValueCombinationPolicy.class);
- if(propertyValueCombinationPolicy==null) {
- propertyValueCombinationPolicy = PropertyValueCombinationPolicy.DEFAULT_OVERRIDING_COLLECTOR;
- }
- LOG.info("Using PropertyValueCombinationPolicy: " + propertyValueCombinationPolicy);
- }
-
- /**
- * Pick up all {@link PropertySourceProvider}s and return all the
- * {@link PropertySource}s they like to register.
- */
- private Collection<? extends PropertySource> evaluatePropertySourcesFromProviders() {
- List<PropertySource> propertySources = new ArrayList<>();
- Collection<PropertySourceProvider> propertySourceProviders = ServiceContextManager.getServiceContext().getServices(PropertySourceProvider.class);
- for (PropertySourceProvider propertySourceProvider : propertySourceProviders) {
- Collection<PropertySource> sources = propertySourceProvider.getPropertySources();
- LOG.finer("PropertySourceProvider " + propertySourceProvider.getClass().getName() +
- " provided the following property sources: " + sources);
- propertySources.addAll(sources);
- }
-
- return propertySources;
- }
-
- @Override
- public void addPropertySources(PropertySource... propertySourcesToAdd) {
- Lock writeLock = propertySourceLock.writeLock();
- try {
- writeLock.lock();
- List<PropertySource> newPropertySources = new ArrayList<>(this.immutablePropertySources);
- newPropertySources.addAll(Arrays.asList(propertySourcesToAdd));
- Collections.sort(newPropertySources, new PropertySourceComparator());
-
- this.immutablePropertySources = Collections.unmodifiableList(newPropertySources);
- } finally {
- writeLock.unlock();
- }
- }
-
- /**
- * Comparator used for comparing PropertySources.
- */
- private static class PropertySourceComparator implements Comparator<PropertySource>, Serializable {
-
- private static final long serialVersionUID = 1L;
-
- /**
- * Order property source reversely, the most important come first.
- *
- * @param source1 the first PropertySource
- * @param source2 the second PropertySource
- * @return the comparison result.
- */
- private int comparePropertySources(PropertySource source1, PropertySource source2) {
- if (source1.getOrdinal() < source2.getOrdinal()) {
- return -1;
- } else if (source1.getOrdinal() > source2.getOrdinal()) {
- return 1;
- } else {
- return source1.getClass().getName().compareTo(source2.getClass().getName());
- }
- }
-
- @Override
- public int compare(PropertySource source1, PropertySource source2) {
- return comparePropertySources(source1, source2);
- }
- }
-
- /**
- * Comparator used for comparing PropertyFilters.
- */
- private static class PropertyFilterComparator implements Comparator<PropertyFilter>, Serializable{
-
- private static final long serialVersionUID = 1L;
-
- /**
- * Compare 2 filters for ordering the filter chain.
- *
- * @param filter1 the first filter
- * @param filter2 the second filter
- * @return the comparison result
- */
- private int comparePropertyFilters(PropertyFilter filter1, PropertyFilter filter2) {
- Priority prio1 = filter1.getClass().getAnnotation(Priority.class);
- Priority prio2 = filter2.getClass().getAnnotation(Priority.class);
- int ord1 = prio1 != null ? prio1.value() : 0;
- int ord2 = prio2 != null ? prio2.value() : 0;
-
- if (ord1 < ord2) {
- return -1;
- } else if (ord1 > ord2) {
- return 1;
- } else {
- return filter1.getClass().getName().compareTo(filter2.getClass().getName());
- }
- }
-
- @Override
- public int compare(PropertyFilter filter1, PropertyFilter filter2) {
- return comparePropertyFilters(filter1, filter2);
- }
- }
-
- @Override
- public List<PropertySource> getPropertySources() {
- return immutablePropertySources;
- }
-
- @Override
- public <T> void addPropertyConverter(TypeLiteral<T> typeToConvert, PropertyConverter<T> propertyConverter) {
- propertyConverterManager.register(typeToConvert, propertyConverter);
- LOG.info("Added PropertyConverter: " + propertyConverter.getClass().getName());
- }
-
- @Override
- public Map<TypeLiteral<?>, List<PropertyConverter<?>>> getPropertyConverters() {
- return propertyConverterManager.getPropertyConverters();
- }
-
- @Override
- public <T> List<PropertyConverter<T>> getPropertyConverters(TypeLiteral<T> targetType) {
- return propertyConverterManager.getPropertyConverters(targetType);
- }
-
- @Override
- public List<PropertyFilter> getPropertyFilters() {
- return immutablePropertyFilters;
- }
-
- @Override
- public PropertyValueCombinationPolicy getPropertyValueCombinationPolicy(){
- return propertyValueCombinationPolicy;
- }
-
- @Override
- public ConfigurationContextBuilder toBuilder() {
- return ConfigurationProvider.getConfigurationContextBuilder().setContext(this);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/EnumConverter.java
----------------------------------------------------------------------
diff --git a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/EnumConverter.java b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/EnumConverter.java
deleted file mode 100644
index d003ccb..0000000
--- a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/EnumConverter.java
+++ /dev/null
@@ -1,68 +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.spisupport;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.Locale;
-import java.util.Objects;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Converter, converting from String to tge given enum type.
- * @param <T> the enum type.
- */
-public class EnumConverter<T> implements PropertyConverter<T> {
- private final Logger LOG = Logger.getLogger(EnumConverter.class.getName());
- private Class<T> enumType;
- private Method factory;
-
- public EnumConverter(Class<T> enumType) {
- if (!Enum.class.isAssignableFrom(enumType)) {
- throw new IllegalArgumentException("Not an Enum: " + enumType.getName());
- }
- this.enumType = Objects.requireNonNull(enumType);
- try {
- this.factory = enumType.getMethod("valueOf", String.class);
- } catch (NoSuchMethodException e) {
- throw new ConfigException("Uncovertible enum type without valueOf method found, please provide a custom " +
- "PropertyConverter for: " + enumType.getName());
- }
- }
-
- @Override
- public T convert(String value, ConversionContext context) {
- try {
- return (T) factory.invoke(null, value);
- } catch (InvocationTargetException | IllegalAccessException e) {
- LOG.log(Level.FINEST, "Invalid enum value '" + value + "' for " + enumType.getName(), e);
- }
- try {
- return (T) factory.invoke(null, value.toUpperCase(Locale.ENGLISH));
- } catch (InvocationTargetException | IllegalAccessException e) {
- LOG.log(Level.FINEST, "Invalid enum value '" + value + "' for " + enumType.getName(), e);
- }
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/MapPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/MapPropertySource.java b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/MapPropertySource.java
deleted file mode 100644
index ec4abc9..0000000
--- a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/MapPropertySource.java
+++ /dev/null
@@ -1,147 +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.spisupport;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Properties;
-
-/**
- * Simple PropertySource implementation that just takes a Map and an (optional) priority.
- * Optionally the entries passed can be mapped to a different rootContext.
- */
-public class MapPropertySource extends BasePropertySource {
-
- /** The unique name of the PropertySource. */
- private final String name;
-
- /**
- * The Property Sources priority, a fixed priority should be used.
- */
- private final Integer priority;
-
- /**
- * The current properties.
- */
- private final Map<String, String> props = new HashMap<>();
-
- /**
- * Creates a new instance, hereby using the default mechanism for evaluating the property source's
- * priority.
- *
- * @param name unique name of this source.
- * @param props the properties
- */
- public MapPropertySource(String name, Map<String, String> props) {
- this(name, props, null, null);
- }
-
- /**
- * Creates a new instance, hereby using the default mechanism for evaluating the property source's
- * priority, but applying a custom mapping {@code rootContext} to the entries provided.
- *
- * @param name unique name of this source.
- * @param props the properties
- * @param rootContext the root context mapping, or null (for no mapping).
- */
- public MapPropertySource(String name, Map<String, String> props, String rootContext) {
- this(name, props, rootContext, null);
- }
-
- /**
- * Creates a new instance, hereby using the default mechanism for evaluating the property source's
- * priority, but applying a custom mapping {@code rootContext} to the entries provided.
- *
- * @param name unique name of this source.
- * @param props the properties
- * @param rootContext the root context mapping, or null (for no mapping).
- * @param priority the (optional) fixed priority. If null, the default priority
- * evaluation is used.
- */
- public MapPropertySource(String name, Map<String, String> props, String rootContext, Integer priority) {
- this.priority = priority;
- this.name = Objects.requireNonNull(name);
- if (rootContext == null) {
- this.props.putAll(props);
- } else {
- for (Map.Entry<String, String> en : props.entrySet()) {
- String prefix = rootContext;
- if (!prefix.endsWith(".") && prefix.length() > 0) {
- prefix += ".";
- }
- this.props.put(prefix + en.getKey(), en.getValue());
- }
- }
- }
-
- /**
- * Creates a new instance, hereby using the default mechanism for evaluating the property source's
- * priority, but applying a custom mapping {@code rootContext} to the entries provided.
- *
- * @param name unique name of this source.
- * @param props the properties
- * @param rootContext the root context mapping, or null (for no mapping).
- * @param priority the (optional) fixed priority. If null, the default priority
- * evaluation is used.
- */
- public MapPropertySource(String name, Properties props, String rootContext, Integer priority) {
- this(name, getMap(props), rootContext, priority);
- }
-
- /**
- * Simple method to convert Properties into a Map instance.
- * @param props the properties, not null.
- * @return the corresponding Map instance.
- */
- public static Map<String, String> getMap(Properties props) {
- Map<String, String> result = new HashMap<>();
- for (Map.Entry en : props.entrySet()) {
- result.put(en.getKey().toString(), en.getValue().toString());
- }
- return result;
- }
-
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public Map<String, String> getProperties() {
- return Collections.unmodifiableMap(this.props);
- }
-
- @Override
- public int getOrdinal() {
- if(priority!=null) {
- return priority;
- }
- return super.getOrdinal();
- }
-
- @Override
- public String toString() {
- return "SimplePropertiesPropertySource{" +
- "name=" + name + ", " +
- "priority=" + priority +
- '}';
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PriorityServiceComparator.java
----------------------------------------------------------------------
diff --git a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PriorityServiceComparator.java b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PriorityServiceComparator.java
deleted file mode 100644
index 8f15696..0000000
--- a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PriorityServiceComparator.java
+++ /dev/null
@@ -1,59 +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.spisupport;
-
-import javax.annotation.Priority;
-import java.io.Serializable;
-import java.util.Comparator;
-
-/**
- * Comparator implementation for odering services loaded based on their increasing priority values.
- */
-public class PriorityServiceComparator implements Comparator<Object>, Serializable {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public int compare(Object o1, Object o2) {
- int prio = getPriority(o1) - getPriority(o2);
- if (prio < 0) {
- return 1;
- } else if (prio > 0) {
- return -1;
- } else {
- return o1.getClass().getSimpleName().compareTo(o2.getClass().getSimpleName());
- }
- }
-
- /**
- * Checks the given instance for a @Priority annotation. If present the annotation's value s evaluated. If no such
- * annotation is present, a default priority is returned (1);
- *
- * @param o the instance, not null.
- * @return a priority, by default 1.
- */
- public static int getPriority(Object o) {
- int prio = 1;
- Priority priority = o.getClass().getAnnotation(Priority.class);
- if (priority != null) {
- prio = priority.value();
- }
- return prio;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertiesResourcePropertySource.java
----------------------------------------------------------------------
diff --git a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertiesResourcePropertySource.java b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertiesResourcePropertySource.java
deleted file mode 100644
index bb8ba0b..0000000
--- a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertiesResourcePropertySource.java
+++ /dev/null
@@ -1,78 +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.spisupport;
-
-import java.io.InputStream;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Simple PropertySource, with a fixed ordinal that reads a .properties file from a given URL.
- */
-public class PropertiesResourcePropertySource extends MapPropertySource {
- /** The logger used. */
- private static final Logger LOGGER = Logger.getLogger(PropertiesResourcePropertySource.class.getName());
- /** The resource loaded. */
- private final URL url;
-
- /**
- * Creates a new instance.
- * @param url the resource URL, not null.
- * @param priority the optional (fixed) priority ordinal.
- */
- public PropertiesResourcePropertySource(URL url, Integer priority){
- this(null, url, priority);
- }
-
- /**
- * Creates a new instance.
- * @param rootContext the (optional) root context for mapping (prefixing) the properties loaded.
- * @param url the resource URL, not null.
- * @param priority the optional (fixed) priority ordinal.
- */
- public PropertiesResourcePropertySource(String rootContext, URL url, Integer priority){
- super(url.toExternalForm(), loadProps(url), rootContext, priority);
- this.url = url;
- }
-
- /**
- * Loads the properties using the JDK's Property loading mechanism.
- * @param url the resource URL, not null.
- * @return the loaded properties.
- */
- private static Map<String, String> loadProps(URL url) {
- Map<String,String> result = new HashMap<>();
- try(InputStream is = url.openStream()){
- Properties props = new Properties();
- props.load(is);
- for(Map.Entry en: props.entrySet()){
- result.put(en.getKey().toString(), en.getValue().toString());
- }
- }
- catch(Exception e){
- LOGGER.log(Level.WARNING, "Failed to read properties from " + url, e);
- }
- return result;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyConverterManager.java
----------------------------------------------------------------------
diff --git a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyConverterManager.java b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyConverterManager.java
deleted file mode 100644
index 2be6313..0000000
--- a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyConverterManager.java
+++ /dev/null
@@ -1,437 +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.spisupport;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-import org.apache.tamaya.spi.ServiceContextManager;
-
-import javax.annotation.Priority;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.lang.reflect.Type;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-import java.util.logging.Logger;
-
-/**
- * Manager that deals with {@link PropertyConverter} instances.
- * This class is thread-safe.
- */
-public class PropertyConverterManager {
- /**
- * The logger used.
- */
- private static final Logger LOG = Logger.getLogger(PropertyConverterManager.class.getName());
- /**
- * The registered converters.
- */
- private final Map<TypeLiteral<?>, List<PropertyConverter<?>>> converters = new ConcurrentHashMap<>();
- /**
- * The transitive converters.
- */
- private final Map<TypeLiteral<?>, List<PropertyConverter<?>>> transitiveConverters = new ConcurrentHashMap<>();
- /**
- * The lock used.
- */
- private final ReadWriteLock lock = new ReentrantReadWriteLock();
-
- private static final Comparator<Object> PRIORITY_COMPARATOR = new Comparator<Object>() {
-
- @Override
- public int compare(Object o1, Object o2) {
- int prio = getPriority(o1) - getPriority(o2);
- if (prio < 0) {
- return 1;
- } else if (prio > 0) {
- return -1;
- } else {
- return o1.getClass().getSimpleName().compareTo(o2.getClass().getSimpleName());
- }
- }
- };
-
- /**
- * Checks the given instance for a @Priority annotation. If present the annotation's value s evaluated. If no such
- * annotation is present, a default priority is returned (1);
- * @param o the instance, not null.
- * @return a priority, by default 1.
- */
- public static int getPriority(Object o){
- int prio = 1;
- Priority priority = o.getClass().getAnnotation(Priority.class);
- if (priority != null) {
- prio = priority.value();
- }
- return prio;
- }
-
- /**
- * Constructor.
- */
- public PropertyConverterManager() {
- this(true);
- }
-
- public PropertyConverterManager(boolean init) {
- if (init) {
- initConverters();
- }
- }
-
- /**
- * Registers the default converters provided out of the box.
- */
- protected void initConverters() {
- for (PropertyConverter conv : ServiceContextManager.getServiceContext().getServices(PropertyConverter.class)) {
- Type type = TypeLiteral.getGenericInterfaceTypeParameters(conv.getClass(), PropertyConverter.class)[0];
- register(TypeLiteral.of(type), conv);
- }
- }
-
- /**
- * Registers a ew converter instance.
- *
- * @param targetType the target type, not null.
- * @param converter the converter, not null.
- * @param <T> the type.
- */
- public <T> void register(TypeLiteral<T> targetType, PropertyConverter<T> converter) {
- Objects.requireNonNull(converter);
- Lock writeLock = lock.writeLock();
- try {
- writeLock.lock();
- List converters = List.class.cast(this.converters.get(targetType));
- List<PropertyConverter<?>> newConverters = new ArrayList<>();
- if (converters != null) {
- newConverters.addAll(converters);
- }
- newConverters.add(converter);
- Collections.sort(newConverters, PRIORITY_COMPARATOR);
- this.converters.put(targetType, Collections.unmodifiableList(newConverters));
- // evaluate transitive closure for all inherited supertypes and implemented interfaces
- // direct implemented interfaces
- for (Class<?> ifaceType : targetType.getRawType().getInterfaces()) {
- converters = List.class.cast(this.transitiveConverters.get(TypeLiteral.of(ifaceType)));
- newConverters = new ArrayList<>();
- if (converters != null) {
- newConverters.addAll(converters);
- }
- newConverters.add(converter);
- Collections.sort(newConverters, PRIORITY_COMPARATOR);
- this.transitiveConverters.put(TypeLiteral.of(ifaceType), Collections.unmodifiableList(newConverters));
- }
- Class<?> superClass = targetType.getRawType().getSuperclass();
- while (superClass != null && !superClass.equals(Object.class)) {
- converters = List.class.cast(this.transitiveConverters.get(TypeLiteral.of(superClass)));
- newConverters = new ArrayList<>();
- if (converters != null) {
- newConverters.addAll(converters);
- }
- newConverters.add(converter);
- Collections.sort(newConverters, PRIORITY_COMPARATOR);
- this.transitiveConverters.put(TypeLiteral.of(superClass), Collections.unmodifiableList(newConverters));
- for (Class<?> ifaceType : superClass.getInterfaces()) {
- converters = List.class.cast(this.transitiveConverters.get(TypeLiteral.of(ifaceType)));
- newConverters = new ArrayList<>();
- if (converters != null) {
- newConverters.addAll(converters);
- }
- newConverters.add(converter);
- Collections.sort(newConverters, PRIORITY_COMPARATOR);
- this.transitiveConverters.put(TypeLiteral.of(ifaceType), Collections.unmodifiableList(newConverters));
- }
- superClass = superClass.getSuperclass();
- }
- } finally {
- writeLock.unlock();
- }
- }
-
- /**
- * Allows to evaluate if a given target type is supported.
- *
- * @param targetType the target type, not null.
- * @return true, if a converter for the given type is registered, or a default one can be created.
- */
- public boolean isTargetTypeSupported(TypeLiteral<?> targetType) {
- return converters.containsKey(targetType) || transitiveConverters.containsKey(targetType)
- || createDefaultPropertyConverter(targetType) != null;
- }
-
- /**
- * Get a map of all property converters currently registered. This will not contain the converters that
- * may be created, when an instance is adapted, which provides a String constructor or compatible
- * factory methods taking a single String instance.
- *
- * @return the current map of instantiated and registered converters.
- * @see #createDefaultPropertyConverter(TypeLiteral)
- */
- public Map<TypeLiteral<?>, List<PropertyConverter<?>>> getPropertyConverters() {
- Lock readLock = lock.readLock();
- try {
- readLock.lock();
- return new HashMap<>(this.converters);
- } finally {
- readLock.unlock();
- }
- }
-
- /**
- * Get the list of all current registered converters for the given target type.
- * If not converters are registered, they component tries to create and register a dynamic
- * converter based on String costructor or static factory methods available.
- *
- * <p>The converters provided are of the following type and returned in the following order:</p>
- *
- * <ul>
- * <li>Converters mapped explicitly to the required target type are returned first, ordered
- * by decreasing priority. This means, if explicit converters are registered these are used
- * primarly for converting a value.</li>
- * <li>The target type of each explicitly registered converter also can be transitively mapped to
- * 1) all directly implemented interfaces, 2) all its superclasses (except Object), 3) all the interfaces
- * implemented by its superclasses. These groups of transitive converters is returned similarly in the
- * order as mentioned, whereas also here a priority based decreasing ordering is applied.</li>
- * <li>java.lang wrapper classes and native types are automatically mapped.</li>
- * <li>If no explicit converters are registered, for Enum types a default implementation is provided that
- * compares the configuration values with the different enum members defined (cases sensitive mapping).</li>
- * </ul>
- *
- *
- * So given that list above directly registered mappings always are tried first, before any transitive mapping
- * should be used. Also in all cases @Priority annotations are honored for ordering of the converters in place.
- * Transitive conversion is supported for all directly implemented interfaces (including inherited ones) and
- * the inheritance hierarchy (exception Object). Superinterfaces of implemented interfaces are ignored.
- *
- *
- * @param targetType the target type, not null.
- * @param <T> the type class
- * @return the ordered list of converters (may be empty for not convertible types).
- * @see #createDefaultPropertyConverter(TypeLiteral)
- */
- public <T> List<PropertyConverter<T>> getPropertyConverters(TypeLiteral<T> targetType) {
- Lock readLock = lock.readLock();
- List<PropertyConverter<T>> converterList = new ArrayList<>();
- List<PropertyConverter<T>> converters;
- // direct mapped converters
- try {
- readLock.lock();
- converters = List.class.cast(this.converters.get(targetType));
- } finally {
- readLock.unlock();
- }
- if (converters != null) {
- converterList.addAll(converters);
- }
- // transitive converter
- try {
- readLock.lock();
- converters = List.class.cast(this.transitiveConverters.get(targetType));
- } finally {
- readLock.unlock();
- }
- if (converters != null) {
- converterList.addAll(converters);
- }
- // handling of java.ui.lang wrapper classes
- TypeLiteral<T> boxedType = mapBoxedType(targetType);
- if (boxedType != null) {
- try {
- readLock.lock();
- converters = List.class.cast(this.converters.get(boxedType));
- } finally {
- readLock.unlock();
- }
- if (converters != null) {
- converterList.addAll(converters);
- }
- }
- if (converterList.isEmpty()) {
- // adding any converters created on the fly, e.g. for enum types.
- PropertyConverter<T> defaultConverter = createDefaultPropertyConverter(targetType);
- if (defaultConverter != null) {
- register(targetType, defaultConverter);
- try {
- readLock.lock();
- converters = List.class.cast(this.converters.get(targetType));
- } finally {
- readLock.unlock();
- }
- }
- if (converters != null) {
- converterList.addAll(converters);
- }
- }
- return converterList;
- }
-
- /**
- * Maps native types to the corresponding boxed types.
- *
- * @param targetType the native type.
- * @param <T> the type
- * @return the boxed type, or null.
- */
- @SuppressWarnings("all")
- private <T> TypeLiteral<T> mapBoxedType(TypeLiteral<T> targetType) {
- Type parameterType = targetType.getType();
- if (parameterType == int.class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Integer.class));
- }
- if (parameterType == short.class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Short.class));
- }
- if (parameterType == byte.class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Byte.class));
- }
- if (parameterType == long.class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Long.class));
- }
- if (parameterType == boolean.class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Boolean.class));
- }
- if (parameterType == char.class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Character.class));
- }
- if (parameterType == float.class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Float.class));
- }
- if (parameterType == double.class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Double.class));
- }
- if (parameterType == int[].class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Integer[].class));
- }
- if (parameterType == short[].class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Short[].class));
- }
- if (parameterType == byte[].class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Byte[].class));
- }
- if (parameterType == long[].class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Long[].class));
- }
- if (parameterType == boolean.class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Boolean.class));
- }
- if (parameterType == char[].class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Character[].class));
- }
- if (parameterType == float[].class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Float[].class));
- }
- if (parameterType == double[].class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Double[].class));
- }
- return null;
- }
-
- /**
- * Creates a dynamic PropertyConverter for the given target type.
- *
- * @param targetType the target type
- * @param <T> the type class
- * @return a new converter, or null.
- */
- protected <T> PropertyConverter<T> createDefaultPropertyConverter(final TypeLiteral<T> targetType) {
- if (Enum.class.isAssignableFrom(targetType.getRawType())) {
- return new EnumConverter<>(targetType.getRawType());
- }
- PropertyConverter<T> converter = null;
- final Method factoryMethod = getFactoryMethod(targetType.getRawType(), "of", "valueOf", "instanceOf", "getInstance", "from", "fromString", "parse");
- if (factoryMethod != null) {
- converter = new PropertyConverter<T>() {
- @Override
- public T convert(String value, ConversionContext context) {
- try {
- if (!Modifier.isStatic(factoryMethod.getModifiers())) {
- throw new ConfigException(factoryMethod.toGenericString() +
- " is not a static method. Only static " +
- "methods can be used as factory methods.");
- }
- AccessController.doPrivileged(new PrivilegedAction<Object>() {
- public Object run() {
- factoryMethod.setAccessible(true);
- return null;
- }
- });
- Object invoke = factoryMethod.invoke(null, value);
- return targetType.getRawType().cast(invoke);
- } catch (Exception e) {
- throw new ConfigException("Failed to decode '" + value + "'", e);
- }
- }
- };
- }
- if (converter == null) {
- try {
- final Constructor<T> constr = targetType.getRawType().getDeclaredConstructor(String.class);
- converter = new PropertyConverter<T>() {
- @Override
- public T convert(String value, ConversionContext context) {
- try {
- constr.setAccessible(true);
- return constr.newInstance(value);
- } catch (Exception e) {
- throw new ConfigException("Failed to decode '" + value + "'", e);
- }
- }
- };
- } catch (Exception e) {
- LOG.finest("Failed to construct instance of type: " + targetType.getRawType().getName() + ": " + e);
- }
- }
- return converter;
- }
-
- /**
- * Tries to evaluate a factory method that can be used to create an instance based on a String.
- *
- * @param type the target type
- * @param methodNames the possible static method names
- * @return the first method found, or null.
- */
- private Method getFactoryMethod(Class<?> type, String... methodNames) {
- Method m;
- for (String name : methodNames) {
- try {
- m = type.getDeclaredMethod(name, String.class);
- return m;
- } catch (NoSuchMethodException | RuntimeException e) {
- LOG.finest("No such factory method found on type: " + type.getName() + ", methodName: " + name);
- }
- }
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyFiltering.java
----------------------------------------------------------------------
diff --git a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyFiltering.java b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyFiltering.java
deleted file mode 100644
index eef758b..0000000
--- a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertyFiltering.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.spisupport;
-
-import org.apache.tamaya.spi.ConfigurationContext;
-import org.apache.tamaya.spi.FilterContext;
-import org.apache.tamaya.spi.PropertyFilter;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Implementation of the Configuration API. This class uses the current {@link ConfigurationContext} to evaluate the
- * chain of {@link org.apache.tamaya.spi.PropertySource} and {@link PropertyFilter}
- * instance to evaluate the current Configuration.
- */
-public final class PropertyFiltering{
- /**
- * The logger.
- */
- private static final Logger LOG = Logger.getLogger(PropertyFiltering.class.getName());
- /**
- * The maximal number of filter cycles performed before aborting.
- */
- private static final int MAX_FILTER_LOOPS = 10;
-
- /**
- * Private singleton constructor.
- */
- private PropertyFiltering(){}
-
- public static String applyFilter(String key, Map<String,String> configData, ConfigurationContext configurationContext) {
- // Apply filters to values, prevent values filtered to null!
- String unfilteredValue = configData.get(key);
- for (int i = 0; i < MAX_FILTER_LOOPS; i++) {
- boolean changed = false;
- // Apply filters to values, prevent values filtered to null!
- for (PropertyFilter filter : configurationContext.getPropertyFilters()) {
- String newValue = filter.filterProperty(unfilteredValue, new FilterContext(key, configData, true));
- if (newValue != null && !newValue.equals(unfilteredValue)) {
- changed = true;
- if (LOG.isLoggable(Level.FINEST)) {
- LOG.finest("Filter - " + key + ": " + unfilteredValue + " -> " + newValue + " by " + filter);
- }
- } else if (unfilteredValue != null && !unfilteredValue.equals(newValue)) {
- changed = true;
- if (LOG.isLoggable(Level.FINEST)) {
- LOG.finest("Filter - " + key + ": " + unfilteredValue + " -> " + newValue + " by " + filter);
- }
- }
- unfilteredValue = newValue;
- }
- if (!changed) {
- LOG.finest("Finishing filter loop, no changes detected.");
- break;
- } else {
- if (i == (MAX_FILTER_LOOPS - 1)) {
- if (LOG.isLoggable(Level.WARNING)) {
- LOG.warning("Maximal filter loop count reached, aborting filter evaluation after cycles: " + i);
- }
- } else {
- LOG.finest("Repeating filter loop, changes detected.");
- }
- }
- }
- return unfilteredValue;
- }
-
- public static Map<String, String> applyFilters(Map<String, String> inputMap, ConfigurationContext configurationContext) {
- Map<String, String> resultMap = new HashMap<>(inputMap);
- // Apply filters to values, prevent values filtered to null!
- for (int i = 0; i < MAX_FILTER_LOOPS; i++) {
- AtomicInteger changes = new AtomicInteger();
- for (PropertyFilter filter : configurationContext.getPropertyFilters()) {
- for (Map.Entry<String, String> entry : inputMap.entrySet()) {
- final String k = entry.getKey();
- final String v = entry.getValue();
-
- String newValue = filter.filterProperty(v, new FilterContext(k, inputMap, false));
- if (newValue != null && !newValue.equals(v)) {
- changes.incrementAndGet();
- LOG.finest("Filter - " + k + ": " + v + " -> " + newValue + " by " + filter);
- } else if (v != null && !v.equals(newValue)) {
- changes.incrementAndGet();
- LOG.finest("Filter - " + k + ": " + v + " -> " + newValue + " by " + filter);
- }
- // Remove null values
- if (null != newValue) {
- resultMap.put(k, newValue);
- }else{
- resultMap.remove(k);
- }
- }
- }
- if (changes.get() == 0) {
- LOG.finest("Finishing filter loop, no changes detected.");
- break;
- } else {
- if (i == (MAX_FILTER_LOOPS - 1)) {
- if (LOG.isLoggable(Level.WARNING)) {
- LOG.warning("Maximal filter loop count reached, aborting filter evaluation after cycles: " + i);
- }
- } else {
- LOG.finest("Repeating filter loop, changes detected: " + changes.get());
- }
- changes.set(0);
- }
- }
- return resultMap;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertySourceComparator.java
----------------------------------------------------------------------
diff --git a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertySourceComparator.java b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertySourceComparator.java
deleted file mode 100644
index 6554167..0000000
--- a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/PropertySourceComparator.java
+++ /dev/null
@@ -1,54 +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.spisupport;
-
-import org.apache.tamaya.spi.PropertySource;
-
-import java.io.Serializable;
-import java.util.Comparator;
-
-/**
- * Comparator for ordering of PropertySources based on their ordinal method and class name.
- */
-public class PropertySourceComparator implements Comparator<PropertySource>, Serializable {
- /** serial version UID. */
- private static final long serialVersionUID = 1L;
-
- /**
- * Order property source reversely, the most important come first.
- *
- * @param source1 the first PropertySource
- * @param source2 the second PropertySource
- * @return the comparison result.
- */
- private int comparePropertySources(PropertySource source1, PropertySource source2) {
- if (source1.getOrdinal() < source2.getOrdinal()) {
- return -1;
- } else if (source1.getOrdinal() > source2.getOrdinal()) {
- return 1;
- } else {
- return source1.getClass().getName().compareTo(source2.getClass().getName());
- }
- }
-
- @Override
- public int compare(PropertySource source1, PropertySource source2) {
- return comparePropertySources(source1, source2);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/yaml/pom.xml
----------------------------------------------------------------------
diff --git a/modules/yaml/pom.xml b/modules/yaml/pom.xml
deleted file mode 100644
index 483b6a9..0000000
--- a/modules/yaml/pom.xml
+++ /dev/null
@@ -1,117 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-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.
--->
-<project xmlns="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">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-extensions</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
- <artifactId>tamaya-yaml</artifactId>
- <name>Apache Tamaya Modules - YAML Support</name>
- <packaging>bundle</packaging>
- <inceptionYear>2016</inceptionYear>
-
- <properties>
- <jdkVersion>1.7</jdkVersion>
- <snakeyaml.version>1.17</snakeyaml.version>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-api</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-core</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-formats</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.yaml</groupId>
- <artifactId>snakeyaml</artifactId>
- <version>${snakeyaml.version}</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>java-hamcrest</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>copyMain</id>
- <phase>process-test-sources</phase>
- <goals>
- <goal>copy</goal>
- </goals>
- <configuration>
- <outputDirectory>${project.build.directory}</outputDirectory>
- <overWriteReleases>false</overWriteReleases>
- <overWriteSnapshots>false</overWriteSnapshots>
- <overWriteIfNewer>true</overWriteIfNewer>
- <stripVersion>true</stripVersion>
- <artifactItems>
- <artifactItem>
- <groupId>org.jboss.arquillian.daemon</groupId>
- <artifactId>arquillian-daemon-main</artifactId>
- </artifactItem>
- </artifactItems>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.tamaya.json
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/yaml/src/main/java/org/apache/tamaya/json/YAMLFormat.java
----------------------------------------------------------------------
diff --git a/modules/yaml/src/main/java/org/apache/tamaya/json/YAMLFormat.java b/modules/yaml/src/main/java/org/apache/tamaya/json/YAMLFormat.java
deleted file mode 100644
index 06e431e..0000000
--- a/modules/yaml/src/main/java/org/apache/tamaya/json/YAMLFormat.java
+++ /dev/null
@@ -1,156 +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.json;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.format.ConfigurationData;
-import org.apache.tamaya.format.ConfigurationDataBuilder;
-import org.apache.tamaya.format.ConfigurationFormat;
-import org.yaml.snakeyaml.Yaml;
-
-import java.io.InputStream;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import static java.lang.String.format;
-
-
-/**
- * Implementation of the {@link org.apache.tamaya.format.ConfigurationFormat}
- * able to read configuration properties represented in JSON
- *
- * @see <a href="http://www.json.org">JSON format specification</a>
- */
-public class YAMLFormat implements ConfigurationFormat {
- /**
- * THe logger.
- */
- private static final Logger LOG = Logger.getLogger(YAMLFormat.class.getName());
-
- /**
- * Constructor, itniaitlizing zhe JSON reader factory.
- */
- public YAMLFormat(){
- }
-
- @Override
- public String getName() {
- return "yaml";
- }
-
- @Override
- public boolean accepts(URL url) {
- return Objects.requireNonNull(url).getPath().endsWith(".yaml");
- }
-
- @Override
- public ConfigurationData readConfiguration(String resource, InputStream inputStream) {
- try( InputStream in = inputStream;) {
- Map<String, String> values = readConfig(resource, inputStream);
- return ConfigurationDataBuilder.of(resource, this).addProperties(values)
- .build();
- } catch (Exception e) {
- throw new ConfigException("Failed to read data from " + resource, e);
- }
- }
-
- /**
- * Reads the configuration.
- * @param inputStream the input stream, not null.
- * @param resource resource URI, not null.
- * @return the configuration read from the given resource URI.
- * @throws ConfigException if resource URI cannot be read.
- */
- protected Map<String, String> readConfig(String resource, InputStream inputStream) {
- try{
- Yaml yaml = new Yaml();
- HashMap<String, String> values = new HashMap<>();
- Object config = yaml.load(inputStream);
- mapYamlIntoProperties(config, values);
- if(LOG.isLoggable(Level.FINEST)){
- LOG.finest("Read data from " + resource + " : " + values);
- }
- return values;
- }catch (Throwable t) {
- throw new ConfigException(format("Failed to read properties from %s", resource), t);
- }
- }
- /**
- * Reads the configuration.
- * @param urlResource soure of the configuration.
- * @return the configuration read from the given resource URL.
- * @throws ConfigException if resource URL cannot be read.
- */
- protected Map<String, String> readConfig(URL urlResource) {
- try (InputStream is = urlResource.openStream()) {
- return readConfig(urlResource.toExternalForm(), is);
- }
- catch (Throwable t) {
- throw new ConfigException(format("Failed to read properties from %s", urlResource.toExternalForm()), t);
- }
- }
-
- private void mapYamlIntoProperties(Object config, HashMap<String, String> values) {
- mapYamlIntoProperties("", config, values);
- }
-
- /**
- * Maps the given config item (could be a String, a collection type or something else returned by the yaml parser
- * to a key/value pair and adds it to {@code values} (hereby honoring the prefix as a key to be used.).
- * Collection types are recursively to remapped hereby extending the given prefix as needed and recursively
- * delegate mapping of values contained.
- * @param prefix the prefix or key evaluated so far, never null (but can be empty for root entries).
- * @param config the config value. Could be a single value or a collection type.
- * @param values the properties where items identified must be written into. These properties are going to be
- * returned as result of the format reading operation ans integrated into the overall configuration
- * map.
- */
- protected void mapYamlIntoProperties(String prefix, Object config, HashMap<String, String> values) {
- // add further data types supported by yaml, e.g. date, ...
- if(config instanceof List){
- StringBuilder b = new StringBuilder();
- for(Object val:((List<Object>)config)){
- b.append(mapValueToString(val));
- b.append(",");
- }
- if(b.length()>0){
- b.setLength(b.length()-1);
- }
- values.put(prefix, b.toString());
- values.put("_"+prefix+".collection-type", "List");
- } else if(config instanceof Map){
- for(Map.Entry<String,Object> en:((Map<String,Object>)config).entrySet()){
- String newPrefix = prefix.isEmpty()?en.getKey():prefix +"."+en.getKey();
- mapYamlIntoProperties(newPrefix, en.getValue(), values);
- }
- } else{
- values.put(prefix, mapValueToString(config));
- }
- }
-
- protected String mapValueToString(Object val) {
- return String.valueOf(val);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/yaml/src/main/java/org/apache/tamaya/json/YAMLPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/yaml/src/main/java/org/apache/tamaya/json/YAMLPropertySource.java b/modules/yaml/src/main/java/org/apache/tamaya/json/YAMLPropertySource.java
deleted file mode 100644
index e29d2e7..0000000
--- a/modules/yaml/src/main/java/org/apache/tamaya/json/YAMLPropertySource.java
+++ /dev/null
@@ -1,100 +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.json;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-
-import java.net.URL;
-import java.util.*;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-
-
-/**
- * Property source based on a JSON file.
- */
-public class YAMLPropertySource implements PropertySource {
- /** The underlying resource. */
- private final URL urlResource;
- /** The values read. */
- private final Map<String, String> values;
- /** The evaluated ordinal. */
- private int ordinal;
- /** The format implementation used for parsing. */
- private YAMLFormat format = new YAMLFormat();
-
- /**
- * Constructor, hereby using 0 as the default ordinal.
- * @param resource the resource modelled as URL, not null.
- */
- public YAMLPropertySource(URL resource) {
- this(resource, 0);
- }
-
- /**
- * Constructor.
- * @param resource the resource modelled as URL, not null.
- * @param defaultOrdinal the defaultOrdinal to be used.
- */
- public YAMLPropertySource(URL resource, int defaultOrdinal) {
- urlResource = Objects.requireNonNull(resource);
- this.ordinal = defaultOrdinal; // may be overriden by read...
- this.values = format.readConfig(urlResource);
- if (this.values.containsKey(TAMAYA_ORDINAL)) {
- this.ordinal = Integer.parseInt(this.values.get(TAMAYA_ORDINAL));
- }
- }
-
- @Override
- public int getOrdinal() {
- PropertyValue configuredOrdinal = get(TAMAYA_ORDINAL);
- if(configuredOrdinal!=null){
- try{
- return Integer.parseInt(configuredOrdinal.getValue());
- } catch(Exception e){
- Logger.getLogger(getClass().getName()).log(Level.WARNING,
- "Configured Ordinal is not an int number: " + configuredOrdinal, e);
- }
- }
- return ordinal;
- }
-
- @Override
- public String getName() {
- return urlResource.toExternalForm();
- }
-
- @Override
- public PropertyValue get(String key) {
- return PropertyValue.of(key, getProperties().get(key), getName());
- }
-
- @Override
- public Map<String, String> getProperties() {
- return Collections.unmodifiableMap(values);
- }
-
-
- @Override
- public boolean isScannable() {
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/yaml/src/main/resources/META-INF/services/org.apache.tamaya.format.ConfigurationFormat
----------------------------------------------------------------------
diff --git a/modules/yaml/src/main/resources/META-INF/services/org.apache.tamaya.format.ConfigurationFormat b/modules/yaml/src/main/resources/META-INF/services/org.apache.tamaya.format.ConfigurationFormat
deleted file mode 100644
index 1b5d57d..0000000
--- a/modules/yaml/src/main/resources/META-INF/services/org.apache.tamaya.format.ConfigurationFormat
+++ /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.json.YAMLFormat
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/yaml/src/test/java/org/apache/tamaya/json/YAMLFormatTest.java
----------------------------------------------------------------------
diff --git a/modules/yaml/src/test/java/org/apache/tamaya/json/YAMLFormatTest.java b/modules/yaml/src/test/java/org/apache/tamaya/json/YAMLFormatTest.java
deleted file mode 100644
index 0f0e589..0000000
--- a/modules/yaml/src/test/java/org/apache/tamaya/json/YAMLFormatTest.java
+++ /dev/null
@@ -1,73 +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.json;
-
-
-import org.apache.tamaya.format.ConfigurationData;
-import org.apache.tamaya.format.FlattenedDefaultPropertySource;
-import org.apache.tamaya.spi.PropertySource;
-import org.junit.Test;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Map;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-public class YAMLFormatTest {
- private final YAMLFormat format = new YAMLFormat();
-
- @Test
- public void testAcceptURL() throws MalformedURLException {
- assertTrue(format.accepts(new URL("http://127.0.0.1/anyfile.yaml")));
- }
-
- @Test
- public void testAcceptURL_BC1() throws MalformedURLException {
- assertFalse(format.accepts(new URL("http://127.0.0.1/anyfile.YAML")));
- }
-
- @Test(expected = NullPointerException.class)
- public void testAcceptURL_BC2() throws MalformedURLException {
- assertFalse(format.accepts(null));
- }
-
- @Test
- public void testAcceptURL_BC3() throws MalformedURLException {
- assertFalse(format.accepts(new URL("http://127.0.0.1/anyfile.docx")));
- }
-
- @Test
- public void testRead() throws IOException {
- URL configURL = YAMLPropertySourceTest.class.getResource("/configs/valid/contact.yaml");
- assertTrue(format.accepts(configURL));
- ConfigurationData data = format.readConfiguration(configURL.toString(), configURL.openStream());
- assertNotNull(data);
- for(Map.Entry<String,String> en:data.getDefaultProperties().entrySet()) {
- System.out.println(en.getKey() + " -> " + en.getValue());
- }
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/yaml/src/test/java/org/apache/tamaya/json/YAMLPropertySourceTest.java
----------------------------------------------------------------------
diff --git a/modules/yaml/src/test/java/org/apache/tamaya/json/YAMLPropertySourceTest.java b/modules/yaml/src/test/java/org/apache/tamaya/json/YAMLPropertySourceTest.java
deleted file mode 100644
index 7f1c7a3..0000000
--- a/modules/yaml/src/test/java/org/apache/tamaya/json/YAMLPropertySourceTest.java
+++ /dev/null
@@ -1,54 +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.json;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.spi.PropertySource;
-import org.hamcrest.CoreMatchers;
-import org.junit.Test;
-
-import java.net.URL;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-
-public class YAMLPropertySourceTest {
-
- @Test
- public void testYamlWithOrdinal() throws Exception {
- URL configURL = YAMLPropertySourceTest.class.getResource("/configs/valid/test-with-prio.yaml");
-
- assertThat(configURL, CoreMatchers.notNullValue());
-
- YAMLPropertySource source = new YAMLPropertySource(configURL, 4);
- assertEquals(source.getOrdinal(), 16784);
- }
-
- @Test
- public void testYamlDefaultOrdinal() throws Exception {
- URL configURL = YAMLPropertySourceTest.class.getResource("/configs/valid/test.yaml");
-
- assertThat(configURL, CoreMatchers.notNullValue());
-
- YAMLPropertySource source = new YAMLPropertySource(configURL, 4);
- assertEquals(source.getOrdinal(), 4);
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/yaml/src/test/resources/configs/valid/contact.yaml
----------------------------------------------------------------------
diff --git a/modules/yaml/src/test/resources/configs/valid/contact.yaml b/modules/yaml/src/test/resources/configs/valid/contact.yaml
deleted file mode 100644
index 95d5a03..0000000
--- a/modules/yaml/src/test/resources/configs/valid/contact.yaml
+++ /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 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.
-#
-invoice: 34843
-date : 2001-01-23
-bill-to: &id001
- given : Chris
- family : Dumars
- address:
- lines: |
- 458 Walkman Dr.
- Suite #292
- city : Royal Oak
- state : MI
- postal : 48046
-ship-to: *id001
-product:
- - sku : BL394D
- quantity : 4
- description : Basketball
- price : 450.00
- - sku : BL4438H
- quantity : 1
- description : Super Hoop
- price : 2392.00
-tax : 251.42
-total: 4443.52
-comments: >
- Late afternoon is best.
- Backup contact is Nancy
- Billsmer @ 338-4338.
\ No newline at end of file