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
import java.util.NavigableMap; | |
import java.util.TreeMap; | |
import java.util.concurrent.atomic.AtomicInteger; | |
import java.util.stream.Stream; | |
public class Fibonacci { | |
public static final Fibonacci BASE = new Fibonacci(0, 1); |
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
@Override | |
public void savePaymentStatus(String paymentId, AcquiringResponse.PaymentStatus paymentStatus) { | |
pmcRedisTemplate.execute(new SessionCallback<Void>(){ | |
@Override | |
public Void execute(RedisOperations operations) throws DataAccessException { | |
operations.watch(paymentId); | |
if (!findPaymentStatusByPaymentId(paymentId).isPresent()) { | |
operations.multi(); | |
updatePaymentStatus(paymentId, paymentStatus.getValue()); | |
operations.exec(); |
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
import org.apache.logging.log4j.core.pattern.LogEventPatternConverter; | |
import java.util.regex.Matcher; | |
import java.util.regex.Pattern; | |
@Plugin(name = "EraseSensitiveData", category = "Converter") | |
@ConverterKeys({ "msg" }) | |
public class EraseSensitiveDataConverter extends LogEventPatternConverter { | |
private static final String NAME = "msg"; | |
private static final String JSON_REPLACEMENT_REGEX_1 = "\"$1\":\"٩(◕‿◕。)۶\""; |
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
import org.togglz.core.manager.EnumBasedFeatureProvider; | |
import org.togglz.core.spi.FeatureProvider; | |
@Configuration | |
public class ToggleConfiguration { | |
@Bean | |
public FeatureProvider featureProvider() { | |
return new EnumBasedFeatureProvider(FeatureEnum.class); | |
} |
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
@RestController | |
public class PromotionController { | |
private final PromotionService promotionService; | |
@Autowired | |
public PromotionController(PromotionService promotionService){ | |
this.promotionService = promotionService; | |
} |
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
@Service | |
public class PromotionService { | |
@FeatureSwitch(value = FeatureEnum.PROMOTION_MANAGEMENT_FEATURE) | |
public void performPromotion() { | |
System.out.println("Perform Promotion.") | |
} | |
} |
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
@Aspect | |
@Component | |
public class FeaturesAspect { | |
private static final Logger LOG = Logger.getLogger(FeaturesAspect.class); | |
@Around(value = "@within(featureSwitch) || @annotation(featureSwitch)") | |
public Object checkAspect(ProceedingJoinPoint joinPoint, FeatureSwitch featureSwitch) throws Throwable { | |
if (featureSwitch.value().isActive()) { | |
LOG.info("Feature " + featureSwitch.value().name() + " is Open"); |
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
@Retention(RetentionPolicy.RUNTIME) | |
@Target({ ElementType.METHOD, ElementType.TYPE }) | |
public @interface FeatureSwitch { | |
FeatureEnum value(); | |
} |
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
import org.togglz.core.Feature; | |
public enum FeatureEnum implements Feature { | |
@Label("Promotion Management Feature") | |
@EnabledByDefault | |
@DefaultActivationStrategy( | |
id = SystemPropertyActivationStrategy.ID, | |
parameters = { @ActivationParameter(name = SystemPropertyActivationStrategy.PARAM_PROPERTY_NAME, | |
value = "promotion.feature"), |
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
<!-- https://mvnrepository.com/artifact/org.togglz/togglz-core --> | |
<dependency> | |
<groupId>org.togglz</groupId> | |
<artifactId>togglz-core</artifactId> | |
<version>2.5.0.Final</version> | |
</dependency> |
NewerOlder