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:39 UTC
[22/24] incubator-tamaya git commit: Removed all modules from the
main repository. They will be reborn in separate ASF repository.
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;
- }
-}