Skip to content

Commit

Permalink
自动决定使用哪一个libsigar
Browse files Browse the repository at this point in the history
  • Loading branch information
ysc committed Mar 23, 2014
1 parent 59cfc83 commit 71a2393
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,28 @@ protected String getSplitString(String str, String split, int length){
}
String result=finalMachineCode.toString().substring(0, finalMachineCode.toString().length()-1);
return result;
}
}
protected String getSigarFile(String osName){
StringBuilder result = new StringBuilder();
result.append("libsigar-");
String osArch = System.getProperty("os.arch");
if(osArch.contains("64")){
result.append("amd64-");
}else{
result.append("x86-");
}
result.append(osName).append("-1.6.4.so");
return result.toString();
}
/**
* 利用sigar来生成机器码,当然这个实现不是很好,无法获得CPU ID,希望有兴趣的朋友来改进这个实现
* @param osName 操作系统类型
* @return 机器码
*/
protected String getSigarSequence(String osName) {
try {
File libFile = new File(FileUtils.getAbsolutePath("/WEB-INF/lib/"+PropertyHolder.getProperty("libsigar."+osName)));
LOG.debug("libsigar."+osName+" : "+libFile.getAbsolutePath());
File libFile = new File(FileUtils.getAbsolutePath("/WEB-INF/lib/"+getSigarFile(osName)));
LOG.debug("libsigar: "+libFile.getAbsolutePath());

System.load(libFile.getAbsolutePath());
Set<String> result = new HashSet<>();
Expand Down
5 changes: 0 additions & 5 deletions APDPlat_Core/src/main/resources/org/apdplat/config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,5 @@ dictionary.generator.freemarker.template=/org/apdplat/module/dictionary/generato
action.generator.freemarker.template=/org/apdplat/platform/action/generator/freemarker/template/
model.generator.freemarker.template=/org/apdplat/platform/model/generator/freemarker/template/

#\u751f\u6210\u673a\u5668\u7801\u6240\u4f7f\u7528\u7684sigar\u5e93\u6587\u4ef6
libsigar.linux=libsigar-amd64-linux-1.6.4.so
libsigar.mac=libsigar-universal64-macosx-1.6.4.dylib
libsigar.solaris=libsigar-amd64-solaris-1.6.4.so

demo=false
context.path=

0 comments on commit 71a2393

Please sign in to comment.