You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by st...@apache.org on 2015/01/03 19:07:42 UTC

[1/9] incubator-tamaya git commit: TAMAYA-38 implemented standard System- and EnvironmentPropertySource

Repository: incubator-tamaya
Updated Branches:
  refs/heads/master 574332226 -> 0734e210e


TAMAYA-38 implemented standard System- and EnvironmentPropertySource


Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/51960ef0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/51960ef0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/51960ef0

Branch: refs/heads/master
Commit: 51960ef0f1fe507cb894228b1097d35e4d7d077a
Parents: 0791e87
Author: Reinhard Sandtner <re...@gmail.com>
Authored: Fri Jan 2 19:40:19 2015 +0100
Committer: Reinhard Sandtner <re...@gmail.com>
Committed: Sat Jan 3 13:18:49 2015 +0100

----------------------------------------------------------------------
 .../org/apache/tamaya/spi/PropertySource.java   |   7 ++
 core/pom.xml                                    |   5 +
 .../core/propertysource/BasePropertySource.java |  76 +++++++++++++
 .../core/propertysource/DefaultOrdinal.java     |  46 ++++++++
 .../EnvironmentPropertySource.java              |  47 ++++++++
 .../propertysource/SystemPropertySource.java    |  82 ++++++++++++++
 .../propertysource/BasePropertySourceTest.java  | 107 +++++++++++++++++++
 .../EnvironmentPropertySourceTest.java          |  70 ++++++++++++
 .../SystemPropertySourceTest.java               | 103 ++++++++++++++++++
 9 files changed, 543 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/51960ef0/api/src/main/java/org/apache/tamaya/spi/PropertySource.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/spi/PropertySource.java b/api/src/main/java/org/apache/tamaya/spi/PropertySource.java
