Skip to content

Commit

Permalink
Performance improvement in EnvUtils. Read "weavingMode" system property
Browse files Browse the repository at this point in the history
only one time.
  • Loading branch information
ricardoletgo committed Oct 19, 2016
1 parent c175837 commit 9f62a5f
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,22 @@
* Created by dmgcodevil
*/
public final class EnvUtils {

private static final String WEAVING_MODE;

static {
WEAVING_MODE = System.getProperty("weavingMode", WeavingMode.RUNTIME.name()).toUpperCase();
}

private EnvUtils(){

}

public static WeavingMode getWeavingMode() {
String wavingModeParam = System.getProperty("weavingMode", WeavingMode.RUNTIME.name()).toUpperCase();
try {
return WeavingMode.valueOf(wavingModeParam);
return WeavingMode.valueOf(EnvUtils.WEAVING_MODE);
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("wrong 'weavingMode' property, supported: " + Arrays.toString(WeavingMode.values()) + ", actual = " + wavingModeParam, e);
throw new IllegalArgumentException("wrong 'weavingMode' property, supported: " + Arrays.toString(WeavingMode.values()) + ", actual = " + EnvUtils.WEAVING_MODE, e);
}
}

Expand Down

0 comments on commit 9f62a5f

Please sign in to comment.