]> git.mxchange.org Git - jbonuscard-lib.git/blobdiff - src/org/mxchange/addressbook/BaseAddressbookSystem.java
Continued:
[jbonuscard-lib.git] / src / org / mxchange / addressbook / BaseAddressbookSystem.java
index aa8c235ad6d6c0d30e538f0125a8d03410487ce4..6f4ec4ac64909598d09d2dfcb61a4b472db9c7a0 100644 (file)
  */
 package org.mxchange.addressbook;
 
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
 import org.mxchange.jcore.BaseFrameworkSystem;
+import org.mxchange.jcoreeelogger.beans.local.logger.Log;
+import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
 
 /**
- * General class for addressbook application
- *
+ * A general addressbook class
+ * <p>
  * @author Roland Haeder
  */
-public class BaseAddressbookSystem extends BaseFrameworkSystem {
+public abstract class BaseAddressbookSystem extends BaseFrameworkSystem {
+
+       /**
+        * Logger instance
+        */
+       @Log
+       private LoggerBeanLocal logger;
+
        /**
-        * No instances can be created of this class
+        * Protected constructor
         */
        protected BaseAddressbookSystem () {
+               try {
+                       // Get initial context
+                       Context context = new InitialContext();
+
+                       // Lookup logger
+                       this.logger = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal");
+               } catch (final NamingException ex) {
+                       // Continue to throw
+                       throw new RuntimeException(ex);
+               }
+       }
+
+       /**
+        * Getter for logger instance
+        * <p>
+        * @return Logger instance
+        */
+       protected LoggerBeanLocal getLogger () {
+               return this.logger;
+       }
+
+       /**
+        * Logs given exception
+        * <p>
+        * @param exception Throwable
+        */
+       protected void logException (final Throwable exception) {
+               throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+       }
+
+       /**
+        * Log exception and abort program.
+        * <p>
+        * @param throwable Throwable
+        */
+       protected void abortProgramWithException (final Throwable throwable) {
+               // Log exception
+               this.logException(throwable);
+
+               // Abort here
+               System.exit(1);
        }
 }