add: 添加一个配置项,可以完全关闭druid的monitor页面

This commit is contained in:
Wendal Chen 2020-03-12 16:53:58 +08:00
parent 19756e93a0
commit a13e476f72

View File

@ -23,6 +23,9 @@ public class DruidWebStatServletStarter implements WebServletFace {
protected static final String PRE = "druid.web.servlet."; protected static final String PRE = "druid.web.servlet.";
@PropDoc(group="druid", type="boolean", defaultValue="true", value="是否启动monitor页面")
public static final String PROP_ENABLE = PRE + "enable";
@PropDoc(group="druid", type="boolean", defaultValue="true", value="是否允许重置统计结果") @PropDoc(group="druid", type="boolean", defaultValue="true", value="是否允许重置统计结果")
public static final String PROP_RESET_ENABLE = PRE + StatViewServlet.PARAM_NAME_RESET_ENABLE; public static final String PROP_RESET_ENABLE = PRE + StatViewServlet.PARAM_NAME_RESET_ENABLE;
@ -80,6 +83,10 @@ public class DruidWebStatServletStarter implements WebServletFace {
public Servlet getServlet() { public Servlet getServlet() {
if (!DataSourceStarter.isDruid(conf)) if (!DataSourceStarter.isDruid(conf))
return null; return null;
if (!conf.getBoolean(PROP_ENABLE, true)) {
log.debug("druid monitor enable=false, disable it");
return null;
}
return new StatViewServlet(); return new StatViewServlet();
} }