本文整理匯總了Java中org.springframework.boot.ApplicationArguments.containsOption方法的典型用法代碼示例。如果您正苦於以下問題:Java ApplicationArguments.containsOption方法的具體用法?Java ApplicationArguments.containsOption怎麽用?Java ApplicationArguments.containsOption使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.boot.ApplicationArguments
的用法示例。
在下文中一共展示了ApplicationArguments.containsOption方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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 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);
}
}
示例3: run
import org.springframework.boot.ApplicationArguments; //導入方法依賴的package包/類
@Override
public void run(final ApplicationArguments args) throws Exception {
if (args.getOptionNames().isEmpty() || args.containsOption(HELP_FLAG)) {
printUsageInfo();
return;
}
executionConfigurator.initExecutionParameters(args);
logExecutionParameters();
try {
migrationTasks.stream()
.peek(migrationTask -> {
if (!migrationTask.isRequested()) {
log.debug("Skipping {} - not requested", migrationTask.getClass().getSimpleName());
}
})
.filter(MigrationTask::isRequested).forEach(MigrationTask::execute);
} catch (final Exception e) {
log.error("Migration has failed.", e);
} finally {
migrationReport.generate();
migrationReport.logErrors();
logExecutionParameters();
}
}
示例4: run
import org.springframework.boot.ApplicationArguments; //導入方法依賴的package包/類
@Override
public void run(ApplicationArguments args) throws Exception {
synchronize();
if (args.containsOption("adhoc")) {
LOG.info("Run only one import. Don't starting scheduler");
System.exit(0);
}
}
示例5: BurpService
import org.springframework.boot.ApplicationArguments; //導入方法依賴的package包/類
@Autowired
public BurpService(ApplicationArguments args, @Value("${headless.mode}") boolean headlessMode, @Value("${burp.edition}") String burpEdition)
throws IOException {
if (!headlessMode) {
log.info("Setting java.awt.headless to false...");
System.setProperty("java.awt.headless", Boolean.toString(false));
}
log.info("# of command line arguments received to Burp suite: {}", args.getSourceArgs().length);
log.info("Launching the Burp suite ({} edition) in {} mode...", burpEdition, headlessMode ? "headless" : "UI");
if (args.getSourceArgs().length == 0 || !args.containsOption(PROJECT_FILE)) {
Resource defaultProjectOptionsFile = new ClassPathResource(
"/static/burp-default-project-options.json");
Resource defaultUserOptionsFile = new ClassPathResource(
"/static/burp-default-user-options.json");
Path projectOptionsTempFile = Files.createTempFile("project-options", ".json");
Path userOptionsTempFile = Files.createTempFile("user-options", ".json");
FileCopyUtils
.copy(FileCopyUtils.copyToByteArray(defaultProjectOptionsFile.getInputStream()),
projectOptionsTempFile.toFile());
FileCopyUtils.copy(FileCopyUtils.copyToByteArray(defaultUserOptionsFile.getInputStream()),
userOptionsTempFile.toFile());
// As of Burp 1.7.03 version, --project-file option is mandatory to launch the jar in CI/CD pipeline.
// --config-file option is optional
String projectFileArgument = PROJECT_FILE_ARGUMENT + TEMPORARY_PROJECT_FILE_NAME;
String configFileArgumentWithProjectOptions =
CONFIG_FILE_ARGUMENT + projectOptionsTempFile.toAbsolutePath();
String configFileArgumentWithUserOptions =
CONFIG_FILE_ARGUMENT + userOptionsTempFile.toAbsolutePath();
// Free edition does not allow PROJECT_FILE_ARGUMENT
String[] burpOptions;
if (burpEdition.equalsIgnoreCase("free")) {
burpOptions = new String[] { configFileArgumentWithProjectOptions, configFileArgumentWithUserOptions };
} else {
burpOptions = new String[] { projectFileArgument,
configFileArgumentWithProjectOptions, configFileArgumentWithUserOptions };
}
log.info("Launching the Burp suite with options: {}", Arrays.toString(burpOptions));
burp.StartBurp.main(burpOptions);
// Deletes the temporary project file while exiting the application.
File file = new File(TEMPORARY_PROJECT_FILE_NAME);
file.deleteOnExit();
projectOptionsTempFile.toFile().deleteOnExit();
userOptionsTempFile.toFile().deleteOnExit();
} else {
log.info("Launching the Burp with options: {}", Arrays.toString(args.getSourceArgs()));
burp.StartBurp.main(args.getSourceArgs());
}
scans = new ScanQueueMap();
}
示例6: run
import org.springframework.boot.ApplicationArguments; //導入方法依賴的package包/類
@Override
public void run(ApplicationArguments arguments) throws Exception {
if (arguments.containsOption(OPTION_GENERATE_GRAPHITE_DATA)) {
for (int i = 0; i < 1000; i++) {
Long id = new Long((int) Math.ceil((i / 3.35) + 1));
System.out.println("***** GetCustomerById *****");
Customer customer = customerClient.getCustomerById(id);
printCustomer(customer);
System.out.println("***** GetCustomerByFirstName *****");
List<Customer> customers = customerClient.getCustomerByFirstName("Addison");
printCustomers(customers);
System.out.println("***** GetCustomerByLastName *****");
customers = customerClient.getCustomerByLastName("Alvin");
printCustomers(customers);
System.out.println("***** GetCustomerByFirstNameAndLastName *****");
customers = customerClient.getCustomerByFirstNameAndLastName("Carlos", "Lucius");
printCustomers(customers);
System.out.println("***** GetAllCustomers *****");
customers = customerClient.getAllCustomers();
System.out.println(">>> Total number of customers: " + customers.size());
System.out.println("***** CreateCustomer *****");
customer = customerClient.createCustomer(new Customer("John", "Doe"));
printCustomer(customer);
System.out.println("***** UpdateCustomer *****");
customer = customerClient
.updateCustomer(new Customer(customer.getId(), "Jane", customer.getLastName()));
printCustomer(customer);
System.out.println("***** DeleteCustomer *****");
customerClient.deleteCustomer(customer.getId());
System.out.println("***** GetCustomerByFirstNameAndLastName *****");
customers = customerClient.getCustomerByFirstNameAndLastName("Jane", "Doe");
printCustomers(customers);
}
}
}