List of usage examples for org.springframework.context ApplicationContext getBean
Object getBean(String name) throws BeansException;
From source file:org.apius.server.JseComponentBootstrap.java
/** * Takes two string parameters:/*from ww w.ja v a 2 s. c o m*/ * 1) Classpath to the bean factory. * 2) Name (ref) of the Restlet Component as indicated in the bean factory XML file. * * @param path * @param name * @return void */ public static void main(String[] args) throws Exception { String resourceClassPath = args[0]; String componentBean = args[1]; ClassPathResource resource = new ClassPathResource(resourceClassPath); ApplicationContext context = new ClassPathXmlApplicationContext(resource.getPath()); Component component = (Component) context.getBean(componentBean); component.start(); }
From source file:org.devware.batch.main.Launcher.java
public static void main(String arg[]) { String[] springConfig = { "org/devware/config/context/readerConfig.xml", "org/devware/config/context/writerConfig.xml", "org/devware/config/context/processorConfig.xml", "org/devware/config/datasource/datasource.xml" }; ApplicationContext context = new ClassPathXmlApplicationContext(springConfig); JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher"); Job job = (Job) context.getBean("ExcelReaderJob"); try {/*from w w w.j a v a2s . c o m*/ JobExecution execution = jobLauncher.run(job, new JobParameters()); System.out.println("Exit Status : " + execution.getStatus()); } catch (Exception e) { // e.printStackTrace(); } System.out.println("Done"); }
From source file:org.springone2gx_2011.integration.retry.RetryDemo.java
public static void main(String[] args) { ApplicationContext context = new ClassPathXmlApplicationContext("retry-config.xml", RetryDemo.class); RetryGateway gateway = context.getBean(RetryGateway.class); String reply = gateway.process("a"); System.out.println("Reply: " + reply); }
From source file:org.apache.cxf.transport.xmpp.iq.Client.java
public static void main(String[] args) { ApplicationContext context = new ClassPathXmlApplicationContext("client-iq-applicationContext.xml"); HelloWorld client = (HelloWorld) context.getBean("helloClient"); long startTime = System.currentTimeMillis(); String serviceResponse = client.sayHi("XMPP Service Call-1"); System.out.println("Elapsed time: " + (System.currentTimeMillis() - startTime)); System.out.println("Service said: " + serviceResponse); startTime = System.currentTimeMillis(); serviceResponse = client.sayHi("XMPP Service Call-2"); System.out.println("Elapsed time: " + (System.currentTimeMillis() - startTime)); System.out.println("Service said: " + serviceResponse); }
From source file:com.jatin.auto.imdg.node.Main.java
public static void main(String args[]) { ApplicationContext context = new ClassPathXmlApplicationContext("app-context.xml"); CustomerService customerService = context.getBean(CustomerService.class); log.info("Retrieving objects not in cache..."); for (long i = 1; i <= 2; i++) { log.info("Retrieving object with id: " + i); Customer c = customerService.findCustomer(i); log.info("Retrieved " + c.getFirstname() + " " + c.getLastname()); }/*from w w w . j ava2 s . c o m*/ log.info("Retrieving the same objects again. This time, the target method is not actually invoked!"); log.info("@Cacheable causes Spring to wrap CustomerService in a proxy: " + customerService.getClass().getName()); for (int i = 1; i <= 2; i++) { log.info("Retrieving object with id: " + i); Customer c = customerService.findCustomer(i); log.info("Retrieved " + c.getFirstname() + " " + c.getLastname()); } }
From source file:dev.dposadsky.java.swingteacherdesktop.main.Start.java
public static void main(String[] args) throws SQLException { SwingUtilities.invokeLater(new Runnable() { @Override// w w w . ja v a2s .c o m public void run() { ApplicationContext context = new ClassPathXmlApplicationContext("context.xml"); MainFrameController mainFrameController = (MainFrameController) context .getBean("mainFrameController"); } }); }
From source file:org.seasar.dao.spring.example.Employee2DaoClient.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 w w w. j a v a 2 s.c o m final Employee2Dao dao = (Employee2Dao) context.getBean("employee2Dao"); final List employees = dao.getEmployees("CO"); for (int i = 0; i < employees.size(); ++i) { System.out.println(employees.get(i)); } final Employee employee = dao.getEmployee(7788); System.out.println(employee); } finally { ref.release(); } }
From source file:com.igorbaiborodine.example.mybatis.MyBatisWithAnnotaionsExample.java
public static void main(String[] args) throws ServiceException { ApplicationContext ctx = new ClassPathXmlApplicationContext("/spring/application-context.xml"); CustomerService customerService = (CustomerService) ctx.getBean("customerService"); Customer customer = customerService.findCustomer((short) 1); logger.info("Found " + customer); }
From source file:de.iritgo.nexim.App.java
public static void main(String[] args) { ApplicationContext appContext = new ClassPathXmlApplicationContext("nexim.spring.xml"); @SuppressWarnings("unused") IMServer imServer = (IMServer) appContext.getBean("de.iritgo.nexim.IMServer"); }
From source file:org.rcop.main.DrawingApp.java
public static void main(String[] args) { //Triangle triangle = new Triangle(); //BeanFactory factory = new XmlBeanFactory(new FileSystemResource("spring.xml"));//ficheiro tem de estar no ficheiros de raiz do proj //Triangle triangle = (Triangle) factory.getBean("triangle"); ApplicationContext context = new ClassPathXmlApplicationContext("org/rcop/main/spring.xml");//ficheiro tem de estar nos resources Triangle triangle = (Triangle) context.getBean("triangle"); triangle.draw();/*from w w w. ja v a2 s . c o m*/ }