List of usage examples for org.springframework.context.support ClassPathXmlApplicationContext ClassPathXmlApplicationContext
public ClassPathXmlApplicationContext(String... configLocations) throws BeansException
From source file:com.us.test.PageTest.java
public static void main(String[] args) { ApplicationContext app = new ClassPathXmlApplicationContext("classpath:/applicationContext.xml"); IDao dao = app.getBean(IDao.class); DetachedCriteria criteria = dao.init(User.class); criteria.addOrder(Order.asc("uuid")); criteria.addOrder(Order.asc("name")); criteria.add(Restrictions.gt("uuid", 0l)); dao.findPage(criteria, 1, 20);/*from ww w. jav a 2 s. co m*/ }
From source file:yangqi.spring3.aop.AopMain.java
/** * @param args//w w w.jav a2 s . c o m */ public static void main(String[] args) { ApplicationContext context = new ClassPathXmlApplicationContext("aop.xml"); Performer performer = (Performer) context.getBean("performer"); System.out.println("START NOW"); performer.perform(); System.out.println("shit"); }
From source file:edu.eci.arsw.loannetsim.LoanNetworkSimulation.java
public static void main(String args[]) throws InterruptedException, IOException { ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml"); int balancesSum = 0; List<Lender> lenders = setupLoanNetwork(NUMOF_LENDERS, ac); if (lenders != null) { for (Lender im : lenders) { new Thread(im).start(); }/* ww w.ja v a 2s .co m*/ } while (true) { Thread.sleep(10000); FixedMoneyLender.pause(); System.out.println("*** PRESS ENTER TO VIEW STATISTICS ***"); System.in.read(); balancesSum = 0; for (Lender ln : lenders) { balancesSum += ln.getBalance(); } System.out.println("Sum of balances:" + balancesSum); System.out.println("Press enter to continue simulation or Ctrl+C to abort..."); System.in.read(); FixedMoneyLender.resume(); synchronized (lenders) { lenders.notifyAll(); } } }
From source file:com.spring.tutorial.messages.App.java
public static void main(String[] args) { ApplicationContext ctx = new ClassPathXmlApplicationContext( "com/spring/tutorial/messages/applicationContext.xml"); MessageSource ms = ctx.getBean(MessageSource.class); //Message resolution String success = ms.getMessage("msg.success", null, Locale.getDefault()); String successEN = ms.getMessage("msg.success", null, Locale.ENGLISH); String successFR = ms.getMessage("msg.success", null, Locale.FRENCH); String successDE = ms.getMessage("msg.success", null, Locale.GERMAN); //Message resolution and i18n String label = ms.getMessage("lbl.result", null, Locale.getDefault()); //Not necessary to pass the locale String error = ms.getMessage("err.failure", null, null); //Non-existent message (if the call does not specify, the default message argument, //and the message code does not exist, an exception will be thrown) String nonExistent = ms.getMessage("my.message", null, "Not found, defaults to this message", null); LOGGER.info("Success message (es - the default): " + success); LOGGER.info("Success message (en): " + successEN); LOGGER.info("Success message (fr): " + successFR); LOGGER.info("Success message (de) defaults to local language: " + successDE); LOGGER.info("Label text: " + label); LOGGER.info("Error message: " + error); LOGGER.info("Non-existent message (defaults to message specified as argument): " + nonExistent); ((ClassPathXmlApplicationContext) ctx).close(); }
From source file:com.fileanalyzer.main.Main.java
public static void main(String[] args) throws IOException { FileAnalyzer fl = null;/*from w w w.j a v a 2 s . c o m*/ try { ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("spring.xml"); Configuration conf = (Configuration) ctx.getBean("configuration"); fl = (FileAnalyzer) ctx.getBean("fileAnalyzer"); if (args.length == 3 && args[1].equalsIgnoreCase("s")) { log.info("Added file id: " + fl.analizeString(args[0], args[2])); } else if (args.length == 2 && args[1].equalsIgnoreCase("a")) { fl.analizeFile(args[0], true); } else if (args.length == 1) fl.analizeFile(args[0], false); else { log.info(conf.getWrongParams()); Thread.sleep(3000); System.exit(1); } log.info("Press any key to exit..."); System.in.read(); } catch (Exception ex) { ex.printStackTrace(); } finally { if (fl != null) { fl.shutDown(); } System.exit(0); } }
From source file:net.vnt.ussdapp.util.ContextTest.java
public static void main(String[] args) { ApplicationContext context = new ClassPathXmlApplicationContext(new String[] { "/context.xml" }); ContextProperties ctxProp = (ContextProperties) Context.getInstance().getBean("ContextProperties"); TXTParser parser = (TXTParser) Context.getInstance().getBean("TXTParser"); String mainmenu = ctxProp.getProperty("ussdapp.wrong"); try {/*from w ww . j av a2 s.c o m*/ Vector<String> vs = parser.readFields(mainmenu); Enumeration<String> ens = vs.elements(); StringBuilder sb = new StringBuilder(); while (ens.hasMoreElements()) { sb.append(ens.nextElement()).append("\n"); } System.out.println(sb.toString()); } catch (IOException ex) { Logger.getLogger(ContextTest.class.getName()).log(Level.SEVERE, null, ex); } System.out.println(System.getProperty("os.arch")); }
From source file:com.aan.girsang.server.launcher.ServerLauncher.java
public static void main(String[] args) { try {/* w w w .j a va2 s .c o m*/ AbstractApplicationContext ctx = new ClassPathXmlApplicationContext( new String[] { "applicationContext.xml", "serverContext.xml" }); ctx.registerShutdownHook(); log.info("SERVER ONLINE"); } catch (BeanCreationException bce) { JOptionPane.showMessageDialog(null, "Server Sudah Aktif"); bce.printStackTrace(); } }
From source file:com.dbconnection.DataSourceConnection.java
public static void main(String[] args) throws Exception { ApplicationContext appContext = new ClassPathXmlApplicationContext("beans.xml"); DataSource dataSource = (DataSource) appContext.getBean("dataSource"); Connection connection = dataSource.getConnection(); System.out.println("Database with data source connected!"); String result = query(connection); System.out.println(result);//from w w w.j a v a2 s. com }
From source file:yangqi.spring3.aop.anno.AnnoMain.java
/** * @param args/* w ww . j a v a2 s . c om*/ */ public static void main(String[] args) { ApplicationContext context = new ClassPathXmlApplicationContext("aop.xml"); Human human = (Human) context.getBean("human"); human.sleep(); Dog dog = (Dog) context.getBean("dog"); dog.sleep(); human.speak("fuck you"); }
From source file:com.anton.dev.tqrbs2.test.TestApp.java
public static void main(String[] args) { LOGGER.info("Iniciacion App."); ApplicationContext context = new ClassPathXmlApplicationContext("test-spring-config.xml"); final TestSender bean = context.getBean(TestSender.class); bean.sendMessage();/*from www.j a va 2 s .co m*/ }