List of usage examples for org.springframework.context.support ClassPathXmlApplicationContext ClassPathXmlApplicationContext
public ClassPathXmlApplicationContext(String... configLocations) throws BeansException
From source file:com.apress.prospringintegration.social.mail.ImapIdleMail.java
public static void main(String[] args) throws Exception { ApplicationContext context = new ClassPathXmlApplicationContext("/spring/mail/imap-idle-mail.xml"); DirectChannel inputChannel = context.getBean("inputChannel", DirectChannel.class); inputChannel.subscribe(new MessageHandler() { public void handleMessage(Message<?> message) throws MessagingException { LOG.info("Message: " + message); }/*ww w. j a v a2 s .c om*/ }); }
From source file:org.ivanursul.investigation.CamelClient.java
public static void main(final String[] args) throws Exception { AbstractApplicationContext context = new ClassPathXmlApplicationContext("camel-client.xml"); ProducerTemplate camelTemplate = context.getBean("camelTemplate", ProducerTemplate.class); Integer value = 33;/*w ww. j a va 2s . c o m*/ // Sending request and receiving result. int response = (Integer) camelTemplate.sendBody("jms:queue:numbers?requestTimeout=2000000", ExchangePattern.InOut, value); // Sending to votes without receiving any result. camelTemplate.sendBody("jms:queue:votes", response); IOHelper.close(context); }
From source file:org.slc.sli.ingestion.tool.OfflineTool.java
public static void main(String[] args) throws IOException { ApplicationContext context = new ClassPathXmlApplicationContext("spring/applicationContext.xml"); OfflineTool main = context.getBean(OfflineTool.class); main.start(args);//from w w w .j av a2s .c o m }
From source file:com.gopivotal.training.VerifyClient.java
/** * @param args/* w ww . j av a 2s.co m*/ */ public static void main(String[] args) { ApplicationContext context = new ClassPathXmlApplicationContext("META-INF/spring/gemfire/cache-config.xml"); ClientCache cache = context.getBean("clientCache", ClientCache.class); if (cache != null) { new VerifyClient(cache).testClient(); } else { System.out.println("Failed to initialize Client Cache"); } }
From source file:com.cimpress.puzzle.Main.java
public static void main(final String... args) { logger.debug("tt"); ApplicationContext cntx = new ClassPathXmlApplicationContext("classpath:spring-integration-context.xml"); AsyncLogger asyncLogger = cntx.getBean("asyncLogger", AsyncLogger.class); asyncLogger.log("Container loaded", String.class, Main.class, logger); PuzzleAPI puzzleAPI = cntx.getBean("puzzleAPI", PuzzleAPI.class); DateTime dt = new DateTime(); Puzzle puzzle = puzzleAPI.generatePuzzle(); // new SquareFinder().solvePuzzle(Environment.getPuzzleObject()); List<Square> squareList = new SquareFinder().solvePuzzle(puzzle); System.out.println("Total squares :" + squareList.size()); puzzleAPI.postSolution(squareList, puzzle.getId()); DateTime d2 = new DateTime(); Duration elapsedTime = new Duration(dt, d2); System.out.println("\nTotal Time Taken :" + elapsedTime.getStandardSeconds()); }
From source file:com.spring.batch.BatchMain.java
public static void main(String[] args) { ApplicationContext ctx = new ClassPathXmlApplicationContext("spring-batch.xml"); JobParametersBuilder jobPara = new JobParametersBuilder(); // Job job = (Job) ctx.getBean("sampleFlow"); JobLauncher launcher = (JobLauncher) ctx.getBean("jobLauncher"); JobExecution result = null;/*from w w w. j a v a 2 s. c om*/ try { result = launcher.run(job, jobPara.toJobParameters()); } catch (JobExecutionAlreadyRunningException e) { e.printStackTrace(); } catch (JobRestartException e) { e.printStackTrace(); } catch (JobInstanceAlreadyCompleteException e) { e.printStackTrace(); } catch (JobParametersInvalidException e) { e.printStackTrace(); } ExitStatus es = result.getExitStatus(); if (es.getExitCode().equals(ExitStatus.COMPLETED.getExitCode())) { System.out.println("finished"); } else { System.out.println("failed"); } }
From source file:tetrad.rrd.install.TestInstallTotal.java
public static void main(String[] args) throws Exception { String[] configLocations = new String[] { "applicationContext_rrd.xml" }; ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(configLocations); TetradRrdInitializer tetradInitial = (TetradRrdInitializer) context.getBean("tetradRrdInitializer"); tetradInitial.installTotalRrdDb();/*w ww. j a va2s . co m*/ System.out.println("done!!"); }
From source file:de.extra.client.crypto.ExtraPasswordEncryptor.java
public static void main(final String[] args) { final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring-encryption.xml"); final StringEncryptor stringEncryptor = context.getBean("configurationEncryptor", StringEncryptor.class); if (args == null || args.length != 1) { System.err.println("Argument fehlt. Aufruf mit\nencrypt-password.bat <Passwort>"); System.exit(ReturnCode.TECHNICAL.getCode()); }//from w w w .java 2 s . com System.out.println("ENC(" + stringEncryptor.encrypt(args[0]) + ")"); System.exit(ReturnCode.SUCCESS.getCode()); }
From source file:com.bow.rest.RestConsumer.java
public static void main(String[] args) throws Exception { String config = RestConsumer.class.getPackage().getName().replace('.', '/') + "/rest-consumer.xml"; ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(config); context.start();//www. j a va2 s . c om AnotherUserRestService userService = (AnotherUserRestService) context.getBean("anotherUserRestService"); User user = new User(1L, "larrypage"); System.out.println("SUCCESS: registered user with id " + userService.registerUser(user).getId()); RpcContext.getContext().setAttachment("clientName", "demo"); RpcContext.getContext().setAttachment("clientImpl", "dubbox"); System.out.println("SUCCESS: got user " + userService.getUser(1L)); System.in.read(); }
From source file:be.kdg.repaircafemodel.TestRepairCafe.java
public static void main(String[] args) { ApplicationContext context = new ClassPathXmlApplicationContext( "be/kdg/repaircafemodel/spring/root-context.xml"); // Get userService from Spring Context UserService userService = (UserService) context.getBean("userService"); // Get repairService from Spring Context RepairService repairService = (RepairService) context.getBean("repairService"); // Create a client Address address1 = new Address("Nationalestraat", "5", "2000", "Antwerpen"); Person person1 = new Person("Jan", "Peeters", address1); Client client = new Client(person1, "jan.peeters@student.kdg.be", "jan"); // Create a repairer Address address2 = new Address("Nationalestraat", "5", "2000", "Antwerpen"); Person person2 = new Person("Wouter", "Deketelaere", address2); Repairer repairGuy = new Repairer(person2, "wouter.deketelaere@kdg.be", "jef", "Master"); try {//w w w . j a v a 2 s . c o m userService.addUser(client); userService.addUser(repairGuy); } catch (UserServiceException ex) { Logger.getLogger(TestRepairCafe.class.getName()).log(Level.SEVERE, null, ex); } // update een gebruiker met een nieuw wachtwoord try { userService.updatePassword(repairGuy, "jef", "wouter"); userService.checkLogin(repairGuy.getUsername(), "wouter"); } catch (UserServiceException ex) { Logger.getLogger(TestRepairCafe.class.getName()).log(Level.SEVERE, null, ex); } try { userService.checkLogin("wouter.deketelaere@kdg.be", "wouter"); } catch (UserServiceException ex) { Logger.getLogger(TestRepairCafe.class.getName()).log(Level.SEVERE, null, ex); } Repair repair = new Repair(new Item("G 4210 i", "Miele", "Vaatwasser"), new RepairDetails("Elektrisch", "Toestel stopt niet meer", RepairDetails.PriceModel.FIXED, new DateTime().plusWeeks(2))); repairService.submitRepair(client, repair); System.out.println(repairService.getAllCategories()); repairService.placeBid(repairGuy, repair, 200.0); System.out.println(repairService.findAllRepairsByClient(client)); repairService.placeBid(repairGuy, repair, 150); try { System.out.println(repairService.findRepairsByCategory("Vaatwasser")); System.out.println(repairService.findRepairsByDefect("Elektrisch")); System.out.println(repairService.getBids(repairGuy)); } catch (RepairServiceException ex) { Logger.getLogger(TestRepairCafe.class.getName()).log(Level.SEVERE, null, ex); } }