Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
ipgallery.common.java
/
utils
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
96b469b9
authored
Aug 08, 2016
by
amir
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
## 1.1.4: overriding config file properties with env
parent
ae92bfbd
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
15 deletions
README.md
build.gradle
src/main/java/common/configuration/ConfigProperties.java
README.md
View file @
96b469b9
### general utils
### general utils
## 1.1.4: overriding config file properties with env
## 1.2.3:
## 1.2.3:
-
add "mavenLocal", for local repository. enables to check this dependency locally
-
add "mavenLocal", for local repository. enables to check this dependency locally
-
Handle correctly Exceptions in http requsts/responses
-
Handle correctly Exceptions in http requsts/responses
...
...
build.gradle
View file @
96b469b9
group
'com.ipgallery.common'
group
'com.ipgallery.common'
version
'1.1.
3
'
version
'1.1.
4
'
apply
plugin:
'java'
apply
plugin:
'java'
apply
plugin:
'maven-publish'
apply
plugin:
'maven-publish'
...
...
src/main/java/common/configuration/ConfigProperties.java
View file @
96b469b9
...
@@ -193,11 +193,18 @@ public class ConfigProperties
...
@@ -193,11 +193,18 @@ public class ConfigProperties
try
try
{
{
propFile
=
new
FileInputStream
(
CONFIG_FILE_LOCATION
);
propFile
=
new
FileInputStream
(
CONFIG_FILE_LOCATION
);
Properties
p
=
new
Properties
(
System
.
getProperties
());
Properties
fileProperties
=
new
Properties
();
p
.
load
(
propFile
);
fileProperties
.
load
(
propFile
);
addPropertiesFromProviders
(
p
);
Properties
sysProperties
=
System
.
getProperties
();
// Adding properties from file only if absent in env
fileProperties
.
entrySet
().
forEach
(
prop
->
sysProperties
.
putIfAbsent
(
prop
.
getKey
(),
prop
.
getValue
()));
// Adding other providers properties - override system
configurationProviderList
.
forEach
(
provider
->
provider
.
getAllProperties
().
forEach
(
propEntry
->
sysProperties
.
setProperty
(
propEntry
.
getKey
(),
propEntry
.
getValue
())));
// set the system properties
// set the system properties
System
.
setProperties
(
p
);
System
.
setProperties
(
sysProperties
);
// display new properties
// display new properties
System
.
getProperties
().
list
(
System
.
out
);
System
.
getProperties
().
list
(
System
.
out
);
}
catch
(
FileNotFoundException
e
)
}
catch
(
FileNotFoundException
e
)
...
@@ -212,16 +219,6 @@ public class ConfigProperties
...
@@ -212,16 +219,6 @@ public class ConfigProperties
}
}
}
}
private
void
addPropertiesFromProviders
(
Properties
p
)
{
for
(
IConfigurationProvider
provider:
configurationProviderList
)
{
for
(
Entry
<
String
,
String
>
propEntry:
provider
.
getAllProperties
())
{
p
.
setProperty
(
propEntry
.
getKey
(),
propEntry
.
getValue
());
}
}
}
public
Object
addConfigurationPropertyToHash
(
String
key
,
String
defaultValue
,
EnumPropertyType
eType
)
public
Object
addConfigurationPropertyToHash
(
String
key
,
String
defaultValue
,
EnumPropertyType
eType
)
{
{
String
valueStr
=
System
.
getProperty
(
key
,
defaultValue
);
String
valueStr
=
System
.
getProperty
(
key
,
defaultValue
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment