001 package com.khubla.goxmon; 002 003 import com.khubla.pragmatach.framework.annotation.Controller; 004 import com.khubla.pragmatach.framework.annotation.Route; 005 import com.khubla.pragmatach.framework.annotation.View; 006 import com.khubla.pragmatach.framework.api.PragmatachException; 007 import com.khubla.pragmatach.framework.api.Response; 008 import com.khubla.pragmatach.plugin.freemarker.FreemarkerController; 009 import com.xeiam.xchange.Exchange; 010 import com.xeiam.xchange.ExchangeFactory; 011 import com.xeiam.xchange.currency.Currencies; 012 import com.xeiam.xchange.service.marketdata.polling.PollingMarketDataService; 013 014 /** 015 * @author tome 016 */ 017 @Controller(name = "IndexController") 018 @View(view = "index.ftl") 019 public class IndexController extends FreemarkerController { 020 /** 021 * the ticket 022 */ 023 private String ticker; 024 025 public String getTicker() { 026 return ticker; 027 } 028 029 @Route(uri = "/") 030 public Response render() throws PragmatachException { 031 try { 032 final Exchange mtGox = ExchangeFactory.INSTANCE.createExchange("com.xeiam.xchange.mtgox.v1.MtGoxExchange"); 033 final PollingMarketDataService marketDataService = mtGox.getPollingMarketDataService(); 034 ticker = marketDataService.getTicker(Currencies.BTC, Currencies.USD).toString(); 035 return super.render(); 036 } catch (final Exception e) { 037 throw new PragmatachException("Exception in render", e); 038 } 039 } 040 041 public void setTicker(String ticker) { 042 this.ticker = ticker; 043 } 044 }