]> git.somenet.org - pub/jan/sbc.git/blob - src/main/java/at/ac/tuwien/sbc/valesriegler/waiter/WaiterAgent.java
added commandline argument parsing to allow custom IDs.
[pub/jan/sbc.git] / src / main / java / at / ac / tuwien / sbc / valesriegler / waiter / WaiterAgent.java
1 package at.ac.tuwien.sbc.valesriegler.waiter;
2
3 import org.slf4j.Logger;
4 import org.slf4j.LoggerFactory;
5
6 import at.ac.tuwien.sbc.valesriegler.waiter.jms.JMSWaiter;
7
8 /**
9  * A waiter is a person who does all the stuff and gets lousy tips in return.
10  * The WaiterAgent runs the XVSM/JMSWaiter to do all the Waiter stuff.
11  * 
12  * @author jan
13  * 
14  */
15 public class WaiterAgent {
16         private static final String USAGE = "This application needs exactly 2 parameters: <\"XVSM\"|\"JMS\"> <ID of type Integer>";
17         private static final Logger log = LoggerFactory.getLogger(WaiterAgent.class);
18
19         public static void main(String[] args) {
20                 if (args.length != 2) {
21                         throw new IllegalArgumentException(USAGE);
22                 }
23
24                 String mw = args[0];
25                 int parsedId = 0;
26                 try {
27                         parsedId = Integer.parseInt(args[1]);
28                 } catch (NumberFormatException e) {
29                         log.error(USAGE);
30                         return;
31                 }
32
33                 if ("JMS".equalsIgnoreCase(mw)) {
34                         new JMSWaiter(parsedId);
35                 }
36         }
37 }