List of usage examples for org.springframework.context ApplicationContext getBean
Object getBean(String name) throws BeansException;
From source file:org.sitoolkit.editor.EditorBatch.java
public static void main(String[] args) { ApplicationContext appCtx = new ClassPathXmlApplicationContext(""); EditorBatch batch = appCtx.getBean(EditorBatch.class); System.exit(batch.execute(args[0])); }
From source file:uk.co.onehp.trickle.dao.HibernateSessionTokenDaoCustomT.java
@Ignore public static void main(final String[] args) { final ApplicationContext applicationContext = new ClassPathXmlApplicationContext( "classpath:/spring-trickle.xml"); final SessionTokenDao dao = (SessionTokenDao) applicationContext.getBean("sessionTokenDao"); final SessionToken token = new SessionToken(); token.setSessionType(SessionType.GLOBAL); token.setToken("kjngshjgsdlhkjn"); token.setUpdatedDateTime(new LocalDateTime()); dao.saveOrUpdate(token);//from www .j a v a 2 s. c o m final SessionToken result = dao.getSessionToken(SessionType.GLOBAL); System.out.println(result); result.setToken("sdgnsdlgsgdsag"); result.setUpdatedDateTime(new LocalDateTime()); dao.saveOrUpdate(result); final SessionToken result2 = dao.getSessionToken(SessionType.GLOBAL); System.out.println(result2); }
From source file:internal.diff.common.launcher.SampleApplication.java
public static void main(String[] args) throws IOException { ApplicationContext context = new AnnotationConfigApplicationContext(SampleApplication.class); AmazonS3DirectoryMetadataService s3DirectoryMetadataService = context .getBean(AmazonS3DirectoryMetadataService.class); FileSystemDirectoryMetadataService fileSystemDirectoryMetadataService = context .getBean(FileSystemDirectoryMetadataService.class); DirectoryMetadataDifferenceService differenceService = context .getBean(DirectoryMetadataDifferenceService.class); log.info("The metadata of S3 bucket '{}' with prefix '{}' is going to be read.", S3_BUCKET, S3_PREFIX); DirectoryMetadata directory2 = s3DirectoryMetadataService.getMetadata(S3_BUCKET, S3_PREFIX); log.info("The metadata of file system directory '{}' is going to be read.", FILE_SYSTEM_DIRECTORY); DirectoryMetadata directory1 = fileSystemDirectoryMetadataService.getMetadata(FILE_SYSTEM_DIRECTORY); log.info("The differences between the metadata is being calculated."); DirectoryMetadataDifference difference = differenceService.getDifference(directory1, directory2); new ObjectMapper().writerWithDefaultPrettyPrinter().writeValue(System.out, difference); }
From source file:example.springdata.redis.sentinel.RedisSentinelApplication.java
public static void main(String[] args) throws Exception { ApplicationContext context = SpringApplication.run(RedisSentinelApplication.class, args); StringRedisTemplate template = context.getBean(StringRedisTemplate.class); template.opsForValue().set("loop-forever", "0"); StopWatch stopWatch = new StopWatch(); while (true) { try {/* w ww. j a v a2 s.c o m*/ String value = "IT:= " + template.opsForValue().increment("loop-forever", 1); printBackFromErrorStateInfoIfStopWatchIsRunning(stopWatch); System.out.println(value); } catch (RuntimeException e) { System.err.println(e.getCause().getMessage()); startStopWatchIfNotRunning(stopWatch); } Thread.sleep(1000); } }
From source file:uk.co.onehp.trickle.dao.HibernateBetDaoCustomT.java
@Ignore public static void main(final String[] args) { final ApplicationContext applicationContext = new ClassPathXmlApplicationContext( "classpath:/spring-trickle.xml"); final BetDao betDao = (BetDao) applicationContext.getBean("betDao"); final RaceDao raceDao = (RaceDao) applicationContext.getBean("raceDao"); final Race race = new Race(867, "Race", new LocalDateTime(2012, 2, 22, 19, 19, 0), "meeting"); final Horse horse = new Horse(); horse.setRunnerId(441);//from ww w .j a va 2 s . c om horse.setRaceId(867); horse.setRace(race); race.addHorse(horse); final Strategy strategy1 = new Strategy(); strategy1.setBetSecondsBeforeStartTime(Lists.newArrayList(120, 270, 600)); final Strategy strategy2 = new Strategy(); strategy2.setBetSecondsBeforeStartTime(Lists.newArrayList(120, 270, 700)); raceDao.saveOrUpdate(race); final Bet bet1 = new Bet(horse, strategy1); betDao.saveOrUpdate(bet1); final Bet bet2 = new Bet(horse, strategy2); betDao.saveOrUpdate(bet2); System.out.println(betDao.getBetsToPlace()); }
From source file:org.ala.hbase.BioCacheLoader.java
public static void main(String[] args) throws Exception { ApplicationContext context = SpringUtils.getContext(); BioCacheLoader l = context.getBean(BioCacheLoader.class); l.load();/*from ww w .j a va 2 s.com*/ System.exit(0); }
From source file:uk.co.onehp.trickle.dao.HibernateMarketDaoCustomT.java
@Ignore public static void main(final String[] args) { final ApplicationContext applicationContext = new ClassPathXmlApplicationContext( "classpath:/spring-trickle.xml"); final MarketDao marketDao = (MarketDao) applicationContext.getBean("marketDao"); final HorseDao horseDao = (HorseDao) applicationContext.getBean("horseDao"); final Market market = new Market(7483, "Market"); final Meeting meeting = new Meeting(234, "Meeting"); final Race race = new Race(867, "Race", new LocalDateTime(), "meeting"); final Horse horse = new Horse(); final Pricing pricing = new Pricing(new BigDecimal("3.45"), new BigDecimal("3090.96"), BettingAspect.BACK); horse.setRunnerId(441);/*www . ja v a2 s . c o m*/ horse.setRaceId(867); horse.setRace(race); horse.setPrices(Lists.newArrayList(pricing)); race.addHorse(horse); meeting.addRace(race); market.addMeeting(meeting); marketDao.saveOrUpdate(market); System.out.println(marketDao.getMarket(7483)); }
From source file:koper.reactor.demo.ProducerApp.java
/** * Reactor produce demo./*from ww w .j a va 2 s.c om*/ * Create prototype(multiple instances) reactor and send message to them. * @param args */ public static void main(String[] args) { ApplicationContext context = new ClassPathXmlApplicationContext( "classpath:kafka/context-data-producer.xml"); MessageSender messageSender = (MessageSender) context.getBean("messageSender"); ReactorRef ref = ReactorRef.create(Digger.class); ref.setMessageSender(messageSender); System.out.println("ref created " + ref.getId() + "," + ref); for (int i = 0; i < 3; i++) { String msg = "Hello" + i; System.out.println("send->" + msg); ref.send("Hello" + i); } ReactorRef ref1 = ReactorRef.create(Digger.class); ref1.setMessageSender(messageSender); ref1.send("NewYork"); ReactorRef ref2 = ReactorRef.create(Digger.class); ref2.setMessageSender(messageSender); ref2.send("SF"); }
From source file:com.estafeta.flujos.DemoMain.java
/** * Clase principal del proyecto/*from w w w .java 2s . co m*/ * @param args argumentos de linea de comandos */ public static void main(String[] args) { // init spring context ApplicationContext ctx = new ClassPathXmlApplicationContext(APPLOCATION_CONTEXT_FILE); // get bean from context JmsMessageSender jmsMessageSender = (JmsMessageSender) ctx.getBean(JMS_MESSAGE_SENDER_BEAN_NAME); // send to a code specified destination Queue queue = new ActiveMQQueue(JMS_DESTINATION_NAME); try { ClassLoader classLoader = DemoMain.class.getClassLoader(); FileInputStream fileInputStream = new FileInputStream( classLoader.getResource(MOCK_INPUT_FILE).getFile()); BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(fileInputStream, Charset.forName(UTF_8_CHARSET))); String line; while ((line = bufferedReader.readLine()) != null) { jmsMessageSender.send(queue, line); } fileInputStream.close(); } catch (Exception e) { e.printStackTrace(); } // close spring application context ((ClassPathXmlApplicationContext) ctx).close(); }
From source file:example.springdata.redis.sentinel.RedisSentinelApplicationConfig.java
public static void main(String[] args) throws Exception { ApplicationContext context = SpringApplication.run(RedisSentinelApplicationConfig.class, args); RedisConnectionFactory factory = context.getBean(RedisConnectionFactory.class); StringRedisTemplate template = new StringRedisTemplate(); template.setConnectionFactory(factory); template.afterPropertiesSet();// w w w . j av a2 s .com template.opsForValue().set("loop-forever", "0"); StopWatch stopWatch = new StopWatch(); while (true) { try { String value = "IT:= " + template.opsForValue().increment("loop-forever", 1); printBackFromErrorStateInfoIfStopWatchIsRunning(stopWatch); System.out.println(value); } catch (RuntimeException e) { System.err.println(e.getCause().getMessage()); startStopWatchIfNotRunning(stopWatch); } Thread.sleep(1000); } }