You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by st...@apache.org on 2017/05/09 08:56:59 UTC
[1/2] deltaspike git commit: remove redundant license headers
Repository: deltaspike
Updated Branches:
refs/heads/master f5ba10bb7 -> 270f3d0bb
remove redundant license headers
Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/d927aa3b
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/d927aa3b
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/d927aa3b
Branch: refs/heads/master
Commit: d927aa3b725eb240657c18ade2eef8d44146059c
Parents: f5ba10b
Author: Mark Struberg <st...@apache.org>
Authored: Tue May 9 09:46:57 2017 +0200
Committer: Mark Struberg <st...@apache.org>
Committed: Tue May 9 09:46:57 2017 +0200
----------------------------------------------------------------------
...eltaspike.core.api.config.PropertyFileConfig | 57 --------------------
1 file changed, 57 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d927aa3b/deltaspike/core/impl/src/test/resources/META-INF/services/org.apache.deltaspike.core.api.config.PropertyFileConfig
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/resources/META-INF/services/org.apache.deltaspike.core.api.config.PropertyFileConfig b/deltaspike/core/impl/src/test/resources/META-INF/services/org.apache.deltaspike.core.api.config.PropertyFileConfig
index a578338..a7f802c 100644
--- a/deltaspike/core/impl/src/test/resources/META-INF/services/org.apache.deltaspike.core.api.config.PropertyFileConfig
+++ b/deltaspike/core/impl/src/test/resources/META-INF/services/org.apache.deltaspike.core.api.config.PropertyFileConfig
@@ -1,60 +1,3 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
[2/2] deltaspike git commit: DELTASPIKE-1253 support file:// for
PropertyFileConfig
Posted by st...@apache.org.
DELTASPIKE-1253 support file:// for PropertyFileConfig
A PropertyFileConfig can now also pick up other URLs than from the classpath.
By returning a "file:///var/opt/myapp/my.properties" you might now load properties
from a file on the classpath.
Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/270f3d0b
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/270f3d0b
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/270f3d0b
Branch: refs/heads/master
Commit: 270f3d0bbbc8e4e5ea8328cd23e56101bef9a4a7
Parents: d927aa3
Author: Mark Struberg <st...@apache.org>
Authored: Tue May 9 10:55:13 2017 +0200
Committer: Mark Struberg <st...@apache.org>
Committed: Tue May 9 10:55:13 2017 +0200
----------------------------------------------------------------------
.../core/api/config/PropertyFileConfig.java | 7 +-
.../deltaspike/core/util/PropertyFileUtils.java | 9 ++
.../FileConfigSourceTest.java | 105 +++++++++++++++++++
3 files changed, 120 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/270f3d0b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/PropertyFileConfig.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/PropertyFileConfig.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/PropertyFileConfig.java
index e3057cf..7ebe1e4 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/PropertyFileConfig.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/PropertyFileConfig.java
@@ -81,7 +81,12 @@ public interface PropertyFileConfig
{
/**
* All the property files on the classpath which have this name will get picked up and registered as
- * {@link org.apache.deltaspike.core.spi.config.ConfigSource}s.
+ * {@link org.apache.deltaspike.core.spi.config.ConfigSource}.
+ *
+ * If the the returned String starts with 'file://' then we pick up the configuration from a file
+ * on the File System instead of the ClassPath.
+ * The same works for other URLs which are passed, e.g. 'http://'.
+ * Note that reading the property values only gets performed once right now.
*
* @return the full file name (including path) of the property files to pick up.
*/
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/270f3d0b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/PropertyFileUtils.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/PropertyFileUtils.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/PropertyFileUtils.java
index fabba11..514c2c9 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/PropertyFileUtils.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/PropertyFileUtils.java
@@ -26,6 +26,7 @@ import java.util.Enumeration;
import java.util.Locale;
import java.util.Properties;
import java.util.ResourceBundle;
+import java.util.Vector;
@Typed()
public abstract class PropertyFileUtils
@@ -40,6 +41,14 @@ public abstract class PropertyFileUtils
public static Enumeration<URL> resolvePropertyFiles(String propertyFileName) throws IOException
{
+ if (propertyFileName != null && propertyFileName.contains("://"))
+ {
+ // the given string is actually already an URL
+ Vector<URL> propertyFileUrls = new Vector<URL>();
+ propertyFileUrls.add(new URL(propertyFileName));
+ return propertyFileUrls.elements();
+ }
+
ClassLoader cl = ClassUtils.getClassLoader(null);
Enumeration<URL> propertyFileUrls = cl.getResources(propertyFileName);
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/270f3d0b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/config/propertyconfigsource/FileConfigSourceTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/config/propertyconfigsource/FileConfigSourceTest.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/config/propertyconfigsource/FileConfigSourceTest.java
new file mode 100644
index 0000000..65b61eb
--- /dev/null
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/config/propertyconfigsource/FileConfigSourceTest.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.test.core.api.config.propertyconfigsource;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+
+import org.apache.deltaspike.core.api.config.ConfigResolver;
+import org.apache.deltaspike.core.api.config.PropertyFileConfig;
+import org.apache.deltaspike.core.api.exclude.Exclude;
+import org.apache.deltaspike.test.category.SeCategory;
+import org.apache.deltaspike.test.util.ArchiveUtils;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+/**
+ * Test for picking up a file system based config
+ */
+@RunWith(Arquillian.class)
+@Category(SeCategory.class)
+public class FileConfigSourceTest
+{
+ @Deployment
+ public static WebArchive deploy()
+ {
+ JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, "FileConfigSourceTest.jar")
+ .addClasses(FileConfigSourceTest.class, FileSystemConfig.class)
+ .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+
+ return ShrinkWrap.create(WebArchive.class, "beanProvider.war")
+ .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreArchive())
+ .addAsLibraries(testJar)
+ .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
+ }
+
+
+ @Test
+ public void testConfig() {
+ String val = ConfigResolver.getPropertyValue("deltaspike.test.config.from.file");
+ Assert.assertNotNull(val);
+ Assert.assertEquals("it works", val);
+ }
+
+ public static class FileSystemConfig implements PropertyFileConfig
+ {
+ private final String configFileLocation;
+
+ /**
+ * This ct is actually only a hack to create a temporary file on the target system
+ * With exactly the content we will later look up.
+ */
+ public FileSystemConfig()
+ {
+ try
+ {
+ File tempFile = File.createTempFile("deltaspike", ".properties");
+ FileWriter fw = new FileWriter(tempFile);
+ fw.write("deltaspike.test.config.from.file=it works");
+ fw.close();
+ configFileLocation = "file://" + tempFile.getCanonicalPath();
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public String getPropertyFileName()
+ {
+ return configFileLocation;
+ }
+
+ @Override
+ public boolean isOptional()
+ {
+ return false;
+ }
+ }
+}