-
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.
Merge pull request #1 from transferwise/fix_build
New proper initial version.
- Loading branch information
Showing
32 changed files
with
575 additions
and
304 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
version=0.0.1 | ||
version=0.0.2 |
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
ext.projectArtifactName = "wise-environment" | ||
ext.projectArtifactName = "wise-environment-starter" | ||
|
||
apply from: "$rootProject.rootDir/build.common.gradle" | ||
apply from: "$rootProject.rootDir/build.library.gradle" | ||
|
||
dependencies { | ||
compileOnly libraries.springBootStarter | ||
implementation libraries.commonsLang3 | ||
implementation libraries.springBootStarter | ||
|
||
testImplementation libraries.springBootStarterTest | ||
} |
39 changes: 39 additions & 0 deletions
39
...ent-starter/src/main/java/com/wise/common/environment/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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.wise.common.environment; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
public class CachingWiseEnvironmentProvider implements WiseEnvironmentProvider { | ||
|
||
private final List<WiseEnvironment> activeEnvironments; | ||
|
||
private Map<WiseEnvironment, Boolean> isActiveCache = new ConcurrentHashMap<>(); | ||
|
||
public CachingWiseEnvironmentProvider(List<WiseEnvironment> activeEnvironments) { | ||
this.activeEnvironments = activeEnvironments; | ||
} | ||
|
||
@Override | ||
public List<WiseEnvironment> getActiveEnvironments() { | ||
return activeEnvironments; | ||
} | ||
|
||
@Override | ||
public boolean isEnvironmentActive(WiseEnvironment environment) { | ||
return isActiveCache.computeIfAbsent(environment, k -> { | ||
var activeEnvironments = getActiveEnvironments(); | ||
|
||
for (var activeEnvironment : activeEnvironments) { | ||
while (activeEnvironment != null) { | ||
if (activeEnvironment == environment) { | ||
return true; | ||
} | ||
activeEnvironment = activeEnvironment.parent(); | ||
} | ||
} | ||
|
||
return false; | ||
}); | ||
} | ||
} |
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; | ||
} | ||
} | ||
} |
64 changes: 0 additions & 64 deletions
64
...environment-starter/src/main/java/com/wise/common/environment/DefaultWiseEnvironment.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.