List of usage examples for org.springframework.context.annotation AnnotationConfigApplicationContext AnnotationConfigApplicationContext
public AnnotationConfigApplicationContext(String... basePackages)
From source file:com.springsource.html5expense.config.BatchConfig.java
public static void main(String args[]) throws Exception { AnnotationConfigApplicationContext annotationConfigApplicationContext = new AnnotationConfigApplicationContext( BatchConfig.class); Job job = annotationConfigApplicationContext.getBean("read-eligible-charges", Job.class); JobParametersBuilder builder = new JobParametersBuilder(); builder.addString("file", "foo"); builder.addLong("uid", System.currentTimeMillis()); JobParameters jobParameters = builder.toJobParameters(); JobLauncher jobLauncher = annotationConfigApplicationContext.getBean(JobLauncher.class); jobLauncher.run(job, jobParameters); }
From source file:ru.develgame.jflickrorganizer.MainClass.java
public static void main(String args[]) { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(MainClass.class); try {/*from w ww . j a va 2 s . co m*/ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { } context.getBean(LoginForm.class).setVisible(true); }
From source file:com.thinkbiganalytics.spark.datavalidator.Validator.java
public static void main(String[] args) { log.info("Running Spark Validator with the following command line args (comma separated):" + StringUtils.join(args, ",")); // Check how many arguments were passed in if (args.length < 4) { System.out.println("Proper Usage is: <targetDatabase> <entity> <partition> <path-to-policy-file>"); System.out.println(/*from w w w.j a v a2s .c om*/ "You can optionally add: --hiveConf hive.setting=value --hiveConf hive.other.setting=value"); System.out.println("You can optionally add: --storageLevel rdd_persistence_level_value"); System.out.println("You can optionally add: --numPartitions number_of_rdd_partitions"); System.out.println("You provided " + args.length + " args which are (comma separated): " + StringUtils.join(args, ",")); System.exit(1); } try { ApplicationContext ctx = new AnnotationConfigApplicationContext("com.thinkbiganalytics.spark"); Validator app = ctx.getBean(Validator.class); app.setArguments(args[0], args[1], args[2], args[3]); app.addParameters(parseRemainingParameters(args, 4)); app.doValidate(); } catch (Exception e) { System.out.println(e); } }
From source file:com.cch.aj.entryrecorder.frame.HomeJFrame.java
/** * @param args the command line arguments *///w w w . j a va 2 s . c o m public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(HomeJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(HomeJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(HomeJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(HomeJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> AppHelper.Logger.warn("###Start the Program###"); /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { AppContext.setApplicationContext(new AnnotationConfigApplicationContext(AppConfig.class)); HomeJFrame hf = new HomeJFrame(); hf.setVisible(true); } }); }
From source file:fr.afcepf.atod.wine.data.parser.XmlParser.java
public static void main(String[] args) { log.info("\t ### debut du test ###"); /*URL url;//ww w . j a v a2 s . c o m try { url = new URL(apiBaseUrl+"/categorymap?filter=categories(490)&apikey="+apikey); if(Files.exists(Paths.get(getResourcePath() + "FilesXML/ategoryMap.xml"))==false){ File file = new File(getResourcePath() + "FilesXML/categoryMap.xml"); FileUtils.copyURLToFile(url, file); } //100 vins rouges fr au dela de 100 url = new URL(apiBaseUrl+"/catalog?filter=categories(490+124)+price(100)&size=100&search=France&apikey="+apikey); if(Files.exists(Paths.get(getResourcePath() + "FilesXML/Wines/RedWines100.xml"))==false){ File file = new File(getResourcePath() + "FilesXML/Wines/RedWines100.xml"); FileUtils.copyURLToFile(url, file); } //100 vins rouges fr entre 50 et 100 url = new URL(apiBaseUrl+"/catalog?filter=categories(490+124)+price(50|100)&size=100&search=France&apikey="+apikey); if(Files.exists(Paths.get(getResourcePath() + "FilesXML/Wines/RedWines50-100.xml"))==false){ File file = new File(getResourcePath() + "FilesXML/Wines/RedWines50-100.xml"); FileUtils.copyURLToFile(url, file); } //100 vins rouges fr entre 10 et 50 url = new URL(apiBaseUrl+"/catalog?filter=categories(490+124)+price(10|50)&size=100&search=France&apikey="+apikey); if(Files.exists(Paths.get(getResourcePath() + "FilesXML/Wines/RedWines10-50.xml"))==false){ File file = new File(getResourcePath() + "FilesXML/Wines/RedWines10-50.xml"); FileUtils.copyURLToFile(url, file); } //100 vins blancs fr au dela de 100 url = new URL(apiBaseUrl+"/catalog?filter=categories(490+125)+price(100)&size=100&search=France&apikey="+apikey); if(Files.exists(Paths.get(getResourcePath() + "FilesXML/Wines/WhiteWines100.xml"))==false){ File file = new File(getResourcePath() + "FilesXML/Wines/WhiteWines100.xml"); FileUtils.copyURLToFile(url, file); } //100 vins blancs fr entre 50 et 100 url = new URL(apiBaseUrl+"/catalog?filter=categories(490+125)+price(50|100)&size=100&search=France&apikey="+apikey); if(Files.exists(Paths.get(getResourcePath() + "FilesXML/Wines/WhiteWines50-100.xml"))==false){ File file = new File(getResourcePath() + "FilesXML/Wines/WhiteWines50-100.xml"); FileUtils.copyURLToFile(url, file); } //100 vins blancs fr entre 10 et 50 url = new URL(apiBaseUrl+"/catalog?filter=categories(490+125)+price(10|50)&size=100&search=France&apikey="+apikey); if(Files.exists(Paths.get(getResourcePath() + "FilesXML/Wines/WhiteWines10-50.xml"))==false){ File file = new File(getResourcePath() + "FilesXML/Wines/WhiteWines10-50.xml"); FileUtils.copyURLToFile(url, file); } //100 champagnes fr au dela de 100 url = new URL(apiBaseUrl+"/catalog?filter=categories(490+123)+price(100)&size=100&search=France&apikey="+apikey); if(Files.exists(Paths.get(getResourcePath() + "FilesXML/Wines/ChampagneWines100.xml"))==false){ File file = new File(getResourcePath() + "FilesXML/Wines/ChampagneWines100.xml"); FileUtils.copyURLToFile(url, file); } //100 champagnes fr entre 50 et 100 url = new URL(apiBaseUrl+"/catalog?filter=categories(490+123)+price(50|100)&size=100&search=France&apikey="+apikey); if(Files.exists(Paths.get(getResourcePath() + "FilesXML/Wines/ChampagneWines50-100.xml"))==false){ File file = new File(getResourcePath() + "FilesXML/Wines/ChampagneWines50-100.xml"); FileUtils.copyURLToFile(url, file); } //100 vins ross fr url = new URL(apiBaseUrl+"/catalog?filter=categories(490+126)&size=100&search=France&apikey="+apikey); if(Files.exists(Paths.get(getResourcePath() + "FilesXML/Wines/RoseWines10-50.xml"))==false){ File file = new File(getResourcePath() + "FilesXML/Wines/RoseWines10-50.xml"); FileUtils.copyURLToFile(url, file); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }*/ Locale.setDefault(Locale.US); BeanFactory bf2 = new AnnotationConfigApplicationContext(ElasticsearchConfiguration.class); WineService esRepository = (WineService) bf2.getBean(WineService.class); esRepository.deleteIdx(); BeanFactory bf = new ClassPathXmlApplicationContext("classpath:springData.xml"); IDaoProduct daoVin = (IDaoProduct) bf.getBean(IDaoProduct.class); IDaoSupplier daoSupplier = (IDaoSupplier) bf.getBean(IDaoSupplier.class); IDaoAdmin daoAdmin = bf.getBean(IDaoAdmin.class); IDaoSpecialEvent daoEvent = bf.getBean(IDaoSpecialEvent.class); IDaoCountry daoCountry = bf.getBean(IDaoCountry.class); IDaoCustomer daoCustomer = bf.getBean(IDaoCustomer.class); IDaoShippingMethode daoShippingMethod = bf.getBean(IDaoShippingMethode.class); IDaoPaymentInfo daoPayment = bf.getBean(IDaoPaymentInfo.class); IDaoProductFeature daoFeature = (IDaoProductFeature) bf.getBean(IDaoProductFeature.class); try { daoCountry .insertObj(new Country(null, "AT", "Autriche", "EUR", "Euro", "flaticon-euro-currency-symbol")); daoCountry .insertObj(new Country(null, "BE", "Belgique", "EUR", "Euro", "flaticon-euro-currency-symbol")); daoCountry .insertObj(new Country(null, "BG", "Bulgarie", "BGN", "Lev Bulgare", "flaticon-bulgaria-lev")); daoCountry.insertObj(new Country(null, "CY", "Chypre", "EUR", "Euro", "flaticon-euro-currency-symbol")); daoCountry.insertObj(new Country(null, "CZ", "Rpublique Tchque", "CZK", "Couronne tchque", "flaticon-czech-republic-koruna-currency-symbol")); daoCountry.insertObj( new Country(null, "DE", "Allemagne", "EUR", "Euro", "flaticon-euro-currency-symbol")); daoCountry.insertObj(new Country(null, "DK", "Danemark", "DKK", "Couronne danoise", "flaticon-denmark-krone-currency-symbol")); daoCountry.insertObj(new Country(null, "EE", "Estonie", "EEK", "Couronne estonienne", "flaticon-estonia-kroon-currency-symbol")); daoCountry .insertObj(new Country(null, "ES", "Espagne", "EUR", "Euro", "flaticon-euro-currency-symbol")); daoCountry .insertObj(new Country(null, "FI", "Finlande", "EUR", "Euro", "flaticon-euro-currency-symbol")); daoCountry.insertObj(new Country(null, "GB", "Royaume-Uni", "GBP", "Livre sterling", "flaticon-pound-symbol-variant")); daoCountry.insertObj(new Country(null, "GR", "Grce", "EUR", "Euro", "flaticon-euro-currency-symbol")); daoCountry.insertObj(new Country(null, "HU", "Hongrie", "HUF", "Forint hongrois", "flaticon-hungary-forint-currency-symbol")); daoCountry .insertObj(new Country(null, "IE", "Irlande", "EUR", "Euro", "flaticon-euro-currency-symbol")); daoCountry.insertObj(new Country(null, "IT", "Italie", "EUR", "Euro", "flaticon-euro-currency-symbol")); daoCountry.insertObj( new Country(null, "JP", "Japon", "JPY", "Yen japonais", "flaticon-yen-currency-symbol")); daoCountry.insertObj(new Country(null, "LT", "Lituanie", "LTL", "Litas lituanien", "flaticon-lithuania-litas-currency-symbol")); daoCountry.insertObj( new Country(null, "LU", "Luxembourg", "EUR", "Euro", "flaticon-euro-currency-symbol")); daoCountry.insertObj(new Country(null, "LV", "Lettonie", "LVL", "Lats letton", "flaticon-latvia-lat")); daoCountry.insertObj(new Country(null, "MT", "Malte", "EUR", "Euro", "flaticon-euro-currency-symbol")); daoCountry .insertObj(new Country(null, "NL", "Pays-Bas", "EUR", "Euro", "flaticon-euro-currency-symbol")); daoCountry.insertObj(new Country(null, "PL", "Pologne", "PLN", "Zloty polonais", "flaticon-poland-zloty-currency-symbol")); daoCountry .insertObj(new Country(null, "PT", "Portugal", "EUR", "Euro", "flaticon-euro-currency-symbol")); daoCountry .insertObj(new Country(null, "RO", "Roumanie", "EUR", "Euro", "flaticon-euro-currency-symbol")); daoCountry.insertObj(new Country(null, "SE", "Sude", "SEK", "Couronne sudoise", "flaticon-sweden-krona-currency-symbol")); daoCountry.insertObj( new Country(null, "SI", "Slovnie", "EUR", "Euro", "flaticon-euro-currency-symbol")); daoCountry.insertObj( new Country(null, "SK", "Slovaquie", "EUR", "Euro", "flaticon-euro-currency-symbol")); daoCountry.insertObj(new Country(null, "US", "Etats-Unis", "USD", "Dollar U.S.", "flaticon-dollar-currency-symbol-2")); daoCountry.insertObj(new Country(null, "FR", "France", "EUR", "Euro", "flaticon-euro-currency-symbol")); } catch (WineException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } Admin admin = null; Customer customer1 = null; Customer customer2 = null; Customer customer3 = null; try { admin = new Admin(null, "strateur", "admini", new Date(), "nicolastorero@gmail.com", "nicolastorero@gmail.com", "test1234", "0680413240", new Date(), new Date(), Civility.MR); customer1 = new Customer(null, "Wang", "Fen", new Date(), "fenwang@hotmail.com", "fenwang@hotmail.com", "test1234", "0666666666", new Date(), new Date(), Civility.MISS, true); customer2 = new Customer(null, "Anes", "Zouheir", new Date(), "zouheir.anes@gmail.com", "zouheir.anes@gmail.com", "test1234", "0666666666", new Date(), new Date(), Civility.MR, true); customer3 = new Customer(null, "Storero", "Nicolas", new Date(), "nicolastorero@gmail.com", "nicolastorero@gmail.com", "test1234", "0666666666", new Date(), new Date(), Civility.MR, true); daoAdmin.insertObj(admin); daoShippingMethod.insertObj(new ShippingMethod(null, "Colissimo")); daoPayment.insertObj(new PaymentInfo(null, "Visa")); daoCustomer.insertObj(customer1); daoCustomer.insertObj(customer2); Country c = daoCountry.findObj(29); customer3.addAdress(new Adress(null, "rue de rivoli", "18", "75001", "Paris", c, false)); customer3.addAdress(new Adress(null, "rue de rivoli", "18", "75001", "Paris", c, true)); daoCustomer.updateObj(customer3); } catch (WineException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } Product productRand = new Product(null, "pre", 500.0, "un produit"); SpecialEvent se = new SpecialEvent(null, "Promotest", new Date(), new Date(), new Date(), "10% sur une slection de produits", true, admin, 10); Product productAccessorie = new ProductAccessories(null, "un mug", 25.0, "un beau mug", new Date()); Supplier supplier1 = new Supplier(null, "Aux bon vins de Bourgogne", "05 85 74 85 69", "vinsbourgogne@gmail.com", new Date()); Supplier supplier2 = new Supplier(null, "Aux bon vins de Bordeaux", "04 85 74 85 69", "vinsbordeaux@gmail.com", new Date()); Supplier supplier3 = new Supplier(null, "Aux bon vins de l'Aude", "07 85 74 85 69", "vinsaude@gmail.com", new Date()); try { //Les Set sont particulirement adapts pour manipuler une grande //quantit de donnes. Cependant, les performances de ceux-ci peuvent //tre amoindries en insertion. Gnralement, on opte pour un HashSet, //car il est plus performant en temps d'accs ProductSupplier productSuppliers1 = new ProductSupplier(); ProductSupplier productSuppliers2 = new ProductSupplier(); productSuppliers1.setProduct(productRand); productSuppliers1.setSupplier(daoSupplier.insertObj(supplier1)); productSuppliers1.setQuantity(30); productSuppliers2.setProduct(productRand); productSuppliers2.setSupplier(daoSupplier.insertObj(supplier2)); productSuppliers2.setQuantity(15); productRand.getProductSuppliers().add(productSuppliers1); productRand.getProductSuppliers().add(productSuppliers2); daoVin.insertObj(productRand); ProductSupplier productSuppliers3 = new ProductSupplier(); productSuppliers3.setProduct(productAccessorie); productSuppliers3.setSupplier(daoSupplier.insertObj(supplier3)); productSuppliers3.setQuantity(20); productAccessorie.getProductSuppliers().add(productSuppliers3); daoVin.insertObj(productAccessorie); for (Path filepath : Files.newDirectoryStream(Paths.get(getResourcePath() + "FilesXML/Wines/"))) { if (filepath.getFileName().toString().contains("xml")) { list.add(parseSampleXml("FilesXML/Wines/" + filepath.getFileName())); } } } catch (WineException ex) { java.util.logging.Logger.getLogger(XmlParser.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException e) { java.util.logging.Logger.getLogger(XmlParser.class.getName()).log(Level.SEVERE, null, e); } try { daoEvent.insertObj(se); if (features.isEmpty() == false) { for (ProductFeature pf : features.values()) { daoFeature.insertObj(pf); } } Integer cpt = 0; for (ArrayList<ProductWine> subList : list) { for (ProductWine productWine : subList) { ProductSupplier ps = new ProductSupplier(); ps.setProduct(productWine); ps.setSupplier(supplier1); ps.setQuantity(randomWithRange(1, 50)); productWine.getProductSuppliers().add(ps); if (cpt % 2 == 0) { ProductSupplier ps2 = new ProductSupplier(); ps2.setProduct(productWine); ps2.setSupplier(supplier2); ps2.setQuantity(randomWithRange(1, 50)); productWine.getProductSuppliers().add(ps2); } else if (cpt % 3 == 0) { ProductSupplier ps3 = new ProductSupplier(); ps3.setProduct(productWine); ps3.setSupplier(supplier3); ps3.setQuantity(randomWithRange(1, 50)); productWine.getProductSuppliers().add(ps3); } if (cpt < 11) { productWine.setSpeEvent(se); } daoVin.insertObj(productWine); Wine esWine = new Wine(productWine.getId(), productWine.getName(), productWine.getAppellation(), productWine.getPrice(), productWine.getApiId(), new WineType(productWine.getProductType().getId(), productWine.getProductType().getType()), new WineVintage(((productWine.getProductVintage() != null) ? productWine.getProductVintage().getYear().toString() : "")), new WineVarietal(productWine.getProductVarietal().getId(), productWine.getProductVarietal().getDescription())); for (ProductFeature feat : productWine.getFeatures()) { esWine.addFeature(new WineFeature(feat.getId(), feat.getLabel())); } esRepository.save(esWine); cpt++; } } } catch (WineException paramE) { // TODO Auto-generated catch block paramE.printStackTrace(); } /*BeanFactory bf = new ClassPathXmlApplicationContext("classpath:springData.xml"); IDaoProduct daoVin = (IDaoProduct) bf.getBean(IDaoProduct.class); try { BeanFactory bf = new ClassPathXmlApplicationContext("classpath:springData.xml"); IDaoProduct daoVin = (IDaoProduct) bf.getBean(IDaoProduct.class); List<Product> list = daoVin.findAllObj(); for (Product product : list) { String imagesUrl = ((ProductWine)product).getImagesUrl(); String xmlId = ((ProductWine)product).getApiId().toString(); String [] urls = imagesUrl.split("\\|"); for (int i = 0; i < urls.length; i++) { if(urls[i].trim()!=""){ URL url = new URL(urls[i].trim()); String filename = FilenameUtils.getBaseName(url.toString())+"."+FilenameUtils.getExtension(url.toString()); if(Files.exists(Paths.get(getResourcePath() + "wine_pictures/"+xmlId+"/"+filename))==false){ File file = new File(getResourcePath() + "wine_pictures/"+xmlId+"/"+filename); try { FileUtils.copyURLToFile(url, file); } catch (FileNotFoundException e) { } } if(filename==xmlId+"m.jpg"){ if(Files.exists(Paths.get(getResourcePath() + "wine_pictures/"+xmlId+"/"+xmlId+"l.jpg"))==false){ File file = new File(getResourcePath() + "wine_pictures/"+xmlId+"/"+xmlId+"l.jpg"); URL url2 = new URL(urls[i].trim().replace("m.jpg", "l.jpg")); try { FileUtils.copyURLToFile(url2, file); } catch (FileNotFoundException e) { } } } } } if(xmlId.length()==6){ URL url = new URL("http://cdn.fluidretail.net/customers/c1477/"+xmlId.substring(0, 2)+"/"+xmlId.substring(2,4)+"/"+xmlId.substring(4)+"/_s/pi/n/"+xmlId+"_spin_spin2/main_variation_na_view_01_204x400.jpg"); if(Files.exists(Paths.get(getResourcePath() + "wine_pictures/"+xmlId+"/"+xmlId+"_front.jpg"))==false){ File file = new File(getResourcePath() + "wine_pictures/"+xmlId+"/"+xmlId+"_front.jpg"); try { FileUtils.copyURLToFile(url, file); } catch (FileNotFoundException e) { } } URL url2 = new URL("http://cdn.fluidretail.net/customers/c1477/"+xmlId.substring(0, 2)+"/"+xmlId.substring(2,4)+"/"+xmlId.substring(4)+"/_s/pi/n/"+xmlId+"_spin_spin2/main_variation_na_view_07_204x400.jpg"); if(Files.exists(Paths.get(getResourcePath() + "wine_pictures/"+xmlId+"/"+xmlId+"_back.jpg"))==false){ File file = new File(getResourcePath() + "wine_pictures/"+xmlId+"/"+xmlId+"_back.jpg"); try { FileUtils.copyURLToFile(url2, file); } catch (FileNotFoundException e) { } } } } } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (WineException e) { // TODO Auto-generated catch block e.printStackTrace(); } //http://cdn.fluidretail.net/customers/c1477/13/68/80/_s/pi/n/136880_spin_spin2/main_variation_na_view_01_204x400.jpg*/ insert_translations(bf, bf2); log.info("\t ### Fin du test ###"); }
From source file:ru.elcor.mis.scheduler.point.EndPoint.java
public static void doit() throws InterruptedException { ApplicationContext AppCxt = new AnnotationConfigApplicationContext(AppConfig.class); // System.setProperty("setCron", "0-59 * * * * *"); Job jobs = AppCxt.getBean(Job.class); for (int i = 0; i < 10; i++) { System.out.println("soy"); Thread.sleep(1000);/* w ww . ja va2 s .co m*/ } }
From source file:com.banda.truckmanagement.EncapsulationTest.java
@org.testng.annotations.BeforeClass public static void setUpClass() throws Exception { ApplicationContext ctx = new AnnotationConfigApplicationContext(AppConfig.class); addEmployeeServ = (AddNewEmployeeService) ctx.getBean("addNewEmployee"); }
From source file:walkAlong.NewEmptyTestNGTest.java
@org.testng.annotations.BeforeClass public static void setUpClass() throws Exception { ApplicationContext ctx = new AnnotationConfigApplicationContext(StepsConfig.class); stepsServ = (Steps) ctx.getBean("stepsBean"); }
From source file:TestCases.TestFail.java
@BeforeClass public static void setUpClass() throws Exception { ctx = new AnnotationConfigApplicationContext(Setup.class); }
From source file:ch.elca.training.MainApplication.java
private static void startup() { applicationContext = new AnnotationConfigApplicationContext(ApplicationConfiguration.class); }