检查Glassfish DAS是否以编程方式运行 [英] Check if Glassfish DAS is running programmatically

查看:77
本文介绍了检查Glassfish DAS是否以编程方式运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果Glassfish DAS是否以编程方式运行,即使它部署在本地计算机或远程计算机上也是如此?

How to check if Glassfish DAS is running programmatically even if it is deployed on local machine or remote machine?

使用Java6

推荐答案

我找到了一种方法来检查DAS是否在Linux脚本之外。
通过这种方式,无论我的应用程序和DAS是在同一台机器上还是每台机器安装不同,都无关紧要。

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;

}

这篇关于检查Glassfish DAS是否以编程方式运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