/** * Shuts down the Snow Owl application by performing shut down logic. */ public void shutdown() { if (isRunning()) { LOG.info("Snow Owl is shutting down."); this.environment.services().dispose(); LifecycleUtil.deactivate(environment.container()); running.set(false); } }
/** * Runs the application by performing all necessary initialization logic * like service registrations, etc. * * @param preRunRunnable * - to execute logic between * {@link Bootstrap#preRun(SnowOwlConfiguration, Environment)} * and * {@link Bootstrap#run(SnowOwlConfiguration, Environment, IProgressMonitor)} * @param monitor * - to monitor application startup */ public void run(PreRunRunnable preRunRunnable, IProgressMonitor monitor) throws Exception { if (!isRunning()) { checkState(bootstrap != null, "Bootstrap the application first"); if (preRunCompleted.compareAndSet(false, true)) { this.bootstrap.preRun(configuration, environment); } if (preRunRunnable != null) { preRunRunnable.run(); } LOG.info("Preparing to run Snow Owl..."); this.bootstrap.run(configuration, environment, monitor); checkApplicationState(); running.set(true); LOG.info("Snow Owl successfully started."); } else { LOG.info("Snow Owl is already running."); } }
/** * Bootstraps the application to a minimum runnable form. * * @param configPath * - the configuration file path to use * @param fragments - additional {@link BootstrapFragment} instances to use during initialization */ public void bootstrap(String configPath, BootstrapFragment...fragments) throws Exception { if (!isRunning()) { LOG.info("Bootstrapping Snow Owl..."); this.bootstrap = new Bootstrap(fragments); this.configuration = createConfiguration(bootstrap, configPath); this.environment = new Environment(bootstrap, configuration); logEnvironment(); this.bootstrap.init(this.configuration, this.environment); // after init checks try { this.environment.service(IUserManager.class); } catch (Exception e) { throw new InitializationException("UserManager should be registered after the bootstrap process."); } } }