Package info.walnutstreet.vs.ps03.cache.container

Examples of info.walnutstreet.vs.ps03.cache.container.GoodObject


   */
  @Override
  public void run() {
    while (this.listen) {
      try {
        ClientHandler clientHandler = new ClientHandler(this.serverSocket.accept());
        DataStore.getInstance().addClientHandler(clientHandler);
        clientHandler.start();
      } catch (SocketTimeoutException e) {
        /* timeout */
      } catch (IOException e) {
        e.printStackTrace();
      }
View Full Code Here


   * Constructor.
   *
   * @throws IOException
   */
  public AppServer(int port) throws IOException {
    this.listener = new ConnectionListener(port);
    DataStore.getInstance().refreshLocalStore();
  }
View Full Code Here

  @Override
  public void run() {
    try {
      while (true) {
        ServerObjectBundle bundle = (ServerObjectBundle) this.in.readObject();
        bundle.getCommand().execute(ClientCacheController.getInstance(), bundle);
      }
    } catch (Exception e) {
    }
  }
View Full Code Here

    this.goodCartMap = new HashMap<Integer, Integer>();
   
    this.inputStream = new ObjectInputStream(this.socket.getInputStream());
    this.outputStream = new ObjectOutputStream(this.socket.getOutputStream());
   
    ServerObjectBundle bundle = new ServerObjectBundle(ServerCommands.SERVER_SEND_GOODS, DataStore.getInstance().getPartialGoodList());
    this.outputStream.writeObject(bundle);
  }
View Full Code Here

  }
 
  public void notifyClients(Collection<GoodUpdate> update)
  {
    ClientHandler.logger.error("Notyfiing Clients");
    ServerObjectBundle bundle = new ServerObjectBundle(ServerCommands.SERVER_UPDATE_GOODS, update );
    send(bundle);
  }
View Full Code Here

   * @see info.walnutstreet.vs.ps03.client.controller.ClientInterface#updategoods(java.util.Collection)
   */
  @Override
  public void updategoods(Collection<GoodUpdate> updateCollection) {
    for (GoodUpdate goodUpdate : updateCollection) {
      GoodObject object = this.cachedGoodObjects.get(goodUpdate.getId());
      object.setAvailable(goodUpdate.getAvailable());
      object.setBooked(goodUpdate.getBooked());
     
      this.uiController.updateGood(goodUpdate);
    }
   
  }
View Full Code Here

    Thread lookupOperation = new Thread() {
      public void run() {
        display.asyncExec(new Runnable() {
          public void run() {
            ClientCacheController controller = ClientCacheController.getInstance();
            GoodObject object = controller.lookForGoodDetail(goodId);
           
            shell.setText(object.getName());
            int upperLimit = object.getAvailable();
            if (upperLimit > 0) {
              spinner.setMinimum(1);
              spinner.setMaximum(upperLimit);
            } else {
              buyButton.setEnabled(false);
View Full Code Here

  public void refreshLocalStore() {
    this.goodsFromDatabase.clear();
    // Create Object in Appserver from DBServer
    try {
      for (Integer element : dbserverInterface.getListOfAllArticleIDs()) {
        GoodObject goodObject= new GoodObject();
        goodObject.setId(element);
        goodObject.setName(dbserverInterface.getArticleName(element));
        goodObject.setDescription(dbserverInterface.getArticleDescription(element));
        goodObject.setAvailable(dbserverInterface.getArticleAvailable(element));
        goodObject.setBooked(dbserverInterface.getArticleReserved(element));
        goodObject.setPrice(dbserverInterface.getArticlePrice(element));
        goodsFromDatabase.put(element, goodObject);
      }
    } catch (RemoteException e) {
      DataStore.logger.error(e.getLocalizedMessage());
    }
View Full Code Here

    for (Entry<Integer, Integer> element : map.entrySet()) {
      // if we can buy enough articles in the DB-Server we can update our data in the ServerCache.
      try {
        if ( dbserverInterface.buyArticle(element.getKey(), element.getValue()))
        {
          GoodObject ob=goodsFromDatabase.get(element.getKey());
          ob.setBooked(ob.getBooked()+element.getValue());
          ob.setAvailable(ob.getAvailable()-element.getValue());
          goodUpdates.add(new GoodUpdate(element.getKey(),ob.getAvailable(),ob.getBooked()));
        }
      } catch (RemoteException e) {
        DataStore.logger.error(e.getLocalizedMessage());
      }
    }
View Full Code Here

    Thread lookupOperation = new Thread() {
      public void run() {
        display.asyncExec(new Runnable() {
          public void run() {
            ClientCacheController controller = ClientCacheController.getInstance();
            GoodObject object = controller.lookForGoodDetail(goodId);

            double total = num * object.getPrice();

            TableItem item = new TableItem(table, SWT.None);
            item.setText(0, Integer.toString(object.getId()));
            item.setText(1, Integer.toString(num));
            item.setText(2, object.getName());
            item.setText(3, new Double(object.getPrice()).toString());
            item.setText(4, new Double(total).toString());
          }
        });
      }
    };
View Full Code Here

TOP

Related Classes of info.walnutstreet.vs.ps03.cache.container.GoodObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.