List of usage examples for org.springframework.context.annotation AnnotationConfigApplicationContext getBean
@Override public Object getBean(String name) throws BeansException
From source file:com.khartec.waltz.jobs.sample.FlowGenerator.java
public static void main(String[] args) { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class); AuthoritativeSourceDao authSourceDao = ctx.getBean(AuthoritativeSourceDao.class); ApplicationService applicationDao = ctx.getBean(ApplicationService.class); DataTypeService dataTypesDao = ctx.getBean(DataTypeService.class); DataFlowService dataFlowDao = ctx.getBean(DataFlowService.class); OrganisationalUnitService orgUnitDao = ctx.getBean(OrganisationalUnitService.class); DataSource dataSource = ctx.getBean(DataSource.class); DSLContext dsl = ctx.getBean(DSLContext.class); List<AuthoritativeSource> authSources = authSourceDao.findByEntityKind(EntityKind.ORG_UNIT); List<String> dataTypes = dataTypesDao.getAll().stream().map(dt -> dt.code()).collect(toList()); List<Application> apps = applicationDao.findAll(); List<OrganisationalUnit> orgUnits = orgUnitDao.findAll(); Set<DataFlow> expectedFlows = authSources.stream().flatMap(a -> { long orgUnitId = a.parentReference().id(); return IntStream.range(0, rnd.nextInt(40)) .mapToObj(i -> ImmutableDataFlow.builder().dataType(a.dataType()) .source(a.applicationReference()).target(randomAppPick(apps, orgUnitId)).build()); }).collect(Collectors.toSet()); Set<DataFlow> probableFlows = authSources.stream().flatMap(a -> IntStream.range(0, rnd.nextInt(30)) .mapToObj(i -> ImmutableDataFlow.builder().dataType(a.dataType()).source(a.applicationReference()) .target(randomAppPick(apps, randomPick(orgUnits).id().get())).build())) .collect(Collectors.toSet()); Set<DataFlow> randomFlows = apps.stream() .map(a -> ImmutableDataFlow.builder().source(a.toEntityReference())) .map(b -> b.target(randomAppPick(apps, randomPick(orgUnits).id().get()))) .map(b -> b.dataType(randomPick(dataTypes)).build()).collect(Collectors.toSet()); dsl.deleteFrom(DATA_FLOW).execute(); Set<DataFlow> all = new HashSet<>(); all.addAll(randomFlows);//from ww w . j a v a 2s .c o m all.addAll(expectedFlows); all.addAll(probableFlows); dataFlowDao.addFlows(new ArrayList<>(all)); System.out.println("Done"); }
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(); ///* w w w. j a v a 2 s .com*/ // 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())); }
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 w w w .j a v a2 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.DataFlowHarness.java
public static void main(String[] args) throws ParseException { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class); DataFlowService service = ctx.getBean(DataFlowService.class); DataFlowStatsDao dataFlowStatsDao = ctx.getBean(DataFlowStatsDao.class); DSLContext dsl = ctx.getBean(DSLContext.class); IdSelectionOptions options = ImmutableIdSelectionOptions.builder() .entityReference(ImmutableEntityReference.builder().kind(EntityKind.PERSON).id(74747).build()) .scope(HierarchyQueryScope.CHILDREN).build(); SelectJoinStep<Record1<Integer>> invCount = dsl.select(DSL.countDistinct(INVOLVEMENT.EMPLOYEE_ID).as("C")) .from(INVOLVEMENT);/* www .j a v a 2 s.c o m*/ SelectJoinStep<Record1<Integer>> appCount = dsl.select(DSL.countDistinct(APPLICATION.ID).as("C")) .from(APPLICATION); SelectOrderByStep<Record1<Integer>> union = invCount.unionAll(appCount); union.stream().forEach(System.out::println); FunctionUtilities.time("appCounts", () -> dataFlowStatsDao.countDistinctFlowInvolvement(DSL.select(APPLICATION.ID).from(APPLICATION))); // DataFlowStatistics stats = FunctionUtilities.time("full service", () -> service.calculateStats(options)); dsl.renderNamedParams(selector); empIdParam.setValue("huSs97bwj"); FunctionUtilities.time("appCounts", () -> dataFlowStatsDao.countDistinctAppInvolvement(DSL.select(APPLICATION.ID).from(APPLICATION))); Select<Record1<Long>> subQ = HarnessUtilities.time("build person sub q", () -> mkForPersonReportees("huSs97bwj")); HarnessUtilities.time("build complex q", () -> bigQuery(dsl, mkForPersonReportees("huSs97bwj"))); }
From source file:example.helloworld.HelloWorldApplication.java
public static void main(String[] args) { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( VaultConfiguration.class); context.start();// w w w. j a v a 2 s . c o m VaultTemplate vaultTemplate = context.getBean(VaultTemplate.class); MySecretData mySecretData = new MySecretData(); mySecretData.setUsername("walter"); mySecretData.setPassword("white"); vaultTemplate.write("secret/myapplication/user/3128", mySecretData); log.info("Wrote data to Vault"); VaultResponseSupport<MySecretData> response = vaultTemplate.read("secret/myapplication/user/3128", MySecretData.class); log.info("Retrieved data {} from Vault", response.getData().getUsername()); context.stop(); }
From source file:org.jmangos.realm.RealmServer.java
/** * The main method./* w ww .j av a2s . c om*/ * * @param args * the arguments */ public static void main(final String[] args) { final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); context.scan("org.jmangos.commons", "org.jmangos.world", "org.jmangos.realm"); context.refresh(); ServiceContent.setContext(context); context.getBean(NetworkService.class).start(); console.setVariable("applicationContext", context); console.setVariable("itemStorage", context.getBean(ItemStorages.class)); // console.run(); }
From source file:io.gravitee.gateway.platforms.jetty.bootstrap.Bootstrap.java
public static void main(String[] args) { Thread t = Thread.currentThread(); t.setName("graviteeio-gateway"); final AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(JettyConfiguration.class); ctx.registerShutdownHook();//from www . ja v a2 s. co m ctx.refresh(); try { final Node node = ctx.getBean(Node.class); node.start(); Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { LoggerFactory.getLogger(Bootstrap.class).info("Shutting-down Gravitee Gateway..."); node.stop(); ctx.close(); } }); } catch (Exception ex) { LOGGER.error("Unable to start Gravitee Gateway", ex); } }
From source file:com.khartec.waltz.jobs.sample.InvolvementGenerator.java
public static void main(String[] args) { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class); DSLContext dsl = ctx.getBean(DSLContext.class); List<String> developers = getEmployeeIdsByTitle(dsl, "%developer%"); List<String> managers = getEmployeeIdsByTitle(dsl, "%manager%"); List<String> analysts = getEmployeeIdsByTitle(dsl, "%analyst%"); List<String> administrators = getEmployeeIdsByTitle(dsl, "%administrator%"); List<String> qa = getEmployeeIdsByTitle(dsl, "%qa%"); List<String> directors = getEmployeeIdsByTitle(dsl, "%director%"); ;//from w ww.j av a 2 s . c o m List<Long> orgUnitIds = dsl.select(ORGANISATIONAL_UNIT.ID).from(ORGANISATIONAL_UNIT) .fetch(ORGANISATIONAL_UNIT.ID); List<Long> inHouseApps = getAppIdsByKind(dsl, ApplicationKind.IN_HOUSE); List<Long> hostedApps = getAppIdsByKind(dsl, ApplicationKind.INTERNALLY_HOSTED); List<Long> externalApps = getAppIdsByKind(dsl, ApplicationKind.EXTERNALLY_HOSTED); List<Long> eucApps = getAppIdsByKind(dsl, ApplicationKind.EUC); List<InvolvementRecord> devInvolvements = inHouseApps.stream().map(id -> toAppRef(id)) .flatMap(appRef -> mkInvolvments(appRef, developers, InvolvementKind.DEVELOPER, 7)) .collect(Collectors.toList()); List<InvolvementRecord> qaInvolvements = concat(inHouseApps, hostedApps).stream().map(id -> toAppRef(id)) .flatMap(appRef -> mkInvolvments(appRef, qa, InvolvementKind.QA, 3)).collect(Collectors.toList()); List<InvolvementRecord> projectManagerInvolvements = concat(inHouseApps, externalApps, hostedApps, eucApps) .stream().map(id -> toAppRef(id)) .flatMap(appRef -> mkInvolvments(appRef, managers, InvolvementKind.PROJECT_MANAGER, 1)) .collect(Collectors.toList()); List<InvolvementRecord> supportManagerInvolvments = concat(inHouseApps, externalApps, hostedApps).stream() .map(id -> toAppRef(id)) .flatMap(appRef -> mkInvolvments(appRef, managers, InvolvementKind.SUPPORT_MANAGER, 1)) .collect(Collectors.toList()); List<InvolvementRecord> analystInvolvments = concat(inHouseApps, externalApps, hostedApps).stream() .map(id -> toAppRef(id)) .flatMap(appRef -> mkInvolvments(appRef, analysts, InvolvementKind.BUSINESS_ANALYST, 3)) .collect(Collectors.toList()); List<InvolvementRecord> ouArchitects = orgUnitIds.stream() .map(id -> new InvolvementRecord(EntityKind.ORG_UNIT.name(), id, InvolvementKind.IT_ARCHITECT.name(), randomPick(directors), "RANDOM_GENERATOR")) .collect(Collectors.toList()); List<InvolvementRecord> ouSponsors = orgUnitIds.stream() .map(id -> new InvolvementRecord(EntityKind.ORG_UNIT.name(), id, InvolvementKind.BUSINESS_SPONSOR.name(), randomPick(directors), "RANDOM_GENERATOR")) .collect(Collectors.toList()); dsl.delete(INVOLVEMENT).execute(); dsl.batchInsert(devInvolvements).execute(); dsl.batchInsert(qaInvolvements).execute(); dsl.batchInsert(supportManagerInvolvments).execute(); dsl.batchInsert(projectManagerInvolvements).execute(); dsl.batchInsert(analystInvolvments).execute(); dsl.batchInsert(ouArchitects).execute(); dsl.batchInsert(ouSponsors).execute(); System.out.println("Done"); }
From source file:piecework.client.LoadTester.java
public static final void main(String[] args) throws Exception { String profile = args.length > 0 ? args[0] : "workstation"; StandardEnvironment environment = new StandardEnvironment(); environment.setActiveProfiles(profile); AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.setEnvironment(environment);/*from w w w .j ava2s . c om*/ ctx.register(ClientConfiguration.class); ctx.refresh(); KeyManagerCabinet cabinet = ctx.getBean(KeyManagerCabinet.class); SecuritySettings securitySettings = ctx.getBean(SecuritySettings.class); LoadTester loadTester = new LoadTester(cabinet.getKeystore(), securitySettings); loadTester.retrieveAllTasks(); }
From source file:com.hotinno.feedmonitor.batch.Main.java
public static void main(String[] args) throws Throwable { try {//from w w w . j a v a 2 s . c o m log.error("Entering batch..."); String env = System.getenv("VCAP_SERVICES"); log.error("************************************************************************"); log.error("VCAP_SERVICES is: " + env); log.error("************************************************************************"); AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext( BuffaloBatchConfiguration.class); org.apache.commons.dbcp.BasicDataSource ds = (org.apache.commons.dbcp.BasicDataSource) applicationContext .getBean("myDataSource"); log.error(String.format("URL: %s", ds.getUrl())); log.error(String.format("Username: %s", ds.getUsername())); log.error(String.format("Password: %s", ds.getPassword())); applicationContext.start(); log.error("Running..."); } catch (Throwable t) { System.err.println(t); t.printStackTrace(); log.error("Error occurred.", t); } }