| 34 | } |
| 35 | |
| 36 | class TomcatServer implements Runnable { |
| 37 | private final int port; |
| 38 | |
| 39 | public TomcatServer(int port) { |
| 40 | this.port = port; |
| 41 | } |
| 42 | |
| 43 | @Override |
| 44 | public void run() { |
| 45 | try { |
| 46 | Tomcat tomcat = new Tomcat(); |
| 47 | tomcat.setPort(port); |
| 48 | tomcat.getConnector().setProperty("address", "0.0.0.0"); |
| 49 | |
| 50 | String webappDir = new File("src/main/webapp").getAbsolutePath(); |
| 51 | tomcat.addWebapp("/", webappDir); |
| 52 | |
| 53 | tomcat.start(); |
| 54 | System.out.println("Tomcat server started on http://0.0.0.0:" + port); |
| 55 | tomcat.getServer().await(); |
| 56 | } catch (LifecycleException e) { |
| 57 | Logger.getLogger(TomcatServer.class.getName()).log(Level.SEVERE, "Error starting Tomcat on port " + port, e); |
| 58 | } |
| 59 | } |
| 60 | } |
nothing calls this directly
no outgoing calls
no test coverage detected