mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
PushService for DruidMonitor ,test with druid-monitor
This commit is contained in:
@@ -83,7 +83,7 @@ public class PushService {
|
||||
protected void execute() {
|
||||
Map<String, Object> data = collectAndReset();
|
||||
String json = JSONUtils.toJSONString(data);
|
||||
push(json);
|
||||
push("data=" + json);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.alibaba.druid.support.monitor;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
||||
import com.alibaba.druid.support.logging.Log;
|
||||
import com.alibaba.druid.support.logging.LogFactory;
|
||||
|
||||
public class PushServiceListener implements ServletContextListener {
|
||||
|
||||
private final static Log LOG = LogFactory.getLog(PushServiceListener.class);
|
||||
|
||||
private final static String MONITOR_SERVER_URL = "monitorServerUrl";
|
||||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent sce) {
|
||||
PushService pushService = PushService.getInstance();
|
||||
String serverUrl = sce.getServletContext().getInitParameter(MONITOR_SERVER_URL);
|
||||
if (serverUrl == null) {
|
||||
LOG.error(MONITOR_SERVER_URL + " can't be null");
|
||||
return;
|
||||
}
|
||||
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug(MONITOR_SERVER_URL + "= " + serverUrl);
|
||||
}
|
||||
pushService.setServerUrl(serverUrl);
|
||||
pushService.start();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent sce) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user