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:48 UTC

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

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0734e210/core/src/main/java/org/apache/tamaya/core/resources/InputStreamSource.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/resources/InputStreamSource.java b/core/src/main/java/org/apache/tamaya/core/resources/InputStreamSource.java
deleted file mode 100644
index 3d95269..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