List of usage examples for org.springframework.context.support AbstractApplicationContext close
@Override public void close()
From source file:persons.controller.Main.java
public static void main(String[] args) { AbstractApplicationContext ctx = new FileSystemXmlApplicationContext("beans.xml"); Runnable test = (Runnable) ctx.getBean("test"); test.run();/*from w ww.ja va 2 s . com*/ ctx.close(); }
From source file:com.delphix.appliance.host.example.client.ExampleClientLauncher.java
public static void main(String[] args) { AbstractApplicationContext context = new ClassPathXmlApplicationContext(CONFIG_LOCATION); try {/*from w w w.j ava2s . c om*/ ExampleClient client = (ExampleClient) context.getBean("client"); client.executeRemoteCommand(); client.fini(); } finally { context.close(); } }
From source file:edu.hm.cs.goetz1.seminar.Main.java
public static void main(String[] args) { AbstractApplicationContext context = new ClassPathXmlApplicationContext("beans.xml"); UserService userService = (UserService) context.getBean(UserService.class); userService.addNewUser("test@email.de", "Max", "Mustermann", "totalGeheim", new Date()); userService.changeUserPassword("test@email.de", "totalGeheim", "nochGeheimer"); context.close(); }
From source file:com.delphix.appliance.host.example.server.ExampleServerLauncher.java
public static void main(String[] args) { AbstractApplicationContext context = new ClassPathXmlApplicationContext(CONFIG_LOCATION); try {// w w w .java 2 s.c o m final ExampleServer server = (ExampleServer) context.getBean("server"); Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { server.fini(); } }); } finally { context.close(); } }
From source file:com.springdeveloper.hadoop.hive.HiveApp.java
public static void main(String[] args) throws Exception { AbstractApplicationContext context = new ClassPathXmlApplicationContext("/META-INF/spring/hive-context.xml", HiveApp.class); log.info("Hive Application Running"); context.registerShutdownHook();//w w w.j a v a2 s . c o m HiveTemplate template = context.getBean(HiveTemplate.class); HiveScript script = new HiveScript(new ClassPathResource("tweet-influencers.hql")); template.executeScript(script); context.close(); }
From source file:com.osc.edu.chapter1.Starter.java
public static void main(String[] args) { logger.debug("Initializing Spring context."); AbstractApplicationContext applicationContext = new ClassPathXmlApplicationContext( new String[] { "spring/application-context.xml" }); logger.debug("Spring context initialized."); //Message message = (Message)applicationContext.getBean("message"); Message message = applicationContext.getBean(Message.class); logger.debug("[Title] : {}", message.getTitle()); logger.debug("[Message] : {}", message.getMessage()); applicationContext.close(); }
From source file:com.ifeng.vdn.web.hive.HiveApp.java
public static void main(String[] args) { HiveServer2 hi = null;/* ww w.ja va 2s . co m*/ AbstractApplicationContext context = new ClassPathXmlApplicationContext("spring/application-context.xml", HiveApp.class); log.info("Hive Application Running"); context.registerShutdownHook(); HiveTemplate template = context.getBean(HiveTemplate.class); List<String> tables = template.query("show tables;"); for (String tablName : tables) { log.info(tablName); } PasswordProcessRepository repository = context.getBean(HivePasswordProcessRepository.class); repository.processPasswordFile("/etc/passwd"); log.info("Count of password entries = " + repository.count()); context.close(); log.info("Hive Application Completed"); }
From source file:com.javaetmoi.elasticsearch.musicbrainz.batch.IndexBatchMain.java
public static void main(String... args) { AbstractApplicationContext context = null; try {/*from w w w .j a v a2 s.c o m*/ context = new ClassPathXmlApplicationContext(new String[] { "com/javaetmoi/elasticsearch/musicbrainz/batch/applicationContext-datasource.xml", "com/javaetmoi/elasticsearch/musicbrainz/batch/applicationContext-elasticsearch.xml", "com/javaetmoi/elasticsearch/musicbrainz/batch/applicationContext-batch.xml" }); JobLauncher jobLauncher = context.getBean(JobLauncher.class); Job musicAlbumJob = context.getBean("musicAlbumJob", Job.class); jobLauncher.run(musicAlbumJob, new JobParameters()); } catch (Throwable e) { String message = "Job Terminated in error: " + e.getMessage(); LOG.error(message, e); systemExiter.exit(exitCodeMapper.intValue(ExitStatus.FAILED.getExitCode())); } finally { if (context != null) { context.close(); } } systemExiter.exit(exitCodeMapper.intValue(ExitStatus.COMPLETED.getExitCode())); }
From source file:com.springdeveloper.hadoop.hive.HiveJdbcApp.java
public static void main(String[] args) throws Exception { AbstractApplicationContext context = new ClassPathXmlApplicationContext( "/META-INF/spring/hive-jdbc-context.xml", HiveJdbcApp.class); log.info("Hive JDBC Application Running"); context.registerShutdownHook();//w ww . j a va 2 s.c om String tableDdl = "create external table if not exists tweetdata (value STRING) LOCATION '/tweets/input'"; String query = "select r.retweetedUser, '\t', count(r.retweetedUser) as count " + " from tweetdata j " + " lateral view json_tuple(j.value, 'retweet', 'retweetedStatus') t as retweet, retweetedStatus " + " lateral view json_tuple(t.retweetedStatus, 'fromUser') r as retweetedUser " + " where t.retweet = 'true' " + " group by r.retweetedUser order by count desc limit 10"; String results = "insert overwrite directory '/tweets/hiveout'"; JdbcTemplate template = context.getBean(JdbcTemplate.class); template.execute(tableDdl); template.execute(results + " " + query); context.close(); }
From source file:uk.co.jemos.experiments.integration.HelloWorldApp.java
public static void main(String[] args) { AbstractApplicationContext context = new ClassPathXmlApplicationContext( "/META-INF/spring/integration/helloWorldDemo.xml", HelloWorldApp.class); MessageChannel inputChannel = context.getBean("podamInputChannel", MessageChannel.class); Message<Object> intMessage = MessageBuilder.withPayload(new Object()) .setHeader("type", int.class.toString()).build(); Message<Object> boolMessage = MessageBuilder.withPayload(new Object()) .setHeader("type", boolean.class.toString()).build(); Message<Object> stringMessage = MessageBuilder.withPayload(new Object()) .setHeader("type", String.class.getName()).build(); MessagingTemplate template = new MessagingTemplate(); Message reply = template.sendAndReceive(inputChannel, intMessage); logger.info(reply.getPayload());/*from ww w . ja v a 2 s. c om*/ reply = template.sendAndReceive(inputChannel, boolMessage); logger.info(reply.getPayload()); reply = template.sendAndReceive(inputChannel, stringMessage); logger.info(reply.getPayload()); context.close(); }