List of usage examples for org.springframework.context ApplicationContext getBean
Object getBean(String name) throws BeansException;
From source file:com.netpet.spools.javacore.study.proxy.springcase.testProxyClient.java
/** * Use the Spring for calling the Proxy Class. * * @param args//from www . ja v a 2 s. co m */ public static void main(String[] args) { //SpringDIBean ApplicationContext ctx = new FileSystemXmlApplicationContext("bean.xml"); System.out.println(Subject.class.getCanonicalName()); Subject sub = (Subject) ctx.getBean(Subject.class.getCanonicalName()); MyHandler handler1 = new MyHandler(); MyHandler handler2 = new MyHandler(); handler1.SetSub(sub); //? Subject proxySub1 = (Subject) Proxy.newProxyInstance(RealSubject.class.getClassLoader(), RealSubject.class.getInterfaces(), handler1); Subject proxySub2 = (Subject) Proxy.newProxyInstance(RealSubject.class.getClassLoader(), RealSubject.class.getInterfaces(), handler2); proxySub1.sailBook(); proxySub2.sailBook(); }
From source file:org.ala.hbase.AdfInfoSourceUrlUpdater.java
/** * Usage: outputFileName [option: cassandraAddress cassandraPort] * /* w w w . j a v a2s .c om*/ * @param args */ public static void main(String[] args) throws Exception { Map<String, String> hashtable = new Hashtable<String, String>(); for (int i = 0; i < args.length; i++) { String infoId = args[i].substring(0, args[i].indexOf(':')); String url = args[i].substring(args[i].indexOf(':') + 1); hashtable.put(infoId, url); } ApplicationContext context = SpringUtils.getContext(); AdfInfoSourceUrlUpdater loader = context.getBean(AdfInfoSourceUrlUpdater.class); try { loader.doFullScan(hashtable); } catch (Exception e) { System.out.println("***** Fatal Error !!!.... shutdown cassandra connection."); e.printStackTrace(); logger.error(e); System.exit(0); } System.exit(0); }
From source file:org.ala.hbase.SensitiveStatusLoader.java
/** * Usage: inputFileName//ww w .j ava2 s . c o m * * @param args */ public static void main(String[] args) { System.out.println("Starting Sensitive data process....."); ApplicationContext context = SpringUtils.getContext(); SensitiveStatusLoader l = context.getBean(SensitiveStatusLoader.class); try { System.out.println("Starting load process....."); String fileName = DEFAULT_INPUT_FILE_NAME; if (args.length == 1) { fileName = args[0]; } l.load(fileName); System.out.println("load process finished....."); } catch (Exception e) { e.printStackTrace(); System.exit(1); } System.exit(0); }
From source file:org.lieuofs.extraction.commune.ExtractionGeTax.java
public static void main(String[] args) throws IOException { ApplicationContext context = new ClassPathXmlApplicationContext(new String[] { "beans_extraction.xml" }); ExtractionGeTax extracteur = (ExtractionGeTax) context.getBean("extractionCommuneGeTax"); extracteur.extraire();//www . j a va 2s . co m }
From source file:uk.co.onehp.trickle.routing.BetfairEngineRoutingCustomT.java
/** * @param args/*from w ww. j a va 2 s . c o m*/ * @throws Exception * @throws CamelExecutionException */ public static void main(String[] args) throws CamelExecutionException, Exception { final ApplicationContext applicationContext = new ClassPathXmlApplicationContext( "classpath:/spring-trickle.xml"); final BetfairService betfairService = (BetfairService) applicationContext.getBean("betfairService"); betfairService.login(); // betfairService.getUkMarket(); // betfairService.getMeeting(26676407); // betfairService.getRace(102267423); // betfairService.getRacePrices(102267423); }
From source file:org.freewheelschedule.freewheel.remoteworker.RemoteWorker.java
/** * main method to start the RemoteWorker processes. * @param args//from w ww. ja v a2 s . c om */ public static void main(String[] args) { ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext-RemoteWorker.xml"); RemoteWorker worker = (RemoteWorker) ctx.getBean("remoteWorker"); worker.runRemoteWorker(); worker.joinListenerThread(); }
From source file:org.lieuofs.extraction.etatpays.ExtractionGeTaX.java
/** * @param args/*ww w . j a v a 2 s. c om*/ */ public static void main(String[] args) throws IOException { ApplicationContext context = new ClassPathXmlApplicationContext(new String[] { "beans_extraction.xml" }); ExtractionGeTaX extracteur = (ExtractionGeTaX) context.getBean("extractionEtatGeTax"); extracteur.extraire(); }
From source file:org.seasar.dao.spring.example.EmployeeAutoDaoClient.java
public static void main(final String[] args) { final BeanFactoryLocator locator = ContextSingletonBeanFactoryLocator.getInstance(); final BeanFactoryReference ref = locator.useBeanFactory("context"); final ApplicationContext context = (ApplicationContext) ref.getFactory(); try {//from www.j a v a 2s. c om final EmployeeAutoDao dao = (EmployeeAutoDao) context.getBean("employeeAutoDao"); dao.getEmployeeByJobDeptno(null, null); dao.getEmployeeByJobDeptno("CLERK", null); dao.getEmployeeByJobDeptno(null, new Integer(20)); dao.getEmployeeByJobDeptno("CLERK", new Integer(20)); List employees = dao.getEmployeesBySal(0, 1000); for (int i = 0; i < employees.size(); ++i) { System.out.println(employees.get(i)); } employees = dao.getEmployeeByDname("SALES"); for (int i = 0; i < employees.size(); ++i) { System.out.println(employees.get(i)); } final EmployeeSearchCondition dto = new EmployeeSearchCondition(); dto.setDname("RESEARCH"); employees = dao.getEmployeesBySearchCondition(dto); for (int i = 0; i < employees.size(); ++i) { System.out.println(employees.get(i)); } final Employee employee = dao.getEmployeeByEmpno(7788); System.out.println("before timestamp:" + employee.getTimestamp()); dao.update(employee); System.out.println("after timestamp:" + employee.getTimestamp()); } finally { ref.release(); } }
From source file:to.sparks.mtgox.example.HowToWithdrawBitcoins.java
/** * * Send the entire bitcoin balance of a MtGox account to a destination * bitcoin address.//from www. j ava2 s .c om * OTP is not supported! Please turn off Yubikey/OTP * * @param args The destination bitcoin address * @throws Exception OTP is not supported! Please turn off Yubikey/OTP */ public static void main(String[] args) throws Exception { // Obtain a $USD instance of the API ApplicationContext context = new ClassPathXmlApplicationContext("to/sparks/mtgox/example/Beans.xml"); MtGoxHTTPClient mtGoxAPI = (MtGoxHTTPClient) context.getBean("mtgoxUSD"); HashMap<String, Wallet> wallets = mtGoxAPI.getAccountInfo().getWallets(); Wallet btcWallet = wallets.get("BTC"); MtGoxBitcoin mtgoxBalance = (MtGoxBitcoin) btcWallet.getBalance(); logger.log(Level.INFO, "MtGox account balance: BTC {0}", mtgoxBalance.toPlainString()); if (mtgoxBalance.compareTo(BigDecimal.ZERO) > 0) { MtGoxBitcoin fee = new MtGoxBitcoin(0.0005D); // Transaction fee MtGoxBitcoin transferAmount = new MtGoxBitcoin(mtgoxBalance.subtract(fee)); if (transferAmount.compareTo(BigDecimal.ZERO) > 0) { logger.log(Level.INFO, "Transferring BTC {0} to bitcoin address {1} and paying fee {2}", new Object[] { transferAmount.toPlainString(), args[0], fee.toPlainString() }); SendBitcoinsTransaction trx = mtGoxAPI.sendBitcoins(args[0], transferAmount, fee, true, false); logger.log(Level.INFO, "Transfer success. trx: {0}", trx.getTrx()); } } }
From source file:to.sparks.mtgox.example.HowToGetInfo.java
public static void main(String[] args) throws Exception { // Obtain a $USD instance of the API ApplicationContext context = new ClassPathXmlApplicationContext("to/sparks/mtgox/example/Beans.xml"); MtGoxHTTPClient mtgoxUSD = (MtGoxHTTPClient) context.getBean("mtgoxUSD"); Lag lag = mtgoxUSD.getLag();// w w w .ja v a 2 s.c om logger.log(Level.INFO, "Current lag: {0}", lag.getLag()); Ticker ticker = mtgoxUSD.getTicker(); logger.log(Level.INFO, "Last price: {0}", ticker.getLast().toPlainString()); // Get the private account info AccountInfo info = mtgoxUSD.getAccountInfo(); logger.log(Level.INFO, "Logged into account: {0}", info.getLogin()); Order[] openOrders = mtgoxUSD.getOpenOrders(); if (ArrayUtils.isNotEmpty(openOrders)) { for (Order order : openOrders) { logger.log(Level.INFO, "Open order: {0} status: {1} price: {2}{3} amount: {4}", new Object[] { order.getOid(), order.getStatus(), order.getCurrency().getCurrencyCode(), order.getPrice().getDisplay(), order.getAmount().getDisplay() }); } } else { logger.info("There are no currently open bid or ask orders."); } }