看看Alfresco Server是否可用 [英] See if Alfresco Server is available

查看:191
本文介绍了看看Alfresco Server是否可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在与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 : http://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 = "http://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是否可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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