]> git.mxchange.org Git - addressbook-lib.git/blobdiff - Addressbook/src/org/mxchange/addressbook/database/frontend/contact/ContactDatabaseFrontend.java
Added a lot trace messages + sanity checks for null references and such things
[addressbook-lib.git] / Addressbook / src / org / mxchange / addressbook / database / frontend / contact / ContactDatabaseFrontend.java
index cfd7ec1a7caa959419e3907187a8af6a20375e67..30535fd231b3490861fa08166f22f9f5572eddd2 100644 (file)
 package org.mxchange.addressbook.database.frontend.contact;
 
 import java.io.IOException;
+import java.text.MessageFormat;
 import java.util.Iterator;
 import java.util.List;
-import org.mxchange.addressbook.exceptions.BadTokenException;
 import org.mxchange.addressbook.contact.Contact;
 import org.mxchange.addressbook.database.backend.csv.CsvBackend;
 import org.mxchange.addressbook.database.frontend.BaseDatabaseFrontend;
 import org.mxchange.addressbook.database.storage.Storeable;
+import org.mxchange.addressbook.exceptions.BadTokenException;
 import org.mxchange.addressbook.manager.contact.ContactManager;
 
 /**
@@ -42,6 +43,15 @@ public class ContactDatabaseFrontend extends BaseDatabaseFrontend implements Con
                // Call own constructor
                this();
 
+               // Trace message
+               this.getLogger().trace(MessageFormat.format("manager={0} - CALLED!", manager)); //NOI18N
+
+               // Manager instance must not be null
+               if (manager == null) {
+                       // Abort here
+                       throw new NullPointerException("manager is null"); //NOI18N
+               }
+
                // Set contact manager
                this.setContactManager(manager);
        }
@@ -52,8 +62,11 @@ public class ContactDatabaseFrontend extends BaseDatabaseFrontend implements Con
        protected ContactDatabaseFrontend () {
                super();
 
+               // Trace message
+               this.getLogger().trace("CALLED!"); //NOI18N
+
                // Set "table" name
-               this.setTableName("contacts");
+               this.setTableName("contacts"); //NOI18N
 
                // Initalize backend
                this.initBackend();
@@ -64,8 +77,14 @@ public class ContactDatabaseFrontend extends BaseDatabaseFrontend implements Con
         */
        @Override
        public void doShutdown () {
+               // Trace message
+               this.getLogger().trace("CALLED!"); //NOI18N
+
                // Shutdown backend
                this.getBackend().doShutdown();
+
+               // Trace message
+               this.getLogger().trace("EXIT!"); //NOI18N
        }
 
        /**
@@ -73,6 +92,9 @@ public class ContactDatabaseFrontend extends BaseDatabaseFrontend implements Con
         */
        @Override
        public void flushAllContacts () {
+               // Trace message
+               this.getLogger().trace("CALLED!"); //NOI18N
+
                // Get full list
                List<Contact> contacts = this.getContactManager().getList();
 
@@ -96,6 +118,9 @@ public class ContactDatabaseFrontend extends BaseDatabaseFrontend implements Con
                                System.exit(1);
                        }
                }
+
+               // Trace message
+               this.getLogger().trace("EXIT!"); //NOI18N
        }
 
        /**
@@ -104,6 +129,9 @@ public class ContactDatabaseFrontend extends BaseDatabaseFrontend implements Con
         */
        @Override
        public void readAllContacts () {
+               // Trace message
+               this.getLogger().trace("CALLED!"); //NOI18N
+
                // Get iterator and case it
                CsvBackend backend = (CsvBackend) this.getBackend();
 
@@ -127,5 +155,8 @@ public class ContactDatabaseFrontend extends BaseDatabaseFrontend implements Con
                        // Add contact instance to manager
                        this.getContactManager().addContact(contact);
                }
+
+               // Trace message
+               this.getLogger().trace("EXIT!"); //NOI18N
        }
 }