View Javadoc
1   package de.mxro.webapiexample;
2   
3   import de.mxro.webapiexample.internal.WebApiServerImpl;
4   
5   /**
6    * <p>This class provides the facade for creating and starting servers.
7    * @author Max
8    *
9    */
10  public class WebApi {
11  	
12  	/**
13  	 * This main method will be called upon running the executable jar assembled by the build.
14  	 * @param args The arguments for starting this application
15  	 */
16  	public static void main(String[] args) {
17  		int port = 8989;
18  		if (args.length == 1) {
19  			try {
20  				port = Integer.valueOf(args[0]);
21  			} catch (NumberFormatException ex) {
22  				System.out.println("Please provide a valid port number as a parameter.");
23  				return;
24  			}
25  		}
26  		
27  		
28  		WebApiServer server = createServer();
29  		server.start(port);
30  	}
31  		
32  	/**
33  	 * This method allows creating a new web server.
34  	 * 
35  	 * @return A {@link WebApiServer} instance which can be used to start and stop the server.
36  	 */
37  	public static WebApiServer createServer() {
38  		
39  		return new WebApiServerImpl();
40  		
41  	}
42  	
43  }