/*
- * Copyright (C) 2015 Roland Haeder
+ * Copyright (C) 2016 - 2020 Free Software Foundation
*
* 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
import java.sql.SQLException;
import java.text.MessageFormat;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import javax.naming.Context;
import org.mxchange.addressbook.facade.contact.ContactFacade;
import org.mxchange.addressbook.menu.Menu;
import org.mxchange.jcore.client.BaseClient;
-import org.mxchange.jcore.client.Client;
import org.mxchange.jcoreeelogger.beans.local.logger.Log;
import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
/**
* A general addressbook client
* <p>
- * @author Roland Haeder TODO: Find better name
+ * @author Roland Häder<roland@mxchange.org> TODO: Find better name
*/
public abstract class BaseAddressbookClient extends BaseClient implements AddressbookClient {
* Logger instance
*/
@Log
- private LoggerBeanLocal logger;
+ private LoggerBeanLocal loggerBeanLocal;
/**
* Menu system
// Get 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"); //NOI18N
+ // Lookup loggerBeanLocal
+ this.loggerBeanLocal = (LoggerBeanLocal) context.lookup("java:global/jcore-logger-ejb/logger!org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal"); //NOI18N
} catch (final NamingException ex) {
// Continue to throw
throw new RuntimeException(ex);
* <p>
* @return the currentMenu
*/
- public final String getCurrentMenu () {
+ public String getCurrentMenu () {
return this.currentMenu;
}
@Override
- public final void setCurrentMenu (final String currentMenu) {
+ public void setCurrentMenu (final String currentMenu) {
this.currentMenu = currentMenu;
}
protected abstract void fillMenuMap ();
/**
- * Getter for logger instance
+ * Getter for loggerBeanLocal instance
* <p>
* @return Logger instance
*/
- protected LoggerBeanLocal getLogger () {
- return this.logger;
+ protected LoggerBeanLocal getLoggerBeanLocal () {
+ return this.loggerBeanLocal;
}
/**
* <p>
* @return Map of all menus
*/
- protected final Map<String, Menu> getMenus () {
- return this.menus;
+ protected Map<String, Menu> getMenus () {
+ return Collections.unmodifiableMap(this.menus);
}
/**
*/
protected void initContactManager () throws SQLException {
// Trace message
- this.getLogger().logTrace("CALLED!"); //NOI18N
+ this.getLoggerBeanLocal().logTrace("CALLED!"); //NOI18N
// Debug message
- this.getLogger().logDebug("Initializing contact manager ..."); //NOI18N
+ this.getLoggerBeanLocal().logDebug("Initializing contact manager ..."); //NOI18N
// Init contact facade with console client
// TODO Static initial amount of contacts
- ContactFacade facade = new AddressbookContactFacade((Client) this);
+ ContactFacade facade = new AddressbookContactFacade(this);
// Set it here
this.setFacade(facade);
// Debug message
- this.getLogger().logDebug("Contact manager has been initialized."); //NOI18N
+ this.getLoggerBeanLocal().logDebug("Contact manager has been initialized."); //NOI18N
// Trace message
- this.getLogger().logTrace("EXIT!"); //NOI18N
+ this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N
}
/**
* @param throwable Throwable
*/
protected void logException (final Throwable throwable) {
- // Deligate to logger
- this.getLogger().logException(throwable);
+ // Deligate to loggerBeanLocal
+ this.getLoggerBeanLocal().logException(throwable);
}
/**
*/
protected void showMenu (final String menuType) {
// Trace message
- this.getLogger().logTrace(MessageFormat.format("menuType={0} - CALLED!", menuType)); //NOI18N
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("menuType={0} - CALLED!", menuType)); //NOI18N
// Get menu from type
Menu menu = this.getMenu(menuType);
menu.show(this);
// Trace message
- this.getLogger().logTrace("EXIT!"); //NOI18N
+ this.getLoggerBeanLocal().logTrace("EXIT!"); //NOI18N
}
}