DrupalAuthInfoCommand → AuthInfoCommand (je to obecná implementace, nezávislá na Drupalu)
3 * see AUTHORS for the list of contributors
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 package org.sonews.daemon;
21 import java.sql.SQLException;
22 import org.sonews.storage.StorageManager;
23 import org.sonews.util.Log;
26 * Base class of all sonews threads.
27 * Instances of this class will be automatically registered at the ShutdownHook
28 * to be cleanly exited when the server is forced to exit.
29 * @author Christian Lins
32 public abstract class AbstractDaemon extends Thread
35 /** This variable is write synchronized through setRunning */
36 private boolean isRunning = false;
39 * Protected constructor. Will be called by derived classes.
41 protected AbstractDaemon()
43 setDaemon(true); // VM will exit when all threads are daemons
44 setName(getClass().getSimpleName());
48 * @return true if shutdown() was not yet called.
50 public boolean isRunning()
53 return this.isRunning;
58 * Marks this thread to exit soon. Closes the associated JDBCDatabase connection
60 * @throws java.sql.SQLException
62 public void shutdownNow()
66 this.isRunning = false;
67 StorageManager.disableProvider();
72 * Calls shutdownNow() but catches SQLExceptions if occurring.
74 public void shutdown()
78 } catch (SQLException ex) {
79 Log.get().warning(ex.toString());
90 this.isRunning = true;