-
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.
Separating environment and active profiles terms. (#3)
* Separating environment and active profiles terms.
- Loading branch information
Showing
18 changed files
with
208 additions
and
174 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
version=0.0.2 | ||
version=0.0.3 |
39 changes: 39 additions & 0 deletions
39
...-starter/src/main/java/com/wise/common/environment/CachingWiseActiveProfilesProvider.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 CachingWiseActiveProfilesProvider implements WiseActiveProfilesProvider { | ||
|
||
private final List<WiseProfile> activeProfiles; | ||
|
||
private Map<WiseProfile, Boolean> isActiveCache = new ConcurrentHashMap<>(); | ||
|
||
public CachingWiseActiveProfilesProvider(List<WiseProfile> activeProfiles) { | ||
this.activeProfiles = activeProfiles; | ||
} | ||
|
||
@Override | ||
public List<WiseProfile> getActiveProfiles() { | ||
return activeProfiles; | ||
} | ||
|
||
@Override | ||
public boolean isProfileActive(WiseProfile profile) { | ||
return isActiveCache.computeIfAbsent(profile, k -> { | ||
var activeProfiles = getActiveProfiles(); | ||
|
||
for (var activeProfile : activeProfiles) { | ||
while (activeProfile != null) { | ||
if (activeProfile == profile) { | ||
return true; | ||
} | ||
activeProfile = activeProfile.parent(); | ||
} | ||
} | ||
|
||
return false; | ||
}); | ||
} | ||
} |
39 changes: 0 additions & 39 deletions
39
...ent-starter/src/main/java/com/wise/common/environment/CachingWiseEnvironmentProvider.java
This file was deleted.
Oops, something went wrong.
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
10 changes: 10 additions & 0 deletions
10
...ronment-starter/src/main/java/com/wise/common/environment/WiseActiveProfilesProvider.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,10 @@ | ||
package com.wise.common.environment; | ||
|
||
import java.util.List; | ||
|
||
public interface WiseActiveProfilesProvider { | ||
|
||
List<WiseProfile> getActiveProfiles(); | ||
|
||
boolean isProfileActive(WiseProfile profile); | ||
} |
Oops, something went wrong.