]> git.mxchange.org Git - jcore-logger-ejb.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Wed, 19 Oct 2022 15:08:05 +0000 (17:08 +0200)
committerRoland Häder <roland@mxchange.org>
Wed, 19 Oct 2022 15:08:05 +0000 (17:08 +0200)
- also validate these parameters, e.g. please don't set 2nd parameter "cause" to
  NULL, but use the other method with one parameter instead!

src/java/org/mxchange/jcoreeelogger/beans/local/logger/LoggerBean.java

index 74d63eba14da61033802ad9a7dae7fde65f99624..36d208a56b9d0ff28f712c5513c667d7993ae893 100644 (file)
@@ -50,78 +50,210 @@ public class LoggerBean implements LoggerBeanLocal {
 
        @Override
        public void logDebug (final String message) {
+               // Validate parameters
+               if (null == message) {
+                       // Throw NPE
+                       throw new NullPointerException("message is null"); //NOI18N
+               } else if (message.isEmpty()) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("message is empty"); //NOI18N
+               }
+
                // Deligate to logger
                this.getLogger().debug(message);
        }
 
        @Override
        public void logDebug (final String message, final Throwable cause) {
+               // Validate parameters
+               if (null == message) {
+                       // Throw NPE
+                       throw new NullPointerException("message is null"); //NOI18N
+               } else if (message.isEmpty()) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("message is empty"); //NOI18N
+               } else if (null == cause) {
+                       // Throw NPE again
+                       throw new NullPointerException("cause is null"); //NOI18N
+               }
+
                // Deligate to logger
                this.getLogger().debug(message, cause);
        }
 
        @Override
        public void logError (final String message) {
+               // Validate parameters
+               if (null == message) {
+                       // Throw NPE
+                       throw new NullPointerException("message is null"); //NOI18N
+               } else if (message.isEmpty()) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("message is empty"); //NOI18N
+               }
+
                // Deligate to logger
                this.getLogger().error(message);
        }
 
        @Override
        public void logError (final String message, final Throwable cause) {
+               // Validate parameters
+               if (null == message) {
+                       // Throw NPE
+                       throw new NullPointerException("message is null"); //NOI18N
+               } else if (message.isEmpty()) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("message is empty"); //NOI18N
+               } else if (null == cause) {
+                       // Throw NPE again
+                       throw new NullPointerException("cause is null"); //NOI18N
+               }
+
                // Deligate to logger
                this.getLogger().error(message, cause);
        }
 
        @Override
        public void logException (final Throwable throwable) {
+               // Validate parameter
+               if (null == throwable) {
+                       // Throw NPE again
+                       throw new NullPointerException("throwable is null"); //NOI18N
+               }
+
                // Deligate to logger
                this.getLogger().catching(throwable);
        }
 
        @Override
        public void logFatal (final String message, final Throwable cause) {
+               // Validate parameters
+               if (null == message) {
+                       // Throw NPE
+                       throw new NullPointerException("message is null"); //NOI18N
+               } else if (message.isEmpty()) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("message is empty"); //NOI18N
+               } else if (null == cause) {
+                       // Throw NPE again
+                       throw new NullPointerException("cause is null"); //NOI18N
+               }
+
                // Deligate to logger
                this.getLogger().fatal(message, cause);
        }
 
        @Override
        public void logFatal (final String message) {
+               // Validate parameters
+               if (null == message) {
+                       // Throw NPE
+                       throw new NullPointerException("message is null"); //NOI18N
+               } else if (message.isEmpty()) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("message is empty"); //NOI18N
+               }
+
                // Deligate to logger
                this.getLogger().fatal(message);
        }
 
        @Override
        public void logInfo (final String message) {
+               // Validate parameters
+               if (null == message) {
+                       // Throw NPE
+                       throw new NullPointerException("message is null"); //NOI18N
+               } else if (message.isEmpty()) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("message is empty"); //NOI18N
+               }
+
                // Deligate to logger
                this.getLogger().info(message);
        }
 
        @Override
        public void logInfo (final String message, final Throwable cause) {
+               // Validate parameters
+               if (null == message) {
+                       // Throw NPE
+                       throw new NullPointerException("message is null"); //NOI18N
+               } else if (message.isEmpty()) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("message is empty"); //NOI18N
+               } else if (null == cause) {
+                       // Throw NPE again
+                       throw new NullPointerException("cause is null"); //NOI18N
+               }
+
                // Deligate to logger
                this.getLogger().info(message, cause);
        }
 
        @Override
        public void logTrace (final String message) {
+               // Validate parameters
+               if (null == message) {
+                       // Throw NPE
+                       throw new NullPointerException("message is null"); //NOI18N
+               } else if (message.isEmpty()) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("message is empty"); //NOI18N
+               }
+
                // Deligate to logger
                this.getLogger().trace(message);
        }
 
        @Override
        public void logTrace (final String message, final Throwable cause) {
+               // Validate parameters
+               if (null == message) {
+                       // Throw NPE
+                       throw new NullPointerException("message is null"); //NOI18N
+               } else if (message.isEmpty()) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("message is empty"); //NOI18N
+               } else if (null == cause) {
+                       // Throw NPE again
+                       throw new NullPointerException("cause is null"); //NOI18N
+               }
+
                // Deligate to logger
                this.getLogger().trace(message, cause);
        }
 
        @Override
        public void logWarning (final String message) {
+               // Validate parameters
+               if (null == message) {
+                       // Throw NPE
+                       throw new NullPointerException("message is null"); //NOI18N
+               } else if (message.isEmpty()) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("message is empty"); //NOI18N
+               }
+
                // Deligate to logger
                this.getLogger().warn(message);
        }
 
        @Override
        public void logWarning (final String message, final Throwable cause) {
+               // Validate parameters
+               if (null == message) {
+                       // Throw NPE
+                       throw new NullPointerException("message is null"); //NOI18N
+               } else if (message.isEmpty()) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("message is empty"); //NOI18N
+               } else if (null == cause) {
+                       // Throw NPE again
+                       throw new NullPointerException("cause is null"); //NOI18N
+               }
+
                // Deligate to logger
                this.getLogger().warn(message, cause);
        }