-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
208 additions
and
27 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
3 changes: 1 addition & 2 deletions
3
.../impl/CachingWiseEnvironmentProvider.java → ...nment/CachingWiseEnvironmentProvider.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
64 changes: 64 additions & 0 deletions
64
...ronment-starter/src/main/java/com/wise/common/environment/DefaultPropertiesSetterDsl.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,64 @@ | ||
package com.wise.common.environment; | ||
|
||
public class DefaultPropertiesSetterDsl implements PropertiesSetterDsl { | ||
|
||
private String source; | ||
private WiseEnvironment wiseEnvironment; | ||
|
||
private String keyPrefix; | ||
|
||
private Dsl0 dsl0 = new Dsl0Impl(); | ||
private Dsl1 dsl1 = new Dsl1Impl(); | ||
private Dsl2 dsl2 = new Dsl2Impl(); | ||
|
||
@Override | ||
public Dsl0 source(String source) { | ||
this.source = source; | ||
return dsl0; | ||
} | ||
|
||
class Dsl0Impl implements Dsl0 { | ||
|
||
@Override | ||
public Dsl2 environment(WiseEnvironment wiseEnvironment) { | ||
DefaultPropertiesSetterDsl.this.wiseEnvironment = wiseEnvironment; | ||
return dsl2; | ||
} | ||
|
||
@Override | ||
public Dsl1 keyPrefix(String keyPrefix) { | ||
DefaultPropertiesSetterDsl.this.keyPrefix = keyPrefix; | ||
return dsl1; | ||
} | ||
} | ||
|
||
class Dsl1Impl implements Dsl1 { | ||
|
||
@Override | ||
public Dsl2 environment(WiseEnvironment wiseEnvironment) { | ||
DefaultPropertiesSetterDsl.this.wiseEnvironment = wiseEnvironment; | ||
return dsl2; | ||
} | ||
} | ||
|
||
class Dsl2Impl implements Dsl2 { | ||
|
||
@Override | ||
public Dsl2 environment(WiseEnvironment wiseEnvironment) { | ||
DefaultPropertiesSetterDsl.this.wiseEnvironment = wiseEnvironment; | ||
return this; | ||
} | ||
|
||
@Override | ||
public Dsl2 keyPrefix(String keyPrefix) { | ||
DefaultPropertiesSetterDsl.this.keyPrefix = keyPrefix; | ||
return this; | ||
} | ||
|
||
@Override | ||
public Dsl2 set(String name, Object value) { | ||
WiseEnvironment.setDefaultProperty(source, wiseEnvironment, keyPrefix == null ? name : keyPrefix + name, value); | ||
return this; | ||
} | ||
} | ||
} |
3 changes: 1 addition & 2 deletions
3
.../impl/DefaultWiseEnvironmentDetector.java → ...nment/DefaultWiseEnvironmentDetector.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
28 changes: 28 additions & 0 deletions
28
wise-environment-starter/src/main/java/com/wise/common/environment/PropertiesSetterDsl.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,28 @@ | ||
package com.wise.common.environment; | ||
|
||
public interface PropertiesSetterDsl { | ||
|
||
Dsl0 source(String source); | ||
|
||
interface Dsl0 { | ||
|
||
Dsl2 environment(WiseEnvironment environment); | ||
|
||
Dsl1 keyPrefix(String prefix); | ||
} | ||
|
||
interface Dsl1 { | ||
|
||
Dsl2 environment(WiseEnvironment wiseEnvironment); | ||
|
||
} | ||
|
||
interface Dsl2 { | ||
|
||
Dsl2 environment(WiseEnvironment environment); | ||
|
||
Dsl2 keyPrefix(String keyPrefix); | ||
|
||
Dsl2 set(String property, Object value); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
wise-environment-starter/src/main/java/com/wise/common/environment/PropertyContainer.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,40 @@ | ||
package com.wise.common.environment; | ||
|
||
import lombok.Data; | ||
import lombok.experimental.Accessors; | ||
import org.springframework.boot.origin.Origin; | ||
import org.springframework.util.Assert; | ||
|
||
@Data | ||
@Accessors(chain = true) | ||
public class PropertyContainer { | ||
|
||
private Object value; | ||
|
||
private WiseEnvironmentOrigin origin; | ||
|
||
public PropertyContainer(String source, WiseEnvironment environment, Object value) { | ||
Assert.notNull(value, "Value must not be null"); | ||
this.origin = new WiseEnvironmentOrigin(source, environment); | ||
this.value = value; | ||
} | ||
|
||
@Data | ||
public static class WiseEnvironmentOrigin implements Origin { | ||
|
||
private String source; | ||
|
||
private WiseEnvironment environment; | ||
|
||
public WiseEnvironmentOrigin(String source, WiseEnvironment environment) { | ||
Assert.notNull(source, "Source must not be null"); | ||
Assert.notNull(environment, "Environment must not be null"); | ||
this.source = source; | ||
this.environment = environment; | ||
} | ||
|
||
public String toString() { | ||
return "Wise environment: '" + environment + "', source: '" + source + "'"; | ||
} | ||
} | ||
} |
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
2 changes: 1 addition & 1 deletion
2
...ronment/impl/WiseEnvironmentDetector.java → .../environment/WiseEnvironmentDetector.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
4 changes: 1 addition & 3 deletions
4
...eEnvironmentEnvironmentPostProcessor.java → ...eEnvironmentEnvironmentPostProcessor.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
2 changes: 1 addition & 1 deletion
2
...ronment/impl/WiseEnvironmentProvider.java → .../environment/WiseEnvironmentProvider.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
2 changes: 1 addition & 1 deletion
2
wise-environment-starter/src/main/resources/META-INF/spring.factories
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 |
---|---|---|
@@ -1 +1 @@ | ||
org.springframework.boot.env.EnvironmentPostProcessor=com.wise.common.environment.impl.WiseEnvironmentEnvironmentPostProcessor | ||
org.springframework.boot.env.EnvironmentPostProcessor=com.wise.common.environment.WiseEnvironmentEnvironmentPostProcessor |
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