]> git.mxchange.org Git - jcore.git/blob - src/org/mxchange/jcore/client/BaseClient.java
8ec8883c42dda15c0fad7efb4a4e55f167a2d83d
[jcore.git] / src / org / mxchange / jcore / client / BaseClient.java
1 /*
2  * Copyright (C) 2015 Roland Haeder
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 package org.mxchange.jcore.client;
18
19 import java.io.IOException;
20 import java.sql.SQLException;
21 import org.mxchange.jcore.BaseFrameworkSystem;
22
23 /**
24  * A general client
25  *
26  * @author Roland Haeder
27  */
28 public abstract class BaseClient extends BaseFrameworkSystem implements Client {
29
30         /**
31          * Application is not running by default
32          */
33         private boolean isRunning;
34
35         /**
36          * No instances can be created of this class
37          */
38         protected BaseClient () {
39         }
40
41         /**
42          * Shutdown method for all clients
43          */
44         @Override
45         public void doShutdown () throws SQLException, IOException {
46                 // Trace message
47                 this.getLogger().trace("CALLED!"); //NOI18N
48
49                 // Disable client
50                 this.disableIsRunning();
51
52                 // Shuts down contact manager
53                 this.getManager().doShutdown();
54
55                 // Trace message
56                 this.getLogger().trace("EXIT!"); //NOI18N
57         }
58
59         /**
60          * Enables the client
61          */
62         @Override
63         public final void enableIsRunning () {
64                 this.isRunning = true;
65         }
66
67         /**
68          * Determines whether the application is still active by checking some
69          * conditions
70          *
71          * @return Whether the application is still active
72          */
73         @Override
74         public final boolean isRunning () {
75                 // In console client, 0 may have been used
76                 return this.isRunning;
77         }
78
79         /**
80          * Disables the client
81          */
82         protected final void disableIsRunning () {
83                 this.isRunning = false;
84         }
85 }