Package org.wso2.msf4j.stockquote
Class StockQuoteService
- java.lang.Object
-
- org.wso2.msf4j.stockquote.StockQuoteService
-
- All Implemented Interfaces:
org.wso2.msf4j.Microservice
@Path("/stockquote") public class StockQuoteService extends java.lang.Object implements org.wso2.msf4j.MicroserviceStockQuote microservice.
-
-
Constructor Summary
Constructors Constructor Description StockQuoteService()Add initial stocks IBM, GOOG, AMZN.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidactivate(org.osgi.framework.BundleContext bundleContext)voidaddStock(Stock stock)Add a new stock.protected voiddeactivate(org.osgi.framework.BundleContext bundleContext)StocksgetAllStocks(org.wso2.msf4j.Request request)Retrieve all stocks.javax.ws.rs.core.ResponsegetQuote(java.lang.String symbol)Retrieve a stock for a given symbol.java.lang.StringtoString()
-
-
-
Method Detail
-
activate
protected void activate(org.osgi.framework.BundleContext bundleContext)
-
deactivate
protected void deactivate(org.osgi.framework.BundleContext bundleContext)
-
getQuote
@GET @Path("/{symbol}") @Produces({"application/json","text/xml"}) public javax.ws.rs.core.Response getQuote(@PathParam("symbol") java.lang.String symbol) throws SymbolNotFoundExceptionRetrieve a stock for a given symbol. http://localhost:8080/stockquote/IBM- Parameters:
symbol- Stock symbol will be taken from the path parameter.- Returns:
- Throws:
SymbolNotFoundException
-
addStock
@POST @Consumes("application/json") public void addStock(Stock stock) throws DuplicateSymbolExceptionAdd a new stock. curl -v -X POST -H "Content-Type:application/json" \ -d '{"symbol":"BAR","name": "Bar Inc.", \ "last":149.62,"low":150.78,"high":149.18, "createdByHost":"10.100.1.192"}' \ http://localhost:8080/stockquote- Parameters:
stock- Stock object will be created from the request Json body.- Throws:
DuplicateSymbolException
-
getAllStocks
@GET @Path("/all") @Produces({"application/json","text/xml"}) public Stocks getAllStocks(@Context org.wso2.msf4j.Request request)Retrieve all stocks. http://localhost:8080/stockquote/all- Returns:
- All stocks will be sent to the client as Json/xml according to the Accept header of the request.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-