Created
October 26, 2015 16:30
type-safe config with producer
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
@TypeSafeConfig | |
public interface AppConfig2 { | |
String name(); | |
@Produces //since ds v1.5.1 | |
ApplicationVersion version(); | |
} |
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
//example for injecting and using type-safe configs | |
@Scheduled(cronExpression = "0 0/10 * * * ?") | |
public class CustomBatchStarter2 implements org.quartz.Job { | |
@Inject | |
private LogService logService; | |
@Inject | |
private ApplicationVersion version; | |
@Inject | |
private BatchConfig batchConfig; | |
@Inject | |
private CustomBatchService batchService; | |
@Override | |
public void execute(JobExecutionContext context) throws JobExecutionException { | |
logService.log(appConfig.name(), version, getClass().getName() + " started"); | |
batchService.start(batchConfig.batchSize()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment