+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+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.LoggerBeanLocal;
+
+/**
+ * A general addressbook class
+ *
+ * @author Roland Haeder
+ */
+public abstract class BaseAddressbookSystem extends BaseFrameworkSystem {
+
+ /**
+ * Logger instance
+ */
+ private LoggerBeanLocal logger;
+
+ /**
+ * 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
+ *
+ * @return Logger instance
+ */
+ protected LoggerBeanLocal getLogger () {
+ return this.logger;
+ }
+
+ /**
+ * Logs given exception
+ *
+ * @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.
+ *
+ * @param throwable Throwable
+ */
+ protected void abortProgramWithException (final Throwable throwable) {
+ // Log exception
+ this.logException(throwable);
+
+ // Abort here
+ System.exit(1);
+ }
+}