我正在与Alfresco合作,有时服务器因低空间或其他问题而关闭,事情是我的serverURL我想检查他是否可用(Alfresco服务器)我想做ping但是adresse是简单ping for的复杂内容: http:// 127.0.0.1:8084/alfresco/api/-default-/public/cmis/versions/1.0/atom 我在J2EE项目中工作
I am working with Alfresco and sometimes the server is down for low space or other problem , the thing is with my serverURL i want to check if he is available (Alfresco Server) i thought to make a ping but the adresse is to complexe for a simple ping ex : 127.0.0.1:8084/alfresco/api/-default-/public/cmis/versions/1.0/atom I am working in a J2EE Project
推荐答案您好我想说的是@Gagravarr给出的部分答案
Hi i want to say that the part of the answer where given by @Gagravarr
public void pingADR() throws UnknownHostException, IOException { String url = "127.0.0.1:8084/alfresco/service/api/server"; String status = getStatus(url); System.out.println(url + "\t\tStatus:" + status); }并查看是否可用
public static String getStatus(String url) throws IOException { String result = ""; try { URL siteURL = new URL(url); HttpURLConnection connection = (HttpURLConnection) siteURL .openConnection(); connection.setRequestMethod("GET"); connection.connect(); int code = connection.getResponseCode(); if (code == 200) { result = "Green"; } } catch (Exception e) { result = "->Red<-"; } return result; }我在一个非常有用的网站上找到了这个答案,希望能帮助其他人人
I found this answer in a very helpful web site, Hope that will help other people
更多推荐
看看Alfresco Server是否可用
发布评论