List of usage examples for org.springframework.context ApplicationContext getBean
Object getBean(String name) throws BeansException;
From source file:org.ala.report.CsvImageReportGenerator.java
/** * @param args// w w w. j av a 2 s . c o m */ public static void main(String[] args) throws Exception { if (args.length != 2) { System.out.println("Input File Name && Output Directory...."); System.exit(0); } ApplicationContext context = SpringUtils.getContext(); CsvImageReportGenerator reportGen = (CsvImageReportGenerator) context .getBean(CsvImageReportGenerator.class); reportGen.runReport(args[0], args[1]); System.exit(0); }
From source file:com.mattbolt.javaray.JavaRay.java
public static void main(String[] args) { logger.info("Starting JavaRay Ray-Tracer by: Matt Bolt [mbolt35@gmail.com]"); ApplicationContext appContext = new ClassPathXmlApplicationContext("/JavaRayApplicationContext.xml"); JavaRayConfiguration configuration = (JavaRayConfiguration) appContext.getBean("javaRayConfiguration"); View view = new View(configuration); logger.debug(new StringBuilder("Configuration: [View: ").append(configuration.getViewWidth()).append("x") .append(configuration.getViewHeight()).append("], [Anti-Alias: ") .append(configuration.getAntiAlias()).append("]").toString()); Camera camera = new Camera(new Vector3(4, 3, 3)); Scene scene = getSceneThree(configuration); long t = new Date().getTime(); //new RayTracer(configuration).synchronousRender(scene, view, camera); final ImageTarget image = new ImageTarget("test", ImageTarget.ImageType.PNG, view.getWidth(), view.getHeight());/* w w w . j av a2 s . c o m*/ final WindowTarget window = new WindowTarget(1900, 0, view.getWidth(), view.getHeight()); new RayTracer(configuration).render(scene, view, camera, window); long totalTime = ((new Date().getTime() - t) / 1000); logger.debug("Complete! Took: " + totalTime + "seconds"); }
From source file:org.ala.util.RebuildFromFS.java
/** * @param args/* w w w .jav a2 s . co m*/ */ public static void main(String[] args) throws Exception { ApplicationContext context = new ClassPathXmlApplicationContext("classpath*:spring.xml"); RebuildFromFS r = (RebuildFromFS) context.getBean("rebuilder"); if (args.length == 0) { r.rebuildFS("/data/bie", "/data/bie-new"); r.rebuildDatabase("/data/bie"); } if (args.length == 1 || "fs".equals(args[0])) { r.rebuildFS("/data/bie", "/data/bie-new"); } if (args.length == 2 || "db".equals(args[0])) { r.rebuildDatabase(args[1]); } }
From source file:ch.tatool.app.App.java
/** * Main method. Loads the application through an application context. * Requires two arguments: module ID (integer) and code (String). These are used to * set which module will be loaded. //from www . j a va 2 s .com * * The main class App itself then performs the final initialization by loading the * module and displaying the GUI. */ public static void main(String[] args) { // TODO localize error messages if (args.length < 2) { JOptionPane.showMessageDialog(null, "Please provide module ID number and code.", "Error: missing module data", JOptionPane.ERROR_MESSAGE); return; } // load the application ApplicationContext ctx = new ClassPathXmlApplicationContext("/tatool/application-context.xml"); // Set the module that should be loaded GuiController controller = (GuiController) ctx.getBean("GuiController"); try { controller.setModuleID(Integer.parseInt(args[0])); controller.setCode(args[1]); } catch (NumberFormatException e) { JOptionPane.showMessageDialog(null, args[0] + " is not a valid module ID number.", "Error: invalid module ID", JOptionPane.ERROR_MESSAGE); return; } }
From source file:org.pentaho.aggdes.ui.UIMain.java
/** * The main startup of the Aggregation Designer * @param args// w w w . java2 s. com */ public static void main(String[] args) { try { KettleClientEnvironment.init(); ApplicationContext context = new ClassPathXmlApplicationContext( new String[] { "applicationContext.xml", "plugins.xml" }); //$NON-NLS-1$ //$NON-NLS-2$ UIMain uiMain = (UIMain) context.getBean("uiMain"); //$NON-NLS-1$ uiMain.start(context); } catch (Throwable t) { logger.error("uncaught exception in main", t); System.exit(1); } }
From source file:org.ala.hbase.SpecimenHoldingLoader.java
/** * Usage: inputFileName//from w w w . ja v a2 s . c o m * * @param args */ public static void main(String[] args) { if (args.length < 1) { System.out.println("Input File Name Missing ...."); System.exit(0); } System.out.println("Starting SpecimenHoldingLoader process....."); ApplicationContext context = SpringUtils.getContext(); SpecimenHoldingLoader l = context.getBean(SpecimenHoldingLoader.class); try { System.out.println("Starting load process....."); if (args.length > 1) { l.load(args[0], Boolean.parseBoolean(args[1])); } else { l.load(args[0], true); } System.out.println("load process finished....."); } catch (Exception e) { e.printStackTrace(); System.exit(1); } System.exit(0); }
From source file:org.string_db.jdbc.Postgres2HSQLDB.java
public static void main(final String[] args) throws FileNotFoundException, UnsupportedEncodingException, SQLException { final ApplicationContext ctx = new AnnotationConfigApplicationContext(DbConfig.class, DriverDataSourceConfig.class); final JdbcTemplate jdbcTemplate = ctx.getBean(JdbcTemplate.class); final Postgres2HSQLDB converter = new Postgres2HSQLDB(jdbcTemplate); converter.dumpTable("items", "species", "species_id in (882, 3702, 4932, 7227, 9606, 10090, 272634, 511145)", "hsql-data.sql"); // skip checksum (not used) and annotation_word_vectors columns (postgresql specific data type - tsvector) converter.dumpTable("items", "proteins", "species_id in (511145)", "hsql-data.sql", new String[] { "protein_id", "protein_external_id", "species_id", "annotation", "preferred_name" }); // m.pneumoniae has fewest names: converter.dumpTable("items", "proteins_names", "species_id in (272634)", "hsql-data.sql", new String[] { "protein_id", "protein_name", "species_id", /*escape keyword*/"\"source\"", "linkout" }); }
From source file:com.mvdb.etl.actions.InitCustomerData.java
public static void main(String[] args) { ActionUtils.assertEnvironmentSetupOk(); ActionUtils.assertFileExists("~/.mvdb", "~/.mvdb missing. Existing."); ActionUtils.assertFileExists("~/.mvdb/status.InitDB.complete", "200initdb.sh not executed yet. Exiting"); ActionUtils.assertFileDoesNotExist("~/.mvdb/status.InitCustomerData.complete", "InitCustomerData already done. Start with 100init.sh if required. Exiting"); ActionUtils.setUpInitFileProperty(); ActionUtils.createMarkerFile("~/.mvdb/status.InitCustomerData.start"); Date startDate = null;/* w ww . ja v a 2 s . c om*/ Date endDate = null; String customerName = null; int batchCountF = 0; int batchSizeF = 0; final CommandLineParser cmdLinePosixParser = new PosixParser(); final Options posixOptions = constructPosixOptions(); CommandLine commandLine; try { commandLine = cmdLinePosixParser.parse(posixOptions, args); if (commandLine.hasOption("customer")) { customerName = commandLine.getOptionValue("customer"); } if (commandLine.hasOption("batchSize")) { String batchSizeStr = commandLine.getOptionValue("batchSize"); batchSizeF = Integer.parseInt(batchSizeStr); } if (commandLine.hasOption("batchCount")) { String batchCountStr = commandLine.getOptionValue("batchCount"); batchCountF = Integer.parseInt(batchCountStr); } if (commandLine.hasOption("startDate")) { String startDateStr = commandLine.getOptionValue("startDate"); startDate = ActionUtils.getDate(startDateStr); } if (commandLine.hasOption("endDate")) { String endDateStr = commandLine.getOptionValue("endDate"); endDate = ActionUtils.getDate(endDateStr); } } catch (ParseException parseException) // checked exception { System.err.println( "Encountered exception while parsing using PosixParser:\n" + parseException.getMessage()); } if (startDate == null) { System.err.println( "startDate has not been specified with the correct format YYYYMMddHHmmss. Aborting..."); System.exit(1); } if (endDate == null) { System.err .println("endDate has not been specified with the correct format YYYYMMddHHmmss. Aborting..."); System.exit(1); } if (endDate.after(startDate) == false) { System.err.println("endDate must be after startDate. Aborting..."); System.exit(1); } // if you have time, // it's better to create an unit test rather than testing like this :) ApplicationContext context = Top.getContext(); final OrderDAO orderDAO = (OrderDAO) context.getBean("orderDAO"); final ConfigurationDAO configurationDAO = (ConfigurationDAO) context.getBean("configurationDAO"); initData(orderDAO, batchCountF, batchSizeF, startDate, endDate); initConfiguration(configurationDAO, customerName, endDate); int total = orderDAO.findTotalOrders(); System.out.println("Total : " + total); long max = orderDAO.findMaxId(); System.out.println("maxid : " + max); ActionUtils.createMarkerFile("~/.mvdb/status.InitCustomerData.complete"); }
From source file:dk.teachus.backend.database.SchemaExport.java
public static void main(String[] args) { ApplicationContext context = new ClassPathXmlApplicationContext( new String[] { "/dk/teachus/backend/applicationContext.xml", "/dk/teachus/backend/database/applicationContext-schemaExport.xml", }); LocalSessionFactoryBean sessionFactory = (LocalSessionFactoryBean) context.getBean("&sessionFactory"); org.hibernate.tool.hbm2ddl.SchemaExport export = new org.hibernate.tool.hbm2ddl.SchemaExport( sessionFactory.getConfiguration()); export.setOutputFile("target/schema.sql"); export.execute(false, false, false, true); System.exit(0);//w w w . j a v a2 s .c om }
From source file:org.berlin.crawl.util.ListSeedsMain.java
public static void main(final String[] args) { logger.info("Running"); final ApplicationContext ctx = new ClassPathXmlApplicationContext( "/org/berlin/batch/batch-databot-context.xml"); final BotCrawlerDAO dao = new BotCrawlerDAO(); final SessionFactory sf = (SessionFactory) ctx.getBean("sessionFactory"); Session session = sf.openSession();//from w ww . j av a2 s .c o m final StringBuffer buf = new StringBuffer(); final List<String> seeds = dao.findHosts(session); final String nl = System.getProperty("line.separator"); buf.append(nl); for (final String seed : seeds) { buf.append(PREFIX); buf.append(seed); buf.append(POST1); buf.append("/"); buf.append(POST2); buf.append(nl); } // End of the for // logger.info(buf.toString()); // Now print the number of links // final List<Long> ii = dao.countLinks(session); logger.warn("Count of Links : " + ii); // Also print top hosts // final List<Object[]> hosts = dao.findTopHosts(session); Collections.reverse(hosts); for (final Object[] oo : hosts) { System.out.println(oo[0] + " // " + oo[1].getClass()); } if (session != null) { // May not need to close the session session.close(); } // End of the if // logger.info("Done"); }