-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #182 from kenfinnigan/config-source-extraction
Fixes #178
- Loading branch information
Showing
23 changed files
with
244 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>io.smallrye</groupId> | ||
<artifactId>smallrye-config-parent</artifactId> | ||
<version>1.3.12-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>smallrye-config-common</artifactId> | ||
|
||
<name>SmallRye: Common classes</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.eclipse.microprofile.config</groupId> | ||
<artifactId>microprofile-config-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.logging</groupId> | ||
<artifactId>jboss-logging</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<profiles> | ||
<profile> | ||
<id>coverage</id> | ||
<properties> | ||
<argLine>@{jacocoArgLine}</argLine> | ||
</properties> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.jacoco</groupId> | ||
<artifactId>jacoco-maven-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<argLine>@{jacocoArgLine} -Xmx512m</argLine> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
</profiles> | ||
|
||
</project> |
32 changes: 32 additions & 0 deletions
32
common/src/main/java/io/smallrye/config/AbstractConfigSource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package io.smallrye.config; | ||
|
||
import java.io.Serializable; | ||
|
||
import org.eclipse.microprofile.config.spi.ConfigSource; | ||
|
||
public abstract class AbstractConfigSource implements ConfigSource, Serializable { | ||
private static final long serialVersionUID = 9018847720072978115L; | ||
|
||
private final int ordinal; | ||
private final String name; | ||
|
||
public AbstractConfigSource(String name, int ordinal) { | ||
this.name = name; | ||
this.ordinal = ordinal; | ||
} | ||
|
||
@Override | ||
public int getOrdinal() { | ||
return ordinal; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return getName(); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
common/src/main/java/io/smallrye/config/MapBackedConfigSource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package io.smallrye.config; | ||
|
||
import static io.smallrye.config.utils.ConfigSourceUtil.CONFIG_ORDINAL_100; | ||
import static io.smallrye.config.utils.ConfigSourceUtil.CONFIG_ORDINAL_KEY; | ||
|
||
import java.util.Collections; | ||
import java.util.Map; | ||
|
||
public abstract class MapBackedConfigSource extends AbstractConfigSource { | ||
private static final long serialVersionUID = -7159956218217228877L; | ||
|
||
private final Map<String, String> properties; | ||
|
||
public MapBackedConfigSource(String name, Map<String, String> propertyMap) { | ||
super(name, Integer.parseInt(propertyMap.getOrDefault(CONFIG_ORDINAL_KEY, CONFIG_ORDINAL_100))); | ||
properties = propertyMap; | ||
} | ||
|
||
public MapBackedConfigSource(String name, Map<String, String> propertyMap, int defaultOrdinal) { | ||
super(name, Integer.parseInt(propertyMap.getOrDefault(CONFIG_ORDINAL_KEY, String.valueOf(defaultOrdinal)))); | ||
properties = propertyMap; | ||
} | ||
|
||
@Override | ||
public Map<String, String> getProperties() { | ||
return Collections.unmodifiableMap(properties); | ||
} | ||
|
||
@Override | ||
public String getValue(String propertyName) { | ||
return properties.get(propertyName); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.