Java Code Examples for org.springframework.boot.SpringApplication#addListeners()

The following examples show how to use org.springframework.boot.SpringApplication#addListeners() . 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: Osiam.java    From osiam with MIT License 6 votes vote down vote up
public static void main(String[] args) {
    SpringApplication application = new SpringApplication();
    String command = new CliCommand(args).get();
    OsiamHome osiamHome = new OsiamHome();
    if ("initHome".equals(command)) {
        application.setSources(Collections.<Object>singleton(InitHome.class));
        application.setWebEnvironment(false);
    } else if ("migrateDb".equals(command)) {
        application.setSources(Collections.<Object>singleton(MigrateDb.class));
        application.setWebEnvironment(false);
        osiamHome.shouldInitializeHome(false);
    } else {
        application.setSources(Collections.<Object>singleton(Osiam.class));
    }
    application.addListeners(osiamHome);
    application.setDefaultProperties(DEFAULT_PROPERTIES);
    application.run(args);
}
 
Example 2
Source File: ContainerApplication.java    From tac with MIT License 6 votes vote down vote up
public static void main(String[] args) throws Exception {

        // the code must execute before spring start
        JarFile bootJarFile = BootJarLaucherUtils.getBootJarFile();
        if (bootJarFile != null) {
            BootJarLaucherUtils.unpackBootLibs(bootJarFile);
            log.debug("the temp tac lib folder:{}", BootJarLaucherUtils.getTempUnpackFolder());
        }
        SpringApplication springApplication = new SpringApplication(ContainerApplication.class);

        springApplication.setWebEnvironment(true);
        springApplication.setBannerMode(Banner.Mode.OFF);

        springApplication.addListeners(new ApplicationListener<ApplicationEnvironmentPreparedEvent>() {
            @Override
            public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
                CodeLoadService.changeClassLoader(event.getEnvironment());
            }
        });
        springApplication.run(args);
    }
 
Example 3
Source File: FileCenterApp.java    From open-capacity-platform with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
	// 固定端口
	// SpringApplication.run(FileCenterApp.class, args);

	// 随机端口启动
	SpringApplication app = new SpringApplication(FileCenterApp.class);
	app.addListeners(new PortApplicationEnvironmentPreparedEventListener());
	app.run(args);

}
 
Example 4
Source File: UserCenterApp.java    From open-capacity-platform with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
//		固定端口启动
//		SpringApplication.run(UserCenterApp.class, args);
		
		//随机端口启动
		SpringApplication app = new SpringApplication(UserCenterApp.class);
        app.addListeners(new PortApplicationEnvironmentPreparedEventListener());
        app.run(args);
		
	}
 
Example 5
Source File: GatewayApplication.java    From WeEvent with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
    SpringApplication app = new SpringApplication(GatewayApplication.class);
    app.addListeners(new ApplicationPidFileWriter());
    app.run();

    log.info("start gateway success");
}
 
Example 6
Source File: ParaServer.java    From para with Apache License 2.0 5 votes vote down vote up
/**
 * This is the initializing method when running ParaServer as executable JAR (or WAR),
 * from the command line: java -jar para.jar.
 * @param args command line arguments array (same as those in {@code void main(String[] args)} )
 * @param sources the application classes that will be scanned
 */
public static void runAsJAR(String[] args, Class<?>... sources) {
	// entry point (JAR)
	SpringApplication app = new SpringApplication(sources);
	app.setAdditionalProfiles(Config.ENVIRONMENT);
	app.setWebApplicationType(WebApplicationType.SERVLET);
	app.setBannerMode(Banner.Mode.OFF);
	if (Config.getConfigBoolean("pidfile_enabled", true)) {
		app.addListeners(new ApplicationPidFileWriter(Config.PARA + "_" + getServerPort() + ".pid"));
	}
	initialize(getCoreModules());
	app.run(args);
}
 
Example 7
Source File: BrokerApplication.java    From WeEvent with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
    /* Forbid banner.
    SpringApplicationBuilder builder = new SpringApplicationBuilder(BrokerApplication.class);
    builder.bannerMode(Banner.Mode.OFF).run(args);
    */
    SpringApplication app = new SpringApplication(BrokerApplication.class);
    app.addListeners(new ApplicationPidFileWriter());
    app.run();

    log.info("start broker success");
}
 
Example 8
Source File: ComponentStatusApplication.java    From kardio with Apache License 2.0 5 votes vote down vote up
/**
   * Entry Point.
   * 
   * @param args
   */
  public static void main(String[] args) {
      SpringApplication springApplication = new SpringApplication(ComponentStatusApplication.class);
ApplicationPidFileWriter appPidWriter = new ApplicationPidFileWriter("kardio-api.pid");
      springApplication.addListeners(appPidWriter);
      springApplication.run(args);
  }
 
Example 9
Source File: MicroServiceServer.java    From micro-service with MIT License 5 votes vote down vote up
public static void main(String[] args) throws Exception {
  	
SpringApplication application = new SpringApplication(MicroServiceServer.class);
application.addListeners(new StartedEventApplicationListener(), 
		new EnvironmentPreparedEventApplicationListener(), 
		new PreparedEventApplicationListener(), 
		new FailedEventApplicationListener());
application.run(args);
  	
      logger.info("micro-service-server is running...");
  }
 
Example 10
Source File: SpringStorageApp.java    From pampas with Apache License 2.0 5 votes vote down vote up
public static void init(String[] args, BiConsumer<ApplicationContext, ServerProperties> listener) {
    SpringApplication springApplication = new SpringApplication(SpringStorageApp.class);
    springApplication.addListeners((ApplicationListener<ContextRefreshedEvent>) event -> {
        log.info("网关存储层启动完成");
        ServerProperties properties = SpringContextHolder.getBean(ServerProperties.class);
        if (listener != null) {
            log.info("网关加载启动监听");
            listener.accept(applicationContext, properties);
        }
    });
    springApplication.run(args);
}
 
Example 11
Source File: PiperApplication.java    From piper with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {
  SpringApplication springApplication = new SpringApplication(PiperApplication.class);
  springApplication.addListeners(new ApplicationPidFileWriter());
  springApplication.run(args);
}
 
Example 12
Source File: ChengfengApplication.java    From ChengFeng1.5 with MIT License 4 votes vote down vote up
public static void main(String[] args) {
    System.setProperty("es.set.netty.runtime.available.processors", "false");//ElasticSearch启动报错
    SpringApplication application=new SpringApplication(ChengfengApplication.class);
    application.addListeners(new ChengfengReadyListener());
    application.run(args);
}
 
Example 13
Source File: SampleWebUiApplication.java    From enhanced-pet-clinic with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
	SpringApplication springApplication = new SpringApplication(SampleWebUiApplication.class);
	springApplication.addListeners(new ApplicationPidFileWriter(), new EmbeddedServerPortFileWriter());
	springApplication.run(args);
}
 
Example 14
Source File: RagnarApplication.java    From fiery with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {
    SpringApplication springApplication = new SpringApplication(RagnarApplication.class);
    springApplication.addListeners(new ApplicationPidFileWriter());
    springApplication.run(args);
}
 
Example 15
Source File: FamousGameApplication.java    From Almost-Famous with MIT License 4 votes vote down vote up
public static void main(String[] args) {
    SpringApplication application = new SpringApplication(FamousGameApplication.class);
    application.addListeners(new ApplicationEventListener());
    application.run(args);
}
 
Example 16
Source File: DataAppServiceApplication.java    From DataM with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {
    SpringApplication springApplication =new SpringApplication(DataAppServiceApplication.class);
    springApplication.addListeners(new ApplicationStartup());
    springApplication.run(args);
    logger.info("============= SpringBoot Start Success =============");
}
 
Example 17
Source File: Application.java    From mojito with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws IOException {

        SpringApplication springApplication = new SpringApplication(Application.class);
        springApplication.addListeners(new ApplicationPidFileWriter("application.pid"));
        springApplication.run(args);
    }
 
Example 18
Source File: GovernanceApplication.java    From WeEvent with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args)  {
    SpringApplication app = new SpringApplication(GovernanceApplication.class);
    app.addListeners(new ApplicationPidFileWriter());
    app.run(args);
    log.info("Start Governance success");
}
 
Example 19
Source File: DataAppConsumerApplication.java    From DataM with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {
    SpringApplication springApplication =new SpringApplication(DataAppConsumerApplication.class);
    springApplication.addListeners(new ApplicationStartup());
    springApplication.run(args);
    logger.info("============= SpringBoot Start Success =============");
}
 
Example 20
Source File: Application.java    From youkefu with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {
	SpringApplication springApplication = new SpringApplication(Application.class) ;
	springApplication.addListeners(new StartedEventListener());
	UKDataContext.setApplicationContext(springApplication.run(args));
}