GXHaHostHelper.java
1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package com.sitech.ismp.coll.tivoli;
import java.util.Enumeration;
import java.util.ResourceBundle;
public class GXHaHostHelper
{
static ResourceBundle HA_HOST_NAME = null;
static {
try{
HA_HOST_NAME = ResourceBundle.getBundle("gx_ha_host_name");
}
catch(Exception e){
System.out.println("Bundle gx_ha_host_name.properties error.");
e.printStackTrace();
}
}
/**
* 判断输入的主机名是否为HA HOST
* @param host_name
* @return
*/
public static boolean isHaHost(String host_name)
{
Enumeration en = HA_HOST_NAME.getKeys();
boolean flag=false;
while(en.hasMoreElements())
{
flag = false;
String ha_host_name = (String)en.nextElement();
if(ha_host_name.equalsIgnoreCase(host_name))
{
flag = true;
break;
}
}
return flag;
}
/**
* 返回ha host name
* lianlian 2006-09-22
* @param host_name
* @return
*/
public static String getHaHostName(String host_name)
{
String temp_ha_host_name="";
if(host_name==null)
{
return temp_ha_host_name;
}
Object obj = HA_HOST_NAME.getObject(host_name);
if(obj==null)
{
return temp_ha_host_name;
}
else
{
temp_ha_host_name = (String)obj;
return temp_ha_host_name;
}
}
public static void main(String args[])
{
System.out.println(GXHaHostHelper.isHaHost("ONEBOSS2"));
//IBOSS2
}
}