List of usage examples for org.springframework.context.annotation AnnotationConfigApplicationContext AnnotationConfigApplicationContext
public AnnotationConfigApplicationContext(String... basePackages)
From source file:org.my.spring.batch.java.config.demo.Main.java
public static void main(String[] args) { //System.exit(SpringApplication.exit(SpringApplication.run(MyBatchConfiguration.class, args))); logger.log(Level.INFO, "extracting job parameters from command line arguments {0}", args); JobParameters jobParameters = parseJobParameters(args); String basePackage = Main.class.getPackage().getName(); logger.log(Level.INFO, "scanning {0} for classes with bean definitions", basePackage); AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(basePackage); Job job1 = context.getBean("job1", Job.class); JobLauncher jobLauncher = context.getBean(JobLauncher.class); try {/*from w ww .j av a2 s. c om*/ JobExecution jobExecution = jobLauncher.run(job1, jobParameters); logger.log(Level.INFO, "job execution {0} ended with status: {1}", new Object[] { jobExecution.getId(), jobExecution.getStatus() }); } catch (Exception ex) { logger.log(Level.SEVERE, null, ex); } }
From source file:com.khartec.waltz.jobs.ServerHarness.java
public static void main(String[] args) { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class); ServerInformationService serverInfoService = ctx.getBean(ServerInformationService.class); ServerInformationDao serverInfoDao = ctx.getBean(ServerInformationDao.class); DSLContext dsl = ctx.getBean(DSLContext.class); IdSelectionOptions options = ImmutableIdSelectionOptions.builder() .entityReference(ImmutableEntityReference.builder().kind(EntityKind.ORG_UNIT).id(10).build()) .scope(HierarchyQueryScope.CHILDREN).build(); for (int i = 0; i < 5; i++) { HarnessUtilities.time("stats", () -> serverInfoService.findStatsForAppSelector(options)); }//from w w w. ja v a 2 s. c om String sql = "\n" + "select \n" + " coalesce(\n" + " sum(case [server_information].[is_virtual] when 1 then 1\n" + " else 0\n" + " end), \n" + " 0) [virtual_count], \n" + " coalesce(\n" + " sum(case [server_information].[is_virtual] when 1 then 0\n" + " else 1\n" + " end), \n" + " 0) [physical_count]\n" + "from [server_information]\n" + "where [server_information].[asset_code] in (\n" + " select [application].[asset_code]\n" + " from [application]\n" + " where [application].[id] in (\n" + " select [application].[id]\n" + " from [application]\n" + " where [application].[organisational_unit_id] in (\n" + " 130, 260, 70, 200, 10, 140, 270, 80, 210, 20, 150, 280, 90, 220, 30, 160, \n" + " 290, 100, 230, 40, 170, 300, 110, 240, 50, 180, 120, 250, 60, 190\n" + " )\n" + " )\n" + ");\n"; FunctionUtilities.time("raw q", () -> { dsl.connection(conn -> { PreparedStatement stmt = conn.prepareStatement(sql); ResultSet rs = stmt.executeQuery(); while (rs.next()) { System.out.println(rs.getBigDecimal(1) + " - " + rs.getBigDecimal(2)); } }); return null; }); }
From source file:org.openscore.lang.tools.verifier.VerifierMain.java
public static void main(String[] args) { String repositoryPath = args[0]; Validate.notNull(repositoryPath, "You must pass a path to your repository"); repositoryPath = FilenameUtils.separatorsToSystem(repositoryPath); Validate.isTrue(new File(repositoryPath).isDirectory(), "Directory path argument \'" + repositoryPath + "\' does not lead to a directory"); ApplicationContext context = new AnnotationConfigApplicationContext(VerifierSpringConfiguration.class); SlangContentVerifier slangContentVerifier = context.getBean(SlangContentVerifier.class); try {/*from ww w .j a va 2 s. co m*/ int numberOfValidSlangFiles = slangContentVerifier.verifyAllSlangFilesInDirAreValid(repositoryPath); System.out.println("SUCCESS: Found " + numberOfValidSlangFiles + " slang files under directory: \"" + repositoryPath + "\" and all are valid."); System.exit(0); } catch (Exception e) { System.out.println(e.getMessage() + "\n\nFAILURE: Validation of slang files under directory: \"" + repositoryPath + "\" failed."); // TODO - do we want to throw exception or exit with 1? System.exit(1); } }
From source file:org.italiangrid.storm.webdav.server.Main.java
public static void main(String[] args) { StatusPrinter.printInCaseOfErrorsOrWarnings((LoggerContext) LoggerFactory.getILoggerFactory()); log.info("StoRM WebDAV server v. {}", Version.version()); @SuppressWarnings("resource") ApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class); ServerLifecycle server = context.getBean(ServerLifecycle.class); server.start();// w w w . j a v a 2 s.c o m }
From source file:org.freewheelschedule.freewheel.schedule.ScheduleLauncher.java
public static void main(String[] args) { ApplicationContext ctx = new AnnotationConfigApplicationContext(ServerConfig.class); ScheduleLauncher server = (ScheduleLauncher) ctx.getBean("scheduleLauncher"); server.runScheduleLauncher();// ww w . ja v a 2s . co m }
From source file:com.khartec.waltz.jobs.AssetCostHarness.java
public static void main(String[] args) { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class); DSLContext dsl = ctx.getBean(DSLContext.class); AssetCostService service = ctx.getBean(AssetCostService.class); AssetCostStatsDao statsDao = ctx.getBean(AssetCostStatsDao.class); AssetCostDao costDao = ctx.getBean(AssetCostDao.class); ApplicationIdSelectorFactory selectorFactory = ctx.getBean(ApplicationIdSelectorFactory.class); long st = System.currentTimeMillis(); System.out.println("-- start"); IdSelectionOptions appIdSelectionOptions = ImmutableIdSelectionOptions.builder() .scope(HierarchyQueryScope.CHILDREN) .entityReference(ImmutableEntityReference.builder().id(5600).kind(EntityKind.CAPABILITY).build()) .build();//from w ww. jav a 2s . co m List<Tuple2<Long, BigDecimal>> costs = service.calculateCombinedAmountsForSelector(appIdSelectionOptions); System.out.println("-- end, dur: " + (System.currentTimeMillis() - st)); System.out.println(costs); System.out.println(costs.size()); }
From source file:com.khartec.waltz.jobs.DatabaseHarness.java
public static void main(String[] args) throws ParseException { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class); DatabaseInformationDao databaseDao = ctx.getBean(DatabaseInformationDao.class); DSLContext dsl = ctx.getBean(DSLContext.class); List<DatabaseInformation> dbs = databaseDao.findByApplicationId(801L); System.out.println(dbs.size()); SelectConditionStep<Record1<Long>> idSelector = dsl.select(APPLICATION.ID).from(APPLICATION) .where(APPLICATION.ID.in(801L, 802L, 803L)); Map<Long, List<DatabaseInformation>> moreDbs = databaseDao.findByAppSelector(idSelector); System.out.println(moreDbs.size()); System.out.println(moreDbs.values().size()); }
From source file:com.doctor.ignite.example.spring.CrossCacheQueries.java
public static void main(String[] args) throws InterruptedException { AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext( SpringIgniteConfig.class); Ignite ignite = applicationContext.getBean(Ignite.class); CacheConfiguration<UUID, Person> cacheConfiguration = applicationContext .getBean("CacheConfigurationForDays", CacheConfiguration.class); IgniteCache<UUID, Person> igniteCache1 = getCache("person1", ignite, cacheConfiguration); Person person = new Person(UUID.randomUUID(), "doctor -1 ", BigDecimal.valueOf(88888888.888), "man", "..."); igniteCache1.put(person.getId(), person); Person person1 = new Person(UUID.randomUUID(), "doctor 118", BigDecimal.valueOf(88888888.888), "man", "..."); igniteCache1.put(person1.getId(), person1); Person person2 = new Person(UUID.randomUUID(), "doctor who 88 ", BigDecimal.valueOf(188888888.888), "man", "..."); igniteCache1.put(person2.getId(), person2); IgniteCache<UUID, Person> igniteCache2 = getCache("person2", ignite, cacheConfiguration); Person person3 = new Person(UUID.randomUUID(), "doctor who ---88 ", BigDecimal.valueOf(1188888888.888), "man", "..."); igniteCache2.put(person3.getId(), person3); // try (QueryCursor<List<?>> queryCursor = igniteCache1.query(new SqlFieldsQuery("select name from Person"))) { // for (List<?> entry : queryCursor) { // System.out.println("--}}}}}" + entry); // }//from ww w . jav a 2 s .c o m // } SqlQuery sqlQuery = new SqlQuery<>(Person.class, "from Person , \"person2\".Person "); try (QueryCursor queryCursor = igniteCache1.query(sqlQuery)) { for (Object object : queryCursor) { System.out.println(object); } } applicationContext.close(); }
From source file:com.khartec.waltz.jobs.AppCapabilityHarness.java
public static void main(String[] args) { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class); CapabilityRatingService ratingSvc = ctx.getBean(CapabilityRatingService.class); System.out.println(ratingSvc); List<CapabilityRating> result = ratingSvc.findByAppIdSelector(selector); }
From source file:com.khartec.waltz.jobs.JooqTest2.java
public static void main(String[] args) { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class); DataSource dataSource = ctx.getBean(DataSource.class); DSLContext dsl = DSL.using(dataSource, SQLDialect.POSTGRES_9_4, new Settings().withRenderFormatted(true)); Table<Record> orgTree = table(name("orgTree")); Field<Long> ouIdField = field(name("orgTree", "ouId"), Long.class); SelectJoinStep<Record1<Long>> with = dsl.withRecursive("orgTree", "ouId") .as(select(ORGANISATIONAL_UNIT.ID).from(ORGANISATIONAL_UNIT) .where(ORGANISATIONAL_UNIT.ID.eq(Long.valueOf(210))) .unionAll(select(ORGANISATIONAL_UNIT.ID).from(ORGANISATIONAL_UNIT, orgTree) .where(ORGANISATIONAL_UNIT.PARENT_ID.eq(ouIdField)))) .select(ouIdField).from(orgTree); Field[] fields = new Field[] { APPLICATION.NAME, APPLICATION.ORGANISATIONAL_UNIT_ID, PERSPECTIVE_RATING.CAPABILITY_ID, PERSPECTIVE_RATING.RATING }; String sql = dsl.select(fields).from(PERSPECTIVE_RATING).innerJoin(APPLICATION) .on(PERSPECTIVE_RATING.PARENT_ID.eq(APPLICATION.ID)) .where(PERSPECTIVE_RATING.PERSPECTIVE_CODE.eq("BUSINESS")) .and(APPLICATION.ORGANISATIONAL_UNIT_ID.in(with)).getSQL(); System.out.println(sql);// w w w . ja v a 2 s . c o m }