Created
June 5, 2014 12:55
-
-
Save thomasdarimont/25c2836ffd696026bc17 to your computer and use it in GitHub Desktop.
Runtime Spring Configuration
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
package de.tutorials.training.springconfig; | |
import java.io.Serializable; | |
import lombok.Data; | |
@Data | |
public class ConfigSettingValue implements Serializable { | |
private static final long serialVersionUID = 1L; | |
private final String key; | |
private Object value; | |
private final Object defaultValue; | |
private final Class<?> type; | |
public ConfigSettingValue(String key, Object value, Object defaultValue, Class<?> type) { | |
this.key = key; | |
this.value = value; | |
this.defaultValue = defaultValue; | |
this.type = type; | |
} | |
} |
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
package de.tutorials.training.springconfig; | |
import lombok.Getter; | |
import lombok.Setter; | |
@Getter | |
@Setter | |
public class SimpleComponent { | |
private ConfigSetting<String> stringProperty = new ConfigSetting<>("default"); | |
private ConfigSetting<Integer> intProperty = new ConfigSetting<>(42); | |
private ConfigSetting<Boolean> booleanProperty = new ConfigSetting<>(false); | |
public void businessMethod(/*..*/) { | |
if(booleanProperty.get()) { | |
businessTransaction1(); | |
}else { | |
businessTransaction2(); | |
} | |
} | |
private void businessTransaction2() { | |
//process(stringProperty.get()) | |
//... | |
} | |
private void businessTransaction1() { | |
//process(intProperty.get()) | |
//... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment