码迷,mamicode.com
首页 > 其他好文 > 详细

Tomcat CatalinaProperties的loadProperties()方法

时间:2015-06-17 16:44:34      阅读:98      评论:0      收藏:0      [点我收藏+]

标签:

CatalinaProperties是加载全局配置

该类有一个Properties properties成员

1 从系统变量中看是否有配置文件,如果有的话加载

private static String getConfigUrl() {
        return System.getProperty("catalina.config");
    }
if (configUrl != null) {
                is = (new URL(configUrl)).openStream();
            }


 

2.如果系统变量没有配置,查找CatalinaBase()下的conf目录下的catalina.properties,有的话加载

if (is == null) {
            try {
                File home = new File(getCatalinaBase());
                File conf = new File(home, "conf");
                File propsFile = new File(conf, "catalina.properties");
                is = new FileInputStream(propsFile);
            } catch (Throwable t) {
                handleThrowable(t);
            }
        }


 

3.如果还没有,在/org/apache/catalina/startup下寻找catalina.properties

if (is == null) {
            try {
                is = CatalinaProperties.class.getResourceAsStream
                    ("/org/apache/catalina/startup/catalina.properties");
            } catch (Throwable t) {
                handleThrowable(t);
            }
        }

 

按照以上顺序寻找配置文件,如果找到就load

 properties = new Properties();
 properties.load(is);

 

Tomcat CatalinaProperties的loadProperties()方法

标签:

原文地址:http://blog.csdn.net/u011686226/article/details/46533999

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!