List of usage examples for org.springframework.context.support ClassPathXmlApplicationContext getBean
@Override public Object getBean(String name) throws BeansException
From source file:com.bt.aloha.batchtest.PerformanceMeasurmentDao.java
public static void main(String[] args) throws Exception { BasicConfigurator.configure();//from ww w. ja v a 2s . co m ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext( "batchTestApplicationContext.xml"); PerformanceMeasurmentDao dao = (PerformanceMeasurmentDao) applicationContext .getBean("performanceMeasurementDaoBean"); if (dao != null) { List<Metrics> metrics = dao.findMetricsByRunId(2192); Map<Long, List<Metrics>> m = new HashMap<Long, List<Metrics>>(); m.put(2192L, metrics); Chart c = new Chart(m); m = dao.findLastXMetricsForTestType(10, "performance.database"); c = new Chart(m); c.saveCombinedChart(new File("unitPerSecond-historical.jpg"), "Runs Per Second", "threads", "runs per second", "Standard Deviation", "threads", "std. deviation"); } // List<Long> runids = dao.findLastXRunId(1000, "unknown"); // for(long runid : runids) // { // List<Long[]> vals = dao.getNumberOfApplicationThreadsFromDescription(runid); // int sz = vals.size(); // Long[] v = new Long[sz]; // int p = 0; // for(Long[] i : vals) // v[p++] = i[1]; // long min = v[0]; // long max = v[sz-1]; // long inc = 0; // if(sz>1) // inc = (max - min) / (sz - 1); // for(Long[] i : vals) // { // String format = String.format(Metrics.TI_STRING, i[1], min, max, inc); // dao.updateThreadInfo(i[0], format); // } // // } System.exit(0); }
From source file:com.all.rds.loader.Loader.java
public static void main(String[] args) { boolean isPlaylistOpt = parseArgs(args); ClassPathXmlApplicationContext appCtx = new ClassPathXmlApplicationContext("applicationContext.xml"); appCtx.refresh();/*from ww w. ja v a 2s. c o m*/ HibernateTemplate hibernateTemplate = (HibernateTemplate) appCtx.getBean("hibernateTemplate"); Loader loader = new Loader(hibernateTemplate); File baseDir = new File(args[args.length - 1]); if (isPlaylistOpt) { loader.loadAllPlaylists(baseDir); } else { loader.loadAllTracks(baseDir); } }
From source file:org.hyperic.hq.hqapi1.tools.Shell.java
public static void main(String[] args) throws Exception { try {//from w w w. ja v a 2 s. c om initConnectionProperties(args); } catch (Exception e) { System.err.println("Error parsing command line connection properties. Cause: " + e.getMessage()); e.printStackTrace(System.err); System.exit(1); } final ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(new String[] { "classpath:/META-INF/spring/hqapi-context.xml", "classpath*:/META-INF/**/*commands-context.xml" }); try { final int exitCode = ((Shell) applicationContext.getBean("commandDispatcher")).dispatchCommand(args); System.exit(exitCode); } catch (Exception e) { System.err.println("Error running command: " + e.getMessage()); e.printStackTrace(System.err); System.exit(1); } }
From source file:th.ac.kmutt.dashboard.rest.application.Main.java
public static void main(String[] args) throws Exception { // Load the Spring application context final ClassPathXmlApplicationContext springContext = new ClassPathXmlApplicationContext( new String[] { "config/applicationContext-common.xml", "config/applicationContext-hibernate.xml", "config/applicationContext-dashboard-resource.xml", "config/applicationContext-root-router.xml", "config/applicationContext-server.xml" }); // Obtain the Restlet component from the Spring context and start it ((Component) springContext.getBean("top")).start(); springContext.close();/*from ww w . j av a2 s . co m*/ /* applicationContext-bps-resource.xml applicationContext-common.xml applicationContext-hibernate.xml applicationContext-root-router.xml applicationContext-server.xml*/ //testXStream(); }
From source file:th.ac.fi2.rest.application.Main.java
public static void main(String[] args) throws Exception { // Load the Spring application context final ClassPathXmlApplicationContext springContext = new ClassPathXmlApplicationContext( new String[] { "config/applicationContext-common.xml", "config/applicationContext-hibernate.xml", "config/applicationContext-fi2-common-resource.xml", "config/applicationContext-root-router.xml", "config/applicationContext-server.xml" }); // Obtain the Restlet component from the Spring context and start it ((Component) springContext.getBean("top")).start(); springContext.close();/*from w w w . j a va2 s. c om*/ /* applicationContext-bps-resource.xml applicationContext-common.xml applicationContext-hibernate.xml applicationContext-root-router.xml applicationContext-server.xml*/ //testXStream(); }
From source file:net.sf.gazpachoquest.extractor.dbunit.DBUnitDataExtractorRunner.java
public static void main(final String[] args) throws Exception { String dbEngine = "db_postgres"; logger.info("Extracting data from {} database in DBUnit format", dbEngine); ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(); ctx.getEnvironment().setActiveProfiles("postgres", dbEngine); ctx.refresh();// ww w . j av a 2 s .c om ctx.setConfigLocations( new String[] { "dbunitextractor-datasource-context.xml", "dbunitextractor-context.xml" }); /*- ctx.getEnvironment().getPropertySources() .addLast(new ResourcePropertySource(String.format("classpath:/database/%s.properties", dbEngine))); */ ctx.refresh(); DBUnitDataExtractor extractor = (DBUnitDataExtractor) ctx.getBean("dbUnitDataExtractor"); extractor.extract(); ctx.close(); logger.info("Done successfully. Check your target directory"); }
From source file:com.trailmagic.image.util.ReplaceImageManifestation.java
public static final void main(String[] args) { if (args.length != 4 && args.length != 3) { printUsage();/*from ww w . j a va 2 s .c o m*/ System.exit(1); } s_log.debug("Before loading context"); ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext(new String[] { "applicationContext-global.xml", "applicationContext-user.xml", "applicationContext-imagestore.xml", "applicationContext-imagestore-authorization.xml", "applicationContext-standalone.xml" }); ReplaceImageManifestation worker = (ReplaceImageManifestation) appContext.getBean(REPLACEIM_BEAN); s_log.debug("got bean " + worker + "with sf: " + worker.sessionFactory + " and IMFactory: " + worker.imfFactory); if (args.length == 3) { worker.replaceManifestations(args[0], args[1], args[2]); System.exit(0); } try { Long manifestId = new Long(args[0]); Integer width = new Integer(args[2]); Integer height = new Integer(args[3]); System.out.println("Updating manifestation id " + manifestId + " from file " + args[1] + " with size " + width + "x" + height); worker.replaceManifestation(manifestId, args[1], width, height); } catch (NumberFormatException e) { printUsage(); System.exit(1); } }
From source file:th.ac.kmutt.chart.rest.application.Main.java
public static void main(String[] args) throws Exception { // Load the Spring application context final ClassPathXmlApplicationContext springContext = new ClassPathXmlApplicationContext( new String[] { "config/applicationContext-common.xml", "config/applicationContext-hibernate.xml", "config/applicationContext-chart-common-resource.xml", "config/applicationContext-root-router.xml", "config/applicationContext-server.xml" }); // Obtain the Restlet component from the Spring context and start it ((Component) springContext.getBean("top")).start(); springContext.close();/*from w ww . jav a 2 s. c o m*/ //initCon(); }
From source file:tetrad.rrd.TestVelocity.java
/** * @param args/* w w w . j ava2 s . co m*/ * @throws Exception */ public static void main(String[] args) throws Exception { String[] configLocations = new String[] { "applicationContext_rrd.xml" }; ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(configLocations); // // String from = "master@tetrad.citsoft.net"; // String[] to = {"tomouki@naver.com", "tomouki@hanmail.net", "tomouki@citsoft.net"}; // String subject = "?? "; // // MailResource mailResource = (MailResource)context.getBean("mailResource"); // mailResource.sendMail(from, to, subject); TestVelocity testVelocity = (TestVelocity) context.getBean("testVelocity"); System.out.println(testVelocity.getText3()); }
From source file:com.jmstoolkit.pipeline.Pipeline.java
/** * * @param args the command line arguments *///from ww w. j av a2s. co m public static void main(final String[] args) { // Have to use System.out as logging is configured by Spring // application context. try { Settings.loadSystemSettings("jndi.properties"); Settings.loadSystemSettings("app.properties"); } catch (JTKException ex) { System.out.println("Failed to load application settings"); System.out.println(JTKException.formatException(ex)); System.exit(1); } final ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(new String[] { "/logging-context.xml", "/infrastructure-context.xml", "/mdb-context.xml", "/jmx-context.xml" }); applicationContext.start(); final DefaultMessageListenerContainer dmlc = (DefaultMessageListenerContainer) applicationContext .getBean("listenerContainer"); if (dmlc != null) { dmlc.start(); final Pipeline pipeline = (Pipeline) applicationContext.getBean("pipelineService"); // enable access to the original application context pipeline.setApplicationContext(applicationContext); // Insure that the Pipeline loads configuration files AFTER // the listenerContainer is running. while (!dmlc.isRunning()) { try { Thread.sleep(100); } catch (InterruptedException ex) { } } pipeline.loadPlugins(); pipeline.sendProperties(); // Keep thread alive while (true) { try { Thread.sleep(1000); } catch (InterruptedException ex) { } } } }