Home » synapse-1.2-src » samples.services » [javadoc | source]

    1   /*
    2    *  Licensed to the Apache Software Foundation (ASF) under one
    3    *  or more contributor license agreements.  See the NOTICE file
    4    *  distributed with this work for additional information
    5    *  regarding copyright ownership.  The ASF licenses this file
    6    *  to you under the Apache License, Version 2.0 (the
    7    *  "License"); you may not use this file except in compliance
    8    *  with the License.  You may obtain a copy of the License at
    9    *
   10    *   http://www.apache.org/licenses/LICENSE-2.0
   11    *
   12    *  Unless required by applicable law or agreed to in writing,
   13    *  software distributed under the License is distributed on an
   14    *   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   15    *  KIND, either express or implied.  See the License for the
   16    *  specific language governing permissions and limitations
   17    *  under the License.
   18    */
   19   package samples.services;
   20   import java.util.Date;
   21   
   22   import javax.xml.stream.XMLStreamException;
   23   import org.apache.axiom.om.OMAbstractFactory;
   24   import org.apache.axiom.om.OMElement;
   25   import org.apache.axiom.om.OMFactory;
   26   import org.apache.axiom.om.OMNamespace;
   27   
   28   public class FastStockQuoteService {
   29   	
   30   		private final static OMElement response = createResponse();
   31   
   32   		private static OMElement createResponse() {
   33   			
   34   			  OMFactory fac = OMAbstractFactory.getOMFactory();
   35           OMNamespace ns = fac.createOMNamespace("http://services.samples/xsd", "ns");
   36           OMElement getQuoteResponse = fac.createOMElement("getQuoteResponse ", ns);
   37           OMElement returnElt = fac.createOMElement("return", ns);
   38           
   39           OMElement change = fac.createOMElement("change", ns);        
   40           change.addChild(fac.createOMText(change, "-2.573165716892239"));
   41           returnElt.addChild(change);
   42           
   43           OMElement earnings = fac.createOMElement("earnings", ns);        
   44           earnings.addChild(fac.createOMText(earnings, "12.729598827258027"));
   45           returnElt.addChild(earnings);
   46           
   47           OMElement high = fac.createOMElement("high", ns);        
   48           high.addChild(fac.createOMText(high, "181.57938605633444"));
   49           returnElt.addChild(high);
   50           
   51           OMElement last = fac.createOMElement("last", ns);        
   52           last.addChild(fac.createOMText(last, "79.93167957835779"));
   53           returnElt.addChild(last);
   54           
   55           OMElement lastTradeTimestamp = fac.createOMElement("lastTradeTimestamp", ns);        
   56           lastTradeTimestamp.addChild(fac.createOMText(lastTradeTimestamp, "Thu Jan 25 17:39:12 IST 2007"));
   57           returnElt.addChild(lastTradeTimestamp);
   58           
   59           OMElement low = fac.createOMElement("low", ns);        
   60           low.addChild(fac.createOMText(low, "9.93167957835779"));
   61           returnElt.addChild(low);
   62           
   63           OMElement marketCap = fac.createOMElement("marketCap", ns);        
   64           marketCap.addChild(fac.createOMText(marketCap, "5.93167957835779"));
   65           returnElt.addChild(marketCap);
   66           
   67           OMElement name = fac.createOMElement("name", ns);        
   68           name.addChild(fac.createOMText(name, "IBM Company"));
   69           returnElt.addChild(name);
   70           
   71           OMElement open = fac.createOMElement("open", ns);        
   72           open.addChild(fac.createOMText(open, "15.93167957835779"));
   73           returnElt.addChild(open);
   74           
   75           OMElement peRatio = fac.createOMElement("peRatio", ns);        
   76           peRatio.addChild(fac.createOMText(peRatio, "24.283806785853777"));
   77           returnElt.addChild(peRatio);
   78           
   79           OMElement percentageChange = fac.createOMElement("percentageChange", ns);        
   80           percentageChange.addChild(fac.createOMText(percentageChange, "-2.334460572410184"));
   81           returnElt.addChild(percentageChange);
   82           
   83           OMElement prevClose = fac.createOMElement("prevClose", ns);        
   84           prevClose.addChild(fac.createOMText(prevClose, "-179.58650497565893"));
   85           returnElt.addChild(prevClose);
   86           
   87           OMElement symbol = fac.createOMElement("symbol", ns);        
   88           symbol.addChild(fac.createOMText(symbol, "IBM"));
   89           returnElt.addChild(symbol);
   90           
   91           OMElement volume = fac.createOMElement("volume", ns);        
   92           volume.addChild(fac.createOMText(volume, "7618"));
   93           returnElt.addChild(volume);
   94           
   95           getQuoteResponse.addChild(returnElt);
   96           return getQuoteResponse;
   97   		}
   98   		
   99       // in-out
  100       public OMElement getQuote(OMElement request) {
  101           //System.out.println(new Date() + " FastStockQuoteService :: Generating quote for : " + request.getSymbol());
  102           //return new GetQuoteResponse(request.getSymbol());
  103           return response;
  104       }
  105   
  106       // in only
  107       /*public void placeOrder(OMElement order) {
  108           System.out.println(new Date() + " FastStockQuoteService :: Accepted order for : " +
  109               order.getQuantity() + " stocks of " + order.getSymbol() +
  110               " at $ " + order.getPrice());
  111       }*/
  112   }

Home » synapse-1.2-src » samples.services » [javadoc | source]