Pablo Pita Leira created DELTASPIKE-1084:
--------------------------------------------
Summary: Integrate configuration sources expressed as URLs.
Key: DELTASPIKE-1084
URL: https://issues.apache.org/jira/browse/DELTASPIKE-1084
Project: DeltaSpike
Issue Type: Improvement
Components: Configuration
Reporter: Pablo Pita Leira
Priority: Minor
The PropertyFileUtils class can load the properties file as follows :
{code}
String root = System.getProperty("user.dir");
String path = root + "/src/test/resources/myurlconfig.properties";
String urlPath = "file:/" + path;
URL propertyFileUrl = new URL(urlPath);
Poperties p = PropertyFileUtils.loadProperties(propertyFileUrl);
{code}
Using the following code to incorporate the properties does not work:
{code}
public class MyUrlCustomPropertyFileConfig implements PropertyFileConfig
{
@Override
public String getPropertyFileName()
{
String root = System.getProperty("user.dir");
String path = root + "/src/test/resources/myurlconfig.properties";
return "file:/" + path;
}
@Override
public boolean isOptional()
{
return false;
}
}
{code}
I get an exception as follows:
{code}
java.lang.IllegalStateException: com.example.MyUrlCustomPropertyFileConfig
points to an invalid file:
'file:/D:\Dev\GIT\example-test/src/test/resources/myurlconfig.properties'
at
org.apache.deltaspike.core.impl.config.ConfigurationExtension.createPropertyConfigSource(ConfigurationExtension.java:210)
at
org.apache.deltaspike.core.impl.config.ConfigurationExtension.registerUserConfigSources(ConfigurationExtension.java:135)
at
org.apache.deltaspike.core.impl.config.ConfigurationExtension$Proxy$_$$_WeldClientProxy.registerUserConfigSources(ConfigurationExtension$Proxy$_$$_WeldClientProxy.java)
{code}
By looking into the test code in DeltaSpike I do not see any usage of the URL
mechanism as a property configuration source. This should be improved.
There should be a way to integrate easily configuration sources expressed as
URLs. As user, I would like that the way to integrate URL paths as
configuration sources is also documented (including those starting with file:/).
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)