List of usage examples for org.springframework.context.annotation AnnotationConfigApplicationContext AnnotationConfigApplicationContext
public AnnotationConfigApplicationContext(String... basePackages)
From source file:com.khartec.waltz.jobs.sample.EndUserAppMaker.java
public static void main(String[] args) { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class); OrganisationalUnitDao organisationalUnitDao = ctx.getBean(OrganisationalUnitDao.class); DSLContext dsl = ctx.getBean(DSLContext.class); EndUserAppService endUserService = ctx.getBean(EndUserAppService.class); List<Long> ids = IdUtilities.toIds(organisationalUnitDao.findAll()); String[] subjects = { "Trade", "Risk", "Balance", "PnL", "Rate", "Fines", "Party", "Confirmations", "Settlement", "Instruction", "Person", "Profit", "Margin", "Finance", "Account" }; String[] types = { "Report", "Summary", "Draft", "Calculations", "Breaks", "Record", "Statement", "Information", "Pivot" }; String[] tech = { "MS ACCESS", "MS EXCEL", "VBA" }; dsl.delete(END_USER_APPLICATION).execute(); final Long[] idCounter = { 1L }; ids.forEach(ouId -> {//from w w w . ja v a 2 s . co m for (int i = 0; i < new Random().nextInt(100) + 40; i++) { EndUserApplicationRecord record = dsl.newRecord(END_USER_APPLICATION); String name = new StringBuilder().append(randomPick(subjects)).append(" ") .append(randomPick(subjects)).append(" ").append(randomPick(types)).append(" ") .append(randomPick(types)).toString(); record.setName(name); record.setDescription("About the " + name + " End user app"); record.setKind(randomPick(tech)); record.setRiskRating(randomPick(RiskRating.values()).name()); record.setLifecyclePhase(randomPick(LifecyclePhase.values()).name()); record.setOrganisationalUnitId(ouId); record.setId(idCounter[0]++); record.insert(); } }); }
From source file:com.khartec.waltz.jobs.EntityStatisticHarness.java
public static void main(String[] args) { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class); DSLContext dsl = ctx.getBean(DSLContext.class); EntityStatisticValueDao dao = ctx.getBean(EntityStatisticValueDao.class); EntityStatisticService service = ctx.getBean(EntityStatisticService.class); /*// w w w .j a v a2 s . com select outcome, sum(CASE ISNUMERIC(value) when 1 then cast(value as BIGINT) else 0 end) from entity_statistic_value where statistic_id = 20010 GROUP BY outcome; */ AggregateFunction<BigDecimal> summer = DSL.sum(DSL.cast(esv.VALUE, Long.class)); dsl.select(esv.OUTCOME, summer).from(esv).where(esv.STATISTIC_ID.eq(20010L)).groupBy(esv.OUTCOME).fetch() .forEach(System.out::println); System.out.println("done"); }
From source file:com.khartec.waltz.jobs.sample.PersonDataGenerator.java
public static void main(String[] args) { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class); PersonService personService = ctx.getBean(PersonService.class); Person person = fairy.person();//from w w w. jav a 2s. c om ImmutablePerson root = ImmutablePerson.builder().employeeId(person.passportNumber()) .kind(PersonKind.EMPLOYEE).userPrincipalName(person.username()).title(randomPick(jobTitles[0])) .departmentName("CEO").displayName(person.fullName()).email(person.email()).build(); peeps.add(root); visit(root, 1); System.out.println(peeps.size()); personService.bulkSave(peeps); }
From source file:com.alexshabanov.springrestapi.App.java
public static void main(String[] args) { System.out.println("Client app demo, expecting server to be available at " + APP_URL); final ConfigurableApplicationContext applicationContext = new AnnotationConfigApplicationContext( App.Config.class); applicationContext.start();/*from ww w. j av a2 s. co m*/ try { applicationContext.getBean(Runnable.class).run(); } finally { applicationContext.close(); } }
From source file:com.oreilly.springdata.rest.client.ProductsClient.java
public static void main(String[] args) { // Bootstrap RestOperations instance using Spring ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(ClientConfiguration.class); context.registerShutdownHook();//w w w . j a va 2s. c o m RestOperations operations = context.getBean(RestOperations.class); // Access root resource ResourceSupport root = operations.getForObject(ClientConfiguration.BASE_URL, Resource.class); Link productLink = root.getLink(ClientConfiguration.PRODUCTS_REL); // Follow link to access products Products products = operations.getForObject(productLink.getHref(), Products.class); System.out.println(products.getContent().iterator().next()); }
From source file:ch.sdi.SocialDataImporterTestRunner.java
public static void main(String[] args) { myLog.info("main starting"); mySpringContext = new AnnotationConfigApplicationContext( SocialDataImporterTestRunner.class.getPackage().getName()); try {//from w w w .j a va 2s.c om // Object o = mySpringContext.getBean(SdiMainProperties.class); mySpringContext.getBean(SocialDataImporterRunner.class).run(args); } catch (SdiException t) { myLog.error("Exception caught. Terminating with exitcode " + t.getExitCode(), t); System.exit(t.getExitCode()); } catch (Throwable t) { myLog.error("Exception caught: ", t); System.exit(1); } finally { mySpringContext.close(); } }
From source file:rooms.Application.java
public static void main(String[] args) throws ValueException, ThingException, InterruptedException { AbstractApplicationContext context = new AnnotationConfigApplicationContext(RoomConfig.class); //AbstractApplicationContext context = new AnnotationConfigApplicationContext(RoomConfigMongo.class); // MongoOperations mo = (MongoOperations) context.getBean("mongoTemplate"); final ThingControl tc = (ThingControl) context.getBean("thingControl"); for (String s : context.getBeanDefinitionNames()) { System.out.println(s);//from w w w. jav a 2s . co m } System.out.println("THINGSSSS"); for (Thing t : tc.findAllThings()) { System.out.println("THING: " + t); } // mo.dropCollection(Thing.class); // mo.dropCollection(Bridge.class); // mo.dropCollection(Light.class); List<Thing> t = tc.findThingsForType("bridge"); Bridge b = new Bridge("10.0.0.40"); Thing tb = tc.createThing("bridge", b); Light l = new Light(Group.GROUP_1, "white"); Thing tl = tc.createThing("bedroom_ceiling", l); Light l2 = new Light(Group.GROUP_2, "white"); Thing tl2 = tc.createThing("bedroom_bed", l2); Light l3 = new Light(Group.GROUP_3, "white"); Thing tl3 = tc.createThing("bedroom_desk", l3); tc.addChildThing(tb, tl); tc.addChildThing(tb, tl2); tc.addChildThing(tb, tl3); List<Thing<Bridge>> bridges = tc.findThingsForType(Bridge.class); Map<String, LightWhiteV2> lights = Maps.newHashMap(); for (Thing<Bridge> bridgeThing : bridges) { Bridge bridge = tc.getValue(bridgeThing); LimitlessLEDControllerV2 c = new LimitlessLEDControllerV2(b.getHost(), b.getPort()); List<Thing<Light>> lightThings = tc.getChildrenForType(Observable.just(bridgeThing), Light.class, true); for (Thing<Light> tempLight : lightThings) { Light ll = tc.getValue(tempLight); LightWhiteV2 white = new LightWhiteV2(tempLight.getKey(), c, ll.getLightGroup()); lights.put(white.getName(), white); System.out.println("LIGHT: " + white.getName()); } } // lights.get("bedroom_ceiling").setOn(true); lights.get("bedroom_bed").setOn(true); Thread.sleep(2000); // lights.get("bedroom_ceiling").setOn(false); lights.get("bedroom_bed").setOn(false); Thread.sleep(2000); }
From source file:com.oreilly.springdata.rest.client.CustomerClient.java
public static void main(String[] args) { // Setup RestTemplate though Spring ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(ClientConfiguration.class); context.registerShutdownHook();/* w w w . j ava 2s . c o m*/ RestOperations restOperations = context.getBean(RestOperations.class); // Access root resource ResourceSupport result = restOperations.getForObject(ClientConfiguration.BASE_URL, Resource.class); Link link = result.getLink(ClientConfiguration.CUSTOMERS_REL); System.out.println("Following: " + link.getHref()); // Follow link relation for customers to access those Customers customers = restOperations.getForObject(link.getHref(), Customers.class); for (Customer dto : customers) { com.oreilly.springdata.rest.core.Customer customer = dto.getContent(); System.out.println(customer.getFirstname() + " " + customer.getLastname()); } }
From source file:br.com.gumga.academia.aplicacao.MainService3.java
public static void main(String[] args) { ApplicationContext ctx = new AnnotationConfigApplicationContext(Aplicacao.class); MainService3 ms = ctx.getBean(MainService3.class); ms.run();//from w w w. j ava2 s.co m }
From source file:com.khartec.waltz.jobs.JooqHarness.java
public static void main(String[] args) { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class); ApplicationDao appDao = ctx.getBean(ApplicationDao.class); ApplicationService appSvc = ctx.getBean(ApplicationService.class); DataFlowDao dfDao = ctx.getBean(DataFlowDao.class); CapabilityRatingDao capRatDao = ctx.getBean(CapabilityRatingDao.class); OrganisationalUnitDao orgDao = ctx.getBean(OrganisationalUnitDao.class); AppCapabilityDao appCapDao = ctx.getBean(AppCapabilityDao.class); CapabilityDao capDao = ctx.getBean(CapabilityDao.class); BookmarkDao bookmarkDao = ctx.getBean(BookmarkDao.class); PersonService personDao = ctx.getBean(PersonService.class); DSLContext dsl = ctx.getBean(DSLContext.class); int FRONT_OFFICE = 260; // app 552 int EQUITIES = 270; // app 669 // appCapDao.findApplicationCapabilitiesForOrgUnit(400).forEach(System.out::println); // System.out.println(); // System.out.println(); // appCapDao.findCapabilitiesForApp(594).forEach(System.out::println); // System.out.println(); // System.out.println(); ///*ww w. jav a 2 s .co m*/ // ImmutableGroupedApplications grouped = appCapDao.findGroupedApplicationsByCapability(1200L); // // grouped.primaryApps().forEach(System.out::println); // System.out.println("2222222222222"); // grouped.secondaryApps().forEach(System.out::println); //// // // appCapDao.tallyByCapabilityId().forEach(System.out::println); // // appCapDao.addCapabilitiesToApp(2010L, ListUtilities.newArrayList(999L)); // // // List<Capability> descendants = capDao.findDescendants(3000); // List<Long> ids = toIds(descendants); // System.out.println(ids); // Bookmark r = bookmarkDao.create(ImmutableBookmark.builder() // .title("test") // .parent(ImmutableEntityReference.builder() // .id(1) // .kind(EntityKind.APPLICATION) // .build()) // .kind(BookmarkKind.APPLICATION_INSTANCE) // .description("test desc") // .build()); // // System.out.println(r); List<Person> ellasMgrs = personDao.findAllManagersByEmployeeId("dvkDz0djp"); ellasMgrs.forEach(m -> System.out.println(m.displayName())); }