本文整理匯總了Java中org.springframework.boot.ApplicationArguments類的典型用法代碼示例。如果您正苦於以下問題:Java ApplicationArguments類的具體用法?Java ApplicationArguments怎麽用?Java ApplicationArguments使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ApplicationArguments類屬於org.springframework.boot包,在下文中一共展示了ApplicationArguments類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: run
import org.springframework.boot.ApplicationArguments; //導入依賴的package包/類
@Override
public void run(ApplicationArguments args) throws Exception {
logger.info("Consumer running with binder {}", binder);
SubscribableChannel consumerChannel = new ExecutorSubscribableChannel();
consumerChannel.subscribe(new MessageHandler() {
@Override
public void handleMessage(Message<?> message) throws MessagingException {
messagePayload = (String) message.getPayload();
logger.info("Received message: {}", messagePayload);
}
});
String group = null;
if (args.containsOption("group")) {
group = args.getOptionValues("group").get(0);
}
binder.bindConsumer(ConsulBinderTests.BINDING_NAME, group, consumerChannel,
new ConsumerProperties());
isBound = true;
}
示例2: run
import org.springframework.boot.ApplicationArguments; //導入依賴的package包/類
@Override
public void run(ApplicationArguments args) throws Exception {
if (ShellUtils.hasHelpOption(args)) {
String usageInstructions;
final Reader reader = new InputStreamReader(getInputStream(HelpAwareShellApplicationRunner.class, "/usage.txt"));
try {
usageInstructions = FileCopyUtils.copyToString(new BufferedReader(reader));
usageInstructions.replaceAll("(\\r|\\n)+", System.getProperty("line.separator"));
}
catch (Exception ex) {
throw new IllegalStateException("Cannot read stream", ex);
}
System.out.println(usageInstructions);
}
}
示例3: run
import org.springframework.boot.ApplicationArguments; //導入依賴的package包/類
@Override
public void run(ApplicationArguments args) throws Exception {
// user just wants to print help, do not try
// to init connection. HelpAwareShellApplicationRunner simply output
// usage and InteractiveModeApplicationRunner forces to run help.
if (ShellUtils.hasHelpOption(args)) {
return;
}
Target target = new Target(skipperClientProperties.getServerUri(), skipperClientProperties.getUsername(),
skipperClientProperties.getPassword(), skipperClientProperties.isSkipSslValidation());
// Attempt connection (including against default values) but do not crash the shell on
// error
try {
targetHolder.changeTarget(target, null);
}
catch (Exception e) {
resultHandler.handleResult(e);
}
}
開發者ID:spring-cloud,項目名稱:spring-cloud-skipper,代碼行數:23,代碼來源:InitializeConnectionApplicationRunner.java
示例4: run
import org.springframework.boot.ApplicationArguments; //導入依賴的package包/類
@Override
public void run(ApplicationArguments args) throws Exception {
// if we have args, assume one time run
ArrayList<String> argsToShellCommand = new ArrayList<>();
for (String arg : args.getSourceArgs()) {
// consider client connection options as non command args
if (!arg.contains("spring.cloud.skipper.client")) {
argsToShellCommand.add(arg);
}
}
if (argsToShellCommand.size() > 0) {
if (ShellUtils.hasHelpOption(args)) {
// going into 'help' mode. HelpAwareShellApplicationRunner already
// printed usage, we just force running just help.
argsToShellCommand.clear();
argsToShellCommand.add("help");
}
}
if (!argsToShellCommand.isEmpty()) {
InteractiveShellApplicationRunner.disable(environment);
shell.run(new StringInputProvider(argsToShellCommand));
}
}
示例5: run
import org.springframework.boot.ApplicationArguments; //導入依賴的package包/類
@Override
public void run(ApplicationArguments args) {
Instant deletionCutoff = new Instant().minus(housekeeping.getExpiredPathDuration());
LOG.info("Housekeeping at instant {} has started", deletionCutoff);
CompletionCode completionCode = CompletionCode.SUCCESS;
try {
housekeepingService.cleanUp(deletionCutoff);
LOG.info("Housekeeping at instant {} has finished", deletionCutoff);
} catch (Exception e) {
completionCode = CompletionCode.FAILURE;
LOG.error("Housekeeping at instant {} has failed", deletionCutoff, e);
throw e;
} finally {
Map<String, Long> metricsMap = ImmutableMap
.<String, Long> builder()
.put("housekeeping", completionCode.getCode())
.build();
metricSender.send(metricsMap);
}
}
示例6: run
import org.springframework.boot.ApplicationArguments; //導入依賴的package包/類
@Override
public void run(ApplicationArguments args) throws InterruptedException {
while (true) {
try {
if(LOG.isDebugEnabled()) {
LOG.debug(" In Run: " + System.currentTimeMillis());
}
marathonSDService.updateServiceData();
f5ScraperService.updateF5Stats();
for (Map.Entry<String, F5ScraperService.F5Stats> stats : f5ScraperService.getF5StatsMap().entrySet()) {
LOG.info("Service id: " + stats.getKey()
+ " serviceConfig: " + stats.getValue());
if (isScalable(stats.getValue())) {
scaleIfRequired(stats);
}
}
isHealthy = true;
} catch (Exception e) {
isHealthy = false;
LOG.error("Exception", e);
} finally {
waitFor(props.getService().getSchedulingIntervalInSecs() * 1000);
}
}
}
示例7: run
import org.springframework.boot.ApplicationArguments; //導入依賴的package包/類
public void run(ApplicationArguments args) {
new Thread(new Runnable() {
@Override
public void run() {
while (true) {
long time = System.currentTimeMillis();
producer.sendHeightQueue("lowQueue message " + time);
producer.sendMiddleQueue("middleQueue message " + time);
producer.sendLowQueue("lowQueue message " + time);
producer.publishHeightTopic("heightTopic message " + time);
producer.publishMiddleTopic("middleTopic message " + time);
producer.publishLowTopic("lowTopic message " + time);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}).run();
}
示例8: run
import org.springframework.boot.ApplicationArguments; //導入依賴的package包/類
@Override
public void run(ApplicationArguments arg0) throws Exception {
final String FIRST_TIME = "FIRST_TIME";
if (turConfigVarRepository.findById(FIRST_TIME) == null) {
System.out.println("First Time Configuration ...");
turLocaleOnStartup.createDefaultRows();
turNLPVendorOnStartup.createDefaultRows();
turNLPEntityOnStartup.createDefaultRows();
turNLPVendorEntityOnStartup.createDefaultRows();
turNLPFeatureOnStartup.createDefaultRows();
turNLPInstanceOnStartup.createDefaultRows();
turMLVendorOnStartup.createDefaultRows();
turMLInstanceOnStartup.createDefaultRows();
turSEVendorOnStartup.createDefaultRows();
turSEInstanceOnStartup.createDefaultRows();
turDataGroupStartup.createDefaultRows();
turSNSiteOnStartup.createDefaultRows();
turConfigVarOnStartup.createDefaultRows();
System.out.println("Configuration finished.");
}
}
示例9: run
import org.springframework.boot.ApplicationArguments; //導入依賴的package包/類
@Override
public void run(ApplicationArguments args) throws Exception {
DataFileReader<BaseItemTypes> baseItemTypeReader = dataFileReaderFactory.create(BaseItemTypes.class);
DataFileReader<ComponentAttributeRequirement> attrReqReader = dataFileReaderFactory.create(ComponentAttributeRequirement.class);
List<ItemData> items = baseItemTypeReader.read()
.filter(row -> row.getInheritsFrom().contains("Abstract"))
.flatMap(baseItemType -> {
return attrReqReader.read()
.filter(componentAttributeRequirement -> componentAttributeRequirement.getBaseItemTypesKey().equals(baseItemType));
}).map(ItemData::new)
.collect(toList());
File outFile = Paths.get("item-data.json").toFile();
log.info("Writing to {}", outFile.getAbsolutePath());
objectMapper.writerWithDefaultPrettyPrinter().writeValue(outFile, items);
}
示例10: run
import org.springframework.boot.ApplicationArguments; //導入依賴的package包/類
@Override
public void run(ApplicationArguments args) throws Exception {
ImageBanner imageBanner = new ImageBanner(
this.resolveInputImage());
int maxWidth = this.properties.getMaxWidth();
double aspectRatio = this.properties.getAspectRatio();
boolean invert = this.properties.isInvert();
Resource output = this.properties.getOutput();
String banner = imageBanner.printBanner(maxWidth, aspectRatio, invert);
if (output != null) {
try (PrintWriter pw = new PrintWriter(output.getFile(), "UTF-8")) {
pw.println(banner);
}
} else {
System.out.println(banner);
}
}
示例11: TaskLifecycleListener
import org.springframework.boot.ApplicationArguments; //導入依賴的package包/類
/**
* @param taskRepository The repository to record executions in.
*/
public TaskLifecycleListener(TaskRepository taskRepository,
TaskNameResolver taskNameResolver,
ApplicationArguments applicationArguments, TaskExplorer taskExplorer,
TaskProperties taskProperties) {
Assert.notNull(taskRepository, "A taskRepository is required");
Assert.notNull(taskNameResolver, "A taskNameResolver is required");
Assert.notNull(taskExplorer, "A taskExplorer is required");
Assert.notNull(taskProperties, "TaskProperties is required");
this.taskRepository = taskRepository;
this.taskNameResolver = taskNameResolver;
this.applicationArguments = applicationArguments;
this.taskExplorer = taskExplorer;
this.taskProperties = taskProperties;
}
示例12: run
import org.springframework.boot.ApplicationArguments; //導入依賴的package包/類
@Override
public void run(ApplicationArguments applicationArguments) throws Exception {
boolean mapsProvided = applicationArguments.containsOption("maps");
if (mapsProvided) {
List<String> maps = applicationArguments.getOptionValues("maps");
maps.forEach(map -> AppConfig.experimentMaps.addAll(Arrays.asList(map.split(","))));
List<String> toRemove = new ArrayList<>();
AppConfig.experimentMaps.forEach(file -> {
File f = new File(file);
if (f.isDirectory()) {
toRemove.add(file);
List<String> files = Arrays
.stream(f.listFiles((dir, name) -> name.toLowerCase().endsWith(".yaml")))
.map(File::getAbsolutePath).collect(Collectors.toList());
AppConfig.experimentMaps.addAll(files);
}
});
AppConfig.experimentMaps.removeAll(toRemove);
}
boolean resultsDir = applicationArguments.containsOption("results");
if (resultsDir) {
List<String> outDirs = applicationArguments.getOptionValues("results");
if (outDirs.size() > 1) {
throw new IllegalArgumentException("Cannot have more than 1 results directories");
}
AppConfig.outputDir = outDirs.get(0);
}
}
示例13: run
import org.springframework.boot.ApplicationArguments; //導入依賴的package包/類
@Override
@SuppressFBWarnings("DM_EXIT")
public void run(ApplicationArguments args) {
try {
System.out.println("To: "+to); //NOPMD
generateIntegrationProject(new File(to));
} catch (IOException e) {
e.printStackTrace(); //NOPMD
System.exit(1); //NOPMD
}
}
示例14: run
import org.springframework.boot.ApplicationArguments; //導入依賴的package包/類
@Override
public void run(ApplicationArguments args) {
LOG.info("{} tables to compare.", tableReplications.size());
for (TableReplication tableReplication : tableReplications) {
try {
TableComparator tableComparison = tableComparisonFactory.newInstance(tableReplication);
tableComparison.run();
} catch (Throwable t) {
LOG.error("Failed.", t);
}
}
}
示例15: validate
import org.springframework.boot.ApplicationArguments; //導入依賴的package包/類
private void validate(ApplicationArguments args) {
List<String> optionValues = args.getOptionValues(OUTPUT_FILE);
if (optionValues == null) {
throw new IllegalArgumentException("Missing --" + OUTPUT_FILE + " argument");
} else if (optionValues.isEmpty()) {
throw new IllegalArgumentException("Missing --" + OUTPUT_FILE + " argument value");
}
outputFile = new File(optionValues.get(0));
}