]> git.mxchange.org Git - jcore.git/blob - src/org/mxchange/jcore/manager/application/ApplicationManager.java
Updated copyright year
[jcore.git] / src / org / mxchange / jcore / manager / application / ApplicationManager.java
1 /*
2  * Copyright (C) 2016 - 2024 Free Software Foundation
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.manager.application;
18
19 import org.mxchange.jcore.application.Application;
20 import org.mxchange.jcore.exceptions.MenuInitializationException;
21 import org.mxchange.jcore.facade.BaseFacade;
22
23 /**
24  * Application manager
25  * <p>
26  * @author Roland Häder<roland@mxchange.org>
27  */
28 public class ApplicationManager extends BaseFacade implements ManageableApplication {
29
30         /**
31          * Self instance of this manager
32          */
33         private static ManageableApplication selfInstance;
34
35         /**
36          * Getter for a singleton application manager
37          * <p>
38          * @param application An instance of a Application class
39          * <p>
40          * @return Get a managable application
41          */
42         public static ManageableApplication getSingeltonManager (final Application application) {
43                 // Application instance must be set
44                 if (null == application) {
45                         // Abort here
46                         throw new NullPointerException("application is null"); //NOI18N
47                 }
48
49                 // Is own instance set?
50                 if (null == selfInstance) {
51                         // Get manager
52                         selfInstance = new ApplicationManager(application);
53                 }
54
55                 // Return manager
56                 return selfInstance;
57         }
58
59         /**
60          * Constructor for this manager
61          * <p>
62          * @param application An instance of an Application class
63          */
64         private ApplicationManager (final Application application) {
65                 // Invoke super constructor
66                 super(application);
67         }
68
69         @Override
70         public void doShutdown () {
71                 // Shutdown this manager, for now nothing
72                 // TODO Maybe add something here?
73         }
74
75         @Override
76         public void start () throws MenuInitializationException {
77                 // Bootstrap application
78                 this.getApplication().doBootstrap();
79
80                 // Run the main loop
81                 this.getApplication().doMainLoop();
82         }
83
84 }