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