]> git.mxchange.org Git - addressbook-swing.git/blob - Addressbook/src/org/mxchange/addressbook/manager/application/ApplicationManager.java
f27cfb3e874c3325c3ec7b72ee11a257666be4be
[addressbook-swing.git] / Addressbook / src / org / mxchange / addressbook / manager / application / ApplicationManager.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.addressbook.manager.application;
18
19 import org.mxchange.addressbook.application.Application;
20 import org.mxchange.addressbook.manager.BaseManager;
21
22 /**
23  *
24  * @author Roland Haeder
25  */
26 public class ApplicationManager extends BaseManager implements ManageableApplication {
27
28         /**
29          * Getter for application manager
30          *
31          * @param application An instance of a Application class
32          * @return
33          */
34         public static final ManageableApplication getManager (final Application application) {
35                 // Application instance must be set
36                 if (application == null) {
37                         // Abort here
38                         throw new NullPointerException("application is null"); //NOI18N
39                 }
40
41                 // Get manager
42                 ManageableApplication manager = new ApplicationManager(application);
43
44                 // Return manager
45                 return manager;
46         }
47
48         /**
49          * Constructor for this manager
50          *
51          * @param application An instance of an Application class
52          */
53         private ApplicationManager (final Application application) {
54                 super();
55
56                 // Application instance must be set
57                 if (application == null) {
58                         // Abort here
59                         throw new NullPointerException("application is null"); //NOI18N
60                 }
61
62                 // Trace message
63                 this.getLogger().trace("CALLED!"); //NOI18N
64
65                 // Set application instance
66                 this.setApplication(application);
67         }
68
69         @Override
70         public void start () {
71                 // Trace message
72                 this.getLogger().trace("CALLED!"); //NOI18N
73
74                 // Bootstrap application
75                 this.getApplication().doBootstrap();
76
77                 // Run the main loop
78                 this.getApplication().doMainLoop();
79
80                 // Trace message
81                 this.getLogger().trace("EXIT!"); //NOI18N
82         }
83 }