org.springframework.boot.ApplicationArguments Java Examples
The following examples show how to use
org.springframework.boot.ApplicationArguments.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InitializeConnectionApplicationRunner.java From spring-cloud-skipper with Apache License 2.0 | 6 votes |
@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); } }
Example #2
Source File: SetupDefaultData.java From KOMORAN with Apache License 2.0 | 6 votes |
@Override public void run(ApplicationArguments args) throws IOException { logger.debug("DicWord : " + dicWordRepository.count()); logger.debug("GrammarIn : " + grammarInRepository.count()); // Initialize DicWord if (dicWordRepository.count() <= 0 && getDefaultFilePath("dicword") != null) { logger.debug("Importing DicWord from file named " + filenameDicWord); dicWordService.importFromFile(getDefaultFilePath("dicword")); } // Initialize GrammarIn if (grammarInRepository.count() <= 0 && getDefaultFilePath("grammarin") != null) { logger.debug("Importing GrammarIn from file named " + filenameGrammarIn); grammarInService.importFromFile(getDefaultFilePath("grammarin")); } }
Example #3
Source File: BootifulBannersApplication.java From bootiful-banners with Apache License 2.0 | 6 votes |
@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); } }
Example #4
Source File: ReservationServiceApplication.java From bootiful-reactive-microservices with Apache License 2.0 | 6 votes |
@Override public void run(ApplicationArguments args) throws Exception { Flux<String> stringFlux = Flux .just("Josh", "Rada", "Jason", "Ming", "Kieran", "Rudrakshi", "Sean", "Sumi"); Flux<Reservation> flux = stringFlux .map(name -> new Reservation(null, name)) .flatMap(this.reservationRepository::save); this.reservationRepository .deleteAll() .thenMany(flux) .thenMany(this.reservationRepository.findAll()) .subscribe(System.out::println); }
Example #5
Source File: TweetServiceApplication.java From reactive-spring-online-training with Apache License 2.0 | 6 votes |
@Override public void run(ApplicationArguments args) throws Exception { Author viktor = new Author("viktorklang"); Author jboner = new Author("jboner"); Author josh = new Author("starbuxman"); Flux<Tweet> tweets = Flux.just( new Tweet(viktor, "woot, @Konrad will be talking #enterprise #integration done right!"), new Tweet(viktor, "#scala implicits can easily be used to model capabilities, but can they encode obligations easily?"), new Tweet(viktor, "this is so cool! #akka"), new Tweet(jboner, "cross data center replication of event sourced #akka actors is soon available (using #crdts and more!)"), new Tweet(josh, "a reminder: @SpringBoot lets you pair program with the #Spring team. #bootiful"), new Tweet(josh, "whatever your next platform is, don't build it yourself.\n\n" + "Even companies with the $$ and the motivation to do it fail. A LOT. #bootiful") ); this .tweetRepository .deleteAll() .thenMany(tweets.flatMap(tweetRepository::save)) .thenMany(tweetRepository.findAll()) // .subscribeOn(Schedulers.fromExecutor(Executors.newSingleThreadExecutor())) .subscribe(System.out::println); }
Example #6
Source File: FabricEdgeRunner.java From fabric-net-server with Apache License 2.0 | 6 votes |
@Override public void run(ApplicationArguments args) { if (!hadSuperAdmin()) { initRola(); } addUser(); System.out.println(); System.out.println(" _____ _ _ ____ "); System.out.println("| ____| | \\ | | | _ \\ "); System.out.println("| _| | \\| | | | | | "); System.out.println("| |___ | |\\ | | |_| | "); System.out.println("|_____| |_| \\_| |____/ "); System.out.println(); System.out.println("===================== please make your fabric net work ===================== "); System.out.println(); System.out.println("================================= read logs ================================ "); }
Example #7
Source File: HelpAwareShellApplicationRunner.java From spring-cloud-skipper with Apache License 2.0 | 6 votes |
@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); } }
Example #8
Source File: HousekeepingRunner.java From circus-train with Apache License 2.0 | 6 votes |
@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); } }
Example #9
Source File: InteractiveModeApplicationRunner.java From spring-cloud-skipper with Apache License 2.0 | 6 votes |
@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)); } }
Example #10
Source File: AoomsApplicationRunner.java From Aooms with Apache License 2.0 | 6 votes |
@Override public void run(ApplicationArguments applicationArguments) { LogUtils.info("Aooms("+ Aooms.VERSION +") Start Sucess, At " + DateUtil.now()); ApplicationContext context = SpringUtils.getApplicationContext(); ServiceConfigurations serviceConfigurations = context.getBean(ServiceConfigurations.class); AoomsWebMvcConfigurer webMvcConfigurer = (AoomsWebMvcConfigurer) context.getBean("webMvcConfigurer"); String[] beanNames = context.getBeanNamesForType(AoomsSetting.class); LogUtils.info("SettingBeanNames = " + JSON.toJSONString(beanNames)); for(String name : beanNames){ AoomsSetting settingBean = (AoomsSetting)context.getBean(name); //settingBean.configInterceptor(webMvcConfigurer.getInterceptorRegistryProxy()); settingBean.configProps(Aooms.self().getPropertyObject()); settingBean.configService(serviceConfigurations); settingBean.onFinish(Aooms.self()); } //Set<Class<?>> classes = ClassScaner.scanPackageByAnnotation("net",AoomsSettingBean.class); //System.err.println(classes.size()); }
Example #11
Source File: WebApplication.java From TrackRay with GNU General Public License v3.0 | 5 votes |
private static void run(String[] args, ApplicationArguments applicationArguments) { if (!applicationArguments.getNonOptionArgs().isEmpty()){ List<String> funcArgs = applicationArguments.getNonOptionArgs(); for (String f : TrackrayConfiguration.Function.names()) { if (funcArgs.contains(f)){ //TrackrayConfiguration.sysVariable.put(f,true); TrackrayConfiguration.Function.valueOf(f).setEnable(true); }else{ //TrackrayConfiguration.sysVariable.put(f,false); TrackrayConfiguration.Function.valueOf(f).setEnable(false); } } } if (!applicationArguments.getOptionNames().isEmpty()){ if (applicationArguments.containsOption("burp.local")){ BurpSuiteConfiguration.mode = BurpSuiteConfiguration.Mode.LOCAL; }else if (applicationArguments.containsOption("burp.remote")){ BurpSuiteConfiguration.mode = BurpSuiteConfiguration.Mode.REMOTE; } } loadPlugins(applicationArguments); SpringApplication.run(WebApplication.class, args); }
Example #12
Source File: GenericTaskRunner.java From super-cloudops with Apache License 2.0 | 5 votes |
/** * Auto initialization on startup. * * @throws Exception */ @Override public void run(ApplicationArguments args) throws Exception { if (running.compareAndSet(false, true)) { // Call PreStartup preStartupProperties(); // Create worker(if necessary) if (config.getConcurrency() > 0) { // See:https://www.jianshu.com/p/e7ab1ac8eb4c ThreadFactory tf = new NamedThreadFactory(getClass().getSimpleName() + "-worker"); worker = new SafeEnhancedScheduledTaskExecutor(config.getConcurrency(), config.getKeepAliveTime(), tf, config.getAcceptQueue(), config.getReject()); } else { log.warn("No start threads worker, because the number of workthreads is less than 0"); } // Boss asynchronously execution.(if necessary) if (config.isAsyncStartup()) { boss = new NamedThreadFactory(getClass().getSimpleName() + "-boss").newThread(this); boss.start(); } else { run(); // Sync execution. } // Call post startup postStartupProperties(); } else { log.warn("Could not startup runner! because already builders are read-only and do not allow task modification"); } }
Example #13
Source File: InitApplicationRunner.java From Fame with MIT License | 5 votes |
@Transactional(rollbackFor = Throwable.class) @Override public void run(ApplicationArguments args) throws Exception { log.info("Initializing Fame after springboot loading completed..."); long startTime = System.currentTimeMillis(); boolean isInit = optionService.get(OptionKeys.FAME_INIT, Boolean.FALSE); if (!isInit) { createDefaultIfAbsent(); } initDispatcherServlet(); log.info("Fame initialization in " + (System.currentTimeMillis() - startTime) + " ms"); }
Example #14
Source File: LoadGeneratorMain.java From titus-control-plane with Apache License 2.0 | 5 votes |
@Bean @Named(SimulatedRemoteInstanceCloudConnector.SIMULATED_CLOUD) public Channel getSimulatedCloudChannel(ApplicationArguments arguments) { List<String> cloud = arguments.getOptionValues("cloud"); String cloudAddress = CollectionsExt.isNullOrEmpty(cloud) ? "localhost:8093" : cloud.get(0); return NettyChannelBuilder .forTarget(cloudAddress) .usePlaintext(true) .maxHeaderListSize(65536) .build(); }
Example #15
Source File: GRpcServerApplicationRunner.java From faster-framework-project with Apache License 2.0 | 5 votes |
@Override public void run(ApplicationArguments args) throws Exception { List<BindServiceAdapter> bindServiceAdapterList = serverBuilderConfigure.getBindServiceAdapterList(); if (CollectionUtils.isEmpty(bindServiceAdapterList)) { log.info("GRpc server services empty.GRpc server is not start."); return; } ServerBuilder serverBuilder = serverBuilderConfigure.serverBuilder(); for (BindServiceAdapter bindServiceAdapter : bindServiceAdapterList) { serverBuilder.addService(bindServiceAdapter); } this.server = serverBuilder.build().start(); startDaemonAwaitThread(); log.info("GRpc start success, listening on port {}.", serverBuilderConfigure.getPort()); }
Example #16
Source File: EmployeeService.java From spring-boot-multi-tenancy with MIT License | 5 votes |
@Override public void run(ApplicationArguments applicationArguments) throws Exception { TenantContext.setCurrentTenant("tenant1"); employeeRepository.save(new Employee(null, "John", "Doe", null)); TenantContext.setCurrentTenant("tenant2"); employeeRepository.save(new Employee(null, "Jane", "Doe", null)); TenantContext.clear(); }
Example #17
Source File: BinLogApplicationRunner.java From kkbinlog with Apache License 2.0 | 5 votes |
@Override public void run(ApplicationArguments applicationArguments) { Map<String, DistributorService> distributorServiceMap = context.getBeansOfType(DistributorService.class); distributorServiceMap.forEach((s, distributorService) -> { distributorService.startDistribute(); }); binaryLogConfigContainer.registerConfigCommandWatcher(); }
Example #18
Source File: RemoveTokenRunner.java From mini-platform with MIT License | 5 votes |
@Override public void run(ApplicationArguments args) { log.info("启动清除Token任务!"); RemoveAccessTokenThread accessTokenExpiredThread = new RemoveAccessTokenThread(accessTokenService, stringRedisTemplate); accessTokenExpiredThread.start(); RemoveRefreshTokenThread refreshTokenExpiredThread = new RemoveRefreshTokenThread(refreshTokenService); refreshTokenExpiredThread.start(); }
Example #19
Source File: ExportManageServerRunner.java From sofa-lookout with Apache License 2.0 | 5 votes |
/** * 暴露6200管理端口 */ @Override public void run(ApplicationArguments args) throws Exception { RouterFunction manageRouterFunction = RouterFunctions .route(RequestPredicates.GET("/ok"), req -> { return ServerResponse.ok() .syncBody("online"); }) .andRoute(RequestPredicates.GET("/cmd/{line}"), request -> { String pathVar = request.pathVariable("line"); try { if ("down".equals(pathVar)) { refuseRequestService.setRefuseRequest(true); } else if ("up".equals(pathVar)) { refuseRequestService.setRefuseRequest(false); } return ServerResponse.ok().body(Mono.just("ok"), String.class); } catch (Throwable e) { LOGGER.error("{} request err!", pathVar, e); return ServerResponse.status(HttpStatus.INTERNAL_SERVER_ERROR).build(); } }); HttpHandler handler = RouterFunctions.toHttpHandler(manageRouterFunction); int managePort = serverPort - 1000; ReactorHttpHandlerAdapter inboundAdapter = new ReactorHttpHandlerAdapter(handler); // manage port HttpServer.create().port(managePort).handle(inboundAdapter).bind(); // HttpServer.create(managePort).newHandler(inboundAdapter).block(); LOGGER.info("management services run on port:{}", managePort); }
Example #20
Source File: FeignClientApplication.java From spring-cloud-release-tools with Apache License 2.0 | 5 votes |
@Bean public ApplicationRunner runner(final UrlRestClient client) { return new ApplicationRunner() { @Override public void run(ApplicationArguments args) throws Exception { System.err.println(client.hello()); } }; }
Example #21
Source File: DemoApplication.java From code-examples with MIT License | 5 votes |
@Override public void run(ApplicationArguments args) throws Exception { logger.info(addressClient.getAddresses().toString()); logger.info(addressClient.getAddress(1L).toString()); addressClient.associateWithCustomer(2L, "http://localhost:8080/customers_mto/1"); logger.info(addressClient.getCustomer(2L).toString()); }
Example #22
Source File: TaskDemo.java From tutorials with MIT License | 5 votes |
@Override public void run(ApplicationArguments arg0) throws Exception { // TODO Auto-generated method stub LOGGER .info("Hello World from Spring Cloud Task!"); }
Example #23
Source File: JobRunner.java From eladmin with Apache License 2.0 | 5 votes |
/** * 项目启动时重新激活启用的定时任务 * * @param applicationArguments / */ @Override public void run(ApplicationArguments applicationArguments) { log.info("--------------------注入定时任务---------------------"); List<QuartzJob> quartzJobs = quartzJobRepository.findByIsPauseIsFalse(); quartzJobs.forEach(quartzManage::addJob); log.info("--------------------定时任务注入完成---------------------"); }
Example #24
Source File: Application.java From tutorials with MIT License | 5 votes |
public static void restart() { ApplicationArguments args = context.getBean(ApplicationArguments.class); Thread thread = new Thread(() -> { context.close(); context = SpringApplication.run(Application.class, args.getSourceArgs()); }); thread.setDaemon(false); thread.start(); }
Example #25
Source File: CliParamsTest.java From lightning with MIT License | 5 votes |
@Test(expectedExceptions = RuntimeException.class) public void testGetFileFromOptionValue_notProvided() { ApplicationArguments args = Mockito.mock(ApplicationArguments.class); Mockito.when(args.containsOption("xml")).thenReturn(false); new CliParams(args).getFileFromOptionValue("xml"); }
Example #26
Source File: TestRunner.java From AuTe-Framework with Apache License 2.0 | 5 votes |
@Override public void run(ApplicationArguments args) { if (args.getNonOptionArgs().contains("execute")) { prepareLoggers(); try { launcher.launch(new ExternalVariables(args).get()); } catch (Exception e) { log.error("Error while running tests", e); } } }
Example #27
Source File: RepositoryTest.java From spring-boot-greendogdelivery-casadocodigo with GNU General Public License v3.0 | 5 votes |
public void run(ApplicationArguments applicationArguments) throws Exception { System.out.println(">>> Iniciando carga de dados..."); Cliente fernando = new Cliente(ID_CLIENTE_FERNANDO,"Fernando Boaglio","Sampa"); Cliente zePequeno = new Cliente(ID_CLIENTE_ZE_PEQUENO,"Zé Pequeno","Cidade de Deus"); Item dog1 = new Item(ID_ITEM1,"Green Dog tradicional",25d); Item dog2 = new Item(ID_ITEM2,"Green Dog tradicional picante",27d); Item dog3 = new Item(ID_ITEM3,"Green Dog max salada",30d); List<Item> listaPedidoFernando1 = new ArrayList<Item>(); listaPedidoFernando1.add(dog1); List<Item> listaPedidoZePequeno1 = new ArrayList<Item>(); listaPedidoZePequeno1.add(dog2); listaPedidoZePequeno1.add(dog3); Pedido pedidoDoFernando = new Pedido(ID_PEDIDO1,fernando,listaPedidoFernando1,dog1.getPreco()); fernando.novoPedido(pedidoDoFernando); Pedido pedidoDoZepequeno = new Pedido(ID_PEDIDO2,zePequeno,listaPedidoZePequeno1, dog2.getPreco()+dog3.getPreco()); zePequeno.novoPedido(pedidoDoZepequeno); System.out.println(">>> Pedido 1 - Fernando : "+ pedidoDoFernando); System.out.println(">>> Pedido 2 - Ze Pequeno: "+ pedidoDoZepequeno); clienteRepository.saveAndFlush(zePequeno); System.out.println(">>> Gravado cliente 2: "+zePequeno); List<Item> listaPedidoFernando2 = new ArrayList<Item>(); listaPedidoFernando2.add(dog2); Pedido pedido2DoFernando = new Pedido(ID_PEDIDO3,fernando,listaPedidoFernando2,dog2.getPreco()); fernando.novoPedido(pedido2DoFernando); clienteRepository.saveAndFlush(fernando); System.out.println(">>> Pedido 2 - Fernando : "+ pedido2DoFernando); System.out.println(">>> Gravado cliente 1: "+fernando); }
Example #28
Source File: GenerateCodeApplicationRunner.java From WeBASE-Codegen-Monkey with Apache License 2.0 | 5 votes |
@Override public void run(ApplicationArguments var1) throws Exception { log.info("Begin to generate code."); codeGenerateService.generateBee(); log.info("Code generation Finished!"); Runtime.getRuntime().exit(0); }
Example #29
Source File: StartJob.java From flash-waimai with MIT License | 5 votes |
@Override public void run(ApplicationArguments applicationArguments) throws Exception { log.info("start Job >>>>>>>>>>>>>>>>>>>>>>>"); List<QuartzJob> list = jobService.getTaskList(); for (QuartzJob quartzJob : list) { jobService.addJob(quartzJob); } }
Example #30
Source File: CliParamsTest.java From lightning with MIT License | 5 votes |
@Test public void testGetParsedCommand_report() { ApplicationArguments args = Mockito.mock(ApplicationArguments.class); List<String> values = Collections.singletonList("report"); Mockito.when(args.getNonOptionArgs()).thenReturn(values); Optional<String> command = new CliParams(args).getParsedCommand(); assertThat(command).isEqualTo(Optional.of("report")); }