Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.mortbay.hightide.example.auction.service;
 
 import java.util.Map;
 
 import  org.mortbay.cometd.BayeuxService;
public class AuctionItemService extends BayeuxService
    public AuctionItemService(Bayeux bayeux)
    {
        super(bayeux"auction-item");
        
        subscribe("/service/auction/categories/id/items""getItemsByCategory");
        subscribe("/service/auction/categories/find""findItems");
        subscribe("/service/auction/items/id""getItemById");        
    }
    
    public void getItemsByCategory(Client sourceString channelMap<StringObjectdata
            String messageId)
    {
        Integer categoryId = new Integer(((Number)data.get("categoryId")).intValue());
        
        Map<String,Objectresponse = new HashMap<String,Object>();
        response.put("handlerId"data.get("handlerId"));
        try
        {
            response.put("auctionItems"new CategoryDao().getItemsInCategory(categoryId));
        }
        catch(Exception e)
        {
            response.put("errorMsg"e.getMessage());
        }
        source.deliver(getClient(), channelresponsenull);
    }
    
    public void findItems(Client sourceString channelMap<StringObjectdata
            String messageId)
    {
        String expression = (String)data.get("expression");
        
        Map<String,Objectresponse = new HashMap<String,Object>();
        response.put("handlerId"data.get("handlerId"));
        try
        {
            response.put("auctionItems"new CategoryDao().findItems(expression));
        }
        catch(Exception e)
        {
            response.put("errorMsg"e.getMessage());
        }
        source.deliver(getClient(), channelresponsenull);
    }
    
    public void getItemById(Client sourceString channelMap<StringObjectdata
            String messageId)
    {
        Integer itemId = new Integer(((Number)data.get("itemId")).intValue());
        
        Map<String,Objectresponse = new HashMap<String,Object>();
        response.put("handlerId"data.get("handlerId"));
        try
        {
            response.put("auctionItem"new CategoryDao().getItem(itemId));
        }
        catch(Exception e)
        {
            response.put("errorMsg"e.getMessage());
        }
        source.deliver(getClient(), channelresponsenull);
    }
    
New to GrepCode? Check out our FAQ X