index 711b84b..eb11358 100644
--- a/api/src/main/java/org/apache/tamaya/spi/PropertySource.java
+++ b/api/src/main/java/org/apache/tamaya/spi/PropertySource.java
@@ -48,6 +48,12 @@ import java.util.Optional;
 public interface PropertySource {
 
     /**
+     * property name to override default tamaya ordinals
+     */
+    static final String TAMAYA_ORDINAL = "tamaya.ordinal";
+
+
+    /**
      * Lookup order:
      * TODO rethink whole default PropertySources and ordering:
      * TODO introduce default values or constants for ordinals
@@ -88,6 +94,7 @@ public interface PropertySource {
     /**
      * Access a property.
      *
+     * //X TODO discuss if the key can be null
      * @param key the property's key, not null.
      * @return the property's keys.
      */

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/51960ef0/core/pom.xml
----------------------------------------------------------------------
diff --git a/core/pom.xml b/core/pom.xml
index 26ccce0..917f2e2 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -36,6 +36,11 @@ under the License.
             <artifactId>tamaya-api</artifactId>
             <version>${project.version}</version>
         </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
     </dependencies>
 
 </project>

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/51960ef0/core/src/main/java/org/apache/tamaya/core/propertysource/BasePropertySource.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/propertysource/BasePropertySource.java b/core/src/main/java/org/apache/tamaya/core/propertysource/BasePropertySource.java
new file mode 100644
index 0000000..2a0107c
--- /dev/null
+++ b/core/src/main/java/org/apache/tamaya/core/propertysource/BasePropertySource.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.core.propertysource;
+
+import org.apache.tamaya.spi.PropertySource;
+
+import java.util.Objects;
+import java.util.Optional;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Base class for {@link PropertySource}s
+ */
+public abstract class BasePropertySource implements PropertySource {
+
+    private static final Logger LOG = Logger.getLogger(BasePropertySource.class.getName());
+
+
+    private int ordinal = DefaultOrdinal.PROPERTY_SOURCE;
+
+
+    @Override
+    public int getOrdinal() {
+        return ordinal;
+    }
+
+
+    @Override
+    public Optional<String> get(String key) {
+        Objects.requireNonNull(key, "key must not be null");
+        return Optional.ofNullable(getProperties().get(key));
+    }
+
+
+    /**
+     * Initializing the ordinal of this {@link PropertySource} with the given defaultOrdinal.
+     *
+     * If {@link PropertySource#TAMAYA_ORDINAL} is present via {@link #get(String)} and the
+     * value is a valid {@link Integer} then, the defaultOrdinal will be overridden.
+     *
+     * @param defaultOrdinal of the {@link PropertySource}
+     */
+    protected void initialzeOrdinal(final int defaultOrdinal) {
+        this.ordinal = defaultOrdinal;
+
+        Optional<String> ordinal = get(PropertySource.TAMAYA_ORDINAL);
+        if (ordinal.isPresent()) {
+
+            try {
+                this.ordinal = Integer.valueOf(ordinal.get());
+            } catch (NumberFormatException e) {
+                LOG.log(Level.WARNING,
+                        "Specified {0} is not a valid Integer value: {1} - using defaultOrdinal {2}",
+                        new Object[]{PropertySource.TAMAYA_ORDINAL, ordinal.get(), defaultOrdinal});
+            }
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/51960ef0/core/src/main/java/org/apache/tamaya/core/propertysource/DefaultOrdinal.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/propertysource/DefaultOrdinal.java b/core/src/main/java/org/apache/tamaya/core/propertysource/DefaultOrdinal.java
new file mode 100644
index 0000000..43b3fad
--- /dev/null
+++ b/core/src/main/java/org/apache/tamaya/core/propertysource/DefaultOrdinal.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.core.propertysource;
+
+
+/**
+ * This interface defines the default ordinals for the 'standard'
+ * {@link org.apache.tamaya.spi.PropertySource}s
+ *
+ * DefaultOrdinals can be overwritten via {@link org.apache.tamaya.spi.PropertySource#TAMAYA_ORDINAL}
+ */
+public interface DefaultOrdinal {
+
+    /**
+     * default ordinal for {@link org.apache.tamaya.core.propertysource.BasePropertySource} if
+     * not overriden in each class
+     */
+    static final int PROPERTY_SOURCE = 1000;
+
+    /**
+     * default ordinal for {@link org.apache.tamaya.core.propertysource.SystemPropertySource}
+     */
+    static final int SYSTEM_PROPERTIES = 400;
+
+    /**
+     * default ordinal for {@link org.apache.tamaya.core.propertysource.EnvironmentPropertySource}
+     */
+    static final int ENVIRONMENT_PROPERTIES = 300;
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/51960ef0/core/src/main/java/org/apache/tamaya/core/propertysource/EnvironmentPropertySource.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/propertysource/EnvironmentPropertySource.java b/core/src/main/java/org/apache/tamaya/core/propertysource/EnvironmentPropertySource.java
new file mode 100644
index 0000000..d1a00f4
--- /dev/null
+++ b/core/src/main/java/org/apache/tamaya/core/propertysource/EnvironmentPropertySource.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.core.propertysource;
+
+import java.util.Map;
+
+/**
+ * This {@link org.apache.tamaya.spi.PropertySource} provides all Properties which are set
+ * via <br />
+ * {@code export myprop=myval} on UNIX Systems or<br />
+ * {@code set myprop=myval} on Windows
+ */
+public class EnvironmentPropertySource extends BasePropertySource {
+
+    public EnvironmentPropertySource() {
+        initialzeOrdinal(DefaultOrdinal.ENVIRONMENT_PROPERTIES);
+    }
+
+
+    @Override
+    public String getName() {
+        return "environment-properties";
+    }
+
+    @Override
+    public Map<String, String> getProperties() {
+        return System.getenv(); // already a map and unmodifiable
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/51960ef0/core/src/main/java/org/apache/tamaya/core/propertysource/SystemPropertySource.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/propertysource/SystemPropertySource.java b/core/src/main/java/org/apache/tamaya/core/propertysource/SystemPropertySource.java
new file mode 100644
index 0000000..afd9f93
--- /dev/null
+++ b/core/src/main/java/org/apache/tamaya/core/propertysource/SystemPropertySource.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.core.propertysource;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * This {@link org.apache.tamaya.spi.PropertySource} manages the system properties.
+ */
+public class SystemPropertySource extends BasePropertySource {
+
+
+    //X TODO disuss default ordinal of SystemProperties
+
+
+    /**
+     * cashed System.getProperties() filled in our Map
+     */
+    private Map<String, String> properties;
+
+    /**
+     * previous System.getProperties().hashCode()
+     * so we can check if we need to reload
+     */
+    private int previousHash;
+
+
+    public SystemPropertySource() {
+        initialzeOrdinal(DefaultOrdinal.SYSTEM_PROPERTIES);
+    }
+
+
+    @Override
+    public String getName() {
+        return "system-properties";
+    }
+
+    @Override
+    public Map<String, String> getProperties() {
+
+        // only need to reload and fill our map if something has changed
+        if (properties == null || previousHash != System.getProperties().hashCode()) {
+
+            synchronized (this) {
+
+                if (properties == null || previousHash != System.getProperties().hashCode()) {
+
+                    Properties systemProperties = System.getProperties();
+                    Map<String, String> properties = new HashMap<>();
+
+                    for (String propertyName : systemProperties.stringPropertyNames()) {
+                        properties.put(propertyName, System.getProperty(propertyName));
+                    }
+
+                    this.properties = Collections.unmodifiableMap(properties);
+                    previousHash = systemProperties.hashCode();
+                }
+            }
+        }
+
+        return properties;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/51960ef0/core/src/test/java/org/apache/tamaya/core/test/propertysource/BasePropertySourceTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/core/test/propertysource/BasePropertySourceTest.java b/core/src/test/java/org/apache/tamaya/core/test/propertysource/BasePropertySourceTest.java
new file mode 100644
index 0000000..7b92910
--- /dev/null
+++ b/core/src/test/java/org/apache/tamaya/core/test/propertysource/BasePropertySourceTest.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.core.test.propertysource;
+
+import org.apache.tamaya.core.propertysource.BasePropertySource;
+import org.apache.tamaya.core.propertysource.DefaultOrdinal;
+import org.apache.tamaya.spi.PropertySource;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Properties;
+
+public class BasePropertySourceTest {
+
+    @Test
+    public void testGetOrdinal() {
+
+        PropertySource defaultPropertySource = new BasePropertySource() {
+
+            @Override
+            public String getName() {
+                return "testWithDefault";
+            }
+
+            @Override
+            public Optional<String> get(String key) {
+                return Optional.ofNullable(null);
+            }
+
+            @Override
+            public Map<String, String> getProperties() {
+                return Collections.emptyMap();
+            }
+        };
+
+        Assert.assertEquals(DefaultOrdinal.PROPERTY_SOURCE, defaultPropertySource.getOrdinal());
+        Assert.assertEquals(1000, new OverriddenOrdinalPropertySource().getOrdinal());
+
+        // propertySource with invalid ordinal
+        Assert.assertEquals(1, new OverriddenInvalidOrdinalPropertySource().getOrdinal());
+    }
+
+    @Test
+    public void testGet() {
+        Assert.assertEquals("1000", new OverriddenOrdinalPropertySource().get(PropertySource.TAMAYA_ORDINAL).get());
+    }
+
+    private static class OverriddenOrdinalPropertySource extends BasePropertySource {
+
+        private OverriddenOrdinalPropertySource() {
+            initialzeOrdinal(250);
+        }
+
+        @Override
+        public String getName() {
+            return "overriddenOrdinal";
+        }
+
+        @Override
+        public Map<String, String> getProperties() {
+            Map<String, String> map = new HashMap<>(1);
+            map.put(PropertySource.TAMAYA_ORDINAL, "1000");
+            return map;
+        }
+    }
+
+    private static class OverriddenInvalidOrdinalPropertySource extends BasePropertySource {
+
+        private OverriddenInvalidOrdinalPropertySource() {
+            initialzeOrdinal(1);
+        }
+
+        @Override
+        public String getName() {
+            return "overriddenInvalidOrdinal";
+        }
+
+        @Override
+        public Map<String, String> getProperties() {
+            Map<String, String> map = new HashMap<>(1);
+            map.put(PropertySource.TAMAYA_ORDINAL, "invalid");
+            return map;
+        }
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/51960ef0/core/src/test/java/org/apache/tamaya/core/test/propertysource/EnvironmentPropertySourceTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/core/test/propertysource/EnvironmentPropertySourceTest.java b/core/src/test/java/org/apache/tamaya/core/test/propertysource/EnvironmentPropertySourceTest.java
new file mode 100644
index 0000000..51cc2dc
--- /dev/null
+++ b/core/src/test/java/org/apache/tamaya/core/test/propertysource/EnvironmentPropertySourceTest.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.core.test.propertysource;
+
+import org.apache.tamaya.core.propertysource.DefaultOrdinal;
+import org.apache.tamaya.core.propertysource.EnvironmentPropertySource;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.Map;
+import java.util.Optional;
+
+public class EnvironmentPropertySourceTest {
+
+    private EnvironmentPropertySource propertySource = new EnvironmentPropertySource();
+
+
+    @Test
+    public void testGetOrdinal() {
+        Assert.assertEquals(DefaultOrdinal.ENVIRONMENT_PROPERTIES, propertySource.getOrdinal());
+    }
+
+    @Test
+    public void testGet() {
+        String environmentPropertyToCheck = System.getenv().keySet().iterator().next();
+
+        Optional<String> value = propertySource.get(environmentPropertyToCheck);
+        Assert.assertTrue(value.isPresent());
+        Assert.assertEquals(System.getenv(environmentPropertyToCheck), value.get());
+    }
+
+    @Test
+    public void testGetProperties() {
+        Map<String, String> environmentProperties = System.getenv();
+
+        Assert.assertEquals(environmentProperties.size(), propertySource.getProperties().size());
+
+        for (Map.Entry<String, String> propertySourceEntry : propertySource.getProperties().entrySet()) {
+            Assert.assertEquals("Entry values for key '" + propertySourceEntry.getKey() + "' do not match",
+                                environmentProperties.get(propertySourceEntry.getKey()), propertySourceEntry.getValue());
+        }
+
+        // modification is not allowed
+        try {
+            propertySource.getProperties().put("add.new.keys", "must throw exception");
+            Assert.fail(UnsupportedOperationException.class.getName() + " expected");
+        }
+        catch (UnsupportedOperationException e) {
+            // expected -> all is fine
+        }
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/51960ef0/core/src/test/java/org/apache/tamaya/core/test/propertysource/SystemPropertySourceTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/core/test/propertysource/SystemPropertySourceTest.java b/core/src/test/java/org/apache/tamaya/core/test/propertysource/SystemPropertySourceTest.java
new file mode 100644
index 0000000..5789346
--- /dev/null
+++ b/core/src/test/java/org/apache/tamaya/core/test/propertysource/SystemPropertySourceTest.java
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.core.test.propertysource;
+
+import org.apache.tamaya.core.propertysource.DefaultOrdinal;
+import org.apache.tamaya.core.propertysource.SystemPropertySource;
+import org.apache.tamaya.spi.PropertySource;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.Map;
+import java.util.Optional;
+import java.util.Properties;
+import java.util.Set;
+
+public class SystemPropertySourceTest {
+
+    private SystemPropertySource testPropertySource = new SystemPropertySource();
+
+
+    @Test
+    public void testGetOrdinal() throws Exception {
+
+        // test the default ordinal
+        Assert.assertEquals(DefaultOrdinal.SYSTEM_PROPERTIES, testPropertySource.getOrdinal());
+
+        // set the ordinal to 1000
+        System.setProperty(PropertySource.TAMAYA_ORDINAL, "1000");
+        Assert.assertEquals(1000, new SystemPropertySource().getOrdinal()); // currently its not possible to change ordinal at runtime
+
+        // reset it to not destroy other tests!!
+        System.clearProperty(PropertySource.TAMAYA_ORDINAL);
+    }
+
+    @Test
+    public void testGetName() throws Exception {
+        Assert.assertEquals("system-properties", new SystemPropertySource().getName());
+    }
+
+    @Test
+    public void testGet() throws Exception {
+        String propertyKeyToCheck = System.getProperties().stringPropertyNames().iterator().next();
+
+        Optional<String> property = testPropertySource.get(propertyKeyToCheck);
+        Assert.assertTrue("Property '" + propertyKeyToCheck + "' is not present in " + SystemPropertySource.class.getSimpleName(),
+                          property.isPresent());
+        Assert.assertEquals(System.getProperty(propertyKeyToCheck), property.get());
+
+
+    }
+
+    @Test
+    public void testGetProperties() throws Exception {
+        checkWithSystemProperties(testPropertySource.getProperties());
+
+        // modify system properties
+        System.setProperty("test", "myTestVal");
+
+        checkWithSystemProperties(testPropertySource.getProperties());
+
+        // cleanup
+        System.clearProperty("test");
+
+        // no modifaction
+        try {
+            testPropertySource.getProperties().put("add.new.keys", "must throw exception");
+            Assert.fail(UnsupportedOperationException.class.getName() + " expected");
+        }
+        catch (UnsupportedOperationException e) {
+            // expected -> all is fine
+        }
+    }
+
+    private void checkWithSystemProperties(Map<String, String> toCheck) {
+        Properties systemEntries = System.getProperties();
+
+        Assert.assertEquals("size of System.getProperties().entrySet() must be the same as SystemPropertySrouce.getProperties().entrySet()",
+                            systemEntries.entrySet().size(), toCheck.size());
+
+        for (Map.Entry<String, String> propertySourceEntry : toCheck.entrySet()) {
+
+            Assert.assertEquals("Entry values for key '" + propertySourceEntry.getKey() + "' do not match",
+                                systemEntries.getProperty(propertySourceEntry.getKey()), propertySourceEntry.getValue());
+        }
+
+    }
+}
\ No newline at end of file


[7/9] incubator-tamaya git commit: remove sources which are not from this very project and don'd have (c) Apache.

Posted by st...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0734e210/core/src/main/java/org/apache/tamaya/core/resources/InputStreamSource.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/resources/InputStreamSource.java b/core/src/main/java/org/apache/tamaya/core/resources/InputStreamSource.java
deleted file mode 100644
index 3d95269..0000000
--- a/core/src/main/java/org/apache/tamaya/core/resources/InputStreamSource.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
-* Copyright 2002-2012 the original author or authors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*      http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.tamaya.core.resources;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * Simple interface for objects that are sources for an {@link InputStream}.
- * <p>
- * <p>This is the base interface for the more extensive {@link Resource} interface.
- *
- * @author Juergen Hoeller
- * @see java.io.InputStream
- * @see Resource
- * @since 20.01.2004
- */
-@FunctionalInterface
-public interface InputStreamSource {
-
-    /**
-     * Return an {@link InputStream}.
-     * <p>It is expected that each call creates a <i>fresh</i> stream.
-     * <p>This requirement is particularly important when you consider an API such
-     * as JavaMail, which needs to be able to read the stream multiple times when
-     * creating mail attachments. For such a use case, it is <i>required</i>
-     * that each {@code getInputStreamSupplier()} call returns a fresh stream.
-     *
-     * @return the input stream for the underlying resource (must not be {@code null})
-     * @throws IOException if the stream could not be opened
-     */
-    InputStream getInputStream() throws IOException;
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0734e210/core/src/main/java/org/apache/tamaya/core/resources/Resource.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/resources/Resource.java b/core/src/main/java/org/apache/tamaya/core/resources/Resource.java
deleted file mode 100644
index 14966e9..0000000
--- a/core/src/main/java/org/apache/tamaya/core/resources/Resource.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Copyright 2002-2012 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tamaya.core.resources;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.Objects;
-
-/**
- * Interface for a resource descriptor that abstracts from the actual
- * type current underlying resource, such as a file or class path resource.
- * <p>
- * <p>An InputStream can be opened for every resource if it exists in
- * physical form, but a URL or File handle can just be returned for
- * certain resources. The actual behavior is implementation-specific.
- *
- * @author Juergen Hoeller
- * @see #getInputStream()
- * @see #toURL()
- * @see #getURI()
- * @see #toFile()
- * @since 28.12.2003
- */
-public interface Resource extends InputStreamSource {
-
-    /**
-     * Return whether this resource actually exists in physical form.
-     * <p>This method performs a definitive existence check, whereas the
-     * existence current a {@code Resource} handle only guarantees a
-     * valid descriptor handle.
-     */
-    default boolean exists() {
-        // Try file existence: can we find the file in the file system?
-        try {
-            return toFile().exists();
-        } catch (IOException ex) {
-            // Fall back to stream existence: can we open the stream?
-            try {
-                InputStream is = getInputStream();
-                is.close();
-                return true;
-            } catch (Throwable isEx) {
-                return false;
-            }
-        }
-    }
-
-    /**
-     * Return whether the contents current this resource can be read,
-     * e.g. via {@link #getInputStream()} or {@link #toFile()}.
-     * <p>Will be {@code true} for typical resource descriptors;
-     * note that actual content reading may still fail when attempted.
-     * However, a keys current {@code false} is a definitive indication
-     * that the resource content cannot be read.
-     *
-     * @see #getInputStream()
-     */
-    default boolean isReadable() {
-        return true;
-    }
-
-    /**
-     * Return whether this resource represents a handle with an open
-     * stream. If true, the InputStream cannot be read multiple times,
-     * and must be read and closed to avoid resource leaks.
-     * <p>Will be {@code false} for typical resource descriptors.
-     */
-    default boolean isOpen() {
-        return false;
-    }
-
-    /**
-     * Return a URL handle for this resource.
-     *
-     * @throws IOException if the resource cannot be resolved as URL,
-     *                     i.e. if the resource is not available as descriptor
-     */
-    default URL toURL() throws IOException {
-        return getURI().toURL();
-    }
-
-    /**
-     * Return a URI handle for this resource.
-     *
-     * @throws IOException if the resource cannot be resolved as URI,
-     *                     i.e. if the resource is not available as descriptor
-     */
-    default URI getURI() throws IOException {
-        URL url = toURL();
-        try {
-            return new URI(url.toString().replaceAll(" ", "%20"));
-        } catch (URISyntaxException ex) {
-            throw new IllegalStateException("Invalid URI [" + url + "]", ex);
-        }
-    }
-
-    /**
-     * Return a File handle for this resource.
-     *
-     * @throws IOException if the resource cannot be resolved as absolute
-     *                     file path, i.e. if the resource is not available in a file system
-     */
-    default File toFile() throws IOException {
-        return new File(getURI());
-    }
-
-    /**
-     * Determine the content length for this resource.
-     *
-     * @throws IOException if the resource cannot be resolved
-     *                     (in the file system or as some other known physical resource type)
-     */
-    default long contentLength() throws IOException {
-        try(InputStream is = this.getInputStream();) {
-            Objects.requireNonNull(is, "resource input stream must not be null");
-            long size = 0;
-            byte[] buf = new byte[255];
-            int read;
-            while ((read = is.read(buf)) != -1) {
-                size += read;
-            }
-            return size;
-        }
-    }
-
-    /**
-     * Determine the last-modified timestamp for this resource.
-     *
-     * @throws IOException if the resource cannot be resolved
-     *                     (in the file system or as some other known physical resource type)
-     */
-    default long lastModified() throws IOException {
-        long lastModified = toFile().lastModified();
-        if (lastModified == 0L) {
-            throw new FileNotFoundException(getDisplayName() +
-                    " cannot be resolved in the file system for resolving its last-modified timestamp");
-        }
-        return lastModified;
-    }
-
-    /**
-     * Create a resource relative to this resource.
-     *
-     * @param relativePath the relative path (relative to this resource)
-     * @return the resource handle for the relative resource
-     * @throws IOException if the relative resource cannot be determined
-     */
-    default Resource createRelative(String relativePath) throws IOException {
-        throw new FileNotFoundException("Cannot of a relative resource for " + getDisplayName());
-    }
-
-    /**
-     * Determine a filename for this resource, i.e. typically the last
-     * part current the path: for example, "myfile.txt".
-     * <p>Returns {@code null} if this type current resource does not
-     * have a filename.
-     */
-    default String getDisplayName() {
-        try {
-            return getURI().toString();
-        } catch (Exception e) {
-            return toString();
-        }
-    }
-
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0734e210/core/src/main/java/org/apache/tamaya/core/resources/ResourceLoader.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/resources/ResourceLoader.java b/core/src/main/java/org/apache/tamaya/core/resources/ResourceLoader.java
deleted file mode 100644
index 849f136..0000000
--- a/core/src/main/java/org/apache/tamaya/core/resources/ResourceLoader.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.core.resources;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * Interface to be implemented by containers that decouples loading current resources from the effective
- * classloader architecture. Implementations of this class encapsulate the mechanism of
- * determining the concrete resources available base on an expression defining the configuration
- * locations. A an example the expression {@code cfg/global/*.xml} defines a
- * location for reading global configuration in the classpath. A resources
- * interprets this expression and evaluates the concrete resources to be read,
- * e.g. {@code cfg/global/default.xml, cfg/global/myApp.xml}.
- */
-public interface ResourceLoader {
-
-    /**
-     * Called, when a given expression has to be resolved.
-     *
-     * @param expressions the expressions to be resolved, not empty.
-     * @return the corresponding collection current {@link java.net.URI}s defining the
-     * concrete resources to be read.
-     * .
-     */
-    default List<Resource> getResources(String... expressions) {
-        return getResources(Arrays.asList(expressions));
-    }
-
-
-    /**
-     * Called, when a given expression has to be resolved.
-     *
-     * @param expressions the expressions to be resolved, not empty.
-     * @return the corresponding collection current {@link java.net.URI}s defining the
-     * concrete resources to be read.
-     * .
-     */
-    default List<Resource> getResources(Collection<String> expressions) {
-        ClassLoader cl = Thread.currentThread().getContextClassLoader();
-        if (cl == null) {
-            cl = getClass().getClassLoader();
-        }
-        return getResources(cl, expressions);
-    }
-
-    /**
-     * Called, when a given expression has to be resolved.
-     *
-     * @param expressions the expressions to be resolved, not empty.
-     * @return the corresponding collection current {@link java.net.URI}s defining the
-     * concrete resources to be read.
-     * .
-     */
-    default List<Resource> getResources(ClassLoader classLoader, String... expressions) {
-        return getResources(classLoader, Arrays.asList(expressions));
-    }
-
-    /**
-     * Called, when a given expression has to be resolved.
-     *
-     * @param expressions the expressions to be resolved, not empty.
-     * @return the corresponding collection current {@link org.apache.tamaya.core.resources.Resource}s defining the
-     * concrete resources to be read.
-     * .
-     */
-    List<Resource> getResources(ClassLoader classLoader, Collection<String> expressions);
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0734e210/core/src/test/java/org/apache/tamaya/core/ConfigurationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/core/ConfigurationTest.java b/core/src/test/java/org/apache/tamaya/core/ConfigurationTest.java
index 9c7b894..be1eadb 100644
--- a/core/src/test/java/org/apache/tamaya/core/ConfigurationTest.java
+++ b/core/src/test/java/org/apache/tamaya/core/ConfigurationTest.java
@@ -41,12 +41,6 @@ public class ConfigurationTest {
         assertEquals("Lukas", Configuration.current().get("name3").get());  // oderridden default
         assertEquals("Sereina", Configuration.current().get("name4").get()); // final only
         assertEquals("Benjamin", Configuration.current().get("name5").get()); // final only
-
-        System.out.println("name : " + Configuration.current().get("name").get());
-        System.out.println("name2: " + Configuration.current().get("name2").get());
-        System.out.println("name3: " + Configuration.current().get("name3").get());
-        System.out.println("name4: " + Configuration.current().get("name4").get());
-        System.out.println("name5: " + Configuration.current().get("name5").get());
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0734e210/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertyDefaultSourceProvider.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertyDefaultSourceProvider.java b/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertyDefaultSourceProvider.java
deleted file mode 100644
index ebd28f7..0000000
--- a/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertyDefaultSourceProvider.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.core.testdata;
-
-import org.apache.tamaya.core.PathBasedPropertySourceProvider;
-import org.apache.tamaya.core.formats.PropertiesFormat;
-
-/**
- * Test provider reading properties from classpath:cfg/defaults/**.properties.
- */
-public class TestPropertyDefaultSourceProvider extends PathBasedPropertySourceProvider{
-
-    public TestPropertyDefaultSourceProvider() {
-        super("default-testdata-properties", PropertiesFormat.of(100), "classpath:cfg/defaults/**/*.properties");
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0734e210/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertySource.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertySource.java b/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertySource.java
new file mode 100644
index 0000000..d03b43b
--- /dev/null
+++ b/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertySource.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.core.testdata;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tamaya.Configuration;
+import org.apache.tamaya.core.propertysource.BasePropertySource;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Test provider reading properties from classpath:cfg/final/**.properties.
+ */
+public class TestPropertySource extends BasePropertySource {
+
+    private static final Map<String, String> VALUES;
+    static {
+        VALUES = new HashMap<String, String>();
+        VALUES.put("name", "Robin");
+        VALUES.put("name2", "Sabine");
+        VALUES.put("name3", "Lukas");
+        VALUES.put("name4", "Sereina");
+        VALUES.put("name5", "Benjamin");
+    }
+
+
+    public TestPropertySource() {
+        initialzeOrdinal(100);
+    }
+
+    @Override
+    public String getName() {
+        return "TestPropertySource";
+    }
+
+    @Override
+    public Map<String, String> getProperties() {
+        return VALUES;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0734e210/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertySourceProvider.java b/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertySourceProvider.java
deleted file mode 100644
index 56413ca..0000000
--- a/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertySourceProvider.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.core.testdata;
-
-import org.apache.tamaya.core.PathBasedPropertySourceProvider;
-import org.apache.tamaya.core.formats.PropertiesFormat;
-
-/**
- * Test provider reading properties from classpath:cfg/final/**.properties.
- */
-public class TestPropertySourceProvider extends PathBasedPropertySourceProvider{
-
-    public TestPropertySourceProvider() {
-        super("final-testdata-properties", PropertiesFormat.of(200), "classpath:cfg/final/**/*.properties");
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0734e210/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
----------------------------------------------------------------------
diff --git a/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource b/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
new file mode 100644
index 0000000..e6f7fad
--- /dev/null
+++ b/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource
@@ -0,0 +1,19 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy current the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+org.apache.tamaya.core.testdata.TestPropertySource
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0734e210/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider
----------------------------------------------------------------------
diff --git a/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider b/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider
deleted file mode 100644
index 9db0ef4..0000000
--- a/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider
+++ /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.core.testdata.TestPropertyDefaultSourceProvider
-org.apache.tamaya.core.testdata.TestPropertySourceProvider
\ No newline at end of file


[4/9] incubator-tamaya git commit: remove logger abstraction

Posted by st...@apache.org.
remove logger abstraction

this should not be part of our project but part of the container integration if any.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/4af87fcc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/4af87fcc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/4af87fcc

Branch: refs/heads/master
Commit: 4af87fcce3ef77679e87d3cd024a937516922b69
Parents: a6c0800
Author: Mark Struberg <st...@apache.org>
Authored: Sat Jan 3 18:11:05 2015 +0100
Committer: Mark Struberg <st...@apache.org>
Committed: Sat Jan 3 18:11:05 2015 +0100

----------------------------------------------------------------------
 .../logging/AbstractDelegatingLogger.java       | 415 -------------------
 .../core/internal/logging/Log4j2Logger.java     |  97 -----
 .../core/internal/logging/Log4jLogger.java      | 200 ---------
 .../core/internal/logging/Slf4jLogger.java      | 181 --------
 4 files changed, 893 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/4af87fcc/core/src/main/java/org/apache/tamaya/core/internal/logging/AbstractDelegatingLogger.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/logging/AbstractDelegatingLogger.java b/core/src/main/java/org/apache/tamaya/core/internal/logging/AbstractDelegatingLogger.java
deleted file mode 100644
index 30c2d2e..0000000
--- a/core/src/main/java/org/apache/tamaya/core/internal/logging/AbstractDelegatingLogger.java
+++ /dev/null
@@ -1,415 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.core.internal.logging;
-
-import java.text.MessageFormat;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-import java.util.logging.Filter;
-import java.util.logging.Handler;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-import java.util.logging.Logger;
-
-/**
- * java.util.logging.Logger implementation delegating to another framework.
- * All methods can be used except:
- * setLevel
- * addHandler / getHandlers
- * setParent / getParent
- * setUseParentHandlers / getUseParentHandlers
- *
- * @author gnodet
- */
-public abstract class AbstractDelegatingLogger extends Logger {
-
-    protected AbstractDelegatingLogger(final String name, final String resourceBundleName) {
-        super(name, resourceBundleName);
-    }
-
-    public void log(final LogRecord record) {
-        if (isLoggable(record.getLevel())) {
-            doLog(record);
-        }
-    }
-
-    public void log(final Level level, final String msg) {
-        if (isLoggable(level)) {
-            final LogRecord lr = new LogRecord(level, msg);
-            doLog(lr);
-        }
-    }
-
-    public void log(final Level level, final String msg, final Object param1) {
-        if (isLoggable(level)) {
-            final LogRecord lr = new LogRecord(level, msg);
-            final Object[] params = {param1};
-            lr.setParameters(params);
-            doLog(lr);
-        }
-    }
-
-    public void log(final Level level, final String msg, final Object[] params) {
-        if (isLoggable(level)) {
-            final LogRecord lr = new LogRecord(level, msg);
-            lr.setParameters(params);
-            doLog(lr);
-        }
-    }
-
-    public void log(final Level level, final String msg, final Throwable thrown) {
-        if (isLoggable(level)) {
-            final LogRecord lr = new LogRecord(level, msg);
-            lr.setThrown(thrown);
-            doLog(lr);
-        }
-    }
-
-    public void logp(final Level level, final String sourceClass, final String sourceMethod, final String msg) {
-        if (isLoggable(level)) {
-            final LogRecord lr = new LogRecord(level, msg);
-            lr.setSourceClassName(sourceClass);
-            lr.setSourceMethodName(sourceMethod);
-            doLog(lr);
-        }
-    }
-
-    public void logp(final Level level, final String sourceClass, final String sourceMethod, final String msg, final Object param1) {
-        if (isLoggable(level)) {
-            final LogRecord lr = new LogRecord(level, msg);
-            lr.setSourceClassName(sourceClass);
-            lr.setSourceMethodName(sourceMethod);
-            final Object[] params = {param1};
-            lr.setParameters(params);
-            doLog(lr);
-        }
-    }
-
-    public void logp(final Level level, final String sourceClass, final String sourceMethod, final String msg, final Object[] params) {
-        if (isLoggable(level)) {
-            final LogRecord lr = new LogRecord(level, msg);
-            lr.setSourceClassName(sourceClass);
-            lr.setSourceMethodName(sourceMethod);
-            lr.setParameters(params);
-            doLog(lr);
-        }
-    }
-
-    public void logp(final Level level, final String sourceClass, final String sourceMethod, final String msg, final Throwable thrown) {
-        if (isLoggable(level)) {
-            final LogRecord lr = new LogRecord(level, msg);
-            lr.setSourceClassName(sourceClass);
-            lr.setSourceMethodName(sourceMethod);
-            lr.setThrown(thrown);
-            doLog(lr);
-        }
-    }
-
-    public void logrb(final Level level, final String sourceClass, final String sourceMethod, final String bundleName, final String msg) {
-        if (isLoggable(level)) {
-            final LogRecord lr = new LogRecord(level, msg);
-            lr.setSourceClassName(sourceClass);
-            lr.setSourceMethodName(sourceMethod);
-            doLog(lr, bundleName);
-        }
-    }
-
-    public void logrb(final Level level, final String sourceClass, final String sourceMethod,
-                      final String bundleName, final String msg, final Object param1) {
-        if (isLoggable(level)) {
-            final LogRecord lr = new LogRecord(level, msg);
-            lr.setSourceClassName(sourceClass);
-            lr.setSourceMethodName(sourceMethod);
-            final Object[] params = {param1};
-            lr.setParameters(params);
-            doLog(lr, bundleName);
-        }
-    }
-
-    public void logrb(final Level level, final String sourceClass, final String sourceMethod,
-                      final String bundleName, final String msg, final Object[] params) {
-        if (isLoggable(level)) {
-            final LogRecord lr = new LogRecord(level, msg);
-            lr.setSourceClassName(sourceClass);
-            lr.setSourceMethodName(sourceMethod);
-            lr.setParameters(params);
-            doLog(lr, bundleName);
-        }
-    }
-
-    public void logrb(final Level level, final String sourceClass, final String sourceMethod,
-                      final String bundleName, final String msg, final Throwable thrown) {
-        if (isLoggable(level)) {
-            final LogRecord lr = new LogRecord(level, msg);
-            lr.setSourceClassName(sourceClass);
-            lr.setSourceMethodName(sourceMethod);
-            lr.setThrown(thrown);
-            doLog(lr, bundleName);
-        }
-    }
-
-    public void entering(final String sourceClass, final String sourceMethod) {
-        if (isLoggable(Level.FINER)) {
-            logp(Level.FINER, sourceClass, sourceMethod, "ENTRY");
-        }
-    }
-
-    public void entering(final String sourceClass, final String sourceMethod, final Object param1) {
-        if (isLoggable(Level.FINER)) {
-            final Object[] params = {param1};
-            logp(Level.FINER, sourceClass, sourceMethod, "ENTRY {0}", params);
-        }
-    }
-
-    public void entering(final String sourceClass, final String sourceMethod, final Object[] params) {
-        if (isLoggable(Level.FINER)) {
-            final String msg = "ENTRY";
-            if (params == null) {
-                logp(Level.FINER, sourceClass, sourceMethod, msg);
-                return;
-            }
-            final StringBuilder builder = new StringBuilder(msg);
-            for (int i = 0; i < params.length; i++) {
-                builder.append(" {");
-                builder.append(Integer.toString(i));
-                builder.append("}");
-            }
-            logp(Level.FINER, sourceClass, sourceMethod, builder.toString(), params);
-        }
-    }
-
-    public void exiting(final String sourceClass, final String sourceMethod) {
-        if (isLoggable(Level.FINER)) {
-            logp(Level.FINER, sourceClass, sourceMethod, "RETURN");
-        }
-    }
-
-    public void exiting(final String sourceClass, final String sourceMethod, final Object result) {
-        if (isLoggable(Level.FINER)) {
-            final Object[] params = {result};
-            logp(Level.FINER, sourceClass, sourceMethod, "RETURN {0}", params);
-        }
-    }
-
-    public void throwing(final String sourceClass, final String sourceMethod, final Throwable thrown) {
-        if (isLoggable(Level.FINER)) {
-            final LogRecord lr = new LogRecord(Level.FINER, "THROW");
-            lr.setSourceClassName(sourceClass);
-            lr.setSourceMethodName(sourceMethod);
-            lr.setThrown(thrown);
-            doLog(lr);
-        }
-    }
-
-    public void severe(final String msg) {
-        if (isLoggable(Level.SEVERE)) {
-            final LogRecord lr = new LogRecord(Level.SEVERE, msg);
-            doLog(lr);
-        }
-    }
-
-    public void warning(final String msg) {
-        if (isLoggable(Level.WARNING)) {
-            final LogRecord lr = new LogRecord(Level.WARNING, msg);
-            doLog(lr);
-        }
-    }
-
-    public void info(final String msg) {
-        if (isLoggable(Level.INFO)) {
-            final LogRecord lr = new LogRecord(Level.INFO, msg);
-            doLog(lr);
-        }
-    }
-
-    public void config(final String msg) {
-        if (isLoggable(Level.CONFIG)) {
-            final LogRecord lr = new LogRecord(Level.CONFIG, msg);
-            doLog(lr);
-        }
-    }
-
-    public void fine(final String msg) {
-        if (isLoggable(Level.FINE)) {
-            final LogRecord lr = new LogRecord(Level.FINE, msg);
-            doLog(lr);
-        }
-    }
-
-    public void finer(final String msg) {
-        if (isLoggable(Level.FINER)) {
-            final LogRecord lr = new LogRecord(Level.FINER, msg);
-            doLog(lr);
-        }
-    }
-
-    public void finest(final String msg) {
-        if (isLoggable(Level.FINEST)) {
-            final LogRecord lr = new LogRecord(Level.FINEST, msg);
-            doLog(lr);
-        }
-    }
-
-    public void setLevel(final Level newLevel) throws SecurityException {
-        throw new UnsupportedOperationException();
-    }
-
-    public abstract Level getLevel();
-
-    public boolean isLoggable(final Level level) {
-        final Level l = getLevel();
-        return level.intValue() >= l.intValue() && l != Level.OFF;
-    }
-
-    protected boolean supportsHandlers() {
-        return false;
-    }
-
-    public synchronized void addHandler(final Handler handler) throws SecurityException {
-        if (supportsHandlers()) {
-            super.addHandler(handler);
-            return;
-        }
-        throw new UnsupportedOperationException();
-    }
-
-    public synchronized void removeHandler(final Handler handler) throws SecurityException {
-        if (supportsHandlers()) {
-            super.removeHandler(handler);
-            return;
-        }
-        throw new UnsupportedOperationException();
-    }
-
-    public synchronized Handler[] getHandlers() {
-        if (supportsHandlers()) {
-            return super.getHandlers();
-        }
-        throw new UnsupportedOperationException();
-    }
-
-    public synchronized void setUseParentHandlers(final boolean useParentHandlers) {
-        if (supportsHandlers()) {
-            super.setUseParentHandlers(useParentHandlers);
-            return;
-        }
-        throw new UnsupportedOperationException();
-    }
-
-    public synchronized boolean getUseParentHandlers() {
-        if (supportsHandlers()) {
-            return super.getUseParentHandlers();
-        }
-        throw new UnsupportedOperationException();
-    }
-
-    public Logger getParent() {
-        return null;
-    }
-
-    public void setParent(final Logger parent) {
-        throw new UnsupportedOperationException();
-    }
-
-    protected void doLog(final LogRecord lr) {
-        lr.setLoggerName(getName());
-        final String rbname = getResourceBundleName();
-        if (rbname != null) {
-            lr.setResourceBundleName(rbname);
-            lr.setResourceBundle(getResourceBundle());
-        }
-        internalLog(lr);
-    }
-
-    protected void doLog(final LogRecord lr, final String rbname) {
-        lr.setLoggerName(getName());
-        if (rbname != null) {
-            lr.setResourceBundleName(rbname);
-            lr.setResourceBundle(loadResourceBundle(rbname));
-        }
-        internalLog(lr);
-    }
-
-    protected void internalLog(final LogRecord record) {
-        final Filter filter = getFilter();
-        if (filter != null && !filter.isLoggable(record)) {
-            return;
-        }
-        final String msg = formatMessage(record);
-        internalLogFormatted(msg, record);
-    }
-
-    protected abstract void internalLogFormatted(String msg, LogRecord record);
-
-    protected String formatMessage(final LogRecord record) {
-        String format = record.getMessage();
-        final ResourceBundle catalog = record.getResourceBundle();
-        if (catalog != null) {
-            try {
-                format = catalog.getString(record.getMessage());
-            } catch (final MissingResourceException ex) {
-                format = record.getMessage();
-            }
-        }
-        try {
-            final Object[] parameters = record.getParameters();
-            if (parameters == null || parameters.length == 0) {
-                return format;
-            }
-            if (format.contains("{0") || format.contains("{1")
-                || format.contains("{2") || format.contains("{3")) {
-                return MessageFormat.format(format, parameters);
-            }
-            return format;
-        } catch (final Exception ex) {
-            return format;
-        }
-    }
-
-    /**
-     * Load the specified resource bundle
-     *
-     * @param resourceBundleName the name current the resource bundle to load, cannot be null
-     * @return the loaded resource bundle.
-     * @throws MissingResourceException If the specified resource bundle can not be loaded.
-     */
-    static ResourceBundle loadResourceBundle(final String resourceBundleName) {
-        // try context class loader to load the resource
-        ClassLoader cl = Thread.currentThread().getContextClassLoader();
-        if (null != cl) {
-            try {
-                return ResourceBundle.getBundle(resourceBundleName, Locale.getDefault(), cl);
-            } catch (final MissingResourceException e) {
-                // Failed to load using context classloader, ignore
-            }
-        }
-        // try system class loader to load the resource
-        cl = ClassLoader.getSystemClassLoader();
-        if (null != cl) {
-            try {
-                return ResourceBundle.getBundle(resourceBundleName, Locale.getDefault(), cl);
-            } catch (final MissingResourceException e) {
-                // Failed to load using system classloader, ignore
-            }
-        }
-        return null;
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/4af87fcc/core/src/main/java/org/apache/tamaya/core/internal/logging/Log4j2Logger.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/logging/Log4j2Logger.java b/core/src/main/java/org/apache/tamaya/core/internal/logging/Log4j2Logger.java
deleted file mode 100644
index 35ae4ab..0000000
--- a/core/src/main/java/org/apache/tamaya/core/internal/logging/Log4j2Logger.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.core.internal.logging;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-
-public class Log4j2Logger extends AbstractDelegatingLogger {
-    private static final Map<Level, org.apache.logging.log4j.Level> TO_LOG4J = new HashMap<>();
-
-    private final Logger log;
-
-    static {
-        //older versions current log4j don't have TRACE, use debug
-//        org.apache.logging.log4j.Level t = org.apache.logging.log4j.Level.DEBUG;
-
-        TO_LOG4J.put(Level.ALL, org.apache.logging.log4j.Level.ALL);
-        TO_LOG4J.put(Level.SEVERE, org.apache.logging.log4j.Level.ERROR);
-        TO_LOG4J.put(Level.WARNING, org.apache.logging.log4j.Level.WARN);
-        TO_LOG4J.put(Level.INFO, org.apache.logging.log4j.Level.INFO);
-        TO_LOG4J.put(Level.CONFIG, org.apache.logging.log4j.Level.DEBUG);
-        TO_LOG4J.put(Level.FINE, org.apache.logging.log4j.Level.DEBUG);
-        TO_LOG4J.put(Level.FINER, org.apache.logging.log4j.Level.TRACE);
-        TO_LOG4J.put(Level.FINEST, org.apache.logging.log4j.Level.TRACE);
-        TO_LOG4J.put(Level.OFF, org.apache.logging.log4j.Level.OFF);
-    }
-
-    public Log4j2Logger(final String name, final String resourceBundleName) {
-        super(name, resourceBundleName);
-        log = LogManager.getLogger(name);
-    }
-
-    public Level getLevel() {
-        final org.apache.logging.log4j.Level l = log.getLevel();
-        if (l != null) {
-            return fromL4J(l);
-        }
-        return null;
-    }
-
-    protected void internalLogFormatted(final String msg, final LogRecord record) {
-        log.log(TO_LOG4J.get(record.getLevel()), msg, record.getThrown());
-    }
-
-
-    private Level fromL4J(final org.apache.logging.log4j.Level l) {
-        Level l2 = null;
-        switch (l.getStandardLevel()) {
-            case ALL:
-                l2 = Level.ALL;
-                break;
-            case FATAL:
-                l2 = Level.SEVERE;
-                break;
-            case ERROR:
-                l2 = Level.SEVERE;
-                break;
-            case WARN:
-                l2 = Level.WARNING;
-                break;
-            case INFO:
-                l2 = Level.INFO;
-                break;
-            case DEBUG:
-                l2 = Level.FINE;
-                break;
-            case OFF:
-                l2 = Level.OFF;
-                break;
-            case TRACE:
-                l2 = Level.FINEST;
-                break;
-            default:
-                l2 = Level.FINE;
-        }
-        return l2;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/4af87fcc/core/src/main/java/org/apache/tamaya/core/internal/logging/Log4jLogger.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/logging/Log4jLogger.java b/core/src/main/java/org/apache/tamaya/core/internal/logging/Log4jLogger.java
deleted file mode 100644
index 224378c..0000000
--- a/core/src/main/java/org/apache/tamaya/core/internal/logging/Log4jLogger.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tamaya.core.internal.logging;
-
-import org.apache.log4j.Appender;
-import org.apache.log4j.AppenderSkeleton;
-import org.apache.log4j.LogManager;
-import org.apache.log4j.Logger;
-import org.apache.log4j.Priority;
-import org.apache.log4j.spi.LoggingEvent;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Handler;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-
-/**
- * java.util.logging.Logger implementation delegating to Log4j.
- * All methods can be used except:
- * setLevel
- * addHandler / getHandlers
- * setParent / getParent
- * setUseParentHandlers / getUseParentHandlers
- *
- * @author gnodet
- */
-public class Log4jLogger extends AbstractDelegatingLogger {
-    private static final Map<Level, org.apache.log4j.Level> TO_LOG4J = new HashMap<>();
-    private static final org.apache.log4j.Level TRACE;
-
-    private final Logger log;
-
-    static {
-        //older versions current log4j don't have TRACE, use debug
-        org.apache.log4j.Level t = org.apache.log4j.Level.DEBUG;
-        try {
-            final Field f = org.apache.log4j.Level.class.getField("TRACE");
-            t = (org.apache.log4j.Level) f.get(null);
-        } catch (final Throwable ex) {
-            //ignore, assume old version current log4j
-        }
-        TRACE = t;
-
-        TO_LOG4J.put(Level.ALL, org.apache.log4j.Level.ALL);
-        TO_LOG4J.put(Level.SEVERE, org.apache.log4j.Level.ERROR);
-        TO_LOG4J.put(Level.WARNING, org.apache.log4j.Level.WARN);
-        TO_LOG4J.put(Level.INFO, org.apache.log4j.Level.INFO);
-        TO_LOG4J.put(Level.CONFIG, org.apache.log4j.Level.DEBUG);
-        TO_LOG4J.put(Level.FINE, org.apache.log4j.Level.DEBUG);
-        TO_LOG4J.put(Level.FINER, TRACE);
-        TO_LOG4J.put(Level.FINEST, TRACE);
-        TO_LOG4J.put(Level.OFF, org.apache.log4j.Level.OFF);
-    }
-
-    public Log4jLogger(final String name, final String resourceBundleName) {
-        super(name, resourceBundleName);
-        log = LogManager.getLogger(name);
-    }
-
-    public Level getLevel() {
-        final org.apache.log4j.Level l = log.getEffectiveLevel();
-        if (l != null) {
-            return fromL4J(l);
-        }
-        return null;
-    }
-
-    public void setLevel(final Level newLevel) throws SecurityException {
-        log.setLevel(TO_LOG4J.get(newLevel));
-    }
-
-    public synchronized void addHandler(final Handler handler) throws SecurityException {
-        log.addAppender(new HandlerWrapper(handler));
-    }
-
-    public synchronized void removeHandler(final Handler handler) throws SecurityException {
-        log.removeAppender("HandlerWrapper-" + handler.hashCode());
-    }
-
-    public synchronized Handler[] getHandlers() {
-        final List<Handler> ret = new ArrayList<>();
-        final Enumeration<?> en = log.getAllAppenders();
-        while (en.hasMoreElements()) {
-            final Appender ap = (Appender) en.nextElement();
-            if (ap instanceof HandlerWrapper) {
-                ret.add(((HandlerWrapper) ap).getHandler());
-            }
-        }
-        return ret.toArray(new Handler[ret.size()]);
-    }
-
-    protected void internalLogFormatted(final String msg, final LogRecord record) {
-        log.log(AbstractDelegatingLogger.class.getName(),
-            TO_LOG4J.get(record.getLevel()),
-            msg,
-            record.getThrown());
-    }
-
-
-    private Level fromL4J(final org.apache.log4j.Level l) {
-        Level l2 = null;
-        switch (l.toInt()) {
-            case org.apache.log4j.Level.ALL_INT:
-                l2 = Level.ALL;
-                break;
-            case org.apache.log4j.Level.FATAL_INT:
-                l2 = Level.SEVERE;
-                break;
-            case org.apache.log4j.Level.ERROR_INT:
-                l2 = Level.SEVERE;
-                break;
-            case org.apache.log4j.Level.WARN_INT:
-                l2 = Level.WARNING;
-                break;
-            case org.apache.log4j.Level.INFO_INT:
-                l2 = Level.INFO;
-                break;
-            case org.apache.log4j.Level.DEBUG_INT:
-                l2 = Level.FINE;
-                break;
-            case org.apache.log4j.Level.OFF_INT:
-                l2 = Level.OFF;
-                break;
-            default:
-                if (l.toInt() == TRACE.toInt()) {
-                    l2 = Level.FINEST;
-                }
-        }
-        return l2;
-    }
-
-
-    private class HandlerWrapper extends AppenderSkeleton {
-        Handler handler;
-
-        public HandlerWrapper(final Handler h) {
-            handler = h;
-            name = "HandlerWrapper-" + h.hashCode();
-        }
-
-        public Handler getHandler() {
-            return handler;
-        }
-
-        @Override
-        protected void append(final LoggingEvent event) {
-            final LogRecord lr = new LogRecord(fromL4J(event.getLevel()),
-                event.getMessage().toString());
-            lr.setLoggerName(event.getLoggerName());
-            if (event.getThrowableInformation() != null) {
-                lr.setThrown(event.getThrowableInformation().getThrowable());
-            }
-            final String rbname = getResourceBundleName();
-            if (rbname != null) {
-                lr.setResourceBundleName(rbname);
-                lr.setResourceBundle(getResourceBundle());
-            }
-            handler.publish(lr);
-        }
-
-        public void close() {
-            handler.close();
-            closed = true;
-        }
-
-        public boolean requiresLayout() {
-            return false;
-        }
-
-        @Override
-        public Priority getThreshold() {
-            return TO_LOG4J.get(handler.getLevel());
-        }
-
-        @Override
-        public boolean isAsSevereAsThreshold(final Priority priority) {
-            final Priority p = getThreshold();
-            return p == null || priority.isGreaterOrEqual(p);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/4af87fcc/core/src/main/java/org/apache/tamaya/core/internal/logging/Slf4jLogger.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/logging/Slf4jLogger.java b/core/src/main/java/org/apache/tamaya/core/internal/logging/Slf4jLogger.java
deleted file mode 100644
index a580128..0000000
--- a/core/src/main/java/org/apache/tamaya/core/internal/logging/Slf4jLogger.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tamaya.core.internal.logging;
-
-import org.slf4j.spi.LocationAwareLogger;
-
-import java.util.logging.Handler;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-
-/**
- * <p>
- * java.util.logging.Logger implementation delegating to SLF4J.
- * </p>
- * <p>
- * Methods {@link java.util.logging.Logger#setParent(Logger)}, {@link java.util.logging.Logger#getParent()},
- * {@link java.util.logging.Logger#setUseParentHandlers(boolean)} and
- * {@link java.util.logging.Logger#getUseParentHandlers()} are not overrriden.
- * </p>
- * <p>
- * Level annotation inspired by {@link org.slf4j.bridge.SLF4JBridgeHandler}:
- * </p>
- * <p/>
- * <pre>
- * FINEST  -&gt; TRACE
- * FINER   -&gt; DEBUG
- * FINE    -&gt; DEBUG
- * CONFIG  -&gt; DEBUG
- * INFO    -&gt; INFO
- * WARN ING -&gt; WARN
- * SEVER   -&gt; ERROR
- * </pre>
- */
-public class Slf4jLogger extends AbstractDelegatingLogger {
-
-    private static final String FQCN = AbstractDelegatingLogger.class.getName();
-
-    private final org.slf4j.Logger logger;
-    private LocationAwareLogger locationAwareLogger;
-
-
-    public Slf4jLogger(final String name, final String resourceBundleName) {
-        super(name, resourceBundleName);
-        logger = org.slf4j.LoggerFactory.getLogger(name);
-        if (logger instanceof LocationAwareLogger) {
-            locationAwareLogger = (LocationAwareLogger) logger;
-        }
-    }
-
-    @Override
-    protected boolean supportsHandlers() {
-        return true;
-    }
-
-    @Override
-    public Level getLevel() {
-        final Level level;
-        // Verify fromMap the wider (trace) to the narrower (error)
-        if (logger.isTraceEnabled()) {
-            level = Level.FINEST;
-        } else if (logger.isDebugEnabled()) {
-            // map to the lowest between FINER, FINE and CONFIG
-            level = Level.FINER;
-        } else if (logger.isInfoEnabled()) {
-            level = Level.INFO;
-        } else if (logger.isWarnEnabled()) {
-            level = Level.WARNING;
-        } else if (logger.isErrorEnabled()) {
-            level = Level.SEVERE;
-        } else {
-            level = Level.OFF;
-        }
-        return level;
-    }
-
-    @Override
-    public boolean isLoggable(final Level level) {
-        final int i = level.intValue();
-        if (i == Level.OFF.intValue()) {
-            return false;
-        } else if (i >= Level.SEVERE.intValue()) {
-            return logger.isErrorEnabled();
-        } else if (i >= Level.WARNING.intValue()) {
-            return logger.isWarnEnabled();
-        } else if (i >= Level.INFO.intValue()) {
-            return logger.isInfoEnabled();
-        } else if (i >= Level.FINER.intValue()) {
-            return logger.isDebugEnabled();
-        }
-        return logger.isTraceEnabled();
-    }
-
-
-    @Override
-    protected void internalLogFormatted(final String msg, final LogRecord record) {
-
-        final Level level = record.getLevel();
-        final Throwable t = record.getThrown();
-
-        final Handler[] targets = getHandlers();
-        if (targets != null) {
-            for (final Handler h : targets) {
-                h.publish(record);
-            }
-        }
-        if (!getUseParentHandlers()) {
-            return;
-        }
-
-        /*
-        * As we can not use a "switch ... case" block but only a "if ... else if ..." block, the order current the
-        * comparisons is important. We first try log level FINE then INFO, WARN, FINER, etc
-        */
-        if (Level.FINE.equals(level)) {
-            if (locationAwareLogger == null) {
-                logger.debug(msg, t);
-            } else {
-                locationAwareLogger.log(null, FQCN, LocationAwareLogger.DEBUG_INT, msg, null, t);
-            }
-        } else if (Level.INFO.equals(level)) {
-            if (locationAwareLogger == null) {
-                logger.info(msg, t);
-            } else {
-                locationAwareLogger.log(null, FQCN, LocationAwareLogger.INFO_INT, msg, null, t);
-            }
-        } else if (Level.WARNING.equals(level)) {
-            if (locationAwareLogger == null) {
-                logger.warn(msg, t);
-            } else {
-                locationAwareLogger.log(null, FQCN, LocationAwareLogger.WARN_INT, msg, null, t);
-            }
-        } else if (Level.FINER.equals(level)) {
-            if (locationAwareLogger == null) {
-                logger.trace(msg, t);
-            } else {
-                locationAwareLogger.log(null, FQCN, LocationAwareLogger.DEBUG_INT, msg, null, t);
-            }
-        } else if (Level.FINEST.equals(level)) {
-            if (locationAwareLogger == null) {
-                logger.trace(msg, t);
-            } else {
-                locationAwareLogger.log(null, FQCN, LocationAwareLogger.TRACE_INT, msg, null, t);
-            }
-        } else if (Level.ALL.equals(level)) {
-            // should never occur, all is used to configure java.util.logging
-            // but not accessible by the API Logger.xxx() API
-            if (locationAwareLogger == null) {
-                logger.error(msg, t);
-            } else {
-                locationAwareLogger.log(null, FQCN, LocationAwareLogger.ERROR_INT, msg, null, t);
-            }
-        } else if (Level.SEVERE.equals(level)) {
-            if (locationAwareLogger == null) {
-                logger.error(msg, t);
-            } else {
-                locationAwareLogger.log(null, FQCN, LocationAwareLogger.ERROR_INT, msg, null, t);
-            }
-        } else if (Level.CONFIG.equals(level)) {
-            if (locationAwareLogger == null) {
-                logger.debug(msg, t);
-            } else {
-                locationAwareLogger.log(null, FQCN, LocationAwareLogger.DEBUG_INT, msg, null, t);
-            }
-        }
-        // don't log if Level.OFF
-    }
-}


[9/9] incubator-tamaya git commit: remove sources which are not from this very project and don'd have (c) Apache.

Posted by st...@apache.org.
remove sources which are not from this very project and don'd have (c) Apache.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/0734e210
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/0734e210
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/0734e210

Branch: refs/heads/master
Commit: 0734e210e8029557cbc2affbb7a67305de713aeb
Parents: 364139f
Author: Mark Struberg <st...@apache.org>
Authored: Sat Jan 3 19:06:52 2015 +0100
Committer: Mark Struberg <st...@apache.org>
Committed: Sat Jan 3 19:06:52 2015 +0100

----------------------------------------------------------------------
 .../core/PathBasedPropertySourceProvider.java   |  89 ---
 .../core/ResourcePropertySourceProvider.java    |  87 ---
 .../core/formats/ConfigurationFormat.java       |  47 --
 .../tamaya/core/formats/PropertiesFormat.java   | 117 ---
 .../core/formats/PropertiesXmlFormat.java       | 118 ---
 .../resource/AbstractFileResolvingResource.java | 224 ------
 .../core/internal/resource/AntPathMatcher.java  | 775 -------------------
 .../internal/resource/ClassPathResource.java    | 258 ------
 .../resource/DefaultResourceLoader.java         | 105 ---
 .../internal/resource/FileSystemResource.java   | 232 ------
 .../internal/resource/InputStreamResource.java  | 124 ---
 .../PathMatchingDefaultResourceLoader.java      | 142 ----
 .../PathMatchingResourcePatternResolver.java    | 725 -----------------
 .../core/internal/resource/ReflectionUtils.java | 201 -----
 .../core/internal/resource/ResourceUtils.java   | 288 -------
 .../core/internal/resource/UrlResource.java     | 279 -------
 .../core/internal/resource/VfsResource.java     | 131 ----
 .../tamaya/core/internal/resource/VfsUtils.java | 206 -----
 .../core/resources/InputStreamSource.java       |  47 --
 .../apache/tamaya/core/resources/Resource.java  | 185 -----
 .../tamaya/core/resources/ResourceLoader.java   |  87 ---
 .../apache/tamaya/core/ConfigurationTest.java   |   6 -
 .../TestPropertyDefaultSourceProvider.java      |  32 -
 .../core/testdata/TestPropertySource.java       |  57 ++
 .../testdata/TestPropertySourceProvider.java    |  32 -
 .../org.apache.tamaya.spi.PropertySource        |  19 +
 ...org.apache.tamaya.spi.PropertySourceProvider |  20 -
 27 files changed, 76 insertions(+), 4557 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0734e210/core/src/main/java/org/apache/tamaya/core/PathBasedPropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/PathBasedPropertySourceProvider.java b/core/src/main/java/org/apache/tamaya/core/PathBasedPropertySourceProvider.java
deleted file mode 100644
index fc04c3b..0000000
--- a/core/src/main/java/org/apache/tamaya/core/PathBasedPropertySourceProvider.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.core;
-
-import org.apache.tamaya.core.formats.ConfigurationFormat;
-import org.apache.tamaya.core.resources.Resource;
-import org.apache.tamaya.core.resources.ResourceLoader;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertySourceProvider;
-import org.apache.tamaya.spi.ServiceContext;
-
-import java.util.*;
-import java.util.ArrayList;
-import java.util.Objects;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Implementation of a {@link PropertySourceProvider} that reads configuration from some given resource paths
- * and using the given formats.
- */
-public class PathBasedPropertySourceProvider implements PropertySourceProvider {
-    /** The lohgger. */
-    private static final Logger LOG = Logger.getLogger(PathBasedPropertySourceProvider.class.getName());
-
-    private String baseName;
-    /** The config formats tried. */
-    private List<ConfigurationFormat> configFormats = new ArrayList<>();
-    /** The paths tpo be evaluated. */
-    private List<String> paths = new ArrayList<>();
-
-    /**
-     * Creates a new instance.
-     * @param baseName the base name of the configuration, used for creating PropertySource child names.
-     * @param formats the formats to be used, not null, not empty.
-     * @param paths the paths to be resolved, not null, not empty.
-     */
-    public PathBasedPropertySourceProvider(String baseName, List<ConfigurationFormat> formats, String... paths) {
-        this.baseName = Objects.requireNonNull(baseName);
-        this.configFormats.addAll(Objects.requireNonNull(formats));
-        this.paths.addAll(Arrays.asList(Objects.requireNonNull(paths)));
-    }
-
-    /**
-     * Creates a new instance.
-     * @param baseName the base name of the configuration, used for creating PropertySource child names.
-     * @param format the format to be used.
-     * @param paths the paths to be resolved, not null, not empty.
-     */
-    public PathBasedPropertySourceProvider(String baseName, ConfigurationFormat format, String... paths) {
-        this.baseName = Objects.requireNonNull(baseName);
-        this.configFormats.add(Objects.requireNonNull(format));
-        this.paths.addAll(Arrays.asList(Objects.requireNonNull(paths)));
-    }
-
-    @Override
-    public Collection<PropertySource> getPropertySources() {
-        List<PropertySource> propertySources = new ArrayList<>();
-        paths.forEach((path) -> {
-            for (Resource res : ServiceContext.getInstance().getService(ResourceLoader.class).get().getResources(path)) {
-                try {
-                    for (ConfigurationFormat format : configFormats) {
-                        propertySources.addAll(format.readConfiguration(res));
-                    }
-                } catch (Exception e) {
-                    LOG.log(Level.WARNING, "Failed to add resource based config: " + res.getDisplayName(), e);
-                }
-            }
-        });
-        return propertySources;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0734e210/core/src/main/java/org/apache/tamaya/core/ResourcePropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/ResourcePropertySourceProvider.java b/core/src/main/java/org/apache/tamaya/core/ResourcePropertySourceProvider.java
deleted file mode 100644
index 48e9790..0000000
--- a/core/src/main/java/org/apache/tamaya/core/ResourcePropertySourceProvider.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.core;
-
-import org.apache.tamaya.core.formats.ConfigurationFormat;
-import org.apache.tamaya.core.resources.Resource;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertySourceProvider;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import java.util.Objects;
-import java.util.logging.Logger;
-
-/**
- * Implementation of a {@link org.apache.tamaya.spi.PropertySourceProvider} that is based on a single resource
- * and a number of formats.
- */
-public class ResourcePropertySourceProvider implements PropertySourceProvider {
-
-    private static final Logger LOG = Logger.getLogger(ResourcePropertySourceProvider.class.getName());
-
-    private List<ConfigurationFormat> formats = new ArrayList<>();
-
-    private Resource resource;
-
-    public ResourcePropertySourceProvider(Resource resource, ConfigurationFormat... formats) {
-        this.resource = Objects.requireNonNull(resource);
-        this.formats.addAll(Arrays.asList(formats));
-    }
-
-    public ResourcePropertySourceProvider(Resource resource, List<ConfigurationFormat> formats) {
-        this.resource = Objects.requireNonNull(resource);
-        this.formats.addAll(formats);
-    }
-
-
-    /**
-     * Get the underlying resource.
-     *
-     * @return
-     */
-    public Resource getResource() {
-        return this.resource;
-    }
-
-
-    @Override
-    public String toString() {
-        return "ResourcePropertySourceProvider{" +
-                "resource=" + resource +
-                ", formats=+" + formats +
-                '}';
-    }
-
-    @Override
-    public Collection<PropertySource> getPropertySources() {
-        List<PropertySource> propertySources = new ArrayList<>();
-        for (ConfigurationFormat format : formats) {
-            try {
-                propertySources.addAll(format.readConfiguration(resource));
-            } catch (Exception e) {
-                LOG.info(() -> "Format was not matching: " + format + " for resource: " + resource.getDisplayName());
-            }
-        }
-        return propertySources;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0734e210/core/src/main/java/org/apache/tamaya/core/formats/ConfigurationFormat.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/formats/ConfigurationFormat.java b/core/src/main/java/org/apache/tamaya/core/formats/ConfigurationFormat.java
deleted file mode 100644
index c8353a8..0000000
--- a/core/src/main/java/org/apache/tamaya/core/formats/ConfigurationFormat.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.core.formats;
-
-import org.apache.tamaya.core.resources.Resource;
-import org.apache.tamaya.spi.PropertySource;
-
-import java.io.IOException;
-import java.util.Collection;
-
-/**
- * Implementations current this class encapsulate the mechanism how to read a
- * resource including interpreting the format correctly (e.g. xml vs.
- * properties). In most cases file only contains entries of the same priority, which would then
- * result in only one {@link PropertySource}. Complex file formats, hoiwever, may contain entries
- * of different priorities. In this cases, each ordinal type found must be returned as a separate
- * {@link PropertySource} instance.
- */
-@FunctionalInterface
-public interface ConfigurationFormat {
-
-    /**
-     * Reads a list {@link org.apache.tamaya.spi.PropertySource} instances from a resource, using this format.
-     * Hereby the ordinal given is used as a base ordinal
-     *
-     * @param resource the configuration resource, not null
-     * @return the corresponding {@link java.util.Map}, never {@code null}.
-     */
-    Collection<PropertySource> readConfiguration(Resource resource) throws IOException;
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0734e210/core/src/main/java/org/apache/tamaya/core/formats/PropertiesFormat.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/formats/PropertiesFormat.java b/core/src/main/java/org/apache/tamaya/core/formats/PropertiesFormat.java
deleted file mode 100644
index 4a06b3c..0000000
--- a/core/src/main/java/org/apache/tamaya/core/formats/PropertiesFormat.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.core.formats;
-
-import org.apache.tamaya.core.resources.Resource;
-import org.apache.tamaya.spi.PropertySource;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Properties;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Implementation of a {@link org.apache.tamaya.core.formats.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());
-
-    /**
-     * The target ordinal.
-     */
-    private int ordinal;
-
-    /**
-     * Creates a new ordinal.
-     *
-     * @param ordinal the target ordinal.
-     */
-    private PropertiesFormat(int ordinal) {
-        this.ordinal = ordinal;
-    }
-
-    public static PropertiesFormat of(int ordinal) {
-        // TODO caching...
-        return new PropertiesFormat(ordinal);
-    }
-
-    /**
-     * Get the target ordinal, produced by this format.
-     *
-     * @return the target ordinal
-     */
-    public int getOrdinal() {
-        return ordinal;
-    }
-
-    @SuppressWarnings("unchecked")
-    @Override
-    public Collection<PropertySource> readConfiguration(Resource resource) {
-        if (resource.exists()) {
-            List<PropertySource> propertySources = new ArrayList<>();
-            try (InputStream is = resource.getInputStream()) {
-                final Properties p = new Properties();
-                p.load(is);
-                propertySources.add(new PropertySource() {
-                    @Override
-                    public int getOrdinal() {
-                        return ordinal;
-                    }
-
-                    @Override
-                    public String getName() {
-                        return resource.getDisplayName();
-                    }
-
-                    @Override
-                    public Optional<String> get(String key) {
-                        return Optional.ofNullable(p.getProperty(key));
-                    }
-
-                    @Override
-                    public Map<String, String> getProperties() {
-                        return Map.class.cast(p);
-                    }
-                });
-                return propertySources;
-            } catch (Exception e) {
-                LOG.log(Level.FINEST, e, () -> "Failed to read config from resource: " + resource);
-            }
-        }
-        return Collections.emptyList();
-    }
-
-    @Override
-    public String toString() {
-        return "PropertiesFormat{" +
-                "ordinal=" + ordinal +
-                '}';
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0734e210/core/src/main/java/org/apache/tamaya/core/formats/PropertiesXmlFormat.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/formats/PropertiesXmlFormat.java b/core/src/main/java/org/apache/tamaya/core/formats/PropertiesXmlFormat.java
deleted file mode 100644
index 81fcd73..0000000
--- a/core/src/main/java/org/apache/tamaya/core/formats/PropertiesXmlFormat.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.core.formats;
-
-import org.apache.tamaya.core.resources.Resource;
-import org.apache.tamaya.spi.PropertySource;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Properties;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Implementation of a {@link org.apache.tamaya.core.formats.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());
-
-    /**
-     * The target ordinal.
-     */
-    private int ordinal;
-
-    /**
-     * Creates a new ordinal.
-     *
-     * @param ordinal the target ordinal.
-     */
-    private PropertiesXmlFormat(int ordinal) {
-        this.ordinal = ordinal;
-    }
-
-    public static PropertiesXmlFormat of(int ordinal) {
-        // TODO caching...
-        return new PropertiesXmlFormat(ordinal);
-    }
-
-    /**
-     * Get the target ordinal, produced by this format.
-     *
-     * @return the target ordinal
-     */
-    public int getOrdinal() {
-        return ordinal;
-    }
-
-    @SuppressWarnings("unchecked")
-    @Override
-    public Collection<PropertySource> readConfiguration(Resource resource) {
-        if (resource.exists()) {
-            List<PropertySource> propertySources = new ArrayList<>();
-            try (InputStream is = resource.getInputStream()) {
-                final Properties p = new Properties();
-                p.loadFromXML(is);
-                propertySources.add(new PropertySource() {
-                    @Override
-                    public int getOrdinal() {
-                        return ordinal;
-                    }
-
-                    @Override
-                    public String getName() {
-                        return resource.getDisplayName();
-                    }
-
-                    @Override
-                    public Optional<String> get(String key) {
-                        return Optional.ofNullable(p.getProperty(key));
-                    }
-
-                    @Override
-                    public Map<String, String> getProperties() {
-                        return Map.class.cast(p);
-                    }
-                });
-                return propertySources;
-            } catch (Exception e) {
-                LOG.log(Level.FINEST, e, () -> "Failed to read config from resource: " + resource);
-            }
-        }
-        return Collections.emptyList();
-    }
-
-    @Override
-    public String toString() {
-        return "PropertiesXmlFormat{" +
-                "ordinal=" + ordinal +
-                '}';
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0734e210/core/src/main/java/org/apache/tamaya/core/internal/resource/AbstractFileResolvingResource.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/resource/AbstractFileResolvingResource.java b/core/src/main/java/org/apache/tamaya/core/internal/resource/AbstractFileResolvingResource.java
deleted file mode 100644
index 2679659..0000000
--- a/core/src/main/java/org/apache/tamaya/core/internal/resource/AbstractFileResolvingResource.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * Copyright 2002-2013 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tamaya.core.internal.resource;
-
-import org.apache.tamaya.core.resources.Resource;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.Objects;
-
-/**
- * Abstract base class for resources which resolve URLs into File references,
- * such as {@code UrlResource} or {@link ClassPathResource}.
- * <p>
- * <p>Detects the "file" protocol as well as the JBoss "vfs" protocol in URLs,
- * resolving file system references accordingly.
- *
- * @author Juergen Hoeller
- * @since 3.0
- */
-abstract class AbstractFileResolvingResource implements Resource {
-
-    /**
-     * This implementation returns a File reference for the underlying class path
-     * resource, provided that it refers to a file in the file system.
-     */
-    @Override
-    public File toFile() throws IOException {
-        URL url = toURL();
-        return ResourceUtils.getFile(url);
-    }
-
-    /**
-     * This implementation determines the underlying File
-     * (or jar file, in case current a resource in a jar/zip).
-     */
-    protected File getFileForLastModifiedCheck() throws IOException {
-        URL url = toURL();
-        if (ResourceUtils.isJarURL(url)) {
-            URL actualUrl = ResourceUtils.extractJarFileURL(url);
-            return ResourceUtils.getFile(actualUrl, "Jar URL");
-        } else {
-            return toFile();
-        }
-    }
-
-    /**
-     * This implementation returns a File reference for the underlying class path
-     * resource, provided that it refers to a file in the file system.
-     *
-     * @see ResourceUtils#getFile(java.net.URI, String)
-     */
-    protected File getFile(URI uri) throws IOException {
-        return ResourceUtils.getFile(uri);
-    }
-
-
-    @Override
-    public boolean exists() {
-        try {
-            URL url = toURL();
-            if (ResourceUtils.isFileURL(url)) {
-                // Proceed with file system resolution...
-                return toFile().exists();
-            } else {
-                // Try a URL connection content-length header...
-                URLConnection con = url.openConnection();
-                customizeConnection(con);
-                HttpURLConnection httpCon =
-                        (con instanceof HttpURLConnection ? (HttpURLConnection) con : null);
-                if (httpCon != null) {
-                    int code = httpCon.getResponseCode();
-                    if (code == HttpURLConnection.HTTP_OK) {
-                        return true;
-                    } else if (code == HttpURLConnection.HTTP_NOT_FOUND) {
-                        return false;
-                    }
-                }
-                if (con.getContentLength() >= 0) {
-                    return true;
-                }
-                if (httpCon != null) {
-                    // no HTTP OK status, and no content-length header: give up
-                    httpCon.disconnect();
-                    return false;
-                } else {
-                    // Fall back to stream existence: can we open the stream?
-                    InputStream is = getInputStream();
-                    is.close();
-                    return true;
-                }
-            }
-        } catch (IOException ex) {
-            return false;
-        }
-    }
-
-    @Override
-    public boolean isReadable() {
-        try {
-            URL url = toURL();
-            if (ResourceUtils.isFileURL(url)) {
-                // Proceed with file system resolution...
-                File file = toFile();
-                return (file.canRead() && !file.isDirectory());
-            } else {
-                return true;
-            }
-        } catch (IOException ex) {
-            return false;
-        }
-    }
-
-    @Override
-    public long contentLength() throws IOException {
-        URL url = toURL();
-        if (ResourceUtils.isFileURL(url)) {
-            // Proceed with file system resolution...
-            return toFile().length();
-        } else {
-            // Try a URL connection content-length header...
-            URLConnection con = url.openConnection();
-            customizeConnection(con);
-            return con.getContentLength();
-        }
-    }
-
-    @Override
-    public long lastModified() throws IOException {
-        URL url = toURL();
-        if (ResourceUtils.isFileURL(url) || ResourceUtils.isJarURL(url)) {
-            // Proceed with file system resolution...
-            long lastModified = getFileForLastModifiedCheck().lastModified();
-            if (lastModified == 0L) {
-                throw new FileNotFoundException(getDisplayName() +
-                        " cannot be resolved in the file system for resolving its last-modified timestamp");
-            }
-            return lastModified;
-        } else {
-            // Try a URL connection last-modified header...
-            URLConnection con = url.openConnection();
-            customizeConnection(con);
-            return con.getLastModified();
-        }
-    }
-
-
-    /**
-     * Customize the given {@link URLConnection}, obtained in the course current an
-     * {@link #exists()}, {@link #contentLength()} or {@link #lastModified()} call.
-     * <p>Calls {@link ResourceUtils#useCachesIfNecessary(URLConnection)} and
-     * delegates to {@link #customizeConnection(HttpURLConnection)} if possible.
-     * Can be overridden in subclasses.
-     *
-     * @param con the URLConnection to customize
-     * @throws IOException if thrown from URLConnection methods
-     */
-    protected void customizeConnection(URLConnection con) throws IOException {
-        ResourceUtils.useCachesIfNecessary(con);
-        if (con instanceof HttpURLConnection) {
-            customizeConnection((HttpURLConnection) con);
-        }
-    }
-
-    /**
-     * Customize the given {@link HttpURLConnection}, obtained in the course current an
-     * {@link #exists()}, {@link #contentLength()} or {@link #lastModified()} call.
-     * <p>Sets request method "HEAD" by default. Can be overridden in subclasses.
-     *
-     * @param con the HttpURLConnection to customize
-     * @throws IOException if thrown from HttpURLConnection methods
-     */
-    protected void customizeConnection(HttpURLConnection con) throws IOException {
-        con.setRequestMethod("HEAD");
-    }
-
-    /**
-     * Resolve the given resource URL to a {@code java.io.File},
-     * i.e. to a file in the file system.
-     *
-     * @param resourceUrl the resource URL to resolve
-     * @param description a description current the original resource that
-     *                    the URL was created for (for example, a class path location)
-     * @return a corresponding File object
-     * @throws FileNotFoundException if the URL cannot be resolved to
-     *                               a file in the file system
-     */
-    private File getFile(URL resourceUrl, String description) throws FileNotFoundException {
-        Objects.requireNonNull(resourceUrl, "Resource URL must not be null");
-        if (!"file".equals(resourceUrl.getProtocol())) {
-            throw new FileNotFoundException(
-                    description + " cannot be resolved to absolute file path " +
-                            "because it does not reside in the file system: " + resourceUrl);
-        }
-        try {
-            return new File(ResourceUtils.toURI(resourceUrl).getSchemeSpecificPart());
-        } catch (URISyntaxException ex) {
-            // Fallback for URLs that are not valid URIs (should hardly ever happen).
-            return new File(resourceUrl.getFile());
-        }
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0734e210/core/src/main/java/org/apache/tamaya/core/internal/resource/AntPathMatcher.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/resource/AntPathMatcher.java b/core/src/main/java/org/apache/tamaya/core/internal/resource/AntPathMatcher.java
deleted file mode 100644
index ae44377..0000000
--- a/core/src/main/java/org/apache/tamaya/core/internal/resource/AntPathMatcher.java
+++ /dev/null
@@ -1,775 +0,0 @@
-/*
- * Copyright 2002-2014 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tamaya.core.internal.resource;
-
-import org.apache.tamaya.core.util.StringUtils;
-
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * PathMatcher implementation for Ant-style path patterns. Examples are provided below.
- * <p>
- * <p>Part current this annotation code has been kindly borrowed from <a href="http://ant.apache.org">Apache Ant</a>.
- * <p>
- * <p>The annotation matches URLs using the following rules:<br> <ul> <li>? matches one character</li> <li>* matches zero
- * or more characters</li> <li>** matches zero or more 'directories' in a path</li> </ul>
- * <p>
- * <p>Some examples:<br> <ul> <li>{@code com/t?st.jsp} - matches {@code com/testdata.jsp} but also
- * {@code com/tast.jsp} or {@code com/txst.jsp}</li> <li>{@code com/*.jsp} - matches all
- * {@code .jsp} files in the {@code com} directory</li> <li>{@code com/&#42;&#42;/testdata.jsp} - matches all
- * {@code testdata.jsp} files underneath the {@code com} path</li> <li>{@code org/springframework/&#42;&#42;/*.jsp}
- * - matches all {@code .jsp} files underneath the {@code org/springframework} path</li>
- * <li>{@code org/&#42;&#42;/servlet/bla.jsp} - matches {@code org/springframework/servlet/bla.jsp} but also
- * {@code org/springframework/testing/servlet/bla.jsp} and {@code org/servlet/bla.jsp}</li> </ul>
- *
- * @author Alef Arendsen
- * @author Juergen Hoeller
- * @author Rob Harrop
- * @author Arjen Poutsma
- * @author Rossen Stoyanchev
- * @since 16.07.2003
- */
-class AntPathMatcher {
-
-    /**
-     * Default path separator: "/"
-     */
-    public static final String DEFAULT_PATH_SEPARATOR = "/";
-
-    private static final int CACHE_TURNOFF_THRESHOLD = 65536;
-
-    private static final Pattern VARIABLE_PATTERN = Pattern.compile("\\{[^/]+?\\}");
-
-
-    private String pathSeparator;
-
-    private PathSeparatorPatternCache pathSeparatorPatternCache;
-
-    private boolean trimTokens = true;
-
-    private volatile Boolean cachePatterns;
-
-    private final Map<String, String[]> tokenizedPatternCache = new ConcurrentHashMap<>(256);
-
-    final Map<String, AntPathStringMatcher> stringMatcherCache = new ConcurrentHashMap<>(256);
-
-
-    /**
-     * Create a new instance with the {@link #DEFAULT_PATH_SEPARATOR}.
-     */
-    public AntPathMatcher() {
-        this.pathSeparator = DEFAULT_PATH_SEPARATOR;
-        this.pathSeparatorPatternCache = new PathSeparatorPatternCache(DEFAULT_PATH_SEPARATOR);
-    }
-
-    /**
-     * A convenience alternative constructor to use with a custom path separator.
-     *
-     * @param pathSeparator the path separator to use, must not be {@code null}.
-     * @since 4.1
-     */
-    public AntPathMatcher(String pathSeparator) {
-        Objects.requireNonNull(pathSeparator, "'pathSeparator' is required");
-        this.pathSeparator = pathSeparator;
-        this.pathSeparatorPatternCache = new PathSeparatorPatternCache(pathSeparator);
-    }
-
-
-    /**
-     * Set the path separator to use for pattern parsing.
-     * Default is "/", as in Ant.
-     */
-    public void setPathSeparator(String pathSeparator) {
-        this.pathSeparator = (pathSeparator != null ? pathSeparator : DEFAULT_PATH_SEPARATOR);
-        this.pathSeparatorPatternCache = new PathSeparatorPatternCache(this.pathSeparator);
-    }
-
-    /**
-     * Specify whether to trim tokenized paths and patterns.
-     * Default is {@code true}.
-     */
-    public void setTrimTokens(boolean trimTokens) {
-        this.trimTokens = trimTokens;
-    }
-
-    /**
-     * Specify whether to cache parsed pattern metadata for patterns passed
-     * into this matcher's {@link #match} method. A keys current {@code true}
-     * activates an unlimited pattern cache; a keys current {@code false} turns
-     * the pattern cache off completely.
-     * <p>Default is for the cache to be on, but with the variant to automatically
-     * turn it off when encountering too many patterns to cache at runtime
-     * (the threshold is 65536), assuming that arbitrary permutations current patterns
-     * are coming in, with little chance for encountering a reoccurring pattern.
-     *
-     * @see #getStringMatcher(String)
-     */
-    public void setCachePatterns(boolean cachePatterns) {
-        this.cachePatterns = cachePatterns;
-    }
-
-    private void deactivatePatternCache() {
-        this.cachePatterns = false;
-        this.tokenizedPatternCache.clear();
-        this.stringMatcherCache.clear();
-    }
-
-
-    public boolean isPattern(String path) {
-        return (path.indexOf('*') != -1 || path.indexOf('?') != -1);
-    }
-
-    public boolean match(String pattern, String path) {
-        return doMatch(pattern, path, true, null);
-    }
-
-    public boolean matchStart(String pattern, String path) {
-        return doMatch(pattern, path, false, null);
-    }
-
-    /**
-     * Actually match the given {@code path} against the given {@code pattern}.
-     *
-     * @param pattern   the pattern to match against
-     * @param path      the path String to testdata
-     * @param fullMatch whether a full pattern match is required (else a pattern match
-     *                  as far as the given base path goes is sufficient)
-     * @return {@code true} if the supplied {@code path} matched, {@code false} if it didn't
-     */
-    protected boolean doMatch(String pattern, String path, boolean fullMatch, Map<String, String> uriTemplateVariables) {
-        if (path.startsWith(this.pathSeparator) != pattern.startsWith(this.pathSeparator)) {
-            return false;
-        }
-
-        String[] pattDirs = tokenizePattern(pattern);
-        String[] pathDirs = tokenizePath(path);
-
-        int pattIdxStart = 0;
-        int pattIdxEnd = pattDirs.length - 1;
-        int pathIdxStart = 0;
-        int pathIdxEnd = pathDirs.length - 1;
-
-        // Match all elements up to the first **
-        while (pattIdxStart <= pattIdxEnd && pathIdxStart <= pathIdxEnd) {
-            String pattDir = pattDirs[pattIdxStart];
-            if ("**".equals(pattDir)) {
-                break;
-            }
-            if (!matchStrings(pattDir, pathDirs[pathIdxStart], uriTemplateVariables)) {
-                return false;
-            }
-            pattIdxStart++;
-            pathIdxStart++;
-        }
-
-        if (pathIdxStart > pathIdxEnd) {
-            // Path is exhausted, only match if rest current pattern is * or **'s
-            if (pattIdxStart > pattIdxEnd) {
-                return (pattern.endsWith(this.pathSeparator) ? path.endsWith(this.pathSeparator) :
-                        !path.endsWith(this.pathSeparator));
-            }
-            if (!fullMatch) {
-                return true;
-            }
-            if (pattIdxStart == pattIdxEnd && pattDirs[pattIdxStart].equals("*") && path.endsWith(this.pathSeparator)) {
-                return true;
-            }
-            for (int i = pattIdxStart; i <= pattIdxEnd; i++) {
-                if (!pattDirs[i].equals("**")) {
-                    return false;
-                }
-            }
-            return true;
-        } else if (pattIdxStart > pattIdxEnd) {
-            // String not exhausted, but pattern is. Failure.
-            return false;
-        } else if (!fullMatch && "**".equals(pattDirs[pattIdxStart])) {
-            // Path start definitely matches due to "**" part in pattern.
-            return true;
-        }
-
-        // up to last '**'
-        while (pattIdxStart <= pattIdxEnd && pathIdxStart <= pathIdxEnd) {
-            String pattDir = pattDirs[pattIdxEnd];
-            if (pattDir.equals("**")) {
-                break;
-            }
-            if (!matchStrings(pattDir, pathDirs[pathIdxEnd], uriTemplateVariables)) {
-                return false;
-            }
-            pattIdxEnd--;
-            pathIdxEnd--;
-        }
-        if (pathIdxStart > pathIdxEnd) {
-            // String is exhausted
-            for (int i = pattIdxStart; i <= pattIdxEnd; i++) {
-                if (!pattDirs[i].equals("**")) {
-                    return false;
-                }
-            }
-            return true;
-        }
-
-        while (pattIdxStart != pattIdxEnd && pathIdxStart <= pathIdxEnd) {
-            int patIdxTmp = -1;
-            for (int i = pattIdxStart + 1; i <= pattIdxEnd; i++) {
-                if (pattDirs[i].equals("**")) {
-                    patIdxTmp = i;
-                    break;
-                }
-            }
-            if (patIdxTmp == pattIdxStart + 1) {
-                // '**/**' situation, so skip one
-                pattIdxStart++;
-                continue;
-            }
-            // Find the pattern between padIdxStart & padIdxTmp in str between
-            // strIdxStart & strIdxEnd
-            int patLength = (patIdxTmp - pattIdxStart - 1);
-            int strLength = (pathIdxEnd - pathIdxStart + 1);
-            int foundIdx = -1;
-
-            strLoop:
-            for (int i = 0; i <= strLength - patLength; i++) {
-                for (int j = 0; j < patLength; j++) {
-                    String subPat = pattDirs[pattIdxStart + j + 1];
-                    String subStr = pathDirs[pathIdxStart + i + j];
-                    if (!matchStrings(subPat, subStr, uriTemplateVariables)) {
-                        continue strLoop;
-                    }
-                }
-                foundIdx = pathIdxStart + i;
-                break;
-            }
-
-            if (foundIdx == -1) {
-                return false;
-            }
-
-            pattIdxStart = patIdxTmp;
-            pathIdxStart = foundIdx + patLength;
-        }
-
-        for (int i = pattIdxStart; i <= pattIdxEnd; i++) {
-            if (!pattDirs[i].equals("**")) {
-                return false;
-            }
-        }
-
-        return true;
-    }
-
-    /**
-     * Tokenize the given path pattern into parts, based on this matcher's settings.
-     * <p>Performs caching based on {@link #setCachePatterns}, delegating to
-     * {@link #tokenizePath(String)} for the actual tokenization algorithm.
-     *
-     * @param pattern the pattern to tokenize
-     * @return the tokenized pattern parts
-     */
-    protected String[] tokenizePattern(String pattern) {
-        String[] tokenized = null;
-        Boolean cachePatterns = this.cachePatterns;
-        if (cachePatterns == null || cachePatterns) {
-            tokenized = this.tokenizedPatternCache.get(pattern);
-        }
-        if (tokenized == null) {
-            tokenized = tokenizePath(pattern);
-            if (cachePatterns == null && this.tokenizedPatternCache.size() >= CACHE_TURNOFF_THRESHOLD) {
-                // Try to adapt to the runtime situation that we're encountering:
-                // There are obviously too many different patterns coming in here...
-                // So let's turn off the cache since the patterns are unlikely to be reoccurring.
-                deactivatePatternCache();
-                return tokenized;
-            }
-            if (cachePatterns == null || cachePatterns) {
-                this.tokenizedPatternCache.put(pattern, tokenized);
-            }
-        }
-        return tokenized;
-    }
-
-    /**
-     * Tokenize the given path String into parts, based on this matcher's settings.
-     *
-     * @param path the path to tokenize
-     * @return the tokenized path parts
-     */
-    protected String[] tokenizePath(String path) {
-        return StringUtils.tokenizeToStringArray(path, this.pathSeparator, this.trimTokens, true);
-    }
-
-    /**
-     * Tests whether or not a string matches against a pattern.
-     *
-     * @param pattern the pattern to match against (never {@code null})
-     * @param str     the String which must be matched against the pattern (never {@code null})
-     * @return {@code true} if the string matches against the pattern, or {@code false} otherwise
-     */
-    private boolean matchStrings(String pattern, String str, Map<String, String> uriTemplateVariables) {
-        return getStringMatcher(pattern).matchStrings(str, uriTemplateVariables);
-    }
-
-    /**
-     * Build or retrieve an {@link AntPathStringMatcher} for the given pattern.
-     * <p>The default implementation checks this AntPathMatcher's internal cache
-     * (see {@link #setCachePatterns}), creating a new AntPathStringMatcher instance
-     * if no cached copy is found.
-     * When encountering too many patterns to cache at runtime (the threshold is 65536),
-     * it turns the default cache off, assuming that arbitrary permutations current patterns
-     * are coming in, with little chance for encountering a reoccurring pattern.
-     * <p>This method may get overridden to implement a custom cache strategy.
-     *
-     * @param pattern the pattern to match against (never {@code null})
-     * @return a corresponding AntPathStringMatcher (never {@code null})
-     * @see #setCachePatterns
-     */
-    protected AntPathStringMatcher getStringMatcher(String pattern) {
-        AntPathStringMatcher matcher = null;
-        Boolean cachePatterns = this.cachePatterns;
-        if (cachePatterns == null || cachePatterns) {
-            matcher = this.stringMatcherCache.get(pattern);
-        }
-        if (matcher == null) {
-            matcher = new AntPathStringMatcher(pattern);
-            if (cachePatterns == null && this.stringMatcherCache.size() >= CACHE_TURNOFF_THRESHOLD) {
-                // Try to adapt to the runtime situation that we're encountering:
-                // There are obviously too many different patterns coming in here...
-                // So let's turn off the cache since the patterns are unlikely to be reoccurring.
-                deactivatePatternCache();
-                return matcher;
-            }
-            if (cachePatterns == null || cachePatterns) {
-                this.stringMatcherCache.put(pattern, matcher);
-            }
-        }
-        return matcher;
-    }
-
-    /**
-     * Given a pattern and a full path, determine the pattern-mapped part. <p>For example: <ul>
-     * <li>'{@code /docs/cvs/commit.html}' and '{@code /docs/cvs/commit.html} -> ''</li>
-     * <li>'{@code /docs/*}' and '{@code /docs/cvs/commit} -> '{@code cvs/commit}'</li>
-     * <li>'{@code /docs/cvs/*.html}' and '{@code /docs/cvs/commit.html} -> '{@code commit.html}'</li>
-     * <li>'{@code /docs/**}' and '{@code /docs/cvs/commit} -> '{@code cvs/commit}'</li>
-     * <li>'{@code /docs/**\/*.html}' and '{@code /docs/cvs/commit.html} -> '{@code cvs/commit.html}'</li>
-     * <li>'{@code /*.html}' and '{@code /docs/cvs/commit.html} -> '{@code docs/cvs/commit.html}'</li>
-     * <li>'{@code *.html}' and '{@code /docs/cvs/commit.html} -> '{@code /docs/cvs/commit.html}'</li>
-     * <li>'{@code *}' and '{@code /docs/cvs/commit.html} -> '{@code /docs/cvs/commit.html}'</li> </ul>
-     * <p>Assumes that {@link #match} returns {@code true} for '{@code pattern}' and '{@code path}', but
-     * does <strong>not</strong> enforce this.
-     */
-    public String extractPathWithinPattern(String pattern, String path) {
-        String[] patternParts = StringUtils.tokenizeToStringArray(pattern, this.pathSeparator, this.trimTokens, true);
-        String[] pathParts = StringUtils.tokenizeToStringArray(path, this.pathSeparator, this.trimTokens, true);
-        StringBuilder builder = new StringBuilder();
-        boolean pathStarted = false;
-
-        for (int segment = 0; segment < patternParts.length; segment++) {
-            String patternPart = patternParts[segment];
-            if (patternPart.indexOf('*') > -1 || patternPart.indexOf('?') > -1) {
-                for (; segment < pathParts.length; segment++) {
-                    if (pathStarted || (segment == 0 && !pattern.startsWith(this.pathSeparator))) {
-                        builder.append(this.pathSeparator);
-                    }
-                    builder.append(pathParts[segment]);
-                    pathStarted = true;
-                }
-            }
-        }
-
-        return builder.toString();
-    }
-
-    public Map<String, String> extractUriTemplateVariables(String pattern, String path) {
-        Map<String, String> variables = new LinkedHashMap<>();
-        boolean result = doMatch(pattern, path, true, variables);
-        if (!result) {
-            throw new IllegalArgumentException("Pattern \"" + pattern + "\" is not a match for \"" + path + "\"");
-        }
-        return variables;
-    }
-
-    /**
-     * Combines two patterns into a new pattern that is returned.
-     * <p>This implementation simply concatenates the two patterns, unless the first pattern
-     * contains a file extension match (such as {@code *.html}. In that case, the second pattern
-     * should be included in the first, or an {@code IllegalArgumentException} is thrown.
-     * <p>For example: <table>
-     * <tr><th>Pattern 1</th><th>Pattern 2</th><th>Result</th></tr> <tr><td>/hotels</td><td>{@code
-     * null}</td><td>/hotels</td></tr> <tr><td>{@code null}</td><td>/hotels</td><td>/hotels</td></tr>
-     * <tr><td>/hotels</td><td>/bookings</td><td>/hotels/bookings</td></tr> <tr><td>/hotels</td><td>bookings</td><td>/hotels/bookings</td></tr>
-     * <tr><td>/hotels/*</td><td>/bookings</td><td>/hotels/bookings</td></tr> <tr><td>/hotels/&#42;&#42;</td><td>/bookings</td><td>/hotels/&#42;&#42;/bookings</td></tr>
-     * <tr><td>/hotels</td><td>{hotel}</td><td>/hotels/{hotel}</td></tr> <tr><td>/hotels/*</td><td>{hotel}</td><td>/hotels/{hotel}</td></tr>
-     * <tr><td>/hotels/&#42;&#42;</td><td>{hotel}</td><td>/hotels/&#42;&#42;/{hotel}</td></tr>
-     * <tr><td>/*.html</td><td>/hotels.html</td><td>/hotels.html</td></tr> <tr><td>/*.html</td><td>/hotels</td><td>/hotels.html</td></tr>
-     * <tr><td>/*.html</td><td>/*.txt</td><td>IllegalArgumentException</td></tr> </table>
-     *
-     * @param pattern1 the first pattern
-     * @param pattern2 the second pattern
-     * @return the combination current the two patterns
-     * @throws IllegalArgumentException when the two patterns cannot be combined
-     */
-    public String combine(String pattern1, String pattern2) {
-        if (!StringUtils.hasText(pattern1) && !StringUtils.hasText(pattern2)) {
-            return "";
-        }
-        if (!StringUtils.hasText(pattern1)) {
-            return pattern2;
-        }
-        if (!StringUtils.hasText(pattern2)) {
-            return pattern1;
-        }
-
-        boolean pattern1ContainsUriVar = pattern1.indexOf('{') != -1;
-        if (!pattern1.equals(pattern2) && !pattern1ContainsUriVar && match(pattern1, pattern2)) {
-            // /* + /hotel -> /hotel ; "/*.*" + "/*.html" -> /*.html
-            // However /user + /user -> /usr/user ; /{foo} + /bar -> /{foo}/bar
-            return pattern2;
-        }
-
-        // /hotels/* + /booking -> /hotels/booking
-        // /hotels/* + booking -> /hotels/booking
-        if (pattern1.endsWith(this.pathSeparatorPatternCache.getEndsOnWildCard())) {
-            return concat(pattern1.substring(0, pattern1.length() - 2), pattern2);
-        }
-
-        // /hotels/** + /booking -> /hotels/**/booking
-        // /hotels/** + booking -> /hotels/**/booking
-        if (pattern1.endsWith(this.pathSeparatorPatternCache.getEndsOnDoubleWildCard())) {
-            return concat(pattern1, pattern2);
-        }
-
-        int starDotPos1 = pattern1.indexOf("*.");
-        if (pattern1ContainsUriVar || starDotPos1 == -1 || this.pathSeparator.equals(".")) {
-            // simply concatenate the two patterns
-            return concat(pattern1, pattern2);
-        }
-        String extension1 = pattern1.substring(starDotPos1 + 1);
-        int dotPos2 = pattern2.indexOf('.');
-        String fileName2 = (dotPos2 == -1 ? pattern2 : pattern2.substring(0, dotPos2));
-        String extension2 = (dotPos2 == -1 ? "" : pattern2.substring(dotPos2));
-        String extension = extension1.startsWith("*") ? extension2 : extension1;
-        return fileName2 + extension;
-    }
-
-    private String concat(String path1, String path2) {
-        if (path1.endsWith(this.pathSeparator) || path2.startsWith(this.pathSeparator)) {
-            return path1 + path2;
-        }
-        return path1 + this.pathSeparator + path2;
-    }
-
-    /**
-     * Given a full path, returns a {@link Comparator} suitable for sorting patterns in order current explicitness.
-     * <p>The returned {@code Comparator} will {@linkplain java.util.Collections#sort(java.util.List,
-     * java.util.Comparator) sort} a list so that more specific patterns (without uri templates or wild cards) come before
-     * generic patterns. So given a list with the following patterns: <ol> <li>{@code /hotels/new}</li>
-     * <li>{@code /hotels/{hotel}}</li> <li>{@code /hotels/*}</li> </ol> the returned comparator will sort this
-     * list so that the order will be as indicated.
-     * <p>The full path given as parameter is used to testdata for exact matches. So when the given path is {@code /hotels/2},
-     * the pattern {@code /hotels/2} will be sorted before {@code /hotels/1}.
-     *
-     * @param path the full path to use for comparison
-     * @return a comparator capable current sorting patterns in order current explicitness
-     */
-    public Comparator<String> getPatternComparator(String path) {
-        return new AntPatternComparator(path);
-    }
-
-
-    /**
-     * Tests whether or not a string matches against a pattern via a {@link Pattern}.
-     * <p>The pattern may contain special characters: '*' means zero or more characters; '?' means one and
-     * only one character; '{' and '}' indicate a URI template pattern. For example <tt>/users/{user}</tt>.
-     */
-    protected static class AntPathStringMatcher {
-
-        private static final Pattern GLOB_PATTERN = Pattern.compile("\\?|\\*|\\{((?:\\{[^/]+?\\}|[^/{}]|\\\\[{}])+?)\\}");
-
-        private static final String DEFAULT_VARIABLE_PATTERN = "(.*)";
-
-        private final Pattern pattern;
-
-        private final List<String> variableNames = new LinkedList<>();
-
-        public AntPathStringMatcher(String pattern) {
-            StringBuilder patternBuilder = new StringBuilder();
-            Matcher m = GLOB_PATTERN.matcher(pattern);
-            int end = 0;
-            while (m.find()) {
-                patternBuilder.append(quote(pattern, end, m.start()));
-                String match = m.group();
-                if ("?".equals(match)) {
-                    patternBuilder.append('.');
-                } else if ("*".equals(match)) {
-                    patternBuilder.append(".*");
-                } else if (match.startsWith("{") && match.endsWith("}")) {
-                    int colonIdx = match.indexOf(':');
-                    if (colonIdx == -1) {
-                        patternBuilder.append(DEFAULT_VARIABLE_PATTERN);
-                        this.variableNames.add(m.group(1));
-                    } else {
-                        String variablePattern = match.substring(colonIdx + 1, match.length() - 1);
-                        patternBuilder.append('(');
-                        patternBuilder.append(variablePattern);
-                        patternBuilder.append(')');
-                        String variableName = match.substring(1, colonIdx);
-                        this.variableNames.add(variableName);
-                    }
-                }
-                end = m.end();
-            }
-            patternBuilder.append(quote(pattern, end, pattern.length()));
-            this.pattern = Pattern.compile(patternBuilder.toString());
-        }
-
-        private String quote(String s, int start, int end) {
-            if (start == end) {
-                return "";
-            }
-            return Pattern.quote(s.substring(start, end));
-        }
-
-        /**
-         * Main entry point.
-         *
-         * @return {@code true} if the string matches against the pattern, or {@code false} otherwise.
-         */
-        public boolean matchStrings(String str, Map<String, String> uriTemplateVariables) {
-            Matcher matcher = this.pattern.matcher(str);
-            if (matcher.matches()) {
-                if (uriTemplateVariables != null) {
-                    // SPR-8455
-                    if (!(this.variableNames.size() == matcher.groupCount())) {
-                        throw new IllegalStateException(
-                                "The number current capturing groups in the pattern segment " + this.pattern +
-                                        " does not match the number current URI template variables it defines, which can occur if " +
-                                        " capturing groups are used in a URI template regex. Use non-capturing groups instead.");
-                    }
-                    for (int i = 1; i <= matcher.groupCount(); i++) {
-                        String name = this.variableNames.get(i - 1);
-                        String value = matcher.group(i);
-                        uriTemplateVariables.put(name, value);
-                    }
-                }
-                return true;
-            } else {
-                return false;
-            }
-        }
-    }
-
-
-    /**
-     * The default {@link Comparator} implementation returned by
-     * {@link #getPatternComparator(String)}.
-     * <p>In order, the most "generic" pattern is determined by the following:
-     * <ul>
-     * <li>if it's null or a capture all pattern (i.e. it is equal to "/**")</li>
-     * <li>if the other pattern is an actual match</li>
-     * <li>if it's a catch-all pattern (i.e. it ends with "**"</li>
-     * <li>if it's got more "*" than the other pattern</li>
-     * <li>if it's got more "{foo}" than the other pattern</li>
-     * <li>if it's shorter than the other pattern</li>
-     * </ul>
-     */
-    protected static class AntPatternComparator implements Comparator<String> {
-
-        private final String path;
-
-        public AntPatternComparator(String path) {
-            this.path = path;
-        }
-
-        /**
-         * Compare two patterns to determine which should match first, i.e. which
-         * is the most specific regarding the current path.
-         *
-         * @return a negative integer, zero, or a positive integer as pattern1 is
-         * more specific, equally specific, or less specific than pattern2.
-         */
-        @Override
-        public int compare(String pattern1, String pattern2) {
-            PatternInfo info1 = new PatternInfo(pattern1);
-            PatternInfo info2 = new PatternInfo(pattern2);
-
-            if (info1.isLeastSpecific() && info2.isLeastSpecific()) {
-                return 0;
-            } else if (info1.isLeastSpecific()) {
-                return 1;
-            } else if (info2.isLeastSpecific()) {
-                return -1;
-            }
-
-            boolean pattern1EqualsPath = pattern1.equals(path);
-            boolean pattern2EqualsPath = pattern2.equals(path);
-            if (pattern1EqualsPath && pattern2EqualsPath) {
-                return 0;
-            } else if (pattern1EqualsPath) {
-                return -1;
-            } else if (pattern2EqualsPath) {
-                return 1;
-            }
-
-            if (info1.isPrefixPattern() && info2.getDoubleWildcards() == 0) {
-                return 1;
-            } else if (info2.isPrefixPattern() && info1.getDoubleWildcards() == 0) {
-                return -1;
-            }
-
-            if (info1.getTotalCount() != info2.getTotalCount()) {
-                return info1.getTotalCount() - info2.getTotalCount();
-            }
-
-            if (info1.getLength() != info2.getLength()) {
-                return info2.getLength() - info1.getLength();
-            }
-
-            if (info1.getSingleWildcards() < info2.getSingleWildcards()) {
-                return -1;
-            } else if (info2.getSingleWildcards() < info1.getSingleWildcards()) {
-                return 1;
-            }
-
-            if (info1.getUriVars() < info2.getUriVars()) {
-                return -1;
-            } else if (info2.getUriVars() < info1.getUriVars()) {
-                return 1;
-            }
-
-            return 0;
-        }
-
-
-        /**
-         * Value class that holds information about the pattern, e.g. number current
-         * occurrences current "*", "**", and "{" pattern elements.
-         */
-        private static class PatternInfo {
-
-            private final String pattern;
-
-            private int uriVars;
-
-            private int singleWildcards;
-
-            private int doubleWildcards;
-
-            private boolean catchAllPattern;
-
-            private boolean prefixPattern;
-
-            private Integer length;
-
-            public PatternInfo(String pattern) {
-                this.pattern = pattern;
-                if (this.pattern != null) {
-                    initCounters();
-                    this.catchAllPattern = this.pattern.equals("/**");
-                    this.prefixPattern = !this.catchAllPattern && this.pattern.endsWith("/**");
-                }
-                if (this.uriVars == 0) {
-                    this.length = (this.pattern != null ? this.pattern.length() : 0);
-                }
-            }
-
-            protected void initCounters() {
-                int pos = 0;
-                while (pos < this.pattern.length()) {
-                    if (this.pattern.charAt(pos) == '{') {
-                        this.uriVars++;
-                        pos++;
-                    } else if (this.pattern.charAt(pos) == '*') {
-                        if (pos + 1 < this.pattern.length() && this.pattern.charAt(pos + 1) == '*') {
-                            this.doubleWildcards++;
-                            pos += 2;
-                        } else if (!this.pattern.substring(pos - 1).equals(".*")) {
-                            this.singleWildcards++;
-                            pos++;
-                        } else {
-                            pos++;
-                        }
-                    } else {
-                        pos++;
-                    }
-                }
-            }
-
-            public int getUriVars() {
-                return this.uriVars;
-            }
-
-            public int getSingleWildcards() {
-                return this.singleWildcards;
-            }
-
-            public int getDoubleWildcards() {
-                return this.doubleWildcards;
-            }
-
-            public boolean isLeastSpecific() {
-                return (this.pattern == null || this.catchAllPattern);
-            }
-
-            public boolean isPrefixPattern() {
-                return this.prefixPattern;
-            }
-
-            public int getTotalCount() {
-                return this.uriVars + this.singleWildcards + (2 * this.doubleWildcards);
-            }
-
-            /**
-             * Returns the length current the given pattern, where template variables are considered to be 1 long.
-             */
-            public int getLength() {
-                if (this.length == null) {
-                    this.length = VARIABLE_PATTERN.matcher(this.pattern).replaceAll("#").length();
-                }
-                return this.length;
-            }
-        }
-    }
-
-
-    /**
-     * A simple cache for patterns that depend on the configured path separator.
-     */
-    private static class PathSeparatorPatternCache {
-
-        private final String endsOnWildCard;
-
-        private final String endsOnDoubleWildCard;
-
-        public PathSeparatorPatternCache(String pathSeparator) {
-            this.endsOnWildCard = pathSeparator + "*";
-            this.endsOnDoubleWildCard = pathSeparator + "**";
-        }
-
-        public String getEndsOnWildCard() {
-            return this.endsOnWildCard;
-        }
-
-        public String getEndsOnDoubleWildCard() {
-            return this.endsOnDoubleWildCard;
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0734e210/core/src/main/java/org/apache/tamaya/core/internal/resource/ClassPathResource.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/resource/ClassPathResource.java b/core/src/main/java/org/apache/tamaya/core/internal/resource/ClassPathResource.java
deleted file mode 100644
index 15d04d6..0000000
--- a/core/src/main/java/org/apache/tamaya/core/internal/resource/ClassPathResource.java
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * Copyright 2002-2014 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tamaya.core.internal.resource;
-
-import org.apache.tamaya.core.util.StringUtils;
-import org.apache.tamaya.core.util.ClassUtils;
-import org.apache.tamaya.core.resources.Resource;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Objects;
-
-/**
- * {@link Resource} implementation for class path resources.
- * Uses either a given ClassLoader or a given Class for loading resources.
- * <p>
- * <p>Supports resolution as {@code java.io.File} if the class path
- * resource resides in the file system, but not for resources in a JAR.
- * Always supports resolution as URL.
- *
- * @author Juergen Hoeller
- * @author Sam Brannen
- * @see ClassLoader#getResourceAsStream(String)
- * @see Class#getResourceAsStream(String)
- * @since 28.12.2003
- */
-public class ClassPathResource extends AbstractFileResolvingResource {
-
-    private final String path;
-
-    private ClassLoader classLoader;
-
-    private Class<?> clazz;
-
-
-    /**
-     * Create a new {@code ClassPathResource} for {@code ClassLoader} usage.
-     * A leading slash will be removed, as the ClassLoader resource access
-     * methods will not accept it.
-     * <p>The thread context class loader will be used for
-     * loading the resource.
-     *
-     * @param path the absolute path within the class path
-     * @see java.lang.ClassLoader#getResourceAsStream(String)
-     */
-    public ClassPathResource(String path) {
-        this(path, (ClassLoader) null);
-    }
-
-    /**
-     * Create a new {@code ClassPathResource} for {@code ClassLoader} usage.
-     * A leading slash will be removed, as the ClassLoader resource access
-     * methods will not accept it.
-     *
-     * @param path        the absolute path within the classpath
-     * @param classLoader the class loader to load the resource with,
-     *                    or {@code null} for the thread context class loader
-     * @see ClassLoader#getResourceAsStream(String)
-     */
-    public ClassPathResource(String path, ClassLoader classLoader) {
-        Objects.requireNonNull(path, "Path must not be null");
-        String pathToUse = StringUtils.cleanPath(path);
-        if (pathToUse.startsWith("/")) {
-            pathToUse = pathToUse.substring(1);
-        }
-        this.path = pathToUse;
-        this.classLoader = (classLoader != null ? classLoader : ClassUtils.getDefaultClassLoader());
-    }
-
-    /**
-     * Create a new {@code ClassPathResource} for {@code Class} usage.
-     * The path can be relative to the given class, or absolute within
-     * the classpath via a leading slash.
-     *
-     * @param path  relative or absolute path within the class path
-     * @param clazz the class to load resources with
-     * @see java.lang.Class#getResourceAsStream
-     */
-    public ClassPathResource(String path, Class<?> clazz) {
-        Objects.requireNonNull(path, "Path must not be null");
-        this.path = StringUtils.cleanPath(path);
-        this.clazz = clazz;
-    }
-
-    /**
-     * Create a new {@code ClassPathResource} with optional {@code ClassLoader}
-     * and {@code Class}. Only for internal usage.
-     *
-     * @param path        relative or absolute path within the classpath
-     * @param classLoader the class loader to load the resource with, if any
-     * @param clazz       the class to load resources with, if any
-     */
-    protected ClassPathResource(String path, ClassLoader classLoader, Class<?> clazz) {
-        this.path = StringUtils.cleanPath(path);
-        this.classLoader = classLoader;
-        this.clazz = clazz;
-    }
-
-
-    /**
-     * Return the path for this resource (as resource path within the class path).
-     */
-    public final String getPath() {
-        return this.path;
-    }
-
-    /**
-     * Return the ClassLoader that this resource will be obtained from.
-     */
-    public final ClassLoader getClassLoader() {
-        return (this.clazz != null ? this.clazz.getClassLoader() : this.classLoader);
-    }
-
-
-    /**
-     * This implementation checks for the resolution current a resource URL.
-     *
-     * @see java.lang.ClassLoader#getResource(String)
-     * @see java.lang.Class#getResource(String)
-     */
-    @Override
-    public boolean exists() {
-        return (resolveURL() != null);
-    }
-
-    /**
-     * Resolves a URL for the underlying class path resource.
-     *
-     * @return the resolved URL, or {@code null} if not resolvable
-     */
-    protected URL resolveURL() {
-        if (this.clazz != null) {
-            return this.clazz.getResource(this.path);
-        } else if (this.classLoader != null) {
-            return this.classLoader.getResource(this.path);
-        } else {
-            return ClassLoader.getSystemResource(this.path);
-        }
-    }
-
-    /**
-     * This implementation opens an InputStream for the given class path resource.
-     *
-     * @see java.lang.ClassLoader#getResourceAsStream(String)
-     * @see java.lang.Class#getResourceAsStream(String)
-     */
-    @Override
-    public InputStream getInputStream() throws IOException {
-        InputStream is;
-        if (this.clazz != null) {
-            is = this.clazz.getResourceAsStream(this.path);
-        } else if (this.classLoader != null) {
-            is = this.classLoader.getResourceAsStream(this.path);
-        } else {
-            is = ClassLoader.getSystemResourceAsStream(this.path);
-        }
-        if (is == null) {
-            throw new IOException(getDisplayName() + " cannot be opened because it does not exist");
-        }
-        return is;
-    }
-
-    /**
-     * This implementation returns a URL for the underlying class path resource,
-     * if available.
-     *
-     * @see java.lang.ClassLoader#getResource(String)
-     * @see java.lang.Class#getResource(String)
-     */
-    @Override
-    public URL toURL() throws IOException {
-        URL url = resolveURL();
-        if (url == null) {
-            throw new FileNotFoundException(getDisplayName() + " cannot be resolved to URL because it does not exist");
-        }
-        return url;
-    }
-
-    /**
-     * This implementation creates a ClassPathResource, applying the given path
-     * relative to the path current the underlying resource current this descriptor.
-     */
-    @Override
-    public Resource createRelative(String relativePath) {
-        String pathToUse = StringUtils.applyRelativePath(this.path, relativePath);
-        return new ClassPathResource(pathToUse, this.classLoader, this.clazz);
-    }
-
-    /**
-     * This implementation returns the name current the file that this class path
-     * resource refers to.
-     */
-    @Override
-    public String getDisplayName() {
-        return StringUtils.getFilename(this.path);
-    }
-
-    /**
-     * This implementation returns a description that includes the class path location.
-     */
-    @Override
-    public String toString() {
-        StringBuilder builder = new StringBuilder("ClassPathResource [");
-        String pathToUse = path;
-        if (this.clazz != null && !pathToUse.startsWith("/")) {
-            builder.append(ClassUtils.classPackageAsResourcePath(this.clazz));
-            builder.append('/');
-        }
-        if (pathToUse.startsWith("/")) {
-            pathToUse = pathToUse.substring(1);
-        }
-        builder.append(pathToUse);
-        builder.append(']');
-        return builder.toString();
-    }
-
-    /**
-     * This implementation compares the underlying class path locations.
-     */
-    @Override
-    public boolean equals(Object obj) {
-        if (obj == this) {
-            return true;
-        }
-        if (obj instanceof ClassPathResource) {
-            ClassPathResource otherRes = (ClassPathResource) obj;
-            return (this.path.equals(otherRes.path) &&
-                    Objects.equals(this.classLoader, otherRes.classLoader) &&
-                    Objects.equals(this.clazz, otherRes.clazz));
-        }
-        return false;
-    }
-
-    /**
-     * This implementation returns the hash code current the underlying
-     * class path location.
-     */
-    @Override
-    public int hashCode() {
-        return this.path.hashCode();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0734e210/core/src/main/java/org/apache/tamaya/core/internal/resource/DefaultResourceLoader.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/resource/DefaultResourceLoader.java b/core/src/main/java/org/apache/tamaya/core/internal/resource/DefaultResourceLoader.java
deleted file mode 100644
index c19ac62..0000000
--- a/core/src/main/java/org/apache/tamaya/core/internal/resource/DefaultResourceLoader.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright 2002-2014 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tamaya.core.internal.resource;
-
-import org.apache.tamaya.core.resources.Resource;
-import org.apache.tamaya.core.resources.ResourceLoader;
-
-import javax.annotation.Priority;
-import java.io.File;
-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.WeakHashMap;
-import java.util.logging.Logger;
-
-/**
- * Simple default implementation of the resource loader.
- */
-@Priority(0)
-public class DefaultResourceLoader implements ResourceLoader {
-
-    private static final Logger LOG = Logger.getLogger(DefaultResourceLoader.class.getName());
-
-    private WeakHashMap<ClassLoader, PathMatchingResourcePatternResolver> resourceLoaders = new WeakHashMap<>();
-
-    @Override
-    public List<Resource> getResources(ClassLoader classLoader, Collection<String> expressions) {
-        List<Resource> resources = new ArrayList<>();
-        for (String expression : expressions) {
-            if (tryClassPath(classLoader, expression, resources) || tryFile(expression, resources) || tryURL(expression, resources)
-                    || tryAntPath(classLoader, expression, resources)) {
-                continue;
-            }
-            LOG.warning("Failed to resolve resource: " + expression);
-        }
-        return resources;
-    }
-
-    private boolean tryClassPath(ClassLoader classLoader, String expression, List<Resource> resources) {
-        try {
-            Enumeration<URL> urls = classLoader.getResources(expression);
-            while (urls.hasMoreElements()) {
-                URL url = urls.nextElement();
-                resources.add(new UrlResource(url));
-            }
-            return !resources.isEmpty();
-        } catch (Exception e) {
-            LOG.finest(() -> "Failed to load resource from CP: " + expression);
-        }
-        return false;
-    }
-
-    private boolean tryFile(String expression, List<Resource> resources) {
-        try {
-            File file = new File(expression);
-            if (file.exists()) {
-                resources.add(new FileSystemResource(file));
-                return true;
-            }
-        } catch (Exception e) {
-            LOG.finest(() -> "Failed to load resource from file: " + expression);
-        }
-        return false;
-    }
-
-    private boolean tryURL(String expression, List<Resource> resources) {
-        try {
-            URL url = new URL(expression);
-            resources.add(new UrlResource(url));
-            return true;
-        } catch (Exception e) {
-            LOG.finest(() -> "Failed to load resource from file: " + expression);
-        }
-        return false;
-
-    }
-
-    private boolean tryAntPath(ClassLoader classLoader, String expression, List<Resource> resources) {
-        PathMatchingResourcePatternResolver loader = resourceLoaders.computeIfAbsent(classLoader, cl -> new PathMatchingResourcePatternResolver(cl));
-        try {
-            resources.addAll(Arrays.asList(loader.getResources(expression)));
-            return !resources.isEmpty();
-        } catch (Exception e) {
-            LOG.finest(() -> "Failed to load resources from pattern: " + expression);
-        }
-        return false;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0734e210/core/src/main/java/org/apache/tamaya/core/internal/resource/FileSystemResource.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/resource/FileSystemResource.java b/core/src/main/java/org/apache/tamaya/core/internal/resource/FileSystemResource.java
deleted file mode 100644
index c5fa68e..0000000
--- a/core/src/main/java/org/apache/tamaya/core/internal/resource/FileSystemResource.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * Copyright 2002-2014 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tamaya.core.internal.resource;
-
-import org.apache.tamaya.core.util.StringUtils;
-import org.apache.tamaya.core.resources.Resource;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.URI;
-import java.net.URL;
-import java.util.Objects;
-
-/**
- * {@link Resource} implementation for {@code java.io.File} handles.
- * Obviously supports resolution as File, and also as URL.
- *
- * @author Juergen Hoeller
- * @see java.io.File
- * @since 28.12.2003
- */
-public class FileSystemResource implements Resource {
-
-    private final File file;
-
-    private final String path;
-
-
-    /**
-     * Create a new {@code FileSystemResource} from a {@link File} handle.
-     * <p>Note: When building relative resources via {@link #createRelative},
-     * the relative path will applyChanges <i>at the same directory level</i>:
-     * e.g. new File("C:/dir1"), relative path "dir2" -> "C:/dir2"!
-     * If you prefer to have relative paths built underneath the given root
-     * directory, use the {@link #FileSystemResource(String) constructor with a file path}
-     * to append a trailing slash to the root path: "C:/dir1/", which
-     * indicates this directory as root for all relative paths.
-     *
-     * @param file a File handle
-     */
-    public FileSystemResource(File file) {
-        Objects.requireNonNull(file, "File must not be null");
-        this.file = file;
-        this.path = StringUtils.cleanPath(file.getPath());
-    }
-
-    /**
-     * Create a new {@code FileSystemResource} from a file path.
-     * <p>Note: When building relative resources via {@link #createRelative},
-     * it makes a difference whether the specified resource base path here
-     * ends with a slash or not. In the case current "C:/dir1/", relative paths
-     * will be built underneath that root: e.g. relative path "dir2" ->
-     * "C:/dir1/dir2". In the case current "C:/dir1", relative paths will applyChanges
-     * at the same directory level: relative path "dir2" -> "C:/dir2".
-     *
-     * @param path a file path
-     */
-    public FileSystemResource(String path) {
-        Objects.requireNonNull(path, "Path must not be null");
-        this.file = new File(path);
-        this.path = StringUtils.cleanPath(path);
-    }
-
-
-    /**
-     * Return the file path for this resource.
-     */
-    public final String getPath() {
-        return this.path;
-    }
-
-
-    /**
-     * This implementation returns whether the underlying file exists.
-     *
-     * @see java.io.File#exists()
-     */
-    @Override
-    public boolean exists() {
-        return this.file.exists();
-    }
-
-    /**
-     * This implementation checks whether the underlying file is marked as readable
-     * (and corresponds to an actual file with content, not to a directory).
-     *
-     * @see java.io.File#canRead()
-     * @see java.io.File#isDirectory()
-     */
-    @Override
-    public boolean isReadable() {
-        return (this.file.canRead() && !this.file.isDirectory());
-    }
-
-    /**
-     * This implementation opens a FileInputStream for the underlying file.
-     *
-     * @see java.io.FileInputStream
-     */
-    @Override
-    public InputStream getInputStream() throws IOException {
-        return new FileInputStream(this.file);
-    }
-
-    /**
-     * This implementation returns a URL for the underlying file.
-     *
-     * @see java.io.File#toURI()
-     */
-    @Override
-    public URL toURL() throws IOException {
-        return this.file.toURI().toURL();
-    }
-
-    /**
-     * This implementation returns a URI for the underlying file.
-     *
-     * @see java.io.File#toURI()
-     */
-    @Override
-    public URI getURI() throws IOException {
-        return this.file.toURI();
-    }
-
-    /**
-     * This implementation returns the underlying File reference.
-     */
-    @Override
-    public File toFile() {
-        return this.file;
-    }
-
-    /**
-     * This implementation returns the underlying File's length.
-     */
-    @Override
-    public long contentLength() throws IOException {
-        return this.file.length();
-    }
-
-    /**
-     * This implementation creates a FileSystemResource, applying the given path
-     * relative to the path current the underlying file current this resource descriptor.
-     *
-     * @see StringUtils#applyRelativePath(String, String)
-     */
-    @Override
-    public Resource createRelative(String relativePath) {
-        String pathToUse = StringUtils.applyRelativePath(this.path, relativePath);
-        return new FileSystemResource(pathToUse);
-    }
-
-    /**
-     * This implementation returns the name current the file.
-     *
-     * @see java.io.File#getName()
-     */
-    @Override
-    public String getDisplayName() {
-        return this.file.getName();
-    }
-
-    /**
-     * This implementation returns a description that includes the absolute
-     * path current the file.
-     *
-     * @see java.io.File#getAbsolutePath()
-     */
-    @Override
-    public String toString() {
-        return "file [" + this.file.getAbsolutePath() + "]";
-    }
-
-
-    // implementation current WritableResource
-
-    /**
-     * This implementation checks whether the underlying file is marked as writable
-     * (and corresponds to an actual file with content, not to a directory).
-     *
-     * @see java.io.File#canWrite()
-     * @see java.io.File#isDirectory()
-     */
-    public boolean isWritable() {
-        return (this.file.canWrite() && !this.file.isDirectory());
-    }
-
-    /**
-     * This implementation opens a FileOutputStream for the underlying file.
-     *
-     * @see java.io.FileOutputStream
-     */
-    public OutputStream getOutputStream() throws IOException {
-        return new FileOutputStream(this.file);
-    }
-
-
-    /**
-     * This implementation compares the underlying File references.
-     */
-    @Override
-    public boolean equals(Object obj) {
-        return (obj == this ||
-                (obj instanceof FileSystemResource && this.path.equals(((FileSystemResource) obj).path)));
-    }
-
-    /**
-     * This implementation returns the hash code current the underlying File reference.
-     */
-    @Override
-    public int hashCode() {
-        return this.path.hashCode();
-    }
-
-}


[2/9] incubator-tamaya git commit: Merge remote-tracking branch 'rsandtner/TAMAYA-38' into TAMAYA-38

Posted by st...@apache.org.
Merge remote-tracking branch 'rsandtner/TAMAYA-38' into TAMAYA-38

Conflicts:
	core/pom.xml


Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/78732d44
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/78732d44
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/78732d44

Branch: refs/heads/master
Commit: 78732d44cfbf18a300ac071276a03204407b7d83
Parents: ced3463 51960ef
Author: Mark Struberg <st...@apache.org>
Authored: Sat Jan 3 14:43:02 2015 +0100
Committer: Mark Struberg <st...@apache.org>
Committed: Sat Jan 3 14:43:02 2015 +0100

----------------------------------------------------------------------
 .../org/apache/tamaya/spi/PropertySource.java   |   7 ++
 core/pom.xml                                    |  33 +-----
 .../core/propertysource/BasePropertySource.java |  76 +++++++++++++
 .../core/propertysource/DefaultOrdinal.java     |  46 ++++++++
 .../EnvironmentPropertySource.java              |  47 ++++++++
 .../propertysource/SystemPropertySource.java    |  82 ++++++++++++++
 .../propertysource/BasePropertySourceTest.java  | 107 +++++++++++++++++++
 .../EnvironmentPropertySourceTest.java          |  70 ++++++++++++
 .../SystemPropertySourceTest.java               | 103 ++++++++++++++++++
 9 files changed, 539 insertions(+), 32 deletions(-)
----------------------------------------------------------------------



[6/9] incubator-tamaya git commit: fix TestConfiguration - did not even compile ...

Posted by st...@apache.org.
fix TestConfiguration - did not even compile ...


Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/364139f5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/364139f5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/364139f5

Branch: refs/heads/master
Commit: 364139f5bc8abe05a87e0899e79a32926e77b153
Parents: 3e1a7a5
Author: Mark Struberg <st...@apache.org>
Authored: Sat Jan 3 18:26:57 2015 +0100
Committer: Mark Struberg <st...@apache.org>
Committed: Sat Jan 3 18:26:57 2015 +0100

----------------------------------------------------------------------
 .../org/apache/tamaya/TestConfiguration.java    | 49 +++++++++-----------
 1 file changed, 21 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/364139f5/api/src/test/java/org/apache/tamaya/TestConfiguration.java
----------------------------------------------------------------------
diff --git a/api/src/test/java/org/apache/tamaya/TestConfiguration.java b/api/src/test/java/org/apache/tamaya/TestConfiguration.java
index 122d671..cdcb0e9 100644
--- a/api/src/test/java/org/apache/tamaya/TestConfiguration.java
+++ b/api/src/test/java/org/apache/tamaya/TestConfiguration.java
@@ -18,6 +18,8 @@
  */
 package org.apache.tamaya;
 
+import java.util.HashMap;
+import java.util.Map;
 import java.util.Optional;
 
 /**
@@ -25,36 +27,23 @@ import java.util.Optional;
  */
 public class TestConfiguration implements Configuration{
 
+    private static final Map<String, String> VALUES;
+    static {
+        VALUES = new HashMap<String, String>();
+        VALUES.put("long", String.valueOf(Long.MAX_VALUE));
+        VALUES.put("int", String.valueOf(Integer.MAX_VALUE));
+        VALUES.put("double", String.valueOf(Double.MAX_VALUE));
+        VALUES.put("float", String.valueOf(Float.MAX_VALUE));
+        VALUES.put("short", String.valueOf(Short.MAX_VALUE));
+        VALUES.put("byte", String.valueOf(Byte.MAX_VALUE));
+        VALUES.put("booleanTrue", "true");
+        VALUES.put("booleanFalse", "false");
+        VALUES.put("String", "aStringValue");
+    }
+
     @Override
     public Optional<String> get(String key) {
-        if("long".equals(key)){
-            return Optional.ofNullable(String.valueOf(Long.MAX_VALUE));
-        }
-        else if("int".equals(key)){
-            return Optional.ofNullable(String.valueOf(Integer.MAX_VALUE));
-        }
-        else if("double".equals(key)){
-            return Optional.ofNullable(String.valueOf(Double.MAX_VALUE));
-        }
-        else if("float".equals(key)){
-            return Optional.ofNullable(String.valueOf(Float.MAX_VALUE));
-        }
-        else if("short".equals(key)){
-            return Optional.ofNullable(String.valueOf(Short.MAX_VALUE));
-        }
-        else if("byte".equals(key)){
-            return Optional.ofNullable(String.valueOf(Byte.MAX_VALUE));
-        }
-        else if("booleanTrue".equals(key)){
-            return Optional.ofNullable("true");
-        }
-        else if("booleanFalse".equals(key)){
-            return Optional.ofNullable("false");
-        }
-        else if("String".equals(key)){
-            return Optional.ofNullable("aStringValue");
-        }
-        return Optional.ofNullable("noValue");
+        return Optional.ofNullable(VALUES.get(key));
     }
 
     @Override
@@ -91,4 +80,8 @@ public class TestConfiguration implements Configuration{
         throw new ConfigException("No such property: " + key);
     }
 
+    @Override
+    public Map<String, String> getProperties() {
+        return null;
+    }
 }


[8/9] incubator-tamaya git commit: remove sources which are not from this very project and don'd have (c) Apache.

Posted by st...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0734e210/core/src/main/java/org/apache/tamaya/core/internal/resource/InputStreamResource.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/resource/InputStreamResource.java b/core/src/main/java/org/apache/tamaya/core/internal/resource/InputStreamResource.java
deleted file mode 100644
index 11dc8ee..0000000
--- a/core/src/main/java/org/apache/tamaya/core/internal/resource/InputStreamResource.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright 2002-2012 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.tamaya.core.internal.resource;
-
-import org.apache.tamaya.core.resources.Resource;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Objects;
-
-/**
- * {@link Resource} implementation for a given InputStream. Should only
- * be used if no specific Resource implementation is applicable.
- * In particular, prefer {@code ByteArrayResource} or any current the
- * file-based Resource implementations where possible.
- * <p>
- * <p>In contrast to other Resource implementations, this is a descriptor
- * for an <i>already opened</i> resource - therefore returning "true" from
- * {@code isOpen()}. Do not use it if you need to keep the resource
- * descriptor somewhere, or if you need to read a stream multiple times.
- *
- * @author Juergen Hoeller
- * @since 28.12.2003
- */
-public class InputStreamResource implements Resource {
-
-    private final InputStream inputStream;
-
-    private final String description;
-
-    private boolean read = false;
-
-
-    /**
-     * Create a new InputStreamResource.
-     *
-     * @param inputStream the InputStream to use
-     */
-    public InputStreamResource(InputStream inputStream) {
-        this(inputStream, "resource loaded through InputStream");
-    }
-
-    /**
-     * Create a new InputStreamResource.
-     *
-     * @param inputStream the InputStream to use
-     * @param description where the InputStream comes from
-     */
-    public InputStreamResource(InputStream inputStream, String description) {
-        this.inputStream = Objects.requireNonNull(inputStream);
-        this.description = (description != null ? description : "");
-    }
-
-
-    /**
-     * This implementation always returns {@code true}.
-     */
-    @Override
-    public boolean exists() {
-        return true;
-    }
-
-    /**
-     * This implementation always returns {@code true}.
-     */
-    @Override
-    public boolean isOpen() {
-        return true;
-    }
-
-    /**
-     * This implementation throws IllegalStateException if attempting to
-     * read the underlying stream multiple times.
-     */
-    @Override
-    public InputStream getInputStream() throws IOException {
-        if (this.read) {
-            throw new IllegalStateException("InputStream has already been read - " +
-                    "do not use InputStreamResource if a stream needs to be read multiple times");
-        }
-        this.read = true;
-        return this.inputStream;
-    }
-
-    /**
-     * This implementation returns the passed-in description, if any.
-     */
-    public String toString() {
-        return this.description != null ? this.description : super.toString();
-    }
-
-
-    /**
-     * This implementation compares the underlying InputStream.
-     */
-    @Override
-    public boolean equals(Object obj) {
-        return (obj == this ||
-                (obj instanceof InputStreamResource && ((InputStreamResource) obj).inputStream.equals(this.inputStream)));
-    }
-
-    /**
-     * This implementation returns the hash code current the underlying InputStream.
-     */
-    @Override
-    public int hashCode() {
-        return this.inputStream.hashCode();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0734e210/core/src/main/java/org/apache/tamaya/core/internal/resource/PathMatchingDefaultResourceLoader.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/resource/PathMatchingDefaultResourceLoader.java b/core/src/main/java/org/apache/tamaya/core/internal/resource/PathMatchingDefaultResourceLoader.java
deleted file mode 100644
index cf16762..0000000
--- a/core/src/main/java/org/apache/tamaya/core/internal/resource/PathMatchingDefaultResourceLoader.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright 2002-2014 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tamaya.core.internal.resource;
-
-import org.apache.tamaya.core.resources.Resource;
-import org.apache.tamaya.core.util.ClassUtils;
-import org.apache.tamaya.core.util.StringUtils;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Objects;
-
-/**
- * <p>Will return a {@code UrlResource} if the location keys is a URL,
- * and a {@code ClassPathResource} if it is a non-URL path or a
- * "classpath:" pseudo-URL.
- *
- * @author Juergen Hoeller
- * @since 10.03.2004
- */
-class PathMatchingDefaultResourceLoader {
-
-    /**
-     * Pseudo URL prefix for loading from the class path: "classpath:"
-     */
-    public static final String CLASSPATH_URL_PREFIX = "classpath:";
-
-    private ClassLoader classLoader;
-
-
-    /**
-     * Create a new DefaultResourceLoader.
-     * <p>ClassLoader access will happen using the thread context class loader
-     * at the time current this ResourceLoader's initialization.
-     *
-     * @see java.lang.Thread#getContextClassLoader()
-     */
-    public PathMatchingDefaultResourceLoader() {
-        this.classLoader = ClassUtils.getDefaultClassLoader();
-    }
-
-    /**
-     * Create a new DefaultResourceLoader.
-     *
-     * @param classLoader the ClassLoader to load class path resources with, or {@code null}
-     *                    for using the thread context class loader at the time current actual resource access
-     */
-    public PathMatchingDefaultResourceLoader(ClassLoader classLoader) {
-        this.classLoader = classLoader;
-    }
-
-
-    /**
-     * Specify the ClassLoader to load class path resources with, or {@code null}
-     * for using the thread context class loader at the time current actual resource access.
-     * <p>The default is that ClassLoader access will happen using the thread context
-     * class loader at the time current this ResourceLoader's initialization.
-     */
-    void setClassLoader(ClassLoader classLoader) {
-        this.classLoader = classLoader;
-    }
-
-    /**
-     * Return the ClassLoader to load class path resources with.
-     * <p>Will get passed to ClassPathResource's constructor for all
-     * ClassPathResource objects created by this resource loader.
-     *
-     * @see ClassPathResource
-     */
-    public ClassLoader getClassLoader() {
-        return (this.classLoader != null ? this.classLoader : ClassUtils.getDefaultClassLoader());
-    }
-
-
-    public Resource getResource(String location) {
-        Objects.requireNonNull(location, "Location must not be null");
-        if (location.startsWith("/")) {
-            return getResourceByPath(location);
-        } else if (location.startsWith(CLASSPATH_URL_PREFIX)) {
-            return new ClassPathResource(location.substring(CLASSPATH_URL_PREFIX.length()), getClassLoader());
-        } else {
-            try {
-                // Try to parse the location as a URL...
-                URL url = new URL(location);
-                return new UrlResource(url);
-            } catch (MalformedURLException ex) {
-                // No URL -> resolve as resource path.
-                return getResourceByPath(location);
-            }
-        }
-    }
-
-    /**
-     * Return a Resource handle for the resource at the given path.
-     * <p>The default implementation supports class path locations. This should
-     * be appropriate for standalone implementations but can be overridden,
-     * e.g. for implementations targeted at a Servlet container.
-     *
-     * @param path the path to the resource
-     * @return the corresponding Resource handle
-     * @see ClassPathResource
-     */
-    protected Resource getResourceByPath(String path) {
-        return new ClassPathContextResource(path, getClassLoader());
-    }
-
-
-    /**
-     * ClassPathResource that explicitly expresses a context-relative path
-     * through implementing the ContextResource interface.
-     */
-    protected static class ClassPathContextResource extends ClassPathResource {
-
-        public ClassPathContextResource(String path, ClassLoader classLoader) {
-            super(path, classLoader);
-        }
-
-        public String getPathWithinContext() {
-            return getPath();
-        }
-
-        @Override
-        public Resource createRelative(String relativePath) {
-            String pathToUse = StringUtils.applyRelativePath(getPath(), relativePath);
-            return new ClassPathContextResource(pathToUse, getClassLoader());
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0734e210/core/src/main/java/org/apache/tamaya/core/internal/resource/PathMatchingResourcePatternResolver.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/resource/PathMatchingResourcePatternResolver.java b/core/src/main/java/org/apache/tamaya/core/internal/resource/PathMatchingResourcePatternResolver.java
deleted file mode 100644
index b4cee0d..0000000
--- a/core/src/main/java/org/apache/tamaya/core/internal/resource/PathMatchingResourcePatternResolver.java
+++ /dev/null
@@ -1,725 +0,0 @@
-/*
- * Copyright 2002-2008 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tamaya.core.internal.resource;
-
-import org.apache.tamaya.core.resources.Resource;
-import org.apache.tamaya.core.util.ClassUtils;
-import org.apache.tamaya.core.util.StringUtils;
-
-import java.io.File;
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.net.JarURLConnection;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-
-import java.lang.reflect.InvocationHandler;
-import java.net.MalformedURLException;
-import java.net.URISyntaxException;
-import java.net.URLClassLoader;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.util.stream.Collectors;
-
-
-/**
- * A {@code ResourcePatternResolver} implementation that is able to resolve a
- * specified resource location path into one or more matching Resources.
- * The source path may be a simple path which has a one-to-one annotation to a
- * target {@code org.springframework.core.io.Resource}, or alternatively
- * may contain the special "{@code classpath*:}" prefix and/or
- * internal Ant-style regular expressions (matched using Spring's
- * {@code org.springframework.util.AntPathMatcher} utility).
- * Both current the latter are effectively wildcards.
- * <p>
- * <p><b>No Wildcards:</b>
- * <p>
- * <p>In the simple case, if the specified location path does not start with the
- * {@code "classpath*:}" prefix, and does not contain a PathMatcher pattern,
- * this resolver will simply return a single resource via a
- * {@code getResource()} call on the underlying {@code ResourceLoader}.
- * Examples are real URLs such as "{@code file:C:/context.xml}", pseudo-URLs
- * such as "{@code classpath:/context.xml}", and simple unprefixed paths
- * such as "{@code /WEB-INF/context.xml}". The latter will resolve in a
- * fashion specific to the underlying {@code ResourceLoader} (e.g.
- * {@code ServletContextResource} for a {@code WebApplicationContext}).
- * <p>
- * <p><b>Ant-style Patterns:</b>
- * <p>
- * <p>When the path location contains an Ant-style pattern, e.g.:
- * <pre class="code">
- * /WEB-INF/*-context.xml
- * com/mycompany/**&#47;applicationContext.xml
- * file:C:/some/path/*-context.xml
- * classpath:com/mycompany/**&#47;applicationContext.xml</pre>
- * the resolver follows a more complex but defined procedure to try to resolve
- * the wildcard. It produces a {@code Resource} for the path up to the last
- * non-wildcard segment and obtains a {@code URL} from it. If this URL is
- * not a "{@code jar:}" URL or container-specific variant (e.g.
- * "{@code zip:}" in WebLogic, "{@code wsjar}" in WebSphere", etc.),
- * then a {@code java.io.File} is obtained from it, and used to resolve the
- * wildcard by walking the filesystem. In the case current a jar URL, the resolver
- * either gets a {@code java.net.JarURLConnection} from it, or manually parses
- * the jar URL, and then traverses the contents current the jar file, to resolve the
- * wildcards.
- * <p>
- * <p><b>Implications on portability:</b>
- * <p>
- * <p>If the specified path is already a file URL (either explicitly, or
- * implicitly because the base {@code ResourceLoader} is a filesystem one,
- * then wildcarding is guaranteed to work in a completely portable fashion.
- * <p>
- * <p>If the specified path is a classpath location, then the resolver must
- * obtain the last non-wildcard path segment URL via a
- * {@code Classloader.getResource()} call. Since this is just a
- * node current the path (not the file at the end) it is actually undefined
- * (in the ClassLoader Javadocs) exactly what sort current a URL is returned in
- * this case. In practice, it is usually a {@code java.io.File} representing
- * the directory, where the classpath resource resolves to a filesystem
- * location, or a jar URL current some sort, where the classpath resource resolves
- * to a jar location. Still, there is a portability concern on this operation.
- * <p>
- * <p>If a jar URL is obtained for the last non-wildcard segment, the resolver
- * must be able to get a {@code java.net.JarURLConnection} from it, or
- * manually parse the jar URL, to be able to walk the contents current the jar,
- * and resolve the wildcard. This will work in most environments, but will
- * fail in others, and it is strongly recommended that the wildcard
- * resolution current resources coming from jars be thoroughly tested in your
- * specific environment before you rely on it.
- * <p>
- * <p><b>{@code classpath*:} Prefix:</b>
- * <p>
- * <p>There is special support for retrieving multiple class path resources with
- * the same name, via the "{@code classpath*:}" prefix. For example,
- * "{@code classpath*:META-INF/beans.xml}" will find all "beans.xml"
- * files in the class path, be it in "classes" directories or in JAR files.
- * This is particularly useful for autodetecting config files current the same name
- * at the same location within each jar file. Internally, this happens via a
- * {@code ClassLoader.getResources()} call, and is completely portable.
- * <p>
- * <p>The "classpath*:" prefix can also be combined with a PathMatcher pattern in
- * the rest current the location path, for example "classpath*:META-INF/*-beans.xml".
- * In this case, the resolution strategy is fairly simple: a
- * {@code ClassLoader.getResources()} call is used on the last non-wildcard
- * path segment to get all the matching resources in the class loader hierarchy,
- * and then off each resource the same PathMatcher resolution strategy described
- * above is used for the wildcard subpath.
- * <p>
- * <p><b>Other notes:</b>
- * <p>
- * <p><b>WARNING:</b> Note that "{@code classpath*:}" when combined with
- * Ant-style patterns will only work reliably with at least one root directory
- * before the pattern starts, unless the actual target files reside in the file
- * system. This means that a pattern like "{@code classpath*:*.xml}" will
- * <i>not</i> retrieve files from the root current jar files but rather only from the
- * root current expanded directories. This originates from a limitation in the JDK's
- * {@code ClassLoader.getResources()} method which only returns file system
- * locations for a passed-in empty String (indicating potential roots to search).
- * <p>
- * <p><b>WARNING:</b> Ant-style patterns with "classpath:" resources are not
- * guaranteed to find matching resources if the root package to search is available
- * in multiple class path locations. This is because a resource such as
- * <pre class="code">
- * com/mycompany/package1/service-context.xml
- * </pre>
- * may be in only one location, but when a path such as
- * <pre class="code">
- * classpath:com/mycompany/**&#47;service-context.xml
- * </pre>
- * is used to try to resolve it, the resolver will work off the (first) URL
- * returned by {@code getResource("com/mycompany");}. If this base package
- * node exists in multiple classloader locations, the actual end resource may
- * not be underneath. Therefore, preferably, use "{@code classpath*:}" with the same
- * Ant-style pattern in such a case, which will search <i>all</i> class path
- * locations that contain the root package.
- *
- * @author Juergen Hoeller
- * @author Colin Sampaleanu
- * @author Marius Bogoevici
- * @author Costin Leau
- * @see ClassLoader#getResources(String)
- * @since 1.0.2
- */
-public final class PathMatchingResourcePatternResolver {
-
-    private static final Logger logger = Logger.getLogger(PathMatchingResourcePatternResolver.class.getName());
-    private static final java.lang.String CLASSPATH_ALL_URL_PREFIX = "classpath:";
-
-    private static Method equinoxResolveMethod;
-
-    static {
-        try {
-            // Detect Equinox OSGi (e.g. on WebSphere 6.1)
-            Class<?> fileLocatorClass = ClassUtils.forName("org.eclipse.core.runtime.FileLocator",
-                    PathMatchingResourcePatternResolver.class.getClassLoader());
-            equinoxResolveMethod = fileLocatorClass.getMethod("resolve", URL.class);
-            logger.finest("Found Equinox FileLocator for OSGi bundle URL resolution");
-        } catch (Throwable ex) {
-            equinoxResolveMethod = null;
-        }
-    }
-
-
-    private final PathMatchingDefaultResourceLoader resourceLoader;
-
-    private AntPathMatcher pathMatcher = new AntPathMatcher();
-
-    private static Map<ClassLoader, PathMatchingResourcePatternResolver> resolvers = new ConcurrentHashMap<>();
-
-    public static PathMatchingResourcePatternResolver of(ClassLoader loader) {
-        return resolvers.computeIfAbsent(loader, PathMatchingResourcePatternResolver::new);
-    }
-
-    /**
-     * Create a new PathMatchingResourcePatternResolver.
-     * <p>ClassLoader access will happen via the thread context class loader.
-     */
-    public PathMatchingResourcePatternResolver() {
-        this.resourceLoader = new PathMatchingDefaultResourceLoader();
-    }
-
-    /**
-     * Create a new PathMatchingResourcePatternResolver with a DefaultResourceLoader.
-     *
-     * @param classLoader the ClassLoader to load classpath resources with,
-     *                    or {@code null} for using the thread context class loader
-     *                    at the time current actual resource access
-     * @see PathMatchingDefaultResourceLoader
-     */
-    public PathMatchingResourcePatternResolver(ClassLoader classLoader) {
-        this.resourceLoader = new PathMatchingDefaultResourceLoader(classLoader);
-    }
-
-    public ClassLoader getClassLoader() {
-        return resourceLoader.getClassLoader();
-    }
-
-    /**
-     * Return the PathMatcher that this resource pattern resolver uses.
-     */
-    public AntPathMatcher getPathMatcher() {
-        return this.pathMatcher;
-    }
-
-    public Resource getResource(String location) {
-        return resourceLoader.getResource(location);
-    }
-
-    public Resource[] getResources(String locationPattern) throws IOException {
-        Objects.requireNonNull(locationPattern, "Location pattern must not be null");
-        if (locationPattern.startsWith(CLASSPATH_ALL_URL_PREFIX)) {
-            // a class path resource (multiple resources for same name possible)
-            if (getPathMatcher().isPattern(locationPattern.substring(CLASSPATH_ALL_URL_PREFIX.length()))) {
-                // a class path resource pattern
-                return findPathMatchingResources(locationPattern);
-            } else {
-                // all class path resources with the given name
-                return findAllClassPathResources(locationPattern.substring(CLASSPATH_ALL_URL_PREFIX.length()));
-            }
-        } else {
-            // Only look for a pattern after a prefix here
-            // (to not get fooled by a pattern symbol in a strange prefix).
-            int prefixEnd = locationPattern.indexOf(':') + 1;
-            if (getPathMatcher().isPattern(locationPattern.substring(prefixEnd))) {
-                // a file pattern
-                return findPathMatchingResources(locationPattern);
-            } else {
-                // a single resource with the given name
-                return new Resource[]{this.resourceLoader.getResource(locationPattern)};
-            }
-        }
-    }
-
-    /**
-     * Find all class location resources with the given location via the ClassLoader.
-     * Delegates to {@link #doFindAllClassPathResources(String)}.
-     *
-     * @param location the absolute path within the classpath
-     * @return the result as Resource array
-     * @throws IOException in case current I/O errors
-     * @see java.lang.ClassLoader#getResources
-     * @see #convertClassLoaderURL
-     */
-    protected Resource[] findAllClassPathResources(String location) throws IOException {
-        String path = location;
-        if (path.startsWith("/")) {
-            path = path.substring(1);
-        }
-        Set<Resource> result = doFindAllClassPathResources(path);
-        return result.toArray(new Resource[result.size()]);
-    }
-
-    /**
-     * Find all class location resources with the given path via the ClassLoader.
-     * Called by {@link #findAllClassPathResources(String)}.
-     *
-     * @param path the absolute path within the classpath (never a leading slash)
-     * @return a mutable Set current matching Resource instances
-     */
-    protected Set<Resource> doFindAllClassPathResources(String path) throws IOException {
-        Set<Resource> result = new LinkedHashSet<>(16);
-        ClassLoader cl = getClassLoader();
-        Enumeration<URL> resourceUrls = (cl != null ? cl.getResources(path) : ClassLoader.getSystemResources(path));
-        while (resourceUrls.hasMoreElements()) {
-            URL url = resourceUrls.nextElement();
-            result.add(convertClassLoaderURL(url));
-        }
-        if ("".equals(path)) {
-            // The above result is likely to be incomplete, i.e. only containing file system references.
-            // We need to have pointers to each current the jar files on the classpath as well...
-            addAllClassLoaderJarRoots(cl, result);
-        }
-        return result;
-    }
-
-    /**
-     * Convert the given URL as returned from the ClassLoader into a {@link Resource}.
-     * <p>The default implementation simply creates a {@link UrlResource} instance.
-     *
-     * @param url a URL as returned from the ClassLoader
-     * @return the corresponding Resource object
-     * @see java.lang.ClassLoader#getResources
-     * @see Resource
-     */
-    protected Resource convertClassLoaderURL(URL url) {
-        return new UrlResource(url);
-    }
-
-    /**
-     * Search all {@link URLClassLoader} URLs for jar file references and add them to the
-     * given set current resources in the form current pointers to the root current the jar file content.
-     *
-     * @param classLoader the ClassLoader to search (including its ancestors)
-     * @param result      the set current resources to add jar roots to
-     */
-    protected void addAllClassLoaderJarRoots(ClassLoader classLoader, Set<Resource> result) {
-        if (classLoader instanceof URLClassLoader) {
-            try {
-                for (URL url : ((URLClassLoader) classLoader).getURLs()) {
-                    if (ResourceUtils.isJarFileURL(url)) {
-                        try {
-                            UrlResource jarResource = new UrlResource(
-                                    ResourceUtils.JAR_URL_PREFIX + url.toString() + ResourceUtils.JAR_URL_SEPARATOR);
-                            if (jarResource.exists()) {
-                                result.add(jarResource);
-                            }
-                        } catch (MalformedURLException ex) {
-                            logger.finest(() -> "Cannot search for matching files underneath [" + url +
-                                    "] because it cannot be converted to a valid 'jar:' URL: " + ex.getMessage());
-                        }
-                    }
-                }
-            } catch (Exception ex) {
-                logger.finest(() -> "Cannot introspect jar files since ClassLoader [" + classLoader +
-                        "] does not support 'getURLs()': " + ex);
-            }
-        }
-        if (classLoader != null) {
-            try {
-                addAllClassLoaderJarRoots(classLoader.getParent(), result);
-            } catch (Exception ex) {
-                logger.finest(() -> "Cannot introspect jar files in parent ClassLoader since [" + classLoader +
-                        "] does not support 'getParent()': " + ex);
-            }
-        }
-    }
-
-    /**
-     * Find all resources that match the given location pattern via the
-     * Ant-style PathMatcher. Supports resources in jar files and zip files
-     * and in the file system.
-     *
-     * @param locationPattern the location pattern to match
-     * @return the result as Resource array
-     * @throws IOException in case current I/O errors
-     * @see #doFindPathMatchingJarResources
-     * @see #doFindPathMatchingFileResources
-     */
-    protected Resource[] findPathMatchingResources(String locationPattern) throws IOException {
-        String rootDirPath = determineRootDir(locationPattern);
-        String subPattern = locationPattern.substring(rootDirPath.length());
-        Resource[] rootDirResources = getResources(rootDirPath);
-        Set<Resource> result = new LinkedHashSet<>(16);
-        for (Resource rootDirResource : rootDirResources) {
-            rootDirResource = resolveRootDirResource(rootDirResource);
-            if (rootDirResource.toURL().getProtocol().startsWith(ResourceUtils.URL_PROTOCOL_VFS)) {
-                result.addAll(VfsResourceMatchingDelegate.findMatchingResources(rootDirResource, subPattern, getPathMatcher()));
-            } else if (isJarResource(rootDirResource)) {
-                result.addAll(doFindPathMatchingJarResources(rootDirResource, subPattern));
-            } else {
-                result.addAll(doFindPathMatchingFileResources(rootDirResource, subPattern));
-            }
-        }
-        logger.finest(() -> "Resolved location pattern [" + locationPattern + "] to resources " + result);
-        return result.toArray(new Resource[result.size()]);
-    }
-
-    /**
-     * Determine the root directory for the given location.
-     * <p>Used for determining the starting point for file matching,
-     * resolving the root directory location to a {@code java.io.File}
-     * and passing it into {@code retrieveMatchingFiles}, with the
-     * remainder current the location as pattern.
-     * <p>Will return "/WEB-INF/" for the pattern "/WEB-INF/*.xml",
-     * for example.
-     *
-     * @param location the location to check
-     * @return the part current the location that denotes the root directory
-     * @see #retrieveMatchingFiles
-     */
-    protected String determineRootDir(String location) {
-        int prefixEnd = location.indexOf(':') + 1;
-        int rootDirEnd = location.length();
-        while (rootDirEnd > prefixEnd && getPathMatcher().isPattern(location.substring(prefixEnd, rootDirEnd))) {
-            rootDirEnd = location.lastIndexOf('/', rootDirEnd - 2) + 1;
-        }
-        if (rootDirEnd == 0) {
-            rootDirEnd = prefixEnd;
-        }
-        return location.substring(0, rootDirEnd);
-    }
-
-    /**
-     * Resolve the specified resource for path matching.
-     * <p>The default implementation detects an Equinox OSGi "bundleresource:"
-     * / "bundleentry:" URL and resolves it into a standard jar file URL that
-     * can be traversed using Spring's standard jar file traversal algorithm.
-     *
-     * @param original the resource to resolve
-     * @return the resolved resource (may be identical to the passed-in resource)
-     * @throws IOException in case current resolution failure
-     */
-    protected Resource resolveRootDirResource(Resource original) throws IOException {
-        if (equinoxResolveMethod != null) {
-            URL url = original.toURL();
-            if (url.getProtocol().startsWith("bundle")) {
-                try {
-                    return new UrlResource((URL) equinoxResolveMethod.invoke(url));
-                } catch (Exception e) {
-                    ReflectionUtils.handleReflectionException(e);
-                }
-            }
-        }
-        return original;
-    }
-
-    /**
-     * Return whether the given resource handle indicates a jar resource
-     * that the {@code doFindPathMatchingJarResources} method can handle.
-     * <p>The default implementation checks against the URL protocols
-     * "jar", "zip" and "wsjar" (the latter are used by BEA WebLogic Server
-     * and IBM WebSphere, respectively, but can be treated like jar files).
-     *
-     * @param resource the resource handle to check
-     *                 (usually the root directory to start path matching from)
-     * @see #doFindPathMatchingJarResources
-     * @see ResourceUtils#isJarURL
-     */
-    protected boolean isJarResource(Resource resource) throws IOException {
-        return ResourceUtils.isJarURL(resource.toURL());
-    }
-
-    /**
-     * 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 a mutable Set current matching Resource instances
-     * @throws IOException in case current I/O errors
-     * @see java.net.JarURLConnection
-     */
-    protected Set<Resource> doFindPathMatchingJarResources(Resource rootDirResource, String subPattern)
-            throws IOException {
-
-        URLConnection con = rootDirResource.toURL().openConnection();
-        JarFile jarFile;
-        String jarFileUrl;
-        String rootEntryPath;
-        boolean newJarFile = false;
-
-        if (con instanceof JarURLConnection) {
-            // Should usually be the case for traditional JAR files.
-            JarURLConnection jarCon = (JarURLConnection) con;
-            ResourceUtils.useCachesIfNecessary(jarCon);
-            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 current 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.toURL().getFile();
-            int separatorIndex = urlFile.indexOf(ResourceUtils.JAR_URL_SEPARATOR);
-            if (separatorIndex != -1) {
-                jarFileUrl = urlFile.substring(0, separatorIndex);
-                rootEntryPath = urlFile.substring(separatorIndex + ResourceUtils.JAR_URL_SEPARATOR.length());
-                jarFile = getJarFile(jarFileUrl);
-            } else {
-                jarFile = new JarFile(urlFile);
-                jarFileUrl = urlFile;
-                rootEntryPath = "";
-            }
-            newJarFile = true;
-        }
-
-        try {
-            logger.finest("Looking for matching resources in jar file [" + jarFileUrl + "]");
-            if (!"".equals(rootEntryPath) && !rootEntryPath.endsWith("/")) {
-                // Root entry path must end with slash to allow for proper matching.
-                // The Sun JRE does not return a slash here, but BEA JRockit does.
-                rootEntryPath = rootEntryPath + "/";
-            }
-            Set<Resource> result = new LinkedHashSet<>(8);
-            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 (getPathMatcher().match(subPattern, relativePath)) {
-                        result.add(rootDirResource.createRelative(relativePath));
-                    }
-                }
-            }
-            return result;
-        } finally {
-            // Close jar file, but only if freshly obtained -
-            // not from JarURLConnection, which might cache the file reference.
-            if (newJarFile) {
-                jarFile.close();
-            }
-        }
-    }
-
-    /**
-     * Resolve the given jar file URL into a JarFile object.
-     */
-    protected JarFile getJarFile(String jarFileUrl) throws IOException {
-        if (jarFileUrl.startsWith(ResourceUtils.FILE_URL_PREFIX)) {
-            try {
-                return new JarFile(ResourceUtils.toURI(jarFileUrl).getSchemeSpecificPart());
-            } catch (URISyntaxException ex) {
-                // Fallback for URLs that are not valid URIs (should hardly ever happen).
-                return new JarFile(jarFileUrl.substring(ResourceUtils.FILE_URL_PREFIX.length()));
-            }
-        } else {
-            return new JarFile(jarFileUrl);
-        }
-    }
-
-    /**
-     * Find all resources in the file system 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 a mutable Set current matching Resource instances
-     * @throws IOException in case current I/O errors
-     * @see #retrieveMatchingFiles
-     */
-    protected Set<Resource> doFindPathMatchingFileResources(Resource rootDirResource, String subPattern)
-            throws IOException {
-
-        File rootDir;
-        try {
-            rootDir = rootDirResource.toFile().getAbsoluteFile();
-        } catch (IOException ex) {
-            logger.log(Level.WARNING, ex, () -> "Cannot search for matching files underneath " + rootDirResource +
-                    " because it does not correspond to a directory in the file system");
-            return Collections.emptySet();
-        }
-        return doFindMatchingFileSystemResources(rootDir, subPattern);
-    }
-
-    /**
-     * Find all resources in the file system that match the given location pattern
-     * via the Ant-style PathMatcher.
-     *
-     * @param rootDir    the root directory in the file system
-     * @param subPattern the sub pattern to match (below the root directory)
-     * @return a mutable Set current matching Resource instances
-     * @throws IOException in case current I/O errors
-     * @see #retrieveMatchingFiles
-     */
-    protected Set<Resource> doFindMatchingFileSystemResources(File rootDir, String subPattern) throws IOException {
-        logger.finest(() -> "Looking for matching resources in directory tree [" + rootDir.getPath() + "]");
-        Set<File> matchingFiles = retrieveMatchingFiles(rootDir, subPattern);
-        Set<Resource> result = new LinkedHashSet<>(matchingFiles.size());
-        result.addAll(matchingFiles.stream().map(FileSystemResource::new).collect(Collectors.toList()));
-        return result;
-    }
-
-    /**
-     * Retrieve files that match the given path pattern,
-     * checking the given directory and its subdirectories.
-     *
-     * @param rootDir the directory to start from
-     * @param pattern the pattern to match against,
-     *                relative to the root directory
-     * @return a mutable Set current matching Resource instances
-     * @throws IOException if directory contents could not be retrieved
-     */
-    protected Set<File> retrieveMatchingFiles(File rootDir, String pattern) throws IOException {
-        if (!rootDir.exists()) {
-            // Silently skip non-existing directories.
-            logger.finest(() -> "Skipping [" + rootDir.getAbsolutePath() + "] because it does not exist");
-            return Collections.emptySet();
-        }
-        if (!rootDir.isDirectory()) {
-            // Complain louder if it exists but is no directory.
-            logger.log(Level.WARNING, () -> "Skipping [" + rootDir.getAbsolutePath() + "] because it does not denote a directory");
-            return Collections.emptySet();
-        }
-        if (!rootDir.canRead()) {
-            logger.log(Level.WARNING, () -> "Cannot search for matching files underneath directory [" + rootDir.getAbsolutePath() +
-                    "] because the application is not allowed to read the directory");
-            return Collections.emptySet();
-        }
-        String fullPattern = StringUtils.replace(rootDir.getAbsolutePath(), File.separator, "/");
-        if (!pattern.startsWith("/")) {
-            fullPattern += "/";
-        }
-        fullPattern = fullPattern + StringUtils.replace(pattern, File.separator, "/");
-        Set<File> result = new LinkedHashSet<>(8);
-        doRetrieveMatchingFiles(fullPattern, rootDir, result);
-        return result;
-    }
-
-    /**
-     * Recursively retrieve files that match the given pattern,
-     * adding them to the given result list.
-     *
-     * @param fullPattern the pattern to match against,
-     *                    with prepended root directory path
-     * @param dir         the current directory
-     * @param result      the Set current matching File instances to add to
-     * @throws IOException if directory contents could not be retrieved
-     */
-    protected void doRetrieveMatchingFiles(String fullPattern, File dir, Set<File> result) throws IOException {
-        logger.finest(() -> "Searching directory [" + dir.getAbsolutePath() +
-                "] for files matching pattern [" + fullPattern + "]");
-        File[] dirContents = dir.listFiles();
-        if (dirContents == null) {
-            logger.log(Level.WARNING, () -> "Could not retrieve contents current directory [" + dir.getAbsolutePath() + "]");
-            return;
-        }
-        for (File content : dirContents) {
-            String currPath = StringUtils.replace(content.getAbsolutePath(), File.separator, "/");
-            if (content.isDirectory() && getPathMatcher().matchStart(fullPattern, currPath + "/")) {
-                if (!content.canRead()) {
-                    logger.finest(() -> "Skipping subdirectory [" + dir.getAbsolutePath() +
-                            "] because the application is not allowed to read the directory");
-                } else {
-                    doRetrieveMatchingFiles(fullPattern, content, result);
-                }
-            }
-            if (getPathMatcher().match(fullPattern, currPath)) {
-                result.add(content);
-            }
-        }
-    }
-
-
-    /**
-     * Inner delegate class, avoiding a hard JBoss VFS API dependency at runtime.
-     */
-    private static class VfsResourceMatchingDelegate {
-
-        public static Set<Resource> findMatchingResources(
-                Resource rootResource, String locationPattern, AntPathMatcher pathMatcher) throws IOException {
-            Object root = VfsUtils.getRoot(rootResource.toURL());
-            PatternVirtualFileVisitor visitor =
-                    new PatternVirtualFileVisitor(VfsUtils.getPath(root), locationPattern, pathMatcher);
-            VfsUtils.visit(root, visitor);
-            return visitor.getResources();
-        }
-    }
-
-
-    /**
-     * VFS visitor for path matching purposes.
-     */
-    @SuppressWarnings("unused")
-    private static class PatternVirtualFileVisitor implements InvocationHandler {
-
-        private final String subPattern;
-
-        private final AntPathMatcher pathMatcher;
-
-        private final String rootPath;
-
-        private final Set<Resource> resources = new LinkedHashSet<>();
-
-        public PatternVirtualFileVisitor(String rootPath, String subPattern, AntPathMatcher pathMatcher) {
-            this.subPattern = subPattern;
-            this.pathMatcher = pathMatcher;
-            this.rootPath = (rootPath.length() == 0 || rootPath.endsWith("/") ? rootPath : rootPath + "/");
-        }
-
-        @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 getAttributes();
-            } else if ("visit".equals(methodName)) {
-                visit(args[0]);
-                return null;
-            } else if ("toString".equals(methodName)) {
-                return toString();
-            }
-
-            throw new IllegalStateException("Unexpected method invocation: " + method);
-        }
-
-        public void visit(Object vfsResource) {
-            if (this.pathMatcher.match(this.subPattern,
-                    VfsUtils.getPath(vfsResource).substring(this.rootPath.length()))) {
-                this.resources.add(new VfsResource(vfsResource));
-            }
-        }
-
-        public Object getAttributes() {
-            return VfsUtils.getVisitorAttribute();
-        }
-
-        public Set<Resource> getResources() {
-            return this.resources;
-        }
-
-        public int size() {
-            return this.resources.size();
-        }
-
-        @Override
-        public String toString() {
-            return "sub-pattern: " + this.subPattern + ", resources: " + this.resources;
-        }
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0734e210/core/src/main/java/org/apache/tamaya/core/internal/resource/ReflectionUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/resource/ReflectionUtils.java b/core/src/main/java/org/apache/tamaya/core/internal/resource/ReflectionUtils.java
deleted file mode 100644
index a638238..0000000
--- a/core/src/main/java/org/apache/tamaya/core/internal/resource/ReflectionUtils.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
-* Copyright 2002-2014 the original author or authors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*      http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.tamaya.core.internal.resource;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.UndeclaredThrowableException;
-import java.util.Arrays;
-import java.util.Map;
-import java.util.Objects;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * Simple utility class for working with the reflection API and handling
- * reflection exceptions.
- * <p>
- * <p>Only intended for internal use.
- *
- * @author Juergen Hoeller
- * @author Rob Harrop
- * @author Rod Johnson
- * @author Costin Leau
- * @author Sam Brannen
- * @author Chris Beams
- * @since 1.2.2
- */
-public abstract class ReflectionUtils {
-    /**
-     * Cache for {@link Class#getDeclaredMethods()}, allowing for fast resolution.
-     */
-    private static final Map<Class<?>, Method[]> DECLARED_METHODS_CACHE =
-            new ConcurrentHashMap<>(256);
-
-
-    /**
-     * 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 current the field
-     * @return the corresponding Field object, or {@code null} if not found
-     */
-    public static Field findField(Class<?> clazz, String name) {
-        return findField(clazz, name, null);
-    }
-
-    /**
-     * Attempt to find a {@link Field field} on the supplied {@link Class} with the
-     * supplied {@code name} and/or {@link Class type}. Searches all superclasses
-     * up to {@link Object}.
-     *
-     * @param clazz the class to introspect
-     * @param name  the name current the field (may be {@code null} if type is specified)
-     * @param type  the type current the field (may be {@code null} if name is specified)
-     * @return the corresponding Field object, or {@code null} if not found
-     */
-    public static Field findField(Class<?> clazz, String name, Class<?> type) {
-        Objects.requireNonNull(clazz, "Class must not be null");
-        if (name == null && type == null) {
-            throw new IllegalArgumentException("Either name or type current the field must be specified");
-        }
-        Class<?> searchType = clazz;
-        while (!Object.class.equals(searchType) && searchType != null) {
-            Field[] fields = searchType.getDeclaredFields();
-            for (Field field : fields) {
-                if ((name == null || name.equals(field.getName())) && (type == null || type.equals(field.getType()))) {
-                    return field;
-                }
-            }
-            searchType = searchType.getSuperclass();
-        }
-        return null;
-    }
-
-    /**
-     * Attempt to find a {@link Method} on the supplied class with the supplied name
-     * and no parameters. 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 current the method
-     * @return the Method object, or {@code null} if none found
-     */
-    public static Method findMethod(Class<?> clazz, String name) {
-        return findMethod(clazz, name, new Class<?>[0]);
-    }
-
-    /**
-     * 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 current the method
-     * @param paramTypes the parameter types current the method
-     *                   (may be {@code null} to indicate any signature)
-     * @return the Method object, or {@code null} if none found
-     */
-    public 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() : getDeclaredMethods(searchType));
-            for (Method method : methods) {
-                if (name.equals(method.getName()) &&
-                        (paramTypes == null || Arrays.equals(paramTypes, method.getParameterTypes()))) {
-                    return method;
-                }
-            }
-            searchType = searchType.getSuperclass();
-        }
-        return null;
-    }
-
-    /**
-     * Handle the given reflection exception. Should only be called if no
-     * checked exception is expected to be thrown by the target method.
-     * <p>Throws the underlying RuntimeException or Error in case current an
-     * InvocationTargetException with such a root cause. Throws an
-     * IllegalStateException with an appropriate message else.
-     *
-     * @param ex the reflection exception to handle
-     */
-    public static void handleReflectionException(Exception ex) {
-        if (ex instanceof NoSuchMethodException) {
-            throw new IllegalStateException("Method not found: " + ex.getMessage());
-        }
-        if (ex instanceof IllegalAccessException) {
-            throw new IllegalStateException("Could not access method: " + ex.getMessage());
-        }
-        if (ex instanceof InvocationTargetException) {
-            handleInvocationTargetException((InvocationTargetException) ex);
-        }
-        if (ex instanceof RuntimeException) {
-            throw (RuntimeException) ex;
-        }
-        throw new UndeclaredThrowableException(ex);
-    }
-
-    /**
-     * Handle the given invocation target exception. Should only be called if no
-     * checked exception is expected to be thrown by the target method.
-     * <p>Throws the underlying RuntimeException or Error in case current such a root
-     * cause. Throws an IllegalStateException else.
-     *
-     * @param ex the invocation target exception to handle
-     */
-    public static void handleInvocationTargetException(InvocationTargetException ex) {
-        rethrowRuntimeException(ex.getTargetException());
-    }
-
-    /**
-     * Rethrow the given {@link Throwable exception}, which is presumably the
-     * <em>target exception</em> current an {@link InvocationTargetException}. Should
-     * only be called if no checked exception is expected to be thrown by the
-     * target method.
-     * <p>Rethrows the underlying exception cast to an {@link RuntimeException} or
-     * {@link Error} if appropriate; otherwise, throws an
-     * {@link IllegalStateException}.
-     *
-     * @param ex the exception to rethrow
-     * @throws RuntimeException the rethrown exception
-     */
-    public static void rethrowRuntimeException(Throwable ex) {
-        if (ex instanceof RuntimeException) {
-            throw (RuntimeException) ex;
-        }
-        if (ex instanceof Error) {
-            throw (Error) ex;
-        }
-        throw new UndeclaredThrowableException(ex);
-    }
-
-    /**
-     * This method retrieves {@link Class#getDeclaredMethods()} from a local cache
-     * in order to avoid the JVM's SecurityManager check and defensive array copying.
-     */
-    private static Method[] getDeclaredMethods(Class<?> clazz) {
-        Method[] result = DECLARED_METHODS_CACHE.get(clazz);
-        if (result == null) {
-            result = clazz.getDeclaredMethods();
-            DECLARED_METHODS_CACHE.put(clazz, result);
-        }
-        return result;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0734e210/core/src/main/java/org/apache/tamaya/core/internal/resource/ResourceUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/resource/ResourceUtils.java b/core/src/main/java/org/apache/tamaya/core/internal/resource/ResourceUtils.java
deleted file mode 100644
index b79da71..0000000
--- a/core/src/main/java/org/apache/tamaya/core/internal/resource/ResourceUtils.java
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
-* Copyright 2002-2014 the original author or authors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*      http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.tamaya.core.internal.resource;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.Objects;
-
-/**
- * Utility methods for resolving resource locations to files in the
- * file system. Mainly for internal use within the framework.
- * <p>
- * <p>Consider using Spring's Resource abstraction in the core package
- * for handling all kinds current file resources in a uniform manner.
- * {@code org.springframework.core.io.ResourceLoader}'s {@code getResource()}
- * method can resolve any location to a {@code org.springframework.core.io.Resource}
- * object, which in turn allows one to obtain a {@code java.io.File} in the
- * file system through its {@code getFile()} method.
- * <p>
- * <p>The main reason for these utility methods for resource location handling
- * is to support {@code Log4jConfigurer}, which must be able to resolve
- * resource locations <i>before the logging system has been initialized</i>.
- * Spring's {@code Resource} abstraction in the core package, on the other hand,
- * already expects the logging system to be available.
- *
- * @author Juergen Hoeller
- * @since 1.1.5
- */
-final class ResourceUtils {
-
-    /**
-     * URL prefix for loading from the file system: "file:"
-     */
-    public static final String FILE_URL_PREFIX = "file:";
-
-    /**
-     * URL prefix for loading from the file system: "jar:"
-     */
-    public static final String JAR_URL_PREFIX = "jar:";
-
-    /**
-     * URL protocol for a file in the file system: "file"
-     */
-    public static final String URL_PROTOCOL_FILE = "file";
-
-    /**
-     * URL protocol for an entry from a jar file: "jar"
-     */
-    public static final String URL_PROTOCOL_JAR = "jar";
-
-    /**
-     * URL protocol for an entry from a zip file: "zip"
-     */
-    public static final String URL_PROTOCOL_ZIP = "zip";
-
-    /**
-     * URL protocol for an entry from a WebSphere jar file: "wsjar"
-     */
-    public static final String URL_PROTOCOL_WSJAR = "wsjar";
-
-    /**
-     * URL protocol for an entry from a JBoss jar file: "vfszip"
-     */
-    public static final String URL_PROTOCOL_VFSZIP = "vfszip";
-
-    /**
-     * URL protocol for a JBoss file system resource: "vfsfile"
-     */
-    public static final String URL_PROTOCOL_VFSFILE = "vfsfile";
-
-    /**
-     * URL protocol for a general JBoss VFS resource: "vfs"
-     */
-    public static final String URL_PROTOCOL_VFS = "vfs";
-
-    /**
-     * File extension for a regular jar file: ".jar"
-     */
-    public static final String JAR_FILE_EXTENSION = ".jar";
-
-    /**
-     * Separator between JAR URL and file path within the JAR: "!/"
-     */
-    public static final String JAR_URL_SEPARATOR = "!/";
-
-    /**
-     * Singleton constructor.
-     */
-    private ResourceUtils() {
-    }
-
-    /**
-     * Resolve the given resource URL to a {@code java.io.File},
-     * i.e. to a file in the file system.
-     *
-     * @param resourceUrl the resource URL to resolve
-     * @return a corresponding File object
-     * @throws FileNotFoundException if the URL cannot be resolved to
-     *                               a file in the file system
-     */
-    public static File getFile(URL resourceUrl) throws FileNotFoundException {
-        return getFile(resourceUrl, "URL");
-    }
-
-    /**
-     * Resolve the given resource URL to a {@code java.io.File},
-     * i.e. to a file in the file system.
-     *
-     * @param resourceUrl the resource URL to resolve
-     * @param description a description current the original resource that
-     *                    the URL was created for (for example, a class path location)
-     * @return a corresponding File object
-     * @throws FileNotFoundException if the URL cannot be resolved to
-     *                               a file in the file system
-     */
-    public static File getFile(URL resourceUrl, String description) throws FileNotFoundException {
-        Objects.requireNonNull(resourceUrl, "Resource URL must not be null");
-        if (!URL_PROTOCOL_FILE.equals(resourceUrl.getProtocol())) {
-            throw new FileNotFoundException(
-                    description + " cannot be resolved to absolute file path " +
-                            "because it does not reside in the file system: " + resourceUrl);
-        }
-        try {
-            return new File(toURI(resourceUrl).getSchemeSpecificPart());
-        } catch (URISyntaxException ex) {
-            // Fallback for URLs that are not valid URIs (should hardly ever happen).
-            return new File(resourceUrl.getFile());
-        }
-    }
-
-    /**
-     * Resolve the given resource URI to a {@code java.io.File},
-     * i.e. to a file in the file system.
-     *
-     * @param resourceUri the resource URI to resolve
-     * @return a corresponding File object
-     * @throws FileNotFoundException if the URL cannot be resolved to
-     *                               a file in the file system
-     */
-    public static File getFile(URI resourceUri) throws FileNotFoundException {
-        return getFile(resourceUri, "URI");
-    }
-
-    /**
-     * Resolve the given resource URI to a {@code java.io.File},
-     * i.e. to a file in the file system.
-     *
-     * @param resourceUri the resource URI to resolve
-     * @param description a description current the original resource that
-     *                    the URI was created for (for example, a class path location)
-     * @return a corresponding File object
-     * @throws FileNotFoundException if the URL cannot be resolved to
-     *                               a file in the file system
-     */
-    public static File getFile(URI resourceUri, String description) throws FileNotFoundException {
-        Objects.requireNonNull(resourceUri, "Resource URI must not be null");
-        if (!URL_PROTOCOL_FILE.equals(resourceUri.getScheme())) {
-            throw new FileNotFoundException(
-                    description + " cannot be resolved to absolute file path " +
-                            "because it does not reside in the file system: " + resourceUri);
-        }
-        return new File(resourceUri.getSchemeSpecificPart());
-    }
-
-    /**
-     * Determine whether the given URL points to a resource in the file system,
-     * that is, has protocol "file", "vfsfile" or "vfs".
-     *
-     * @param url the URL to check
-     * @return whether the URL has been identified as a file system URL
-     */
-    public static boolean isFileURL(URL url) {
-        String protocol = url.getProtocol();
-        return (URL_PROTOCOL_FILE.equals(protocol) || URL_PROTOCOL_VFSFILE.equals(protocol) ||
-                URL_PROTOCOL_VFS.equals(protocol));
-    }
-
-    /**
-     * Determine whether the given URL points to a resource in a jar file,
-     * that is, has protocol "jar", "zip", "vfszip" or "wsjar".
-     *
-     * @param url the URL to check
-     * @return whether the URL has been identified as a JAR URL
-     */
-    public static boolean isJarURL(URL url) {
-        String protocol = url.getProtocol();
-        return (URL_PROTOCOL_JAR.equals(protocol) || URL_PROTOCOL_ZIP.equals(protocol) ||
-                URL_PROTOCOL_VFSZIP.equals(protocol) || URL_PROTOCOL_WSJAR.equals(protocol));
-    }
-
-    /**
-     * Determine whether the given URL points to a jar file itself,
-     * that is, has protocol "file" and ends with the ".jar" extension.
-     *
-     * @param url the URL to check
-     * @return whether the URL has been identified as a JAR file URL
-     * @since 4.1
-     */
-    public static boolean isJarFileURL(URL url) {
-        return (URL_PROTOCOL_FILE.equals(url.getProtocol()) &&
-                url.getPath().toLowerCase().endsWith(JAR_FILE_EXTENSION));
-    }
-
-    /**
-     * Extract the URL for the actual jar file from the given URL
-     * (which may point to a resource in a jar file or to a jar file itself).
-     *
-     * @param jarUrl the original URL
-     * @return the URL for the actual jar file
-     * @throws MalformedURLException if no valid jar file URL could be extracted
-     */
-    public static URL extractJarFileURL(URL jarUrl) throws MalformedURLException {
-        String urlFile = jarUrl.getFile();
-        int separatorIndex = urlFile.indexOf(JAR_URL_SEPARATOR);
-        if (separatorIndex != -1) {
-            String jarFile = urlFile.substring(0, separatorIndex);
-            try {
-                return new URL(jarFile);
-            } catch (MalformedURLException ex) {
-                // Probably no protocol in original jar URL, like "jar:C:/mypath/myjar.jar".
-                // This usually indicates that the jar file resides in the file system.
-                if (!jarFile.startsWith("/")) {
-                    jarFile = "/" + jarFile;
-                }
-                return new URL(FILE_URL_PREFIX + jarFile);
-            }
-        } else {
-            return jarUrl;
-        }
-    }
-
-    /**
-     * Create a URI instance for the given URL,
-     * replacing spaces with "%20" URI encoding first.
-     * <p>Furthermore, this method works on JDK 1.4 as well,
-     * in contrast to the {@code URL.toURI()} method.
-     *
-     * @param url the URL to convert into a URI instance
-     * @return the URI instance
-     * @throws URISyntaxException if the URL wasn't a valid URI
-     * @see java.net.URL#toURI()
-     */
-    public static URI toURI(URL url) throws URISyntaxException {
-        return toURI(url.toString());
-    }
-
-    /**
-     * Create a URI instance for the given location String,
-     * replacing spaces with "%20" URI encoding first.
-     *
-     * @param location the location String to convert into a URI instance
-     * @return the URI instance
-     * @throws URISyntaxException if the location wasn't a valid URI
-     */
-    public static URI toURI(String location) throws URISyntaxException {
-        return new URI(location.replaceAll(" ", "%20"));
-    }
-
-    /**
-     * Set the {@link URLConnection#setUseCaches "useCaches"} flag on the
-     * given connection, preferring {@code false} but leaving the
-     * flag at {@code true} for JNLP based resources.
-     *
-     * @param con the URLConnection to set the flag on
-     */
-    public static void useCachesIfNecessary(URLConnection con) {
-        con.setUseCaches(con.getClass().getSimpleName().startsWith("JNLP"));
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0734e210/core/src/main/java/org/apache/tamaya/core/internal/resource/UrlResource.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/resource/UrlResource.java b/core/src/main/java/org/apache/tamaya/core/internal/resource/UrlResource.java
deleted file mode 100644
index 4576aac..0000000
--- a/core/src/main/java/org/apache/tamaya/core/internal/resource/UrlResource.java
+++ /dev/null
@@ -1,279 +0,0 @@
-/*
- * Copyright 2002-2013 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tamaya.core.internal.resource;
-
-import org.apache.tamaya.core.util.StringUtils;
-import org.apache.tamaya.core.resources.Resource;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.Objects;
-
-/**
- * {@link Resource} implementation for {@code java.net.URL} locators.
- * Obviously supports resolution as URL, and also as File in case current
- * the "file:" protocol.
- *
- * @author Juergen Hoeller
- * @see java.net.URL
- * @since 28.12.2003
- */
-public class UrlResource extends AbstractFileResolvingResource {
-
-    /**
-     * Original URI, if available; used for URI and File access.
-     */
-    private final URI uri;
-
-    /**
-     * Original URL, used for actual access.
-     */
-    private final URL url;
-
-    /**
-     * Cleaned URL (with normalized path), used for comparisons.
-     */
-    private final URL cleanedUrl;
-
-
-    /**
-     * Create a new UrlResource based on the given URI object.
-     *
-     * @param uri a URI
-     * @throws MalformedURLException if the given URL path is not valid
-     */
-    public UrlResource(URI uri) throws MalformedURLException {
-        Objects.requireNonNull(uri, "URI must not be null");
-        this.uri = uri;
-        this.url = uri.toURL();
-        this.cleanedUrl = getCleanedUrl(this.url, uri.toString());
-    }
-
-    /**
-     * Create a new UrlResource based on the given URL object.
-     *
-     * @param url a URL
-     */
-    public UrlResource(URL url) {
-        Objects.requireNonNull(url, "URL must not be null");
-        this.url = url;
-        this.cleanedUrl = getCleanedUrl(this.url, url.toString());
-        this.uri = null;
-    }
-
-    /**
-     * Create a new UrlResource based on a URL path.
-     * <p>Note: The given path needs to be pre-encoded if necessary.
-     *
-     * @param path a URL path
-     * @throws MalformedURLException if the given URL path is not valid
-     * @see java.net.URL#URL(String)
-     */
-    public UrlResource(String path) throws MalformedURLException {
-        Objects.requireNonNull(path, "Path must not be null");
-        this.uri = null;
-        this.url = new URL(path);
-        this.cleanedUrl = getCleanedUrl(this.url, path);
-    }
-
-    /**
-     * Create a new UrlResource based on a URI specification.
-     * <p>The given parts will automatically get encoded if necessary.
-     *
-     * @param protocol the URL protocol to use (e.g. "jar" or "file" - without colon);
-     *                 also known as "scheme"
-     * @param location the location (e.g. the file path within that protocol);
-     *                 also known as "scheme-specific part"
-     * @throws MalformedURLException if the given URL specification is not valid
-     * @see java.net.URI#URI(String, String, String)
-     */
-    public UrlResource(String protocol, String location) throws MalformedURLException {
-        this(protocol, location, null);
-    }
-
-    /**
-     * Create a new UrlResource based on a URI specification.
-     * <p>The given parts will automatically get encoded if necessary.
-     *
-     * @param protocol the URL protocol to use (e.g. "jar" or "file" - without colon);
-     *                 also known as "scheme"
-     * @param location the location (e.g. the file path within that protocol);
-     *                 also known as "scheme-specific part"
-     * @param fragment the fragment within that location (e.g. anchor on an HTML page,
-     *                 as following after a "#" separator)
-     * @throws MalformedURLException if the given URL specification is not valid
-     * @see java.net.URI#URI(String, String, String)
-     */
-    public UrlResource(String protocol, String location, String fragment) throws MalformedURLException {
-        try {
-            this.uri = new URI(protocol, location, fragment);
-            this.url = this.uri.toURL();
-            this.cleanedUrl = getCleanedUrl(this.url, this.uri.toString());
-        } catch (URISyntaxException ex) {
-            MalformedURLException exToThrow = new MalformedURLException(ex.getMessage());
-            exToThrow.initCause(ex);
-            throw exToThrow;
-        }
-    }
-
-    /**
-     * Determine a cleaned URL for the given original URL.
-     *
-     * @param originalUrl  the original URL
-     * @param originalPath the original URL path
-     * @return the cleaned URL
-     */
-    private URL getCleanedUrl(URL originalUrl, String originalPath) {
-        try {
-            return new URL(StringUtils.cleanPath(originalPath));
-        } catch (MalformedURLException ex) {
-            // Cleaned URL path cannot be converted to URL
-            // -> take original URL.
-            return originalUrl;
-        }
-    }
-
-
-    /**
-     * This implementation opens an InputStream for the given URL.
-     * It sets the "UseCaches" flag to {@code false},
-     * mainly to avoid jar file locking on Windows.
-     *
-     * @see java.net.URL#openConnection()
-     * @see java.net.URLConnection#setUseCaches(boolean)
-     * @see java.net.URLConnection#getInputStream()
-     */
-    @Override
-    public InputStream getInputStream() throws IOException {
-        URLConnection con = null;
-        try {
-            con = this.url.openConnection();
-            useCachesIfNecessary(con);
-            return con.getInputStream();
-        } catch (IOException ex) {
-            // Close the HTTP connection (if applicable).
-            if (con instanceof HttpURLConnection) {
-                ((HttpURLConnection) con).disconnect();
-            }
-            throw ex;
-        }
-    }
-
-    /**
-     * This implementation returns the underlying URL reference.
-     */
-    @Override
-    public URL toURL() throws IOException {
-        return this.url;
-    }
-
-    /**
-     * This implementation returns the underlying URI directly,
-     * if possible.
-     */
-    @Override
-    public URI getURI() throws IOException {
-        if (this.uri != null) {
-            return this.uri;
-        } else {
-            return super.getURI();
-        }
-    }
-
-    /**
-     * This implementation returns a File reference for the underlying URL/URI,
-     * provided that it refers to a file in the file system.
-     */
-    @Override
-    public File toFile() throws IOException {
-        if (this.uri != null) {
-            return super.getFile(this.uri);
-        } else {
-            return super.toFile();
-        }
-    }
-
-    /**
-     * This implementation creates a UrlResource, applying the given path
-     * relative to the path current the underlying URL current this resource descriptor.
-     *
-     * @see java.net.URL#URL(java.net.URL, String)
-     */
-    @Override
-    public Resource createRelative(String relativePath) throws MalformedURLException {
-        if (relativePath.startsWith("/")) {
-            relativePath = relativePath.substring(1);
-        }
-        return new UrlResource(new URL(this.url, relativePath));
-    }
-
-    /**
-     * This implementation returns the name current the file that this URL refers to.
-     *
-     * @see java.net.URL#getFile()
-     * @see java.io.File#getName()
-     */
-    @Override
-    public String getDisplayName() {
-        return new File(this.url.getFile()).getName();
-    }
-
-    /**
-     * This implementation returns a description that includes the URL.
-     */
-    @Override
-    public String toString() {
-        return "URL [" + this.url + "]";
-    }
-
-
-    /**
-     * This implementation compares the underlying URL references.
-     */
-    @Override
-    public boolean equals(Object obj) {
-        return (obj == this ||
-                (obj instanceof UrlResource && this.cleanedUrl.equals(((UrlResource) obj).cleanedUrl)));
-    }
-
-    /**
-     * This implementation returns the hash code current the underlying URL reference.
-     */
-    @Override
-    public int hashCode() {
-        return this.cleanedUrl.hashCode();
-    }
-
-    /**
-     * Set the {@link URLConnection#setUseCaches "useCaches"} flag on the
-     * given connection, preferring {@code false} but leaving the
-     * flag at {@code true} for JNLP based resources.
-     *
-     * @param con the URLConnection to set the flag on
-     */
-    private void useCachesIfNecessary(URLConnection con) {
-        con.setUseCaches(con.getClass().getSimpleName().startsWith("JNLP"));
-    }
-
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0734e210/core/src/main/java/org/apache/tamaya/core/internal/resource/VfsResource.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/resource/VfsResource.java b/core/src/main/java/org/apache/tamaya/core/internal/resource/VfsResource.java
deleted file mode 100644
index 7688a6f..0000000
--- a/core/src/main/java/org/apache/tamaya/core/internal/resource/VfsResource.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright 2002-2014 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tamaya.core.internal.resource;
-
-import org.apache.tamaya.core.resources.Resource;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.net.URL;
-import java.util.Objects;
-
-/**
- * JBoss VFS based {@link Resource} implementation.
- * <p>
- * <p>As current Spring 4.0, this class supports VFS 3.x on JBoss AS 6+ (package
- * {@code org.jboss.vfs}) and is in particular compatible with JBoss AS 7 and
- * WildFly 8.
- *
- * @author Ales Justin
- * @author Juergen Hoeller
- * @author Costin Leau
- * @since 3.0
- */
-public class VfsResource implements Resource {
-
-    private final Object resource;
-
-
-    public VfsResource(Object resource) {
-        Objects.requireNonNull(resource, "VirtualFile must not be null");
-        this.resource = resource;
-    }
-
-
-    @Override
-    public InputStream getInputStream() throws IOException {
-        return VfsUtils.getInputStream(this.resource);
-    }
-
-    @Override
-    public boolean exists() {
-        return VfsUtils.exists(this.resource);
-    }
-
-    @Override
-    public boolean isReadable() {
-        return VfsUtils.isReadable(this.resource);
-    }
-
-    @Override
-    public URL toURL() throws IOException {
-        try {
-            return VfsUtils.getURL(this.resource);
-        } catch (Exception ex) {
-            throw new IllegalStateException("Failed to obtain URL for file " + this.resource, ex);
-        }
-    }
-
-    @Override
-    public URI getURI() throws IOException {
-        try {
-            return VfsUtils.getURI(this.resource);
-        } catch (Exception ex) {
-            throw new IllegalStateException("Failed to obtain URI for " + this.resource, ex);
-        }
-    }
-
-    @Override
-    public File toFile() throws IOException {
-        return VfsUtils.getFile(this.resource);
-    }
-
-    @Override
-    public long contentLength() throws IOException {
-        return VfsUtils.getSize(this.resource);
-    }
-
-    @Override
-    public long lastModified() throws IOException {
-        return VfsUtils.getLastModified(this.resource);
-    }
-
-    @Override
-    public Resource createRelative(String relativePath) throws IOException {
-        if (!relativePath.startsWith(".") && relativePath.contains("/")) {
-            try {
-                return new VfsResource(VfsUtils.getChild(this.resource, relativePath));
-            } catch (IOException ex) {
-                // fall back to getRelative
-            }
-        }
-
-        return new VfsResource(VfsUtils.getRelative(new URL(toURL(), relativePath)));
-    }
-
-    @Override
-    public String getDisplayName() {
-        return VfsUtils.getName(this.resource);
-    }
-
-    @Override
-    public String toString() {
-        return this.resource.toString();
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        return (obj == this || (obj instanceof VfsResource && this.resource.equals(((VfsResource) obj).resource)));
-    }
-
-    @Override
-    public int hashCode() {
-        return this.resource.hashCode();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0734e210/core/src/main/java/org/apache/tamaya/core/internal/resource/VfsUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/resource/VfsUtils.java b/core/src/main/java/org/apache/tamaya/core/internal/resource/VfsUtils.java
deleted file mode 100644
index ba07c7b..0000000
--- a/core/src/main/java/org/apache/tamaya/core/internal/resource/VfsUtils.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Copyright 2002-2014 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tamaya.core.internal.resource;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.net.URI;
-import java.net.URL;
-
-/**
- * Utility for detecting and accessing JBoss VFS in the classpath.
- * <p>
- * <p>As current Spring 4.0, this class supports VFS 3.x on JBoss AS 6+ (package
- * {@code org.jboss.vfs}) and is in particular compatible with JBoss AS 7 and
- * WildFly 8.
- * <p>
- * <p>Thanks go to Marius Bogoevici for the initial patch.
- * <b>Note:</b> This is an internal class and should not be used outside the framework.
- *
- * @author Costin Leau
- * @author Juergen Hoeller
- * @since 3.0.3
- */
-class VfsUtils {
-
-    private static final String VFS3_PACKAGE = "org.jboss.vfs.";
-    private static final String VFS_NAME = "VFS";
-
-    private static Method vfsMethodGetRootUrl = null;
-    private static Method vfsMethodGetRootUri = null;
-
-    private static Method virtualFileMethodExists = null;
-    private static Method virtualFileMethodGetInputStream;
-    private static Method virtualFileMethodGetSize;
-    private static Method virtualFileMethodGetLastModified;
-    private static Method virtualFileMethodToUrl;
-    private static Method virtualFileMethodToUri;
-    private static Method virtualFileMethodGetName;
-    private static Method virtualFileMethodGetPathName;
-    private static Method virtualFileMethodGetChild;
-
-    protected static Class<?> virtualFileVisitorInterface;
-    protected static Method virtualFileMethodVisit;
-
-    private static Field visitorAttributesFieldRecurse = null;
-    private static Method getPhysicalFile = null;
-
-    static {
-        ClassLoader loader = VfsUtils.class.getClassLoader();
-        try {
-            Class<?> vfsClass = loader.loadClass(VFS3_PACKAGE + VFS_NAME);
-            vfsMethodGetRootUrl = ReflectionUtils.findMethod(vfsClass, "getChild", URL.class);
-            vfsMethodGetRootUri = ReflectionUtils.findMethod(vfsClass, "getChild", URI.class);
-
-            Class<?> virtualFile = loader.loadClass(VFS3_PACKAGE + "VirtualFile");
-            virtualFileMethodExists = ReflectionUtils.findMethod(virtualFile, "exists");
-            virtualFileMethodGetInputStream = ReflectionUtils.findMethod(virtualFile, "openStream");
-            virtualFileMethodGetSize = ReflectionUtils.findMethod(virtualFile, "getSize");
-            virtualFileMethodGetLastModified = ReflectionUtils.findMethod(virtualFile, "getLastModified");
-            virtualFileMethodToUri = ReflectionUtils.findMethod(virtualFile, "toURI");
-            virtualFileMethodToUrl = ReflectionUtils.findMethod(virtualFile, "toURL");
-            virtualFileMethodGetName = ReflectionUtils.findMethod(virtualFile, "getName");
-            virtualFileMethodGetPathName = ReflectionUtils.findMethod(virtualFile, "getPathName");
-            getPhysicalFile = ReflectionUtils.findMethod(virtualFile, "getPhysicalFile");
-            virtualFileMethodGetChild = ReflectionUtils.findMethod(virtualFile, "getChild", String.class);
-
-            virtualFileVisitorInterface = loader.loadClass(VFS3_PACKAGE + "VirtualFileVisitor");
-            virtualFileMethodVisit = ReflectionUtils.findMethod(virtualFile, "visit", virtualFileVisitorInterface);
-
-            Class<?> visitorAttributesClass = loader.loadClass(VFS3_PACKAGE + "VisitorAttributes");
-            visitorAttributesFieldRecurse = ReflectionUtils.findField(visitorAttributesClass, "RECURSE");
-        } catch (ClassNotFoundException ex) {
-            throw new IllegalStateException("Could not detect JBoss VFS infrastructure", ex);
-        }
-    }
-
-    private VfsUtils() {
-    }
-
-    static void visit(Object resource, InvocationHandler visitor) throws IOException {
-        Object visitorProxy = Proxy.newProxyInstance(
-                virtualFileVisitorInterface.getClassLoader(),
-                new Class<?>[]{virtualFileVisitorInterface}, visitor);
-        invokeVfsMethod(virtualFileMethodVisit, resource, visitorProxy);
-    }
-
-    protected static Object invokeVfsMethod(Method method, Object target, Object... args) throws IOException {
-        try {
-            return method.invoke(target, args);
-        } catch (InvocationTargetException ex) {
-            Throwable targetEx = ex.getTargetException();
-            if (targetEx instanceof IOException) {
-                throw (IOException) targetEx;
-            }
-            ReflectionUtils.handleInvocationTargetException(ex);
-        } catch (Exception ex) {
-            ReflectionUtils.handleReflectionException(ex);
-        }
-
-        throw new IllegalStateException("Invalid code path reached");
-    }
-
-    static boolean exists(Object vfsResource) {
-        try {
-            return (Boolean) invokeVfsMethod(virtualFileMethodExists, vfsResource);
-        } catch (IOException ex) {
-            return false;
-        }
-    }
-
-    static boolean isReadable(Object vfsResource) {
-        try {
-            return ((Long) invokeVfsMethod(virtualFileMethodGetSize, vfsResource) > 0);
-        } catch (IOException ex) {
-            return false;
-        }
-    }
-
-    static long getSize(Object vfsResource) throws IOException {
-        return (Long) invokeVfsMethod(virtualFileMethodGetSize, vfsResource);
-    }
-
-    static long getLastModified(Object vfsResource) throws IOException {
-        return (Long) invokeVfsMethod(virtualFileMethodGetLastModified, vfsResource);
-    }
-
-    static InputStream getInputStream(Object vfsResource) throws IOException {
-        return (InputStream) invokeVfsMethod(virtualFileMethodGetInputStream, vfsResource);
-    }
-
-    static URL getURL(Object vfsResource) throws IOException {
-        return (URL) invokeVfsMethod(virtualFileMethodToUrl, vfsResource);
-    }
-
-    static URI getURI(Object vfsResource) throws IOException {
-        return (URI) invokeVfsMethod(virtualFileMethodToUri, vfsResource);
-    }
-
-    static String getName(Object vfsResource) {
-        try {
-            return (String) invokeVfsMethod(virtualFileMethodGetName, vfsResource);
-        } catch (IOException ex) {
-            throw new IllegalStateException("Cannot get resource name", ex);
-        }
-    }
-
-    static Object getRelative(URL url) throws IOException {
-        return invokeVfsMethod(vfsMethodGetRootUrl, null, url);
-    }
-
-    static Object getChild(Object vfsResource, String path) throws IOException {
-        return invokeVfsMethod(virtualFileMethodGetChild, vfsResource, path);
-    }
-
-    static File getFile(Object vfsResource) throws IOException {
-        return (File) invokeVfsMethod(getPhysicalFile, vfsResource);
-    }
-
-    static Object getRoot(URI url) throws IOException {
-        return invokeVfsMethod(vfsMethodGetRootUri, null, url);
-    }
-
-    // protected methods used by the support sub-package
-
-    protected static Object getRoot(URL url) throws IOException {
-        return invokeVfsMethod(vfsMethodGetRootUrl, null, url);
-    }
-
-    protected static Object getVisitorAttribute() {
-        try {
-            return visitorAttributesFieldRecurse.get(null);
-        } catch (Exception e) {
-            ReflectionUtils.handleReflectionException(e);
-            return null; // never called
-        }
-    }
-
-    protected static String getPath(Object resource) {
-        try {
-            return (String) virtualFileMethodGetPathName.invoke(resource);
-        } catch (Exception e) {
-            ReflectionUtils.handleReflectionException(e);
-            return null; // never called
-        }
-    }
-
-}


[5/9] incubator-tamaya git commit: remove files we don't have the full copyright!

Posted by st...@apache.org.
remove files we don't have the full copyright!

We shall not use code which we did not write ourself!


Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/3e1a7a51
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/3e1a7a51
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/3e1a7a51

Branch: refs/heads/master
Commit: 3e1a7a51540b6f43a0548fb9b9f23dc69a4324ad
Parents: 4af87fc
Author: Mark Struberg <st...@apache.org>
Authored: Sat Jan 3 18:11:56 2015 +0100
Committer: Mark Struberg <st...@apache.org>
Committed: Sat Jan 3 18:11:56 2015 +0100

----------------------------------------------------------------------
 .../org/apache/tamaya/core/util/ClassUtils.java | 1102 ------------------
 .../apache/tamaya/core/util/StringUtils.java    |  473 --------
 2 files changed, 1575 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3e1a7a51/core/src/main/java/org/apache/tamaya/core/util/ClassUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/util/ClassUtils.java b/core/src/main/java/org/apache/tamaya/core/util/ClassUtils.java
deleted file mode 100644
index 9e7e6d9..0000000
--- a/core/src/main/java/org/apache/tamaya/core/util/ClassUtils.java
+++ /dev/null
@@ -1,1102 +0,0 @@
-/*
-* Copyright 2002-2014 the original author or authors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*      http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.apache.tamaya.core.util;
-
-import org.apache.tamaya.core.internal.resource.ReflectionUtils;
-
-import java.lang.reflect.Array;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.lang.reflect.Proxy;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-
-/**
- * Miscellaneous class utility methods.
- * Mainly for internal use within the framework.
- *
- * @author Juergen Hoeller
- * @author Keith Donald
- * @author Rob Harrop
- * @author Sam Brannen
- * @since 1.1
- */
-public final class ClassUtils {
-
-    /**
-     * Suffix for array class names: "[]"
-     */
-    public static final String ARRAY_SUFFIX = "[]";
-
-    /**
-     * Prefix for internal array class names: "["
-     */
-    private static final String INTERNAL_ARRAY_PREFIX = "[";
-
-    /**
-     * Prefix for internal non-primitive array class names: "[L"
-     */
-    private static final String NON_PRIMITIVE_ARRAY_PREFIX = "[L";
-
-    /**
-     * The package separator character '.'
-     */
-    private static final char PACKAGE_SEPARATOR = '.';
-
-    /**
-     * The path separator character '/'
-     */
-    private static final char PATH_SEPARATOR = '/';
-
-    /**
-     * The inner class separator character '$'
-     */
-    private static final char INNER_CLASS_SEPARATOR = '$';
-
-    /**
-     * Map with primitive wrapper type as key and corresponding primitive
-     * type as keys, for example: Integer.class -> int.class.
-     */
-    private static final Map<Class<?>, Class<?>> PRIMITIVE_WRAPPER_TYPE_MAP = new HashMap<>(8);
-
-    /**
-     * Map with primitive type as key and corresponding wrapper
-     * type as keys, for example: int.class -> Integer.class.
-     */
-    private static final Map<Class<?>, Class<?>> PRIMITIVE_TYPE_TO_WRAPPER_MAP = new HashMap<>(8);
-
-    /**
-     * Map with primitive type name as key and corresponding primitive
-     * type as keys, for example: "int" -> "int.class".
-     */
-    private static final Map<String, Class<?>> PRIMITIVE_TYPE_NAME_MAP = new HashMap<>(32);
-
-
-    static {
-        PRIMITIVE_WRAPPER_TYPE_MAP.put(Boolean.class, boolean.class);
-        PRIMITIVE_WRAPPER_TYPE_MAP.put(Byte.class, byte.class);
-        PRIMITIVE_WRAPPER_TYPE_MAP.put(Character.class, char.class);
-        PRIMITIVE_WRAPPER_TYPE_MAP.put(Double.class, double.class);
-        PRIMITIVE_WRAPPER_TYPE_MAP.put(Float.class, float.class);
-        PRIMITIVE_WRAPPER_TYPE_MAP.put(Integer.class, int.class);
-        PRIMITIVE_WRAPPER_TYPE_MAP.put(Long.class, long.class);
-        PRIMITIVE_WRAPPER_TYPE_MAP.put(Short.class, short.class);
-
-        for (Map.Entry<Class<?>, Class<?>> entry : PRIMITIVE_WRAPPER_TYPE_MAP.entrySet()) {
-            PRIMITIVE_TYPE_TO_WRAPPER_MAP.put(entry.getValue(), entry.getKey());
-        }
-
-        Set<Class<?>> primitiveTypes = new HashSet<>(32);
-        primitiveTypes.addAll(PRIMITIVE_WRAPPER_TYPE_MAP.values());
-        primitiveTypes.addAll(Arrays.asList(new Class<?>[]{
-                boolean[].class, byte[].class, char[].class, double[].class,
-                float[].class, int[].class, long[].class, short[].class}));
-        primitiveTypes.add(void.class);
-        for (Class<?> primitiveType : primitiveTypes) {
-            PRIMITIVE_TYPE_NAME_MAP.put(primitiveType.getName(), primitiveType);
-        }
-    }
-
-    /**
-     * Private singleton constructor.
-     */
-    private ClassUtils() {
-    }
-
-
-    /**
-     * Return the default ClassLoader to use: typically the thread context
-     * ClassLoader, if available; the ClassLoader that loaded the ClassUtils
-     * class will be used as fallback.
-     * <p>Call this method if you intend to use the thread context ClassLoader
-     * in a scenario where you clearly prefer a non-null ClassLoader reference:
-     * for example, for class path resource loading (but not necessarily for
-     * {@code Class.forName}, which accepts a {@code null} ClassLoader
-     * reference as well).
-     *
-     * @return the default ClassLoader (only {@code null} if even the system
-     * ClassLoader isn't accessible)
-     * @see Thread#getContextClassLoader()
-     * @see ClassLoader#getSystemClassLoader()
-     */
-    public static ClassLoader getDefaultClassLoader() {
-        ClassLoader cl = null;
-        try {
-            cl = Thread.currentThread().getContextClassLoader();
-        } catch (Throwable ex) {
-            // Cannot access thread context ClassLoader - falling back...
-        }
-        if (cl == null) {
-            // No thread context class loader -> use class loader current this class.
-            cl = ClassUtils.class.getClassLoader();
-            if (cl == null) {
-                // getClassLoader() returning null indicates the bootstrap ClassLoader
-                try {
-                    cl = ClassLoader.getSystemClassLoader();
-                } catch (Throwable ex) {
-                    // Cannot access system ClassLoader - oh well, maybe the caller can live with null...
-                }
-            }
-        }
-        return cl;
-    }
-
-    /**
-     * Replacement for {@code Class.forName()} that also returns Class instances
-     * for primitives (e.g. "int") and array class names (e.g. "String[]").
-     * Furthermore, it is also capable current resolving inner class names in Java source
-     * style (e.g. "java.lang.Thread.State" instead current "java.lang.Thread$State").
-     *
-     * @param name        the name current the Class
-     * @param classLoader the class loader to use
-     *                    (may be {@code null}, which indicates the default class loader)
-     * @return Class instance for the supplied name
-     * @throws ClassNotFoundException if the class was not found
-     * @throws LinkageError           if the class file could not be loaded
-     * @see Class#forName(String, boolean, ClassLoader)
-     */
-    public static Class<?> forName(String name, ClassLoader classLoader) throws ClassNotFoundException, LinkageError {
-        Objects.requireNonNull(name, "Name must not be null");
-
-        Class<?> clazz = resolvePrimitiveClassName(name);
-        if (clazz != null) {
-            return clazz;
-        }
-
-        // "java.lang.String[]" style arrays
-        if (name.endsWith(ARRAY_SUFFIX)) {
-            String elementClassName = name.substring(0, name.length() - ARRAY_SUFFIX.length());
-            Class<?> elementClass = forName(elementClassName, classLoader);
-            return Array.newInstance(elementClass, 0).getClass();
-        }
-
-        // "[Ljava.lang.String;" style arrays
-        if (name.startsWith(NON_PRIMITIVE_ARRAY_PREFIX) && name.endsWith(";")) {
-            String elementName = name.substring(NON_PRIMITIVE_ARRAY_PREFIX.length(), name.length() - 1);
-            Class<?> elementClass = forName(elementName, classLoader);
-            return Array.newInstance(elementClass, 0).getClass();
-        }
-
-        // "[[I" or "[[Ljava.lang.String;" style arrays
-        if (name.startsWith(INTERNAL_ARRAY_PREFIX)) {
-            String elementName = name.substring(INTERNAL_ARRAY_PREFIX.length());
-            Class<?> elementClass = forName(elementName, classLoader);
-            return Array.newInstance(elementClass, 0).getClass();
-        }
-
-        ClassLoader clToUse = classLoader;
-        if (clToUse == null) {
-            clToUse = getDefaultClassLoader();
-        }
-        try {
-            return (clToUse != null ? clToUse.loadClass(name) : Class.forName(name));
-        } catch (ClassNotFoundException ex) {
-            int lastDotIndex = name.lastIndexOf(PACKAGE_SEPARATOR);
-            if (lastDotIndex != -1) {
-                String innerClassName =
-                        name.substring(0, lastDotIndex) + INNER_CLASS_SEPARATOR + name.substring(lastDotIndex + 1);
-                try {
-                    return (clToUse != null ? clToUse.loadClass(innerClassName) : Class.forName(innerClassName));
-                } catch (ClassNotFoundException ex2) {
-                    // Swallow - let original exception get through
-                }
-            }
-            throw ex;
-        }
-    }
-
-
-    /**
-     * Resolve the given class name as primitive class, if appropriate,
-     * according to the JVM's naming rules for primitive classes.
-     * <p>Also supports the JVM's internal class names for primitive arrays.
-     * Does <i>not</i> support the "[]" suffix notation for primitive arrays;
-     * this is only supported by {@link #forName(String, ClassLoader)}.
-     *
-     * @param name the name current the potentially primitive class
-     * @return the primitive class, or {@code null} if the name does not denote
-     * a primitive class or primitive array class
-     */
-    public static Class<?> resolvePrimitiveClassName(String name) {
-        Class<?> result = null;
-        // Most class names will be quite long, considering that they
-        // SHOULD sit in a package, so a length check is worthwhile.
-        if (name != null && name.length() <= 8) {
-            // Could be a primitive - likely.
-            result = PRIMITIVE_TYPE_NAME_MAP.get(name);
-        }
-        return result;
-    }
-
-    /**
-     * Determine whether the {@link Class} identified by the supplied name is present
-     * and can be loaded. Will return {@code false} if either the class or
-     * one current its dependencies is not present or cannot be loaded.
-     *
-     * @param className   the name current the class to check
-     * @param classLoader the class loader to use
-     *                    (may be {@code null}, which indicates the default class loader)
-     * @return whether the specified class is present
-     */
-    public static boolean isPresent(String className, ClassLoader classLoader) {
-        try {
-            forName(className, classLoader);
-            return true;
-        } catch (Throwable ex) {
-            // Class or one current its dependencies is not present...
-            return false;
-        }
-    }
-
-
-    /**
-     * Check whether the given class is cache-safe in the given context,
-     * i.e. whether it is loaded by the given ClassLoader or a parent current it.
-     *
-     * @param clazz       the class to analyze
-     * @param classLoader the ClassLoader to potentially cache metadata in
-     */
-    public static boolean isCacheSafe(Class<?> clazz, ClassLoader classLoader) {
-        Objects.requireNonNull(clazz, "Class must not be null");
-        try {
-            ClassLoader target = clazz.getClassLoader();
-            if (target == null) {
-                return true;
-            }
-            ClassLoader cur = classLoader;
-            if (cur == target) {
-                return true;
-            }
-            while (cur != null) {
-                cur = cur.getParent();
-                if (cur == target) {
-                    return true;
-                }
-            }
-            return false;
-        } catch (SecurityException ex) {
-            // Probably from the system ClassLoader - let's consider it safe.
-            return true;
-        }
-    }
-
-
-    /**
-     * Return the qualified name current the given class: usually simply
-     * the class name, but component type class name + "[]" for arrays.
-     *
-     * @param clazz the class
-     * @return the qualified name current the class
-     */
-    public static String getQualifiedName(Class<?> clazz) {
-        Objects.requireNonNull(clazz, "Class must not be null");
-        if (clazz.isArray()) {
-            return getQualifiedNameForArray(clazz);
-        } else {
-            return clazz.getName();
-        }
-    }
-
-    /**
-     * Build a nice qualified name for an array:
-     * component type class name + "[]".
-     *
-     * @param clazz the array class
-     * @return a qualified name for the array class
-     */
-    private static String getQualifiedNameForArray(Class<?> clazz) {
-        StringBuilder result = new StringBuilder();
-        while (clazz.isArray()) {
-            clazz = clazz.getComponentType();
-            result.append(ClassUtils.ARRAY_SUFFIX);
-        }
-        result.insert(0, clazz.getName());
-        return result.toString();
-    }
-
-    /**
-     * Return the qualified name current the given method, consisting current
-     * fully qualified interface/class name + "." + method name.
-     *
-     * @param method the method
-     * @return the qualified name current the method
-     */
-    public static String getQualifiedMethodName(Method method) {
-        Objects.requireNonNull(method, "Method must not be null");
-        return method.getDeclaringClass().getName() + "." + method.getName();
-    }
-
-    /**
-     * Return a descriptive name for the given object's type: usually simply
-     * the class name, but component type class name + "[]" for arrays,
-     * and an appended list current implemented interfaces for JDK proxies.
-     *
-     * @param keys the keys to introspect
-     * @return the qualified name current the class
-     */
-    public static String getDescriptiveType(Object keys) {
-        if (keys == null) {
-            return null;
-        }
-        Class<?> clazz = keys.getClass();
-        if (Proxy.isProxyClass(clazz)) {
-            StringBuilder result = new StringBuilder(clazz.getName());
-            result.append(" implementing ");
-            Class<?>[] ifcs = clazz.getInterfaces();
-            for (int i = 0; i < ifcs.length; i++) {
-                result.append(ifcs[i].getName());
-                if (i < ifcs.length - 1) {
-                    result.append(',');
-                }
-            }
-            return result.toString();
-        } else if (clazz.isArray()) {
-            return getQualifiedNameForArray(clazz);
-        } else {
-            return clazz.getName();
-        }
-    }
-
-    /**
-     * Check whether the given class matches the user-specified type name.
-     *
-     * @param clazz    the class to check
-     * @param typeName the type name to match
-     */
-    public static boolean matchesTypeName(Class<?> clazz, String typeName) {
-        return (typeName != null &&
-                (typeName.equals(clazz.getName()) || typeName.equals(clazz.getSimpleName()) ||
-                        (clazz.isArray() && typeName.equals(getQualifiedNameForArray(clazz)))));
-    }
-
-
-    /**
-     * Determine whether the given class has a public constructor with the given signature.
-     * <p>Essentially translates {@code NoSuchMethodException} to "false".
-     *
-     * @param clazz      the clazz to analyze
-     * @param paramTypes the parameter types current the method
-     * @return whether the class has a corresponding constructor
-     * @see Class#getMethod
-     */
-    public static boolean hasConstructor(Class<?> clazz, Class<?>... paramTypes) {
-        return (getConstructorIfAvailable(clazz, paramTypes) != null);
-    }
-
-    /**
-     * Determine whether the given class has a public constructor with the given signature,
-     * and return it if available (else return {@code null}).
-     * <p>Essentially translates {@code NoSuchMethodException} to {@code null}.
-     *
-     * @param clazz      the clazz to analyze
-     * @param paramTypes the parameter types current the method
-     * @return the constructor, or {@code null} if not found
-     * @see Class#getConstructor
-     */
-    public static <T> Constructor<T> getConstructorIfAvailable(Class<T> clazz, Class<?>... paramTypes) {
-        Objects.requireNonNull(clazz, "Class must not be null");
-        try {
-            return clazz.getConstructor(paramTypes);
-        } catch (NoSuchMethodException ex) {
-            return null;
-        }
-    }
-
-    /**
-     * Determine whether the given class has a public method with the given signature.
-     * <p>Essentially translates {@code NoSuchMethodException} to "false".
-     *
-     * @param clazz      the clazz to analyze
-     * @param methodName the name current the method
-     * @param paramTypes the parameter types current the method
-     * @return whether the class has a corresponding method
-     * @see Class#getMethod
-     */
-    public static boolean hasMethod(Class<?> clazz, String methodName, Class<?>... paramTypes) {
-        return (getMethodIfAvailable(clazz, methodName, paramTypes) != null);
-    }
-
-    /**
-     * Determine whether the given class has a public method with the given signature,
-     * and return it if available (else throws an {@code IllegalStateException}).
-     * <p>In case current any signature specified, only returns the method if there is a
-     * unique candidate, i.e. a single public method with the specified name.
-     * <p>Essentially translates {@code NoSuchMethodException} to {@code IllegalStateException}.
-     *
-     * @param clazz      the clazz to analyze
-     * @param methodName the name current the method
-     * @param paramTypes the parameter types current the method
-     *                   (may be {@code null} to indicate any signature)
-     * @return the method (never {@code null})
-     * @throws IllegalStateException if the method has not been found
-     * @see Class#getMethod
-     */
-    public static Method getMethod(Class<?> clazz, String methodName, Class<?>... paramTypes) {
-        Objects.requireNonNull(clazz, "Class must not be null");
-        Objects.requireNonNull(methodName, "Method name must not be null");
-        if (paramTypes != null) {
-            try {
-                return clazz.getMethod(methodName, paramTypes);
-            } catch (NoSuchMethodException ex) {
-                throw new IllegalStateException("Expected method not found: " + ex);
-            }
-        } else {
-            Set<Method> candidates = new HashSet<Method>(1);
-            Method[] methods = clazz.getMethods();
-            for (Method method : methods) {
-                if (methodName.equals(method.getName())) {
-                    candidates.add(method);
-                }
-            }
-            if (candidates.size() == 1) {
-                return candidates.iterator().next();
-            } else if (candidates.isEmpty()) {
-                throw new IllegalStateException("Expected method not found: " + clazz + "." + methodName);
-            } else {
-                throw new IllegalStateException("No unique method found: " + clazz + "." + methodName);
-            }
-        }
-    }
-
-    /**
-     * Determine whether the given class has a public method with the given signature,
-     * and return it if available (else return {@code null}).
-     * <p>In case current any signature specified, only returns the method if there is a
-     * unique candidate, i.e. a single public method with the specified name.
-     * <p>Essentially translates {@code NoSuchMethodException} to {@code null}.
-     *
-     * @param clazz      the clazz to analyze
-     * @param methodName the name current the method
-     * @param paramTypes the parameter types current the method
-     *                   (may be {@code null} to indicate any signature)
-     * @return the method, or {@code null} if not found
-     * @see Class#getMethod
-     */
-    public static Method getMethodIfAvailable(Class<?> clazz, String methodName, Class<?>... paramTypes) {
-        Objects.requireNonNull(clazz, "Class must not be null");
-        Objects.requireNonNull(methodName, "Method name must not be null");
-        if (paramTypes != null) {
-            try {
-                return clazz.getMethod(methodName, paramTypes);
-            } catch (NoSuchMethodException ex) {
-                return null;
-            }
-        } else {
-            Set<Method> candidates = new HashSet<Method>(1);
-            Method[] methods = clazz.getMethods();
-            for (Method method : methods) {
-                if (methodName.equals(method.getName())) {
-                    candidates.add(method);
-                }
-            }
-            if (candidates.size() == 1) {
-                return candidates.iterator().next();
-            }
-            return null;
-        }
-    }
-
-    /**
-     * Return the number current methods with a given name (with any argument types),
-     * for the given class and/or its superclasses. Includes non-public methods.
-     *
-     * @param clazz      the clazz to check
-     * @param methodName the name current the method
-     * @return the number current methods with the given name
-     */
-    public static int getMethodCountForName(Class<?> clazz, String methodName) {
-        Objects.requireNonNull(clazz, "Class must not be null");
-        Objects.requireNonNull(methodName, "Method name must not be null");
-        int count = 0;
-        Method[] declaredMethods = clazz.getDeclaredMethods();
-        for (Method method : declaredMethods) {
-            if (methodName.equals(method.getName())) {
-                count++;
-            }
-        }
-        Class<?>[] ifcs = clazz.getInterfaces();
-        for (Class<?> ifc : ifcs) {
-            count += getMethodCountForName(ifc, methodName);
-        }
-        if (clazz.getSuperclass() != null) {
-            count += getMethodCountForName(clazz.getSuperclass(), methodName);
-        }
-        return count;
-    }
-
-    /**
-     * Does the given class or one current its superclasses at least have one or more
-     * methods with the supplied name (with any argument types)?
-     * Includes non-public methods.
-     *
-     * @param clazz      the clazz to check
-     * @param methodName the name current the method
-     * @return whether there is at least one method with the given name
-     */
-    public static boolean hasAtLeastOneMethodWithName(Class<?> clazz, String methodName) {
-        Objects.requireNonNull(clazz, "Class must not be null");
-        Objects.requireNonNull(methodName, "Method name must not be null");
-        Method[] declaredMethods = clazz.getDeclaredMethods();
-        for (Method method : declaredMethods) {
-            if (method.getName().equals(methodName)) {
-                return true;
-            }
-        }
-        Class<?>[] ifcs = clazz.getInterfaces();
-        for (Class<?> ifc : ifcs) {
-            if (hasAtLeastOneMethodWithName(ifc, methodName)) {
-                return true;
-            }
-        }
-        return (clazz.getSuperclass() != null && hasAtLeastOneMethodWithName(clazz.getSuperclass(), methodName));
-    }
-
-    /**
-     * Given a method, which may come from an interface, and a target class used
-     * in the current reflective invocation, find the corresponding target method
-     * if there is one. E.g. the method may be {@code IFoo.bar()} and the
-     * target class may be {@code DefaultFoo}. In this case, the method may be
-     * {@code DefaultFoo.bar()}. This enables attributes on that method to be found.
-     * <p><b>NOTE:</b> In contrast to {@code org.springframework.aop.support.AopUtils#getMostSpecificMethod},
-     * this method does <i>not</i> resolve Java 5 bridge methods automatically.
-     * Call {@code org.springframework.core.BridgeMethodResolver#findBridgedMethod}
-     * if bridge method resolution is desirable (e.g. for obtaining metadata from
-     * the original method definition).
-     * <p><b>NOTE:</b> Since Spring 3.1.1, if Java security settings disallow reflective
-     * access (e.g. calls to {@code Class#getDeclaredMethods} etc, this implementation
-     * will fall back to returning the originally provided method.
-     *
-     * @param method      the method to be invoked, which may come from an interface
-     * @param targetClass the target class for the current invocation.
-     *                    May be {@code null} or may not even implement the method.
-     * @return the specific target method, or the original method if the
-     * {@code targetClass} doesn't implement it or is {@code null}
-     */
-    public static Method getMostSpecificMethod(Method method, Class<?> targetClass) {
-        if (method != null && isOverridable(method, targetClass) &&
-                targetClass != null && !targetClass.equals(method.getDeclaringClass())) {
-            try {
-                if (Modifier.isPublic(method.getModifiers())) {
-                    try {
-                        return targetClass.getMethod(method.getName(), method.getParameterTypes());
-                    } catch (NoSuchMethodException ex) {
-                        return method;
-                    }
-                } else {
-                    Method specificMethod =
-                            ReflectionUtils.findMethod(targetClass, method.getName(), method.getParameterTypes());
-                    return (specificMethod != null ? specificMethod : method);
-                }
-            } catch (SecurityException ex) {
-                // Security settings are disallowing reflective access; fall back to 'method' below.
-            }
-        }
-        return method;
-    }
-
-    /**
-     * Determine whether the given method is declared by the user or at least pointing to
-     * a user-declared method.
-     * <p>Checks {@link Method#isSynthetic()} (for implementation methods) as well as the
-     * {@code GroovyObject} interface (for interface methods; on an implementation class,
-     * implementations current the {@code GroovyObject} methods will be marked as synthetic anyway).
-     * Note that, despite being synthetic, bridge methods ({@link Method#isBridge()}) are considered
-     * as user-level methods since they are eventually pointing to a user-declared generic method.
-     *
-     * @param method the method to check
-     * @return {@code true} if the method can be considered as user-declared; [@code false} otherwise
-     */
-    public static boolean isUserLevelMethod(Method method) {
-        Objects.requireNonNull(method, "Method must not be null");
-        return (method.isBridge() || (!method.isSynthetic() && !isGroovyObjectMethod(method)));
-    }
-
-    private static boolean isGroovyObjectMethod(Method method) {
-        return method.getDeclaringClass().getName().equals("groovy.lang.GroovyObject");
-    }
-
-    /**
-     * Determine whether the given method is overridable in the given target class.
-     *
-     * @param method      the method to check
-     * @param targetClass the target class to check against
-     */
-    private static boolean isOverridable(Method method, Class<?> targetClass) {
-        if (Modifier.isPrivate(method.getModifiers())) {
-            return false;
-        }
-        if (Modifier.isPublic(method.getModifiers()) || Modifier.isProtected(method.getModifiers())) {
-            return true;
-        }
-        return getPackageName(method.getDeclaringClass()).equals(getPackageName(targetClass));
-    }
-
-
-    /**
-     * Determine the name current the package current the given class,
-     * e.g. "java.lang" for the {@code java.lang.String} class.
-     *
-     * @param clazz the class
-     * @return the package name, or the empty String if the class
-     * is defined in the default package
-     */
-    public static String getPackageName(Class<?> clazz) {
-        Objects.requireNonNull(clazz, "Class must not be null");
-        return getPackageName(clazz.getName());
-    }
-
-    /**
-     * Determine the name current the package current the given fully-qualified class name,
-     * e.g. "java.lang" for the {@code java.lang.String} class name.
-     *
-     * @param fqClassName the fully-qualified class name
-     * @return the package name, or the empty String if the class
-     * is defined in the dObjects.requireNonNullefault package
-     */
-    public static String getPackageName(String fqClassName) {
-        Objects.requireNonNull(fqClassName, "Class name must not be null");
-        int lastDotIndex = fqClassName.lastIndexOf(PACKAGE_SEPARATOR);
-        return (lastDotIndex != -1 ? fqClassName.substring(0, lastDotIndex) : "");
-    }
-
-    /**
-     * Return a public static method current a class.
-     *
-     * @param methodName the static method name
-     * @param clazz      the class which defines the method
-     * @param args       the parameter types to the method
-     * @return the static method, or {@code null} if no static method was found
-     * @throws IllegalArgumentException if the method name is blank or the clazz is null
-     */
-    public static Method getStaticMethod(Class<?> clazz, String methodName, Class<?>... args) {
-        Objects.requireNonNull(clazz, "Class must not be null");
-        Objects.requireNonNull(methodName, "Method name must not be null");
-        try {
-            Method method = clazz.getMethod(methodName, args);
-            return Modifier.isStatic(method.getModifiers()) ? method : null;
-        } catch (NoSuchMethodException ex) {
-            return null;
-        }
-    }
-
-
-    /**
-     * Check if the given class represents a primitive wrapper,
-     * i.e. Boolean, Byte, Character, Short, Integer, Long, Float, or Double.
-     *
-     * @param clazz the class to check
-     * @return whether the given class is a primitive wrapper class
-     */
-    public static boolean isPrimitiveWrapper(Class<?> clazz) {
-        Objects.requireNonNull(clazz, "Class must not be null");
-        return PRIMITIVE_WRAPPER_TYPE_MAP.containsKey(clazz);
-    }
-
-    /**
-     * Check if the given class represents a primitive (i.e. boolean, byte,
-     * char, short, int, long, float, or double) or a primitive wrapper
-     * (i.e. Boolean, Byte, Character, Short, Integer, Long, Float, or Double).
-     *
-     * @param clazz the class to check
-     * @return whether the given class is a primitive or primitive wrapper class
-     */
-    public static boolean isPrimitiveOrWrapper(Class<?> clazz) {
-        Objects.requireNonNull(clazz, "Class must not be null");
-        return (clazz.isPrimitive() || isPrimitiveWrapper(clazz));
-    }
-
-    /**
-     * Check if the given class represents an array current primitives,
-     * i.e. boolean, byte, char, short, int, long, float, or double.
-     *
-     * @param clazz the class to check
-     * @return whether the given class is a primitive array class
-     */
-    public static boolean isPrimitiveArray(Class<?> clazz) {
-        Objects.requireNonNull(clazz, "Class must not be null");
-        return (clazz.isArray() && clazz.getComponentType().isPrimitive());
-    }
-
-    /**
-     * Check if the given class represents an array current primitive wrappers,
-     * i.e. Boolean, Byte, Character, Short, Integer, Long, Float, or Double.
-     *
-     * @param clazz the class to check
-     * @return whether the given class is a primitive wrapper array class
-     */
-    public static boolean isPrimitiveWrapperArray(Class<?> clazz) {
-        Objects.requireNonNull(clazz, "Class must not be null");
-        return (clazz.isArray() && isPrimitiveWrapper(clazz.getComponentType()));
-    }
-
-    /**
-     * Resolve the given class if it is a primitive class,
-     * returning the corresponding primitive wrapper type instead.
-     *
-     * @param clazz the class to check
-     * @return the original class, or a primitive wrapper for the original primitive type
-     */
-    public static Class<?> resolvePrimitiveIfNecessary(Class<?> clazz) {
-        Objects.requireNonNull(clazz, "Class must not be null");
-        return (clazz.isPrimitive() && clazz != void.class ? PRIMITIVE_TYPE_TO_WRAPPER_MAP.get(clazz) : clazz);
-    }
-
-    /**
-     * Check if the right-hand side type may be assigned to the left-hand side
-     * type, assuming setting by reflection. Considers primitive wrapper
-     * classes as assignable to the corresponding primitive types.
-     *
-     * @param lhsType the target type
-     * @param rhsType the keys type that should be assigned to the target type
-     * @return if the target type is assignable from the keys type
-     */
-    public static boolean isAssignable(Class<?> lhsType, Class<?> rhsType) {
-        Objects.requireNonNull(lhsType, "Left-hand side type must not be null");
-        Objects.requireNonNull(rhsType, "Right-hand side type must not be null");
-        if (lhsType.isAssignableFrom(rhsType)) {
-            return true;
-        }
-        if (lhsType.isPrimitive()) {
-            Class<?> resolvedPrimitive = PRIMITIVE_WRAPPER_TYPE_MAP.get(rhsType);
-            if (resolvedPrimitive != null && lhsType.equals(resolvedPrimitive)) {
-                return true;
-            }
-        } else {
-            Class<?> resolvedWrapper = PRIMITIVE_TYPE_TO_WRAPPER_MAP.get(rhsType);
-            if (resolvedWrapper != null && lhsType.isAssignableFrom(resolvedWrapper)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
-     * Determine if the given type is assignable from the given keys,
-     * assuming setting by reflection. Considers primitive wrapper classes
-     * as assignable to the corresponding primitive types.
-     *
-     * @param type the target type
-     * @param keys the keys that should be assigned to the type
-     * @return if the type is assignable from the keys
-     */
-    public static boolean isAssignableValue(Class<?> type, Object keys) {
-        Objects.requireNonNull(type, "Type must not be null");
-        return (keys != null ? isAssignable(type, keys.getClass()) : !type.isPrimitive());
-    }
-
-
-    /**
-     * Convert a "/"-based resource path to a "."-based fully qualified class name.
-     *
-     * @param resourcePath the resource path pointing to a class
-     * @return the corresponding fully qualified class name
-     */
-    public static String convertResourcePathToClassName(String resourcePath) {
-        Objects.requireNonNull(resourcePath, "Resource path must not be null");
-        return resourcePath.replace(PATH_SEPARATOR, PACKAGE_SEPARATOR);
-    }
-
-    /**
-     * Convert a "."-based fully qualified class name to a "/"-based resource path.
-     *
-     * @param className the fully qualified class name
-     * @return the corresponding resource path, pointing to the class
-     */
-    public static String convertClassNameToResourcePath(String className) {
-        Objects.requireNonNull(className, "Class name must not be null");
-        return className.replace(PACKAGE_SEPARATOR, PATH_SEPARATOR);
-    }
-
-    /**
-     * Return a path suitable for use with {@code ClassLoader.getResource}
-     * (also suitable for use with {@code Class.getResource} by prepending a
-     * slash ('/') to the return keys). Built by taking the package current the specified
-     * class file, converting all dots ('.') to slashes ('/'), adding a trailing slash
-     * if necessary, and concatenating the specified resource name to this.
-     * <br/>As such, this function may be used to build a path suitable for
-     * loading a resource file that is in the same package as a class file,
-     * although {@code org.springframework.core.io.ClassPathResource} is usually
-     * even more convenient.
-     *
-     * @param clazz        the Class whose package will be used as the base
-     * @param resourceName the resource name to append. A leading slash is optional.
-     * @return the built-up resource path
-     * @see ClassLoader#getResource
-     * @see Class#getResource
-     */
-    public static String addResourcePathToPackagePath(Class<?> clazz, String resourceName) {
-        Objects.requireNonNull(resourceName, "Resource name must not be null");
-        if (!resourceName.startsWith("/")) {
-            return classPackageAsResourcePath(clazz) + "/" + resourceName;
-        }
-        return classPackageAsResourcePath(clazz) + resourceName;
-    }
-
-    /**
-     * Given an input class object, return a string which consists current the
-     * class's package name as a pathname, i.e., all dots ('.') are replaced by
-     * slashes ('/'). Neither a leading nor trailing slash is added. The result
-     * could be concatenated with a slash and the name current a resource and fed
-     * directly to {@code ClassLoader.getResource()}. For it to be fed to
-     * {@code Class.getResource} instead, a leading slash would also have
-     * to be prepended to the returned keys.
-     *
-     * @param clazz the input class. A {@code null} keys or the default
-     *              (empty) package will result in an empty string ("") being returned.
-     * @return a path which represents the package name
-     * @see ClassLoader#getResource
-     * @see Class#getResource
-     */
-    public static String classPackageAsResourcePath(Class<?> clazz) {
-        if (clazz == null) {
-            return "";
-        }
-        String className = clazz.getName();
-        int packageEndIndex = className.lastIndexOf(PACKAGE_SEPARATOR);
-        if (packageEndIndex == -1) {
-            return "";
-        }
-        String packageName = className.substring(0, packageEndIndex);
-        return packageName.replace(PACKAGE_SEPARATOR, PATH_SEPARATOR);
-    }
-
-    /**
-     * Build a String that consists current the names current the classes/interfaces
-     * in the given array.
-     * <p>Basically like {@code AbstractCollection.toString()}, but stripping
-     * the "class "/"interface " prefix before every class name.
-     *
-     * @param classes a Collection current Class objects (may be {@code null})
-     * @return a String current form "[com.foo.Bar, com.foo.Baz]"
-     * @see java.util.AbstractCollection#toString()
-     */
-    public static String classNamesToString(Class<?>... classes) {
-        return classNamesToString(Arrays.asList(classes));
-    }
-
-    /**
-     * Build a String that consists current the names current the classes/interfaces
-     * in the given collection.
-     * <p>Basically like {@code AbstractCollection.toString()}, but stripping
-     * the "class "/"interface " prefix before every class name.
-     *
-     * @param classes a Collection current Class objects (may be {@code null})
-     * @return a String current form "[com.foo.Bar, com.foo.Baz]"
-     * @see java.util.AbstractCollection#toString()
-     */
-    public static String classNamesToString(Collection<Class<?>> classes) {
-        if (classes.isEmpty()) {
-            return "[]";
-        }
-        StringBuilder sb = new StringBuilder("[");
-        for (Iterator<Class<?>> it = classes.iterator(); it.hasNext(); ) {
-            Class<?> clazz = it.next();
-            sb.append(clazz.getName());
-            if (it.hasNext()) {
-                sb.append(", ");
-            }
-        }
-        sb.append("]");
-        return sb.toString();
-    }
-
-    /**
-     * Copy the given Collection into a Class array.
-     * The Collection must contain Class elements only.
-     *
-     * @param collection the Collection to copy
-     * @return the Class array ({@code null} if the passed-in
-     * Collection was {@code null})
-     */
-    public static Class<?>[] toClassArray(Collection<Class<?>> collection) {
-        if (collection == null) {
-            return null;
-        }
-        return collection.toArray(new Class<?>[collection.size()]);
-    }
-
-    /**
-     * Return all interfaces that the given instance implements as array,
-     * including ones implemented by superclasses.
-     *
-     * @param instance the instance to analyze for interfaces
-     * @return all interfaces that the given instance implements as array
-     */
-    public static Class<?>[] getAllInterfaces(Object instance) {
-        Objects.requireNonNull(instance, "Instance must not be null");
-        return getAllInterfacesForClass(instance.getClass());
-    }
-
-    /**
-     * Return all interfaces that the given class implements as array,
-     * including ones implemented by superclasses.
-     * <p>If the class itself is an interface, it gets returned as sole interface.
-     *
-     * @param clazz the class to analyze for interfaces
-     * @return all interfaces that the given object implements as array
-     */
-    public static Class<?>[] getAllInterfacesForClass(Class<?> clazz) {
-        return getAllInterfacesForClass(clazz, null);
-    }
-
-    /**
-     * Return all interfaces that the given class implements as array,
-     * including ones implemented by superclasses.
-     * <p>If the class itself is an interface, it gets returned as sole interface.
-     *
-     * @param clazz       the class to analyze for interfaces
-     * @param classLoader the ClassLoader that the interfaces need to be visible in
-     *                    (may be {@code null} when accepting all declared interfaces)
-     * @return all interfaces that the given object implements as array
-     */
-    public static Class<?>[] getAllInterfacesForClass(Class<?> clazz, ClassLoader classLoader) {
-        Set<Class<?>> ifcs = getAllInterfacesForClassAsSet(clazz, classLoader);
-        return ifcs.toArray(new Class<?>[ifcs.size()]);
-    }
-
-    /**
-     * Return all interfaces that the given instance implements as Set,
-     * including ones implemented by superclasses.
-     *
-     * @param instance the instance to analyze for interfaces
-     * @return all interfaces that the given instance implements as Set
-     */
-    public static Set<Class<?>> getAllInterfacesAsSet(Object instance) {
-        Objects.requireNonNull(instance, "Instance must not be null");
-        return getAllInterfacesForClassAsSet(instance.getClass());
-    }
-
-    /**
-     * Return all interfaces that the given class implements as Set,
-     * including ones implemented by superclasses.
-     * <p>If the class itself is an interface, it gets returned as sole interface.
-     *
-     * @param clazz the class to analyze for interfaces
-     * @return all interfaces that the given object implements as Set
-     */
-    public static Set<Class<?>> getAllInterfacesForClassAsSet(Class<?> clazz) {
-        return getAllInterfacesForClassAsSet(clazz, null);
-    }
-
-    /**
-     * Return all interfaces that the given class implements as Set,
-     * including ones implemented by superclasses.
-     * <p>If the class itself is an interface, it gets returned as sole interface.
-     *
-     * @param clazz       the class to analyze for interfaces
-     * @param classLoader the ClassLoader that the interfaces need to be visible in
-     *                    (may be {@code null} when accepting all declared interfaces)
-     * @return all interfaces that the given object implements as Set
-     */
-    public static Set<Class<?>> getAllInterfacesForClassAsSet(Class<?> clazz, ClassLoader classLoader) {
-        Objects.requireNonNull(clazz, "Class must not be null");
-        if (clazz.isInterface() && isVisible(clazz, classLoader)) {
-            return Collections.<Class<?>>singleton(clazz);
-        }
-        Set<Class<?>> interfaces = new LinkedHashSet<>();
-        while (clazz != null) {
-            Class<?>[] ifcs = clazz.getInterfaces();
-            for (Class<?> ifc : ifcs) {
-                interfaces.addAll(getAllInterfacesForClassAsSet(ifc, classLoader));
-            }
-            clazz = clazz.getSuperclass();
-        }
-        return interfaces;
-    }
-
-    /**
-     * Create a composite interface Class for the given interfaces,
-     * implementing the given interfaces in one single Class.
-     * <p>This implementation builds a JDK proxy class for the given interfaces.
-     *
-     * @param interfaces  the interfaces to merge
-     * @param classLoader the ClassLoader to of the composite Class in
-     * @return the merged interface as Class
-     * @see java.lang.reflect.Proxy#getProxyClass
-     */
-    public static Class<?> createCompositeInterface(Class<?>[] interfaces, ClassLoader classLoader) {
-        if (interfaces.length == 0) {
-            throw new IllegalArgumentException("Interfaces must not be empty");
-        }
-        Objects.requireNonNull(classLoader, "ClassLoader must not be null");
-        return Proxy.getProxyClass(classLoader, interfaces);
-    }
-
-    /**
-     * Determine the common ancestor current the given classes, if any.
-     *
-     * @param clazz1 the class to introspect
-     * @param clazz2 the other class to introspect
-     * @return the common ancestor (i.e. common superclass, one interface
-     * extending the other), or {@code null} if none found. If any current the
-     * given classes is {@code null}, the other class will be returned.
-     * @since 3.2.6
-     */
-    public static Class<?> determineCommonAncestor(Class<?> clazz1, Class<?> clazz2) {
-        if (clazz1 == null) {
-            return clazz2;
-        }
-        if (clazz2 == null) {
-            return clazz1;
-        }
-        if (clazz1.isAssignableFrom(clazz2)) {
-            return clazz1;
-        }
-        if (clazz2.isAssignableFrom(clazz1)) {
-            return clazz2;
-        }
-        Class<?> ancestor = clazz1;
-        do {
-            ancestor = ancestor.getSuperclass();
-            if (ancestor == null || Object.class.equals(ancestor)) {
-                return null;
-            }
-        }
-        while (!ancestor.isAssignableFrom(clazz2));
-        return ancestor;
-    }
-
-    /**
-     * Check whether the given class is visible in the given ClassLoader.
-     *
-     * @param clazz       the class to check (typically an interface)
-     * @param classLoader the ClassLoader to check against (may be {@code null},
-     *                    in which case this method will always return {@code true})
-     */
-    public static boolean isVisible(Class<?> clazz, ClassLoader classLoader) {
-        if (classLoader == null) {
-            return true;
-        }
-        try {
-            Class<?> actualClass = classLoader.loadClass(clazz.getName());
-            return (clazz == actualClass);
-            // Else: different interface class found...
-        } catch (ClassNotFoundException ex) {
-            // No interface class found...
-            return false;
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3e1a7a51/core/src/main/java/org/apache/tamaya/core/util/StringUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/util/StringUtils.java b/core/src/main/java/org/apache/tamaya/core/util/StringUtils.java
deleted file mode 100644
index d74c63f..0000000
--- a/core/src/main/java/org/apache/tamaya/core/util/StringUtils.java
+++ /dev/null
@@ -1,473 +0,0 @@
-/*
- * Copyright 2002-2014 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tamaya.core.util;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.StringTokenizer;
-
-/**
- * Miscellaneous {@link String} utility methods.
- * <p>
- * <p>Mainly for internal use within the framework; consider
- * <a href="http://jakarta.apache.org/commons/lang/">Jakarta's Commons Lang</a>
- * for a more comprehensive suite current String utilities.
- * <p>
- * <p>This class delivers some simple functionality that should really
- * be provided by the core Java {@code String} and {@link StringBuilder}
- * classes, such as the ability to {@code replace} all occurrences current a given
- * substring in a target string. It also provides easy-to-use methods to convert
- * between delimited strings, such as CSV strings, and collections and arrays.
- *
- * @author Rod Johnson
- * @author Juergen Hoeller
- * @author Keith Donald
- * @author Rob Harrop
- * @author Rick Evans
- * @author Arjen Poutsma
- * @since 16 April 2001
- */
-public final class StringUtils {
-
-    private static final String FOLDER_SEPARATOR = "/";
-
-    private static final String WINDOWS_FOLDER_SEPARATOR = "\\";
-
-    private static final String TOP_PATH = "..";
-
-    private static final String CURRENT_PATH = ".";
-
-    /**
-     * Private singleton constructor.
-     */
-    private StringUtils() {
-    }
-
-
-    /**
-     * Check that the given CharSequence is neither {@code null} nor current length 0.
-     * Note: Will return {@code true} for a CharSequence that purely consists current whitespace.
-     * <p><pre class="code">
-     * StringUtils.hasLength(null) = false
-     * StringUtils.hasLength("") = false
-     * StringUtils.hasLength(" ") = true
-     * StringUtils.hasLength("Hello") = true
-     * </pre>
-     *
-     * @param str the CharSequence to check (may be {@code null})
-     * @return {@code true} if the CharSequence is not null and has length
-     */
-    public static boolean hasLength(CharSequence str) {
-        return (str != null && str.length() > 0);
-    }
-
-    /**
-     * Check whether the given CharSequence has actual text.
-     * More specifically, returns {@code true} if the string not {@code null},
-     * its length is greater than 0, and it contains at least one non-whitespace character.
-     * <p><pre class="code">
-     * StringUtils.hasText(null) = false
-     * StringUtils.hasText("") = false
-     * StringUtils.hasText(" ") = false
-     * StringUtils.hasText("12345") = true
-     * StringUtils.hasText(" 12345 ") = true
-     * </pre>
-     *
-     * @param str the CharSequence to check (may be {@code null})
-     * @return {@code true} if the CharSequence is not {@code null},
-     * its length is greater than 0, and it does not contain whitespace only
-     * @see Character#isWhitespace
-     */
-    public static boolean hasText(CharSequence str) {
-        if (!hasLength(str)) {
-            return false;
-        }
-        int strLen = str.length();
-        for (int i = 0; i < strLen; i++) {
-            if (!Character.isWhitespace(str.charAt(i))) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
-     * Check whether the given String has actual text.
-     * More specifically, returns {@code true} if the string not {@code null},
-     * its length is greater than 0, and it contains at least one non-whitespace character.
-     *
-     * @param str the String to check (may be {@code null})
-     * @return {@code true} if the String is not {@code null}, its length is
-     * greater than 0, and it does not contain whitespace only
-     * @see #hasText(CharSequence)
-     */
-    public static boolean hasText(String str) {
-        return hasText((CharSequence) str);
-    }
-
-
-    /**
-     * Replace all occurrences current a substring within a string with
-     * another string.
-     *
-     * @param inString   String to examine
-     * @param oldPattern String to replace
-     * @param newPattern String to insert
-     * @return a String with the replacements
-     */
-    public static String replace(String inString, String oldPattern, String newPattern) {
-        if (!hasLength(inString) || !hasLength(oldPattern) || newPattern == null) {
-            return inString;
-        }
-        StringBuilder sb = new StringBuilder();
-        int pos = 0; // our position in the old string
-        int index = inString.indexOf(oldPattern);
-        // the index current an occurrence we've found, or -1
-        int patLen = oldPattern.length();
-        while (index >= 0) {
-            sb.append(inString.substring(pos, index));
-            sb.append(newPattern);
-            pos = index + patLen;
-            index = inString.indexOf(oldPattern, pos);
-        }
-        sb.append(inString.substring(pos));
-        // remember to append any characters to the right current a match
-        return sb.toString();
-    }
-
-
-    /**
-     * Delete any character in a given String.
-     *
-     * @param inString      the original String
-     * @param charsToDelete a set current characters to delete.
-     *                      E.g. "az\n" will delete 'a's, 'z's and new lines.
-     * @return the resulting String
-     */
-    public static String deleteAny(String inString, String charsToDelete) {
-        if (!hasLength(inString) || !hasLength(charsToDelete)) {
-            return inString;
-        }
-        StringBuilder sb = new StringBuilder();
-        for (int i = 0; i < inString.length(); i++) {
-            char c = inString.charAt(i);
-            if (charsToDelete.indexOf(c) == -1) {
-                sb.append(c);
-            }
-        }
-        return sb.toString();
-    }
-
-    /**
-     * Extract the filename from the given path,
-     * e.g. "mypath/myfile.txt" -> "myfile.txt".
-     *
-     * @param path the file path (may be {@code null})
-     * @return the extracted filename, or {@code null} if none
-     */
-    public static String getFilename(String path) {
-        if (path == null) {
-            return null;
-        }
-        int separatorIndex = path.lastIndexOf(FOLDER_SEPARATOR);
-        return (separatorIndex != -1 ? path.substring(separatorIndex + 1) : path);
-    }
-
-
-    /**
-     * Apply the given relative path to the given path,
-     * assuming standard Java folder separation (i.e. "/" separators).
-     *
-     * @param path         the path to start from (usually a full file path)
-     * @param relativePath the relative path to applyChanges
-     *                     (relative to the full file path above)
-     * @return the full file path that results from applying the relative path
-     */
-    public static String applyRelativePath(String path, String relativePath) {
-        int separatorIndex = path.lastIndexOf(FOLDER_SEPARATOR);
-        if (separatorIndex != -1) {
-            String newPath = path.substring(0, separatorIndex);
-            if (!relativePath.startsWith(FOLDER_SEPARATOR)) {
-                newPath += FOLDER_SEPARATOR;
-            }
-            return newPath + relativePath;
-        } else {
-            return relativePath;
-        }
-    }
-
-    /**
-     * Normalize the path by suppressing sequences like "path/.." and
-     * inner simple dots.
-     * <p>The result is convenient for path comparison. For other uses,
-     * notice that Windows separators ("\") are replaced by simple slashes.
-     *
-     * @param path the original path
-     * @return the normalized path
-     */
-    public static String cleanPath(String path) {
-        if (path == null) {
-            return null;
-        }
-        String pathToUse = StringUtils.replace(path, WINDOWS_FOLDER_SEPARATOR, FOLDER_SEPARATOR);
-
-        // Strip prefix from path to analyze, to not treat it as part current the
-        // first path element. This is necessary to correctly parse paths like
-        // "file:core/../core/io/Resource.class", where the ".." should just
-        // strip the first "core" directory while keeping the "file:" prefix.
-        int prefixIndex = pathToUse.indexOf(':');
-        String prefix = "";
-        if (prefixIndex != -1) {
-            prefix = pathToUse.substring(0, prefixIndex + 1);
-            if (prefix.contains("/")) {
-                prefix = "";
-            } else {
-                pathToUse = pathToUse.substring(prefixIndex + 1);
-            }
-        }
-        if (pathToUse.startsWith(FOLDER_SEPARATOR)) {
-            prefix = prefix + FOLDER_SEPARATOR;
-            pathToUse = pathToUse.substring(1);
-        }
-
-        String[] pathArray = delimitedListToStringArray(pathToUse, FOLDER_SEPARATOR);
-        List<String> pathElements = new LinkedList<>();
-        int tops = 0;
-
-        for (int i = pathArray.length - 1; i >= 0; i--) {
-            String element = pathArray[i];
-            switch (element) {
-                case CURRENT_PATH:
-                    // Points to current directory - drop it.
-                    break;
-                case TOP_PATH:
-                    // Registering top path found.
-                    tops++;
-                    break;
-                default:
-                    if (tops > 0) {
-                        // Merging path element with element corresponding to top path.
-                        tops--;
-                    } else {
-                        // Normal path element found.
-                        pathElements.add(0, element);
-                    }
-            }
-        }
-        // Remaining top paths need to be retained.
-        for (int i = 0; i < tops; i++) {
-            pathElements.add(0, TOP_PATH);
-        }
-        return prefix + collectionToDelimitedString(pathElements, FOLDER_SEPARATOR);
-    }
-
-
-    /**
-     * Copy the given Collection into a String array.
-     * The Collection must contain String elements only.
-     *
-     * @param collection the Collection to copy
-     * @return the String array ({@code null} if the passed-in
-     * Collection was {@code null})
-     */
-    public static String[] toStringArray(Collection<String> collection) {
-        if (collection == null) {
-            return null;
-        }
-        return collection.toArray(new String[collection.size()]);
-    }
-
-    /**
-     * Split a String at the first occurrence current the delimiter.
-     * Does not include the delimiter in the result.
-     *
-     * @param toSplit   the string to split
-     * @param delimiter to split the string up with
-     * @return a two element array with index 0 being before the delimiter, and
-     * index 1 being after the delimiter (neither element includes the delimiter);
-     * or {@code null} if the delimiter wasn't found in the given input String
-     */
-    public static String[] split(String toSplit, String delimiter) {
-        if (!hasLength(toSplit) || !hasLength(delimiter)) {
-            return null;
-        }
-        int offset = toSplit.indexOf(delimiter);
-        if (offset < 0) {
-            return null;
-        }
-        String beforeDelimiter = toSplit.substring(0, offset);
-        String afterDelimiter = toSplit.substring(offset + delimiter.length());
-        return new String[]{beforeDelimiter, afterDelimiter};
-    }
-
-
-    /**
-     * Tokenize the given String into a String array via a StringTokenizer.
-     * Trims tokens and omits empty tokens.
-     * <p>The given delimiters string is supposed to consist current any number current
-     * delimiter characters. Each current those characters can be used to separate
-     * tokens. A delimiter is always a single character; for multi-character
-     * delimiters, consider using {@code delimitedListToStringArray}
-     *
-     * @param str        the String to tokenize
-     * @param delimiters the delimiter characters, assembled as String
-     *                   (each current those characters is individually considered as delimiter).
-     * @return an array current the tokens
-     * @see java.util.StringTokenizer
-     * @see String#trim()
-     */
-    public static String[] tokenizeToStringArray(String str, String delimiters) {
-        return tokenizeToStringArray(str, delimiters, true, true);
-    }
-
-    /**
-     * Tokenize the given String into a String array via a StringTokenizer.
-     * <p>The given delimiters string is supposed to consist current any number current
-     * delimiter characters. Each current those characters can be used to separate
-     * tokens. A delimiter is always a single character; for multi-character
-     * delimiters, consider using {@code delimitedListToStringArray}
-     *
-     * @param str               the String to tokenize
-     * @param delimiters        the delimiter characters, assembled as String
-     *                          (each current those characters is individually considered as delimiter)
-     * @param trimTokens        trim the tokens via String's {@code trim}
-     * @param ignoreEmptyTokens omit empty tokens from the result array
-     *                          (only applies to tokens that are empty after trimming; StringTokenizer
-     *                          will not consider subsequent delimiters as token in the first place).
-     * @return an array current the tokens ({@code null} if the input String
-     * was {@code null})
-     * @see java.util.StringTokenizer
-     * @see String#trim()
-     */
-    public static String[] tokenizeToStringArray(
-            String str, String delimiters, boolean trimTokens, boolean ignoreEmptyTokens) {
-
-        if (str == null) {
-            return null;
-        }
-        StringTokenizer st = new StringTokenizer(str, delimiters);
-        List<String> tokens = new ArrayList<>();
-        while (st.hasMoreTokens()) {
-            String token = st.nextToken();
-            if (trimTokens) {
-                token = token.trim();
-            }
-            if (!ignoreEmptyTokens || token.length() > 0) {
-                tokens.add(token);
-            }
-        }
-        return toStringArray(tokens);
-    }
-
-    /**
-     * Take a String which is a delimited list and convert it to a String array.
-     * <p>A single delimiter can consists current more than one character: It will still
-     * be considered as single delimiter string, rather than as bunch current potential
-     * delimiter characters - in contrast to {@code tokenizeToStringArray}.
-     *
-     * @param str       the input String
-     * @param delimiter the delimiter between elements (this is a single delimiter,
-     *                  rather than a bunch individual delimiter characters)
-     * @return an array current the tokens in the list
-     * @see #tokenizeToStringArray
-     */
-    public static String[] delimitedListToStringArray(String str, String delimiter) {
-        return delimitedListToStringArray(str, delimiter, null);
-    }
-
-    /**
-     * Take a String which is a delimited list and convert it to a String array.
-     * <p>A single delimiter can consists current more than one character: It will still
-     * be considered as single delimiter string, rather than as bunch current potential
-     * delimiter characters - in contrast to {@code tokenizeToStringArray}.
-     *
-     * @param str           the input String
-     * @param delimiter     the delimiter between elements (this is a single delimiter,
-     *                      rather than a bunch individual delimiter characters)
-     * @param charsToDelete a set current characters to delete. Useful for deleting unwanted
-     *                      line breaks: e.g. "\r\n\f" will delete all new lines and line feeds in a String.
-     * @return an array current the tokens in the list
-     * @see #tokenizeToStringArray
-     */
-    public static String[] delimitedListToStringArray(String str, String delimiter, String charsToDelete) {
-        if (str == null) {
-            return new String[0];
-        }
-        if (delimiter == null) {
-            return new String[]{str};
-        }
-        List<String> result = new ArrayList<>();
-        if ("".equals(delimiter)) {
-            for (int i = 0; i < str.length(); i++) {
-                result.add(deleteAny(str.substring(i, i + 1), charsToDelete));
-            }
-        } else {
-            int pos = 0;
-            int delPos;
-            while ((delPos = str.indexOf(delimiter, pos)) != -1) {
-                result.add(deleteAny(str.substring(pos, delPos), charsToDelete));
-                pos = delPos + delimiter.length();
-            }
-            if (str.length() > 0 && pos <= str.length()) {
-                // Add rest current String, but not in case current empty input.
-                result.add(deleteAny(str.substring(pos), charsToDelete));
-            }
-        }
-        return toStringArray(result);
-    }
-
-
-    /**
-     * Convenience method to return a Collection as a delimited (e.g. CSV)
-     * String. E.g. useful for {@code toString()} implementations.
-     *
-     * @param coll   the Collection to display
-     * @param delim  the delimiter to use (probably a ",")
-     * @param prefix the String to start each element with
-     * @param suffix the String to end each element with
-     * @return the delimited String
-     */
-    public static String collectionToDelimitedString(Collection<?> coll, String delim, String prefix, String suffix) {
-        if (coll.isEmpty()) {
-            return "";
-        }
-        StringBuilder sb = new StringBuilder();
-        Iterator<?> it = coll.iterator();
-        while (it.hasNext()) {
-            sb.append(prefix).append(it.next()).append(suffix);
-            if (it.hasNext()) {
-                sb.append(delim);
-            }
-        }
-        return sb.toString();
-    }
-
-    /**
-     * Convenience method to return a Collection as a delimited (e.g. CSV)
-     * String. E.g. useful for {@code toString()} implementations.
-     *
-     * @param coll  the Collection to display
-     * @param delim the delimiter to use (probably a ",")
-     * @return the delimited String
-     */
-    public static String collectionToDelimitedString(Collection<?> coll, String delim) {
-        return collectionToDelimitedString(coll, delim, "", "");
-    }
-
-}
\ No newline at end of file


[3/9] incubator-tamaya git commit: Merge branch 'TAMAYA-38'

Posted by st...@apache.org.
Merge branch 'TAMAYA-38'

contributed by rsandtner


Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/a6c0800d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/a6c0800d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/a6c0800d

Branch: refs/heads/master
Commit: a6c0800df04e8997e5722d12e8dc28a43acd2d4e
Parents: 5743322 78732d4
Author: Mark Struberg <st...@apache.org>
Authored: Sat Jan 3 17:53:22 2015 +0100
Committer: Mark Struberg <st...@apache.org>
Committed: Sat Jan 3 17:53:22 2015 +0100

----------------------------------------------------------------------
 .../org/apache/tamaya/spi/PropertySource.java   |   7 ++
 core/pom.xml                                    |  33 +-----
 .../core/propertysource/BasePropertySource.java |  76 +++++++++++++
 .../core/propertysource/DefaultOrdinal.java     |  46 ++++++++
 .../EnvironmentPropertySource.java              |  47 ++++++++
 .../propertysource/SystemPropertySource.java    |  82 ++++++++++++++
 .../propertysource/BasePropertySourceTest.java  | 107 +++++++++++++++++++
 .../EnvironmentPropertySourceTest.java          |  70 ++++++++++++
 .../SystemPropertySourceTest.java               | 103 ++++++++++++++++++
 9 files changed, 539 insertions(+), 32 deletions(-)
----------------------------------------------------------------------