// Copyright 2012 Georg-August-Universität Göttingen, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package de.ugoe.cs.autoquest.htmlmonitor; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Timer; import java.util.TimerTask; import de.ugoe.cs.util.console.Console; /** *
* The log manager handles different {@link HtmlMonitorOutputWriter}s to perform the logging * of recorded messages. It initializes a new writer if the first message for a specific * client is received and it closes a writer if for a specific period of time no further message * of the same client was received. The writers themselves consider log rotation. For handling * messages, the {@link HtmlMonitorMessageListener} mechanism provided by the * {@link HtmlMonitorServer} is used. *
* * @author Patrick Harms */ class HtmlMonitorLogManager implements HtmlMonitorComponent, HtmlMonitorMessageListener { /** * the timeout after which a writer of an inactive client is closed */ private static final int SESSION_TIMEOUT = 100000; /** * the directory into which the log files shall be written */ private String logFileBaseDir; /** * the mapping of client ids to the respective writers. */ private Map* initializes the log manager with the directory into which the log files shall be stored *
* * @param logFileBaseDir the directory into which the log files shall be stored */ HtmlMonitorLogManager(String logFileBaseDir) { this.logFileBaseDir = logFileBaseDir; } /* (non-Javadoc) * @see de.ugoe.cs.autoquest.htmlmonitor.HtmlMonitorComponent#init() */ @Override public synchronized void init() throws IllegalStateException, HtmlMonitorException { if (writers != null) { throw new IllegalStateException("already initialized"); } writers = new HashMap* internal timer task used for detecting session timeouts of clients *
* * @author Patrick Harms */ public class LogFileMonitorTimerTask extends TimerTask { /* (non-Javadoc) * @see java.lang.Runnable#run() */ @Override public void run() { synchronized (HtmlMonitorLogManager.this) { List