List of usage examples for org.springframework.boot SpringApplication setRegisterShutdownHook
public void setRegisterShutdownHook(boolean registerShutdownHook)
From source file:com.revo.deployr.rbroker.example.FraudEngine.java
public static void main(String[] args) { SpringApplication app = new SpringApplication(FraudEngine.class); // Ensures @PreDestroy called on kill -1 <<pid>>. app.setRegisterShutdownHook(true); app.setShowBanner(false);//from w ww . jav a2s. co m app.run(args); log.info("Fraud Score application server has started."); log.info("Start the Fraud Score client application in your Web browser:\n"); log.info("http://localhost:9080/\n"); }
From source file:com.ewerk.prototype.PrototypeApplication.java
public static void main(String[] args) { final ApplicationPidFileWriter pidFileWriter = new ApplicationPidFileWriter(); pidFileWriter.setTriggerEventType(ApplicationEnvironmentPreparedEvent.class); SpringApplication application = new SpringApplication(PrototypeApplication.class); application.setHeadless(true);/*from ww w . j a v a 2 s . c o m*/ application.setRegisterShutdownHook(true); application.setLogStartupInfo(false); application.setWebEnvironment(true); application.addListeners(pidFileWriter); application.run(args); LOG.info("Prototype launched [OK]"); }
From source file:ubicrypt.UbiCrypt.java
@Override public void start(final Stage stage) throws Exception { setUserAgentStylesheet(STYLESHEET_MODENA); stage.setTitle("UbiCrypt"); anchor().setStage(stage);/*from w ww . j a v a2s . c om*/ try { final PGPKeyPair kp = encryptionKey(); encrypt(Collections.singletonList(kp.getPublicKey()), new ByteArrayInputStream(StringUtils.repeat("ciao", 1).getBytes())); } catch (Exception e) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("Strong Encryption Required"); alert.setHeaderText("Install JCE Unlimited Strength Jurisdiction policy files"); alert.setContentText( "You can install the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files, which are required to use strong encryption.\n" + "Download the files and instructions for Java 8.\n" + "Locate the jre\\lib\\security directory for the Java instance that the UbiCrypt is using.\n" + "For example, this location might be: C:\\Program Files\\Java\\jre8\\lib\\security.\n" + "Replace these two files with the .jar files included in the JCE Unlimited Strength Jurisdiction Policy Files download.\n" + "Stop and restart the UbiCrypt.\n\n\n\n\n\n"); ButtonType icePage = new ButtonType("Go to JCE download Page"); alert.getButtonTypes().addAll(icePage); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == icePage) { getHostServices().showDocument( "http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html"); } Platform.exit(); } final File secFile = securityFile().toFile(); stage.setScene(anchor().show(secFile.exists() ? "login" : "createKey", getHostServices())); stage.show(); final UbiCrypt ubiCrypt = this; anchor().getPasswordStream().subscribeOn(Schedulers.io()).subscribe(pwd -> { final SpringApplication app = new SpringApplication(UbiConf.class, PathConf.class, UIConf.class); app.setRegisterShutdownHook(false); app.addInitializers(new FixPassPhraseInitializer(pwd)); app.setLogStartupInfo(true); ctx = app.run(); ctx.getAutowireCapableBeanFactory().autowireBean(ubiCrypt); ctx.getBeanFactory().registerSingleton("stage", stage); ctx.getBeanFactory().registerSingleton("hostService", getHostServices()); ctx.getBeanFactory().registerSingleton("osUtil", new OSUtil(getHostServices())); ControllerFactory cfactory = new ControllerFactory(ctx); StackNavigator navigator = new StackNavigator(null, "main", cfactory); stage.setScene(new Scene(navigator.open())); }); stage.setOnCloseRequest(windowEvent -> shutdown.run()); Runtime.getRuntime().addShutdownHook(new Thread(shutdown)); }