List of usage examples for org.springframework.context.annotation AnnotationConfigApplicationContext AnnotationConfigApplicationContext
public AnnotationConfigApplicationContext(String... basePackages)
From source file:ro.pippo.demo.spring.SpringApplication.java
@Override protected void onInit() { // create spring application context ApplicationContext applicationContext = new AnnotationConfigApplicationContext(SpringConfiguration.class); // registering SpringControllerFactory // setControllerFactory(new SpringControllerFactory(applicationContext, false)); setControllerFactory(new SpringControllerFactory(applicationContext)); // add routes for static content addPublicResourceRoute();/*w w w. j ava 2 s . co m*/ addWebjarsResourceRoute(); // add controller GET("/", ContactsController.class, "index"); }
From source file:com.grayfox.server.test.BaseWebServiceTest.java
@Override protected Application configure() { return new ResourceConfig().packages("com.grayfox.server.ws.rest").property("contextConfig", new AnnotationConfigApplicationContext(TestConfig.class)); }
From source file:cputgroup3a.integerassertion.IntegerAssertionTest.java
@BeforeClass public static void setUpClass() throws Exception { ApplicationContext ctx = new AnnotationConfigApplicationContext(AppConfig.class); ia = (IntegerAssertion) ctx.getBean("IntAssert"); }
From source file:spring2hello.MainClass.java
public static void maina(String[] args) throws BeansException { // throws BeansException { //@Autowired//from ww w . ja v a 2s.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:com.gopivotal.cloudfoundry.test.ApplicationGlobal.java
@Override public void onStart(Application application) { new InitializationUtils().fail(); this.applicationContext = new AnnotationConfigApplicationContext(ApplicationConfiguration.class); }
From source file:pub.vrtech.common.Start.java
public ApplicationContext initApplication() { ApplicationContext context = new AnnotationConfigApplicationContext(Start.class); return context; }
From source file:repository.BeanTest.java
@Test public void test1() { LocalContainerEntityManagerFactoryBean lm = c.entityManagerFactory(c.dataSource(), c.jpaVendorAdapter()); ApplicationContext ct = new AnnotationConfigApplicationContext(c.build().getClass()); Assert.assertNotNull(ct);/*from ww w . j a v a2 s. c o m*/ System.out.println(); }
From source file:org.duracloud.mill.workman.TestNoopProcessorRoundTripWithSQS.java
/** * @throws java.lang.Exception// ww w . j a va2 s .c om */ @Before public void setUp() throws Exception { context = new AnnotationConfigApplicationContext(AppConfig.class); queue = (TaskQueue) context.getBean("auditQueue"); }
From source file:serviceTests.CountProductsTestNGTest.java
@BeforeClass public static void setUpClass() throws Exception { ctx = new AnnotationConfigApplicationContext(ConnectionConfig.class); counter = new CountProducts(); productRepo = ctx.getBean(ProductRepository.class); applianceRepo = ctx.getBean(ApplianceRepository.class); cosmeticRepo = ctx.getBean(CosmeticRepository.class); medicineRepo = ctx.getBean(MedicineRepository.class); miscRepo = ctx.getBean(MiscRepository.class); productRepo.deleteAll();/* w w w. ja v a 2 s. c o m*/ applianceRepo.deleteAll(); cosmeticRepo.deleteAll(); medicineRepo.deleteAll(); miscRepo.deleteAll(); Product product = new Product.Builder() //.id(0) .productDescription("coco").productName("nestle coco").price(31.50).quantity(3).build(); Appliance appliance = new Appliance.Builder() //.id(0) .modelCode("asd123").price(21.95).productName("Electric Toothbrush") .productDescription("Toothbrush").quantity(7).build(); Cosmetic cosmetic = new Cosmetic.Builder() //.id(0) .cosmeticClass("Hair").productDescription("Shampoo").productName("Pantine Shampoo").price(30.50) .quantity(3).build(); Medicine medicine = new Medicine.Builder() //.id(0) .productDescription("Cancer Antidote").productName("L Davids - Cancer-Away").price(349.95) .quantity(39).treats("cancer").build(); Misc misc = new Misc.Builder() //.id(0) .productDescription("coco").productName("nestle coco").price(31.50).quantity(3).build(); productRepo.save(product); applianceRepo.save(appliance); cosmeticRepo.save(cosmetic); medicineRepo.save(medicine); miscRepo.save(misc); }
From source file:nl.tranquilizedquality.itest.tomcat.TestAppTomcatDeploymentTest.java
@BeforeClass public static void runOnce() throws Exception { // The application server need to be locally started only if the // host is localhost if (isRunningOnLocalHost()) { if (LOGGER.isInfoEnabled()) { LOGGER.info("Starting up the container utility..."); }//from ww w . j ava 2 s .c o m CONTEXT = new AnnotationConfigApplicationContext(TomcatContainerUtilConfiguration.class); CONTAINER_UTIL = (ContainerUtil) CONTEXT.getBean("containerUtil"); CONTAINER_UTIL.start(); } }