*/
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);
}
}