]> git.mxchange.org Git - addressbook-swing.git/blob - src/org/mxchange/addressbook/BaseAddressbookSystem.java
Updated copyright year
[addressbook-swing.git] / src / org / mxchange / addressbook / BaseAddressbookSystem.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.addressbook;
18
19 import javax.naming.Context;
20 import javax.naming.InitialContext;
21 import javax.naming.NamingException;
22 import org.mxchange.jcore.BaseFrameworkSystem;
23 import org.mxchange.jcoreeelogger.beans.local.logger.Log;
24 import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
25
26 /**
27  * A general addressbook class
28  * <p>
29  * @author Roland Häder<roland@mxchange.org>
30  */
31 public abstract class BaseAddressbookSystem extends BaseFrameworkSystem {
32
33         /**
34          * Logger instance
35          */
36         @Log
37         private LoggerBeanLocal loggerBeanLocal;
38
39         /**
40          * Protected constructor
41          */
42         protected BaseAddressbookSystem () {
43                 try {
44                         // Get initial context
45                         Context context = new InitialContext();
46
47                         // Lookup loggerBeanLocal
48                         this.loggerBeanLocal = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal"); //NOI18N
49                 } catch (final NamingException ex) {
50                         // Continue to throw
51                         throw new RuntimeException(ex);
52                 }
53         }
54
55         /**
56          * Log exception and abort program.
57          * <p>
58          * @param throwable Throwable
59          */
60         protected void abortProgramWithException (final Throwable throwable) {
61                 // Log exception
62                 this.logException(throwable);
63
64                 // Abort here
65                 System.exit(1);
66         }
67
68         /**
69          * Getter for loggerBeanLocal instance
70          * <p>
71          * @return Logger instance
72          */
73         protected LoggerBeanLocal getLoggerBeanLocal () {
74                 return this.loggerBeanLocal;
75         }
76
77         /**
78          * Logs given exception
79          * <p>
80          * @param exception Throwable
81          */
82         protected void logException (final Throwable exception) {
83                 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
84         }
85 }