Commit 981e5672 authored by Reiner Jung's avatar Reiner Jung

Minor cleanups

parent eb30c28a
......@@ -29,55 +29,46 @@ public class KiekerServletContextListener implements ServletContextListener {
this.monitoringCtrl = MonitoringController.getInstance();
this.timeSource = this.monitoringCtrl.getTimeSource();
}
public void contextDestroyed(ServletContextEvent contextEvent) {
System.out.println("ServletContextListener destroyed");
public void contextInitialized(ServletContextEvent contextEvent) {
System.out.println("ServletContextListener initialized");
// is monitoring enabled
// is probe enabled
String server = contextEvent.getServletContext().getServerInfo();
String context = contextEvent.getServletContext().getServletContextName();
String hostname = "1.2.3.4";
// log data
this.monitoringCtrl.newMonitoringRecord(new ContextDestroyedEvent(this.timeSource.getTime(), server, context, hostname));
try {
InetAddress ip = InetAddress.getLocalHost();
String hostname = ip.getHostName();
this.monitoringCtrl.newMonitoringRecord(new ContextInitializedEvent(this.timeSource.getTime(), server, context, hostname));
} catch (UnknownHostException e) {
e.printStackTrace();
this.monitoringCtrl.newMonitoringRecord(new ContextInitializedEvent(this.timeSource.getTime(), server, context, "lookup-failed"));
}
}
public void contextInitialized(ServletContextEvent contextEvent) {
System.out.println("ServletContextListener initialized");
System.out.println("source " + contextEvent.getSource());
System.out.println("parameter " + contextEvent.getServletContext().getInitParameterNames());
Enumeration<?> ep = contextEvent.getServletContext().getInitParameterNames();
while (ep.hasMoreElements()) {
String name = (String)ep.nextElement();
System.out.println(" p: name=" + name + " value=" + contextEvent.getServletContext().getInitParameter(name));
}
System.out.println("attributes " + contextEvent.getServletContext().getAttributeNames());
Enumeration<?> ea = contextEvent.getServletContext().getAttributeNames();
while (ea.hasMoreElements()) {
String name = (String)ea.nextElement();
System.out.println(" a: name=" + name + " value=" + contextEvent.getServletContext().getAttribute(name));
}
public void contextDestroyed(ServletContextEvent contextEvent) {
System.out.println("ServletContextListener destroyed");
// is monitoring enabled
// is probe enabled
String server = contextEvent.getServletContext().getServerInfo();
String context = contextEvent.getServletContext().getServletContextName();
InetAddress ip;
// log data
try {
ip = InetAddress.getLocalHost();
InetAddress ip = InetAddress.getLocalHost();
String hostname = ip.getHostName();
// log data
this.monitoringCtrl.newMonitoringRecord(new ContextInitializedEvent(this.timeSource.getTime(), server, context, hostname));
this.monitoringCtrl.newMonitoringRecord(new ContextDestroyedEvent(this.timeSource.getTime(), server, context, hostname));
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
// log data
this.monitoringCtrl.newMonitoringRecord(new ContextInitializedEvent(this.timeSource.getTime(), server, context, "lookup-failed"));
this.monitoringCtrl.newMonitoringRecord(new ContextDestroyedEvent(this.timeSource.getTime(), server, context, "lookup-failed"));
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment