List of usage examples for org.springframework.context ApplicationContext getBeanDefinitionCount
int getBeanDefinitionCount();
From source file:utilities.MinPopulateDatabase.java
public static void main(String[] args) { ApplicationContext populationContext; DatabaseUtil databaseUtil;// w w w . ja v a 2s. c o m databaseUtil = null; try { System.out.printf("MinPopulateDatabase 1.3%n"); System.out.printf("--------------------%n%n"); System.out.printf("Initialising persistence context `%s'...%n", DatabaseConfig.PersistenceUnit); databaseUtil = new DatabaseUtil(); System.out.printf("Creating database `%s' (%s)...%n", databaseUtil.getDatabaseName(), databaseUtil.getDatabaseDialectName()); databaseUtil.recreateDatabase(); System.out.printf("Reading configuration file `%s'...%n", "MinPopulateDatabase.xml"); populationContext = new ClassPathXmlApplicationContext("classpath:minPopulateDatabase.xml"); System.out.printf("Persisting %d entities...%n%n", populationContext.getBeanDefinitionCount()); databaseUtil.openTransaction(); for (Entry<String, Object> entry : populationContext.getBeansWithAnnotation(Entity.class).entrySet()) { String beanName; DomainEntity entity; beanName = entry.getKey(); entity = (DomainEntity) entry.getValue(); System.out.printf("> %s: %s", beanName, entity.getClass().getName()); databaseUtil.persist(entity); System.out.printf(" -> id = %d, version = %d%n", entity.getId(), entity.getVersion()); } databaseUtil.commitTransaction(); } catch (Throwable oops) { System.out.flush(); System.err.printf("%n%s%n", oops.getLocalizedMessage()); oops.printStackTrace(System.err); } finally { if (databaseUtil != null) databaseUtil.close(); } }
From source file:herudi.controller.controllSplash.java
private void longStart() { Service<ApplicationContext> service = new Service<ApplicationContext>() { @Override//from www . ja v a 2 s . c om protected Task<ApplicationContext> createTask() { return new Task<ApplicationContext>() { @Override protected ApplicationContext call() throws Exception { ApplicationContext appContex = config.getInstance().getApplicationContext(); int max = appContex.getBeanDefinitionCount(); updateProgress(0, max); for (int k = 0; k < max; k++) { Thread.sleep(50); updateProgress(k + 1, max); } return appContex; } }; } }; service.start(); service.setOnRunning((WorkerStateEvent event) -> { new FadeInLeftTransition(lblWelcome).play(); new FadeInRightTransition(lblRudy).play(); new FadeInTransition(vboxBottom).play(); }); service.setOnSucceeded((WorkerStateEvent event) -> { config2 config = new config2(); config.newStage(stage, lblClose, "/herudi/view/login.fxml", "Sample Apps", true, StageStyle.UNDECORATED, false); }); }
From source file:com.toyota.carservice.controller.SplashController.java
private void longStart() { Service<ApplicationContext> service = new Service<ApplicationContext>() { @Override//from w w w . jav a 2 s. c o m protected Task<ApplicationContext> createTask() { return new Task<ApplicationContext>() { @Override protected ApplicationContext call() throws Exception { ApplicationContext appContex = config.getInstance().getApplicationContext(); int max = appContex.getBeanDefinitionCount(); updateProgress(0, max); System.out.println(PathUtil.getRootPath()); File file = new File(PathUtil.getRootPath()); if (!file.exists()) { file.mkdir(); } if (max < 50) { max = 50; } for (int k = 0; k < max; k++) { Thread.sleep(50); updateProgress(k + 1, max); } return appContex; } }; } }; service.start(); service.setOnRunning((WorkerStateEvent event) -> { new FadeInLeftTransition(lblWelcome).play(); new FadeInRightTransition(lblRudy).play(); new FadeInTransition(vboxBottom).play(); }); service.setOnSucceeded((WorkerStateEvent event) -> { config2 config = new config2(); config.newStage(stage, lblClose, "/com/toyota/carservice/view/formSwitchMode.fxml", "Aplikasi Informasi Service", true, StageStyle.UNDECORATED, false); }); }
From source file:test.com.azaptree.services.spring.application.SpringApplicationServiceTest.java
@Test public void testSpringApplicationService_configClasses() throws Exception { final String[] args = { "classpath:spring-application-service.xml" }; try {/*from w w w.j a v a2s.c om*/ new Thread(new Runnable() { @Override public void run() { try { SpringApplicationService.main(args); } catch (Exception e) { e.printStackTrace(); } } }).start(); Thread.yield(); ApplicationContext ctx = SpringApplicationService.getApplicationContext(); while (ctx == null) { log.info("Waiting for ApplicationContext to initialize ..."); Thread.sleep(100l); ctx = SpringApplicationService.getApplicationContext(); } Assert.assertNotNull(ctx); final Properties props = ctx.getBean("systemProps", Properties.class); Assert.assertNotNull(props); Assert.assertFalse(CollectionUtils.isEmpty(props)); final Map<String, String> env = ctx.getBean("env", Map.class); Assert.assertNotNull(env); Assert.assertFalse(CollectionUtils.isEmpty(env)); log.info("bean count: {}", ctx.getBeanDefinitionCount()); for (String beanName : ctx.getBeanDefinitionNames()) { log.info("beanName: {}", beanName); } } finally { SpringApplicationService.shutdown(); } }
From source file:test.com.azaptree.services.spring.application.SpringApplicationServiceTest.java
@Test public void testSpringApplicationService() throws Exception { final String[] args = { "classpath:spring-application-service.xml" }; try {/*from w w w .jav a 2 s . co m*/ new Thread(new Runnable() { @Override public void run() { try { SpringApplicationService.main(args); } catch (Exception e) { e.printStackTrace(); } } }).start(); Thread.yield(); ApplicationContext ctx = SpringApplicationService.getApplicationContext(); while (ctx == null) { log.info("Waiting for ApplicationContext to initialize ..."); Thread.sleep(100l); ctx = SpringApplicationService.getApplicationContext(); } Assert.assertNotNull(ctx); final Properties props = ctx.getBean("systemProps", Properties.class); Assert.assertNotNull(props); Assert.assertFalse(CollectionUtils.isEmpty(props)); Assert.assertEquals(props.getProperty("app.env"), "DEV"); final Map<String, String> env = ctx.getBean("env", Map.class); Assert.assertNotNull(env); Assert.assertFalse(CollectionUtils.isEmpty(env)); final Map<String, String> environment = ctx.getBean("environment", Map.class); Assert.assertNotNull(environment); Assert.assertFalse(CollectionUtils.isEmpty(environment)); log.info("bean count: {}", ctx.getBeanDefinitionCount()); for (String beanName : ctx.getBeanDefinitionNames()) { log.info("beanName: {}", beanName); } } finally { SpringApplicationService.shutdown(); } }
From source file:edu.northwestern.bioinformatics.studycalendar.grid.PSCAdverseEventConsumerTest.java
public void testApplicationContextLoads() throws Exception { ApplicationContext loaded = new ClassPathXmlApplicationContext("classpath:applicationContext-grid-ae.xml"); assertTrue("No beans loaded", loaded.getBeanDefinitionCount() > 0); }
From source file:edu.northwestern.bioinformatics.studycalendar.grid.PSCRegistrationConsumerTest.java
public void testApplicationContextLoads() throws Exception { ApplicationContext loaded = new ClassPathXmlApplicationContext("classpath:applicationContext-grid.xml"); assertTrue("No beans loaded", loaded.getBeanDefinitionCount() > 0); }
From source file:org.squale.jraf.bootstrap.test.ApplicationContextFactoryHelper.java
/** * //from w w w .j ava2s. c o m * @param argc0 */ public static void main(String[] argc0) { ApplicationContext ctx = ApplicationContextFactoryHelper.getApplicationContext("applicationTest.xml"); log.debug("" + ctx.getBeanDefinitionCount()); }