Ejemplo n.º 1
0
 // Test method
 public LinkedList<Integer> getLiveAuctionsIds() throws RemoteException {
   LinkedList<Integer> ll = new LinkedList<Integer>();
   for (AuctionItem t : liveAuctionItems.values()) {
     ll.add(t.getAuctionId());
   }
   return ll;
 }
Ejemplo n.º 2
0
 @Override
 // Event though the data structure for live auctions is concurrent the method still needs to be
 // synchronized because the creation
 // of auction items concurrently produces auction items with the same id.
 public synchronized boolean registerAuctionItem(
     String name, double min_item_value, Date closing_date, int client) throws RemoteException {
   AuctionItem item = new AuctionItem(name, min_item_value, closing_date, client, this);
   liveAuctionItems.put(item.getAuctionId(), item);
   Thread t = new Thread(item);
   t.start();
   return true;
 }
Ejemplo n.º 3
0
 @Override
 public boolean moveToExpiredAuctions(int auctionId) {
   if (!liveAuctionItems.containsKey(auctionId)) {
     System.out.println("This auction does not exist\n");
     return false;
   }
   AuctionItem temp;
   if ((temp = liveAuctionItems.remove(auctionId)) != null) {
     System.out.println("Auction successfully removed from list with live auctions\n");
     // Change the auction id to correspond to the index
     expiredAuctions.put(temp.getAuctionId(), temp);
     Thread t = new Thread(temp);
     t.start();
     return true;
   }
   return false;
 }