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.XVSMConnector;
22 * This is a waiter using XVSM
24 * @author Gregor Riegler <gregor DOT riegler AT gmail DOT com>
27 public class Waiter implements Serializable {
28 private static final String USAGE = "Waiter needs exactly one parameter: ID of type Integer";
29 private static final Logger log = LoggerFactory.getLogger(Waiter.class);
32 private XVSMConnector xvsm;
34 public static void main(String[] args) {
35 if (args.length != 1) {
36 throw new IllegalArgumentException(USAGE);
41 parsedId = Integer.parseInt(args[0]);
42 } catch (NumberFormatException e) {
47 Waiter waiter = new Waiter(parsedId);
51 private void start() {
52 xvsm = new XVSMConnector();
53 xvsm.initSpaceCommunication();
55 xvsm.useFreeTablesContainer();
56 xvsm.useAssignTableContainer();
57 xvsm.useTablesContainer();
58 xvsm.useTakeOrderContainer();
60 // when new guests arrive the waiter should try to assign a table to them
61 xvsm.listenForNewGuests();
63 // when tables get free the waiter should have a look if there are waiting guests and assign the new table to them
64 xvsm.listenForFreeTable();
69 public Waiter(int id) {
71 log.info("I AM A WAITER WITH ID {}", id);