List of usage examples for org.springframework.context.support ClassPathXmlApplicationContext refresh
@Override public void refresh() throws BeansException, IllegalStateException
From source file:com.all.rds.loader.Loader.java
public static void main(String[] args) { boolean isPlaylistOpt = parseArgs(args); ClassPathXmlApplicationContext appCtx = new ClassPathXmlApplicationContext("applicationContext.xml"); appCtx.refresh(); HibernateTemplate hibernateTemplate = (HibernateTemplate) appCtx.getBean("hibernateTemplate"); Loader loader = new Loader(hibernateTemplate); File baseDir = new File(args[args.length - 1]); if (isPlaylistOpt) { loader.loadAllPlaylists(baseDir); } else {/*from ww w. j av a2 s . co m*/ loader.loadAllTracks(baseDir); } }
From source file:com.thinkbiganalytics.server.KyloServerApplication.java
/** * Return the database version for Kylo. * * @return the version of Kylo stored in the database *//* w w w.ja v a2 s .c o m*/ private static KyloVersion getDatabaseVersion() { try { //ensure native profile is there for spring to load String profiles = System.getProperty("spring.profiles.active", ""); if (!profiles.contains("native")) { profiles = StringUtils.isEmpty(profiles) ? "native" : profiles + ",native"; System.setProperty("spring.profiles.active", profiles); } //Spring is needed to load the Spring Cloud context so we can decrypt the passwords for the database connection ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext( "kylo-upgrade-check-application-context.xml"); ctx.refresh(); KyloUpgradeDatabaseVersionChecker upgradeDatabaseVersionChecker = (KyloUpgradeDatabaseVersionChecker) ctx .getBean("kyloUpgradeDatabaseVersionChecker"); KyloVersion kyloVersion = upgradeDatabaseVersionChecker.getDatabaseVersion(); ctx.close(); return kyloVersion; } catch (Exception e) { log.error( "Failed get the database version prior to upgrade. The Kylo Upgrade application will load by default. {}", e.getMessage()); } return null; }
From source file:gemlite.core.util.Util.java
public final static ClassPathXmlApplicationContext initContext(boolean refresh, String... resources) { ClassPathXmlApplicationContext mainContext = new ClassPathXmlApplicationContext(resources, false); mainContext.setValidating(true);//from ww w . j a v a2 s . c om if (refresh) mainContext.refresh(); return mainContext; }
From source file:com.przemo.projectmanagementweb.Application.java
@Override protected void init() { super.init(); ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml"); ctx.refresh(); getComponentInstantiationListeners().add(new SpringComponentInjector(this, ctx)); Properties applicationProperties = new Properties(); try {/*ww w . java 2 s . co m*/ applicationProperties.load(this.getClass().getResourceAsStream("application.properties")); APPLICATION_VERSION = applicationProperties.getProperty(APPLICATION_VERSION_PROPERTY); } catch (IOException ex) { APPLICATION_VERSION = "_"; Logger.getLogger(Application.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:org.apache.axis2.sample.spring.service.SpringContextLoader.java
public void startUp(ConfigurationContext configctx, AxisService service) { ClassLoader classLoader = service.getClassLoader(); ClassPathXmlApplicationContext appCtx = new ClassPathXmlApplicationContext( new String[] { "applicationContext.xml" }, false); appCtx.setClassLoader(classLoader);/* w w w . j a v a 2 s. com*/ appCtx.refresh(); }
From source file:any.ejbtest.MoviesTest.java
@Test @Ignore/* w w w. j a v a 2 s . co m*/ public void testInEjbContext() throws Exception { ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("/ejb-context.xml"); applicationContext.refresh(); Movies moviesDefault = (Movies) applicationContext.getBean("moviesImpl"); Movies moviesLegacy = (Movies) applicationContext.getBean("moviesImplLegacy"); System.out.println("Default impl: "); for (Movie movie : moviesDefault.getAllMovies()) { System.out.println(movie); } assertEquals("moviesDefault : ", 2, moviesDefault.getAllMovies().size()); System.out.println("legacy impl: "); for (Movie movie : moviesLegacy.getAllMovies()) { System.out.println(movie); } assertEquals("moviesLegacy : ", 1, moviesLegacy.getAllMovies().size()); // start discriminator Movies moviesDiscriminatedInSpring = (Movies) DiscriminatorConfiguration.discriminateUsing( DiscriminatorForMovies.class, MoviesImplWrapper.class, MoviesImplLegacyWrapper.class); //get any spring bean annotated with @Discriminated or default bean Movies moviesBean = moviesDiscriminatedInSpring; //(Movies) applicationContext.getBean("moviesImplWrapper"); for (Movie movie : moviesBean.getAllMovies()) { System.out.println(movie); } assertEquals("moviesImplWrapper : ", 3, moviesBean.getAllMovies().size()); }
From source file:de.uniwue.dmir.heatmap.PointSpringTest.java
@SuppressWarnings({ "rawtypes", "unchecked" }) public void testHeatmap() throws IOException { System.setProperty("configDir", "classpath:spring/example/points/config"); System.setProperty("workDir", "out/points/work-jar"); // System.setProperty("spring.profiles.active", "minmax"); // System.setProperty("min", "2013-06-01 00:00:00"); // System.setProperty("max", "2013-07-01 00:00:00"); ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext( new String[] { "spring/example/points/config/config.xml" }, false); appContext.refresh(); IHeatmap heatmap = appContext.getBean(HEATMAP_BEAN, IHeatmap.class); ITileProcessor tileProcessor = appContext.getBean(WRITER_BEAN, ITileProcessor.class); heatmap.processTiles(tileProcessor); appContext.close();// ww w . j a v a 2 s. c o m }
From source file:de.uniwue.dmir.heatmap.SpringTest3.java
@SuppressWarnings({ "unchecked", "rawtypes" }) public void testHeatmap() throws IOException { System.setProperty("minTimestamp", "2013-06-01 00:00:00"); System.setProperty("maxTimestamp", "2013-07-30 00:00:00"); System.setProperty("workDir", "out/basic/work-jar"); System.setProperty("configDir", "src/main/resources/spring/example/basic/config"); ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext( new String[] { "spring/example/basic/config/config.xml" }, false); appContext.refresh(); IHeatmap heatmap = appContext.getBean(HEATMAP_BEAN, IHeatmap.class); ITileProcessor tileProcessor = appContext.getBean(WRITER_BEAN, ITileProcessor.class); heatmap.processTiles(tileProcessor); tileProcessor.close();// w w w . j a v a2 s . c o m appContext.close(); }
From source file:com.thinkbiganalytics.server.upgrade.KyloUpgrader.java
/** * Return the database version for Kylo. * * @return the version of Kylo stored in the database *///from w w w . ja va2s . co m public KyloVersion getCurrentVersion() { String profiles = System.getProperty("spring.profiles.active", ""); if (!profiles.contains("native")) { profiles = StringUtils.isEmpty(profiles) ? "native" : profiles + ",native"; System.setProperty("spring.profiles.active", profiles); } //Spring is needed to load the Spring Cloud context so we can decrypt the passwords for the database connection ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext( "kylo-upgrade-check-application-context.xml"); ctx.refresh(); KyloUpgradeDatabaseVersionChecker upgradeDatabaseVersionChecker = (KyloUpgradeDatabaseVersionChecker) ctx .getBean("kyloUpgradeDatabaseVersionChecker"); KyloVersion kyloVersion = upgradeDatabaseVersionChecker.getDatabaseVersion(); ctx.close(); return kyloVersion; }
From source file:org.cometd.annotation.spring.SpringAnnotationTest.java
@Test public void testSpringWiringOfCometDServices() throws Exception { ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(); applicationContext.setConfigLocation("classpath:applicationContext.xml"); applicationContext.refresh(); String beanName = Introspector.decapitalize(SpringBayeuxService.class.getSimpleName()); String[] beanNames = applicationContext.getBeanDefinitionNames(); assertTrue(Arrays.asList(beanNames).contains(beanName)); SpringBayeuxService service = (SpringBayeuxService) applicationContext.getBean(beanName); assertNotNull(service);/*from w w w .jav a 2s .c o m*/ assertNotNull(service.dependency); assertNotNull(service.bayeuxServer); assertNotNull(service.serverSession); assertTrue(service.active); assertEquals(1, service.bayeuxServer.getChannel(SpringBayeuxService.CHANNEL).getSubscribers().size()); applicationContext.close(); assertFalse(service.active); }