How to check if Glassfish DAS is running programmatically even if it is deployed on local machine or remote machine?
Using Java6
I have found a way to check if DAS is up other than Linux script. With this way it does not matter if both my application and DAS are at same machine or each installed different machine.
public static boolean isUrlReachable(String host) {
String URLName="http://"+host+":4848";
boolean isUp = false;
try {
HttpURLConnection.setFollowRedirects(false);
HttpURLConnection con = (HttpURLConnection) new URL(URLName).openConnection();
con.setRequestMethod("GET");
isUp = (con.getResponseCode() == HttpURLConnection.HTTP_OK);
con.disconnect();
}
catch (Exception e) {
return isUp;
}
return isUp;
}