Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦中观雨
cat
提交
676c4eab
C
cat
项目概览
梦中观雨
/
cat
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
cat
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
676c4eab
编写于
9月 10, 2013
作者:
Y
yong.you
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rename test
上级
e6841ac5
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
1 addition
and
98 deletion
+1
-98
cat-home/src/main/java/com/dianping/cat/system/tool/CommonUtil.java
...rc/main/java/com/dianping/cat/system/tool/CommonUtil.java
+0
-97
cat-home/src/test/java/com/dianping/cat/system/tool/DefaultGmailTest.java
...t/java/com/dianping/cat/system/tool/DefaultGmailTest.java
+1
-1
未找到文件。
cat-home/src/main/java/com/dianping/cat/system/tool/CommonUtil.java
已删除
100644 → 0
浏览文件 @
e6841ac5
package
com.dianping.cat.system.tool
;
import
java.io.InputStream
;
import
java.net.Inet4Address
;
import
java.net.InetAddress
;
import
java.net.NetworkInterface
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Map
;
import
org.unidal.helper.Files
;
import
com.dianping.cat.configuration.client.entity.ClientConfig
;
import
com.dianping.cat.configuration.client.entity.Domain
;
import
com.dianping.cat.configuration.client.transform.DefaultSaxParser
;
public
class
CommonUtil
{
private
static
final
String
DEFAULT
=
"UNKOWN"
;
private
static
String
DOMAIN
=
DEFAULT
;
private
static
String
IP
;
private
static
final
String
CAT_CLIENT_XML
=
"/META-INF/cat/client.xml"
;
// public static void main(String args[]) {
// System.out.println(CommonUtil.getDomain());
// System.out.println(CommonUtil.getIp());
// }
static
{
try
{
ClientConfig
clientConfig
=
null
;
InputStream
in
=
Thread
.
currentThread
().
getContextClassLoader
().
getResourceAsStream
(
CAT_CLIENT_XML
);
if
(
in
==
null
)
{
in
=
CommonUtil
.
class
.
getResourceAsStream
(
CAT_CLIENT_XML
);
}
if
(
in
!=
null
)
{
String
xml
=
Files
.
forIO
().
readFrom
(
in
,
"utf-8"
);
clientConfig
=
DefaultSaxParser
.
parse
(
xml
);
}
if
(
clientConfig
!=
null
)
{
Map
<
String
,
Domain
>
domains
=
clientConfig
.
getDomains
();
Domain
firstDomain
=
domains
.
isEmpty
()
?
null
:
domains
.
values
().
iterator
().
next
();
DOMAIN
=
firstDomain
.
getId
();
}
}
catch
(
Exception
e
)
{
}
try
{
List
<
NetworkInterface
>
nis
=
Collections
.
list
(
NetworkInterface
.
getNetworkInterfaces
());
InetAddress
local
=
null
;
for
(
NetworkInterface
ni
:
nis
)
{
if
(
ni
.
isUp
())
{
List
<
InetAddress
>
addresses
=
Collections
.
list
(
ni
.
getInetAddresses
());
for
(
InetAddress
address
:
addresses
)
{
if
(
address
instanceof
Inet4Address
)
{
if
(
address
.
isLoopbackAddress
()
||
address
.
isSiteLocalAddress
())
{
if
(
local
==
null
)
{
local
=
address
;
}
else
if
(
local
.
isLoopbackAddress
()
&&
address
.
isSiteLocalAddress
())
{
// site local address has higher priority than
// loopback address
local
=
address
;
}
else
if
(
local
.
isSiteLocalAddress
()
&&
address
.
isSiteLocalAddress
())
{
// site local address with a host name has higher
// priority than one without host name
if
(
local
.
getHostName
().
equals
(
local
.
getHostAddress
())
&&
!
address
.
getHostName
().
equals
(
address
.
getHostAddress
()))
{
local
=
address
;
}
}
}
}
}
}
}
IP
=
local
.
getHostAddress
();
}
catch
(
Exception
e
)
{
}
}
public
static
final
String
getDomain
()
{
return
DOMAIN
;
}
public
static
final
String
getIp
()
{
return
IP
;
}
}
cat-home/src/test/java/com/dianping/cat/system/tool/DefaultGmail.java
→
cat-home/src/test/java/com/dianping/cat/system/tool/DefaultGmail
Test
.java
浏览文件 @
676c4eab
...
...
@@ -8,7 +8,7 @@ import junit.framework.Assert;
import
org.junit.Test
;
import
org.unidal.lookup.ComponentTestCase
;
public
class
DefaultGmail
extends
ComponentTestCase
{
public
class
DefaultGmail
Test
extends
ComponentTestCase
{
@Test
public
void
test
()
throws
Exception
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录