customizeContext(context); context.refresh(); context.registerShutdownHook(); return context;
customizeContext(context, mergedConfig); context.refresh(); context.registerShutdownHook(); return context;
@Override protected ConfigurableApplicationContext createSingleton(Object... args) { LOGGER.info("Creating new lazily initialized GenericApplicationContext for the portal"); final long startTime = System.currentTimeMillis(); final GenericApplicationContext genericApplicationContext = new GenericApplicationContext(); final XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(genericApplicationContext); reader.setDocumentReaderClass(LazyInitByDefaultBeanDefinitionDocumentReader.class); File file = new File("."); try { URL context = file.toURI().toURL(); URL location = new URL(context, (String) args[0]); reader.loadBeanDefinitions(location.toExternalForm()); } catch (Exception e) { LOGGER.error("Failed to load bean definitions", e); } genericApplicationContext.refresh(); genericApplicationContext.registerShutdownHook(); directCreatorThrowable = new Throwable(); directCreatorThrowable.fillInStackTrace(); LOGGER.info("Created new lazily initialized GenericApplicationContext for the portal in " + (System.currentTimeMillis() - startTime) + "ms"); return genericApplicationContext; } }
protected ConfigurableApplicationContext createContext(CommandLine cli, Iterable<String> paths) { Map<String, BeanDefinition> additionalBeans = new HashMap<String, BeanDefinition>(); GenericApplicationContext ctx = new GenericApplicationContext(); XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(ctx); for (String path : paths) { if (path.startsWith(CLASSPATH_PREFIX)) { path = path.substring(CLASSPATH_PREFIX.length()); xmlReader.loadBeanDefinitions(new ClassPathResource(path)); } else if (path.startsWith(FILE_PREFIX)) { path = path.substring(FILE_PREFIX.length()); xmlReader.loadBeanDefinitions(new FileSystemResource(path)); } else { xmlReader.loadBeanDefinitions(new ClassPathResource(path)); } } for (Map.Entry<String, BeanDefinition> entry : additionalBeans.entrySet()) ctx.registerBeanDefinition(entry.getKey(), entry.getValue()); ctx.refresh(); ctx.registerShutdownHook(); return ctx; }
ctx.registerShutdownHook(); return ctx;
ctx.registerShutdownHook(); return ctx;
public void run(String... configLocations) { if (configLocations == null || configLocations.length < 1) { throw new IllegalArgumentException("Config location missing"); } GenericApplicationContext context = new GenericApplicationContext(); BeanDefinitionReader reader = new XmlBeanDefinitionReader(context); reader.loadBeanDefinitions(configLocations); boolean started = false; try { context.registerShutdownHook(); context.refresh(); logger.info("Application started"); started = true; } catch (RuntimeException e) { throw new RuntimeException("Application failed to start", e); } catch (Exception e) { throw new RuntimeException("Application failed to start", e); } finally { if (!started) { try { context.close(); } catch (Throwable e) { logger.error("Application has failed. Closing context failed too"); } } } }
AnnotationConfigUtils.registerAnnotationConfigProcessors(gac); gac.refresh(); gac.registerShutdownHook();
public static void runUsingProperties(Properties configProperties) throws Exception { GenericApplicationContext appCtx = new GenericApplicationContext(); appCtx.getEnvironment().getPropertySources().addLast( new PropertiesPropertySource("configFile", configProperties)); XmlBeanDefinitionReader xmlBDReader = new XmlBeanDefinitionReader(appCtx); xmlBDReader.loadBeanDefinitions(APP_CONTEXT_LOCATION); // register listeners Map<String, String> listenerImpls = getPrefixedKeyPairs(configProperties, PREFIX_LISTENER_ID); for (String listenerId : listenerImpls.keySet()) { String listenerClass = listenerImpls.get(listenerId); BeanDefinitionBuilder bb = genericBeanDefinition(listenerClass); Map<String, String> listenerProperties = getPrefixedKeyPairs(configProperties, PREFIX_LISTENER_PROPERTY + listenerId + "."); for (String propName : listenerProperties.keySet()) { bb.addPropertyValue(propName, listenerProperties.get(propName)); } appCtx.registerBeanDefinition(listenerId, bb.getBeanDefinition()); } appCtx.refresh(); appCtx.registerShutdownHook(); GoldStandardBasedEvaluation eval = appCtx.getBean(GoldStandardBasedEvaluation.class); eval.run(); }
genericApplicationContext.registerShutdownHook();
protected AbstractApplicationContext createRootApplicationContext() { GenericApplicationContext parent = new GenericApplicationContext(); parent.registerShutdownHook(); parent.getBeanFactory().registerSingleton("database", database.getGraph()); GraphAwareRuntime runtime = RuntimeRegistry.getRuntime(database.getGraph()); if (runtime != null) { runtime.waitUntilStarted(); parent.getBeanFactory().registerSingleton("databaseWriter", runtime.getDatabaseWriter()); } parent.refresh(); return parent; }
genericApplicationContext.registerShutdownHook();
@Override public AbstractApplicationContext createContext(NeoServer neoServer, StatsCollector statsCollector) { GenericApplicationContext parent = new GenericApplicationContext(); parent.registerShutdownHook(); parent.getBeanFactory().registerSingleton("database", neoServer.getDatabase().getGraph()); parent.getBeanFactory().registerSingleton("procedures", neoServer.getDatabase().getGraph().getDependencyResolver().resolveDependency(Procedures.class)); parent.getBeanFactory().registerSingleton("getStatsCollector", statsCollector); GraphAwareRuntime runtime = RuntimeRegistry.getRuntime(neoServer.getDatabase().getGraph()); if (runtime != null) { runtime.waitUntilStarted(); parent.getBeanFactory().registerSingleton("databaseWriter", runtime.getDatabaseWriter()); } parent.refresh(); return parent; } }
customizeContext(context); context.refresh(); context.registerShutdownHook(); return context;
customizeContext(context); context.refresh(); context.registerShutdownHook(); return context;
customizeContext(context, mergedConfig); context.refresh(); context.registerShutdownHook(); return context;
public Bootstrap(String[] args, String[] contextPath) { try { commandLine = SimpleShellCommandLineOptions.parseCommandLine(args); } catch (IOException e) { throw new ShellException(e.getMessage(), e); } ctx = new GenericApplicationContext(); ctx.registerShutdownHook(); configureApplicationContext(ctx); // built-in commands and converters ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(ctx); if (commandLine.getDisableInternalCommands()) { scanner.scan("org.springframework.shell.converters", "org.springframework.shell.plugin.support"); } else { scanner.scan("org.springframework.shell.commands", "org.springframework.shell.converters", "org.springframework.shell.plugin.support"); } // user contributed commands XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(ctx); reader.loadBeanDefinitions(contextPath); ctx.refresh(); }
customizeContext(context, mergedConfig); context.refresh(); context.registerShutdownHook(); return context;