List of usage examples for org.springframework.context.support ClassPathXmlApplicationContext ClassPathXmlApplicationContext
public ClassPathXmlApplicationContext(String... configLocations) throws BeansException
From source file:inc.cygnus.app.MainSpring.java
public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { // Implementasi Konfigurasi Spring framework @SuppressWarnings("resource") ApplicationContext appContext = new ClassPathXmlApplicationContext("applicationContext.xml"); // Initialize service setCustomerService((CustomerService) appContext.getBean("customerService")); setProductService((ProductService) appContext.getBean("productService")); setPurchaseService((PurchaseService) appContext.getBean("purchaseService")); try { // After finish service initialize // Show Form Menu Master UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException ex) { Logger.getLogger(MainSpring.class.getName()).log(Level.SEVERE, null, ex); } catch (InstantiationException ex) { Logger.getLogger(MainSpring.class.getName()).log(Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { Logger.getLogger(MainSpring.class.getName()).log(Level.SEVERE, null, ex); } catch (UnsupportedLookAndFeelException ex) { Logger.getLogger(MainSpring.class.getName()).log(Level.SEVERE, null, ex); }//w w w . j a v a 2s . c o m Menu mmv = new Menu(); mmv.setVisible(true); } catch (BeansException e) { e.printStackTrace(); } } }); }
From source file:org.thys.michels.email2sfdc.email.GmailInboundPop3AdapterTestApp.java
public static void main(String[] args) throws Exception { ApplicationContext ac = new ClassPathXmlApplicationContext( "/META-INF/spring/integration/gmail-pop3-config.xml"); DirectChannel inputChannel = ac.getBean("receiveChannel", DirectChannel.class); inputChannel.subscribe(new MessageHandler() { public void handleMessage(Message<?> message) throws MessagingException { logger.info("Message: " + message.getPayload() + " " + message.getHeaders()); }// w w w . j a v a2 s . co m }); }
From source file:org.ala.jms.service.JmsListenerService.java
public static void main(String[] args) throws Exception { long t = System.currentTimeMillis() + 5000; logger.info("Loading ClassPathXmlApplicationContext....... "); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "classpath*:activemq-context.xml"); logger.info("ClassPathXmlApplicationContext: " + context); // delay for pelpop client stating up if (context != null) { while (true) { if (System.currentTimeMillis() > t) { break; }//from w w w . j av a 2 s .co m } context.start(); logger.info("JMS listener is started!!!"); } }
From source file:tetrad.rrd.MakeUser.java
public static void main(String[] args) { String[] configLocations = new String[] { "applicationContext_rrd.xml" }; ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(configLocations); Operations operation = (Operations) context.getBean("operations"); User user = new User(); user.setUid("user1"); user.setIdx(1);// w w w .j a v a2 s. c om user.setReg_date(DateUtil.getCurrentDate("yyyy-MM-dd hh:mm:ss")); user.setPasswd("0a041b9462caa4a31bac3567e0b6e6fd9100787db2ab433d96f6d178cabfce90"); user.setUsername(""); user.setAuthority(1); operation.insert(user); }
From source file:tetrad.rrd.install.TestInstall.java
/** * @param args//from w w w . j a va 2s . c om * @throws Exception */ 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.install(); System.out.println("done!!"); }
From source file:com.apress.prospringintegration.corespring.iocbasics.BasicThreadColorRunnable.java
public static void main(String[] args) throws Exception { ApplicationContext app = new ClassPathXmlApplicationContext("ioc_basics.xml"); ColorEnum threadColor = app.getBean("threadColor", ColorEnum.class); System.out.println("Parent thread color: " + threadColor); BasicThreadColorRunnable dcr = new BasicThreadColorRunnable(app); new Thread(dcr).start(); }
From source file:nats.client.spring.NatsApplicationEventTest.java
public static void main(String[] args) throws Exception { // TODO Make automated test that starts a NATS server and then runs test. // Nats server must running before running this test. final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "natsApplicationEventContext.xml"); try {// w ww .j av a 2 s . c o m final Nats nats = context.getBean(Nats.class); Assert.assertNotNull(nats); final boolean invokedConnected = context.getBean("connected", ConnectListener.class).invoked.await(2, TimeUnit.SECONDS); Assert.assertTrue(invokedConnected, "The connected application event was never published."); final boolean invokedReady = context.getBean("ready", ReadyListener.class).invoked.await(2, TimeUnit.SECONDS); Assert.assertTrue(invokedReady, "The server ready application event was never published."); nats.close(); final boolean invokedClosed = context.getBean("closed", ClosedListener.class).invoked.await(2, TimeUnit.SECONDS); Assert.assertTrue(invokedClosed, "The closed application event was never published."); } finally { context.close(); } }
From source file:validation.ValidationConsumer.java
public static void main(String[] args) throws Exception { String config = ValidationConsumer.class.getPackage().getName().replace('.', '/') + "/validation-consumer.xml"; ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(config); context.start();/*w w w. ja v a2s .c om*/ ValidationService validationService = (ValidationService) context.getBean("validationService"); // ValidationService validationService=new ValidationServiceImpl(); // Save OK ValidationParameter parameter = new ValidationParameter(); parameter.setName("liangfei"); parameter.setEmail("liangfei@liang.fei"); parameter.setAge(1011111); parameter.setLoginDate(new Date(System.currentTimeMillis() + 1000000)); parameter.setExpiryDate(new Date(System.currentTimeMillis() + 1000000)); validationService.save(parameter); System.out.println("Validation Save OK"); // Save Error try { parameter = new ValidationParameter(); validationService.save(parameter); System.err.println("Validation Save ERROR"); } catch (Exception e) { ConstraintViolationException ve = (ConstraintViolationException) e.getCause(); Set<ConstraintViolation<?>> violations = ve.getConstraintViolations(); System.out.println("---save-" + violations); } // Delete OK validationService.delete(2, "abc"); System.out.println("Validation Delete OK"); // Delete Error try { validationService.delete(0, "abc"); System.err.println("Validation Delete ERROR"); } catch (Exception e) { ConstraintViolationException ve = (ConstraintViolationException) e.getCause(); Set<ConstraintViolation<?>> violations = ve.getConstraintViolations(); System.out.println("---save-" + violations); } }
From source file:at.ac.tuwien.dsg.queue.Main.java
public static void main(String[] args) throws InterruptedException { log.info("Starting up Queue. Initializing application context."); // new FileSystemXmlApplicationContext("/config/mela-data-service-context.xml"); new ClassPathXmlApplicationContext("queue-context.xml"); log.info("Initialized application context. Startup complete"); }
From source file:com.apress.prospringintegration.springbatch.integration.IntegrationMain.java
public static void main(String[] args) throws Throwable { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("integration.xml"); context.start();/*from w ww . j a v a2 s .c o m*/ MessageChannel launchChannel = context.getBean("launchChannel", MessageChannel.class); QueueChannel statusChannel = context.getBean("statusChannel", QueueChannel.class); Job job = (Job) context.getBean("importData"); JobParametersBuilder jobParametersBuilder = new JobParametersBuilder(); jobParametersBuilder.addDate("date", new Date()); jobParametersBuilder.addString("input.file", "registrations"); JobParameters jobParameters = jobParametersBuilder.toJobParameters(); JobLaunchRequest jobLaunchRequest = new JobLaunchRequest(job, jobParameters); launchChannel.send(MessageBuilder.withPayload(jobLaunchRequest).build()); Message<JobExecution> statusMessage = (Message<JobExecution>) statusChannel.receive(); JobExecution jobExecution = statusMessage.getPayload(); System.out.println(jobExecution); System.out.println("Exit status: " + jobExecution.getExitStatus().getExitCode()); JobInstance jobInstance = jobExecution.getJobInstance(); System.out.println("job instance Id: " + jobInstance.getId()); }