1 package at.ac.tuwien.sbc.valesriegler.xvsm.waiter;
3 import java.io.Serializable;
4 import java.util.ArrayList;
7 import javax.swing.SwingUtilities;
9 import org.mozartspaces.core.Entry;
10 import org.mozartspaces.notifications.Notification;
11 import org.mozartspaces.notifications.NotificationListener;
12 import org.mozartspaces.notifications.Operation;
13 import org.slf4j.Logger;
14 import org.slf4j.LoggerFactory;
16 import at.ac.tuwien.sbc.valesriegler.pizzeria.PizzeriaAgent;
17 import at.ac.tuwien.sbc.valesriegler.types.GroupData;
18 import at.ac.tuwien.sbc.valesriegler.types.Table;
19 import at.ac.tuwien.sbc.valesriegler.xvsm.WaiterXVSM;
20 import at.ac.tuwien.sbc.valesriegler.xvsm.XVSMConnector;
23 * This is a waiter using XVSM
25 * @author Gregor Riegler <gregor DOT riegler AT gmail DOT com>
28 public class Waiter implements Serializable {
29 private static final String USAGE = "Waiter needs exactly one parameter: ID of type Integer";
30 private static final Logger log = LoggerFactory.getLogger(Waiter.class);
33 private WaiterXVSM xvsm;
35 public static void main(String[] args) {
36 if (args.length != 1) {
37 throw new IllegalArgumentException(USAGE);
42 parsedId = Integer.parseInt(args[0]);
43 } catch (NumberFormatException e) {
48 Waiter waiter = new Waiter(parsedId);
52 private void start() {
53 xvsm = new WaiterXVSM(id);
55 xvsm.listenForOrders();
57 // when new guests arrive the waiter should try to assign a table to them
58 xvsm.listenForNewGuests();
60 // when tables get free the waiter should have a look if there are waiting guests and assign the new table to them
61 xvsm.listenForFreeTable();
68 public Waiter(int id) {
70 log.info("I AM A WAITER WITH ID {}", id);