处理国际化文件频繁加载导致java.net.SocketException: Too many open files的问题
This commit is contained in:
@@ -9,13 +9,18 @@ import com.nis.util.StringUtil;
|
||||
|
||||
public final class Configurations {
|
||||
private static Properties prop = new Properties();
|
||||
|
||||
private static Properties msgPropZh = new Properties();
|
||||
private static Properties msgPropRu = new Properties();
|
||||
private static Properties msgPropEn = new Properties();
|
||||
static {
|
||||
try {
|
||||
prop.load(Configurations.class.getResourceAsStream("/nis.properties"));
|
||||
prop.load(Configurations.class.getResourceAsStream("/table.properties"));
|
||||
prop.load(Configurations.class.getResourceAsStream("/matt.properties"));
|
||||
|
||||
//加载国际化配置文件
|
||||
msgPropZh.load(Configurations.class.getResourceAsStream("/messages/message_zh_CN.properties"));
|
||||
msgPropRu.load(Configurations.class.getResourceAsStream("/messages/message_ru.properties"));
|
||||
msgPropEn.load(Configurations.class.getResourceAsStream("/messages/message_en.properties"));
|
||||
} catch (Exception e) {
|
||||
prop = null;
|
||||
System.err.println("未知nis.properties,请确定文件是否存在!");
|
||||
@@ -75,10 +80,16 @@ public final class Configurations {
|
||||
return prop;
|
||||
}
|
||||
|
||||
public static Properties getMsgPropEn() {
|
||||
return msgPropEn;
|
||||
}
|
||||
|
||||
public static Properties getMsgPropRu() {
|
||||
return msgPropRu;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static Properties getMsgPropZh() {
|
||||
return msgPropZh;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.util.Properties;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
@@ -206,8 +207,15 @@ public class LogUtils {
|
||||
menuMap2 = Maps.newHashMap();
|
||||
Properties msgProp = new Properties();
|
||||
try {
|
||||
msgProp.load(Configurations.class.getResourceAsStream("/messages/message_en.properties"));
|
||||
} catch (IOException e) {
|
||||
String language = LocaleContextHolder.getLocale().getLanguage();
|
||||
if (language.equals("zh_cn") || language.equals("zh")) {
|
||||
msgProp=Configurations.getMsgPropZh();
|
||||
} else if (language.equals("ru")) {
|
||||
msgProp=Configurations.getMsgPropRu();
|
||||
} else {
|
||||
msgProp=Configurations.getMsgPropEn();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
List<SysMenu> menuList = menuDao.findAllList(new SysMenu());
|
||||
|
||||
Reference in New Issue
Block a user