1 14 package org.jahia.init; 15 16 import java.io.InputStream ; 17 import java.net.URL ; 18 19 28 29 public class TomcatWait 30 { 31 private static org.apache.log4j.Logger logger = 32 org.apache.log4j.Logger.getLogger(TomcatWait.class); 33 34 private static final String DEFAULT_TARGET_URL = "http://localhost:8080/jahia/html/startup/startjahia.html"; 35 36 public static void main(String args[]) 37 { 38 String targetURL = DEFAULT_TARGET_URL; 39 if (args.length == 0) { 40 logger.error("Missing targetURL, defaulting to " + DEFAULT_TARGET_URL); 41 } else { 42 targetURL = args[0]; 43 } 44 URL url = null; 45 try 46 { 47 url = new URL (targetURL); 48 } 49 catch(Throwable throwable) 50 { 51 logger.error("Error in URL parameter : " + targetURL, throwable); 52 return; 53 } 54 boolean flag = false; 55 System.out.print("Waiting for Web Server to become available at " + targetURL + "."); 56 try { 57 Thread.sleep(1000); } catch (InterruptedException ie) { 59 ie.printStackTrace(); 60 } 61 while(!flag) { 62 System.out.print("."); 63 try { 64 Thread.sleep(500); } catch (InterruptedException ie) { 66 ie.printStackTrace(); 67 } 68 69 try 70 { 71 InputStream inputstream = url.openStream(); 72 flag = true; 73 inputstream.close(); 74 } 75 catch(Throwable throwable1) 76 { 77 flag = false; 78 } 79 } 80 System.out.println(""); 81 System.out.println("Web Server now available."); 82 } 83 } 84 | Popular Tags |