Coverage details for ui.util.LogoutDaemon

LineHitsSource
1 /*******************************************************************************
2  * InternetCafe is a software solution that helps the management of Cybercafes
3  * according with the ITALIAN DECREE LAW ON ANTI-TERROR MEASURES, 27 JULY 2005.
4  * Copyright (C) 2006 Guido Angelo Ingenito
5  
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  
110 * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
130 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
160 * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  *******************************************************************************/
200 
210package ui.util;
220 
230import java.util.Date;
24 import java.util.Timer;
250import java.util.TimerTask;
260 
27 import org.apache.log4j.Logger;
280 
29 import ui.Messages;
30 import base.ConfigurationManager;
310 
320public class LogoutDaemon {
330 
340    private static final transient Logger logger = Logger
350            .getLogger(LogoutDaemon.class.getName());
360 
370    private int seconds = 60;
380 
39     private Timer timer;
400 
410    public LogoutDaemon(int seconds) {
420        this.seconds = seconds;
430        timer = new Timer();
440        int scheduleTime = ConfigurationManager.getInstance()
450                .getLogoutScheduleRate() * 1000;
460        logger.debug("Logout Schedule Time :" + scheduleTime / 1000 + Messages.getString("common.unit.second")); //$NON-NLS-1$ //$NON-NLS-2$
470        timer.scheduleAtFixedRate(new LogoutTask(), 0, ConfigurationManager
480                .getInstance().getLogoutScheduleRate() * 1000);
490    }
500 
51     class LogoutTask extends TimerTask {
52         public void run() {
53             Date currentDate = new Date();
54             if (ConfigurationManager.getInstance().getLastSeenUserWorking()
55                     .getTime()
56                     + seconds * 1000 < currentDate.getTime()
57                     && !ConfigurationManager.getInstance()
58                             .getServerLoginDialog().isVisible()
59                     && ConfigurationManager.getInstance().isPasswordProtect()) {
60                 logger.debug(Messages.getString("message.logoutsuccess")); //$NON-NLS-1$
61                 ConfigurationManager.getInstance().getServerLoginDialog()
62                         .setVisible(true);
63             }
64         }
65     }
66  
670    public static void main(String args[]) {
680        new LogoutDaemon(5);
690        System.out.format("Task scheduled.%n"); //$NON-NLS-1$
700    }
710 
72 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.