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