List of usage examples for org.springframework.context.annotation AnnotationConfigApplicationContext getBean
@Override public Object getBean(String name) throws BeansException
From source file:net.slkdev.swagger.confluence.cli.SwaggerConfluence.java
private static SwaggerToConfluenceService bootSwaggerConfluence() { final AnnotationConfigApplicationContext annotationConfigApplicationContext = new AnnotationConfigApplicationContext( SwaggerConfluenceContextConfig.class); final SwaggerToConfluenceService swaggerToConfluenceService = annotationConfigApplicationContext .getBean(SwaggerToConfluenceService.class); annotationConfigApplicationContext.close(); return swaggerToConfluenceService; }
From source file:pieShareAppITs.helper.ITUtil.java
public static void performTearDown(AnnotationConfigApplicationContext context) throws Exception { //shutdown application PieShareService service = context.getBean(PieShareService.class); context.close();// w ww . ja v a2 s. co m service.stop(); //get dirs to delete /*PieShareConfiguration config = context.getBean("pieUser", PieUser.class).getPieShareConfiguration(); File mainWorkingDir = config.getWorkingDir();//config.getWorkingDirectory(); File mainTmpDir = config.getTmpDir(); File configMain = config.getPwdFile(); config = context.getBean("botPieUser", PieUser.class).getPieShareConfiguration(); File botWorkingDir = config.getWorkingDir(); File botTmpDir = config.getTmpDir(); File configBot = config.getPwdFile();*/ //stop context // context.close(); context = null; }
From source file:spring2hello.MainClass.java
public static void maina(String[] args) throws BeansException { // throws BeansException { //@Autowired// w ww .ja va 2 s . c om //OrderService os; //NewMain nm = new NewMain();5 //SpringApplication.run(AppConfig.class); /* ApplicationContext context = (ApplicationContext) new ClassPathXmlApplicationContext("beans.xml"); */ //SpringApplication.run(App2Config.class); AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class); //HelloWorld helloWorld = (HelloWorld) context.getBean("helloWorldBean"); /* Beana b = (Beana) context.getBean("mojaBeana"); User u = (User) context.getBean("userBeana"); Properties ap = (Properties) context.getBean("myProp"); BasicDataSourceFactory f = (BasicDataSourceFactory) context.getBean("myDSfact"); Properties p = new Properties(); /*/ //OrderDAO orderDAO = (OrderDAO)context.getBean(OrderDAO.class); //OrderDAO repo = (OrderDAO)context.getBean("myRepo"); //repo.createDbTable(); //OrderService servis = (OrderService)context.getBean(OrderService.class); OrderService servis = (OrderService) context.getBean(OrderService.class); List<? extends Object> lista = servis.findAll("USER"); for (Object us : lista) { System.out.println("useR " + ((User) us).getId() + " " + ((User) us).getFirst_name() + " : " + ((User) us).getLast_name()); } /* p.setProperty("driverClassName", "com.mysql.jdbc.Driver"); p.setProperty("url", "jdbc:mysql://localhost/iivos_ap"); p.setProperty("username", "root"); p.setProperty("password", ""); /*/ //JdbcTemplate t = (JdbcTemplate) context.getBean("myTempl"); /* try { BasicDataSource c = (BasicDataSource)BasicDataSourceFactory.createDataSource(p); System.out.println(c.toString()); } catch (Exception ex) { Logger.getLogger(MainClass.class.getName()).log(Level.SEVERE, null, ex); } /*/ //SomeUsers usrs = new SomeUsers(); //Beana ab = new Beana(); /* System.out.println(b.saySomething()); System.out.println(u.getFirst_name()); System.out.println(f.toString()); System.out.println(p.toString()); System.out.println(ap.toString()); System.out.println(ab.toString()); System.out.println(t.toString()); */ }
From source file:pieShareAppITs.helper.ITUtil.java
public static void executeLoginToTestCloud(AnnotationConfigApplicationContext context, String cloudName, String password) throws Exception { LoginCommand command = new LoginCommand(); PlainTextPassword pwd = new PlainTextPassword(); pwd.password = password.getBytes();/*w w w . j av a 2 s . c om*/ command.setPlainTextPassword(pwd); command.setUserName(cloudName); command.setCallback(new ILoginFinished() { @Override public void error(Exception ex) { ex.printStackTrace(); Assert.fail(ex.getLocalizedMessage()); } @Override public void wrongPassword(WrongPasswordException ex) { Assert.fail(ex.getMessage()); } @Override public void OK() { } }); LoginTask task = context.getBean(LoginTask.class); task.setEvent(command); task.run(); }
From source file:org.cellcore.code.exec.ExecAddSingle.java
@Override protected void execute(CommandLine commandLine) { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ContextConfig.class); FetchGathererData fgd = context.getBean(FetchGathererData.class); fgd.extractSingle(commandLine.getOptionValue("cardSet"), commandLine.getOptionValue("cardId")); }
From source file:com.graphaware.runtime.spring.SpringIntegrationTest.java
@Test public void changeFeedShouldWorkWithSpring() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class); assertNotNull(context.getBean(GraphDatabaseService.class)); assertNotNull(context.getBean(UuidReader.class)); context.destroy();/*w ww . ja v a 2s . c om*/ }
From source file:com.petecapra.restconfig.RESTConfigService.java
@Override protected void initialize(RESTConfigConfiguration configuration, Environment environment) throws Exception { // TODO: externalise this and automatically scan context for resources and health checks AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(AppConfig.class); //ctx.scan("com.petecapra.restconfig"); environment.addResource(ctx.getBean(EnvironmentsResource.class)); environment.addResource(ctx.getBean(ApplicationsResource.class)); environment.addResource(ctx.getBean(EnvironmentApplicationsResource.class)); environment.addHealthCheck(ctx.getBean(DatabaseHealthCheck.class)); }
From source file:com.visural.domo.spring.TransactionImplTest.java
@Test public void testH2Execute() throws ClassNotFoundException, SQLException, IOException { ConnectionSource source = new ConnectOnDemandConnectionSource(H2Database.inMemory("test")); AnnotationConfigApplicationContext context = springBootstrap(source); Service service = context.getBean(Service.class); service.run();/*from w w w . j a v a2 s. co m*/ }
From source file:org.cellcore.code.exec.ExecPullFromGatherer.java
@Override protected void execute(CommandLine commandLine) { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ContextConfig.class); FetchGathererData fgd = context.getBean(FetchGathererData.class); GeneralDao dao = context.getBean(GeneralDao.class); Gson gson = GsonUtils.getSerializer(); String configString = null;// w ww .j a v a 2s. c om try { configString = FileUtils.readFileToString(new File(commandLine.getOptionValue("input"))); CrawlConfiguration config = gson.fromJson(configString, CrawlConfiguration.class); GathererEditionLocationCrawler crawler = new GathererEditionLocationCrawler(""); for (Map.Entry<String, String> cardSet : config.getCardSets().entrySet()) { List<String> cardIds = crawler.crawlPage(cardSet.getValue()); logger.info("PROCESSING: " + cardSet + " " + cardIds.size() + " cards"); fgd.extract(cardSet.getKey(), cardIds); } } catch (IOException e) { logger.error("", e); } }
From source file:com.visural.domo.spring.TransactionImplTest.java
@Test public void testH2CommitRollback() throws ClassNotFoundException, SQLException, IOException { final Connection con = mock(Connection.class); ConnectionSource source = new ConnectionSource() { public Connection getNew() throws SQLException { return con; }//from w ww. ja v a 2s.c om public void shutdown() { } }; AnnotationConfigApplicationContext context = springBootstrap(source); Service service = context.getBean(Service.class); service.run(); verify(con).commit(); try { service.runFail(); } catch (Exception e) { } verify(con).rollback(); }