FileDocCategorySizeDatePackage
Wholesaler.javaAPI DocExample4075Tue May 29 16:57:50 BST 2007pricequote.wholesaler.wcf

Wholesaler

public class Wholesaler extends Object implements WholesalerPortType
author
Arun Gupta

Fields Summary
WebServiceContext
context
private static final float[]
PRICES
Constructors Summary
Methods Summary
private java.lang.Stringcarname(int pid)

        switch (pid % 4) {
            case 1:
                return "AM-Vantage-2k6";
            case 2:
                return "BMW-M3-2k6";
            case 3:
                return "MB-SLR-2k6";
            case 0:
            default:
                return "Porsche-911-2k6";
        }
    
public QuotegetQuote(int i)

        Quote response = new Quote();
        response.setPrice(Wholesaler.PRICES[i % 4]);

        ServletContext servletContext = (ServletContext)context.getMessageContext().get(MessageContext.SERVLET_CONTEXT);
        if (servletContext != null) {

            String carName = "/images/" + carname(i) + ".jpg";

            System.out.println("Car name is: " + carName);
            InputStream is = servletContext.getResourceAsStream(carName);
            try {
                BufferedImage bi = ImageIO.read(is);
                response.setPhoto(bi);
                System.out.println(getClass().getName() + ": Added the photo");
            } catch (IOException e) {
                throw new WebServiceException(e);
            }
        }

        return response;