From a533efd802cfccc2428b313d8cbd2855bc9fa562 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Sun, 17 Apr 2016 17:08:54 +0200 Subject: [PATCH] Added noisy trace messages. These are "needed" to check how often an EJB's business method has been called. This helps analyzing bottlenecks (to often called may overload the service) in applications. --- .../jcontacts/contact/PizzaContactSessionBean.java | 6 ++++++ .../PizzaMobileProviderSingletonBean.java | 12 +++++++++++- .../phone/PizzaAdminContactPhoneSessionBean.java | 6 ++++++ .../phonenumbers/phone/PizzaPhoneSessionBean.java | 6 ++++++ 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/java/org/mxchange/jcontacts/contact/PizzaContactSessionBean.java b/src/java/org/mxchange/jcontacts/contact/PizzaContactSessionBean.java index f41072c..8d6ce07 100644 --- a/src/java/org/mxchange/jcontacts/contact/PizzaContactSessionBean.java +++ b/src/java/org/mxchange/jcontacts/contact/PizzaContactSessionBean.java @@ -44,6 +44,9 @@ public class PizzaContactSessionBean extends BaseDatabaseBean implements Contact @Override public Contact findContactById (final Long contactId) throws ContactNotFoundException { + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("findContactById: contactId={0} - CALLED!", contactId)); //NOI18N + // The parameter must be valid if (null == contactId) { // Throw NPE @@ -71,6 +74,9 @@ public class PizzaContactSessionBean extends BaseDatabaseBean implements Contact throw new ContactNotFoundException(contactId, ex); } + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("findContactById: contact={0} - EXIT!", contact)); //NOI18N + // Return found instance return contact; } diff --git a/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/PizzaMobileProviderSingletonBean.java b/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/PizzaMobileProviderSingletonBean.java index 39e7334..2c3f9b9 100644 --- a/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/PizzaMobileProviderSingletonBean.java +++ b/src/java/org/mxchange/jphone/phonenumbers/mobileprovider/PizzaMobileProviderSingletonBean.java @@ -16,6 +16,7 @@ */ package org.mxchange.jphone.phonenumbers.mobileprovider; +import java.text.MessageFormat; import java.util.List; import javax.ejb.Singleton; import javax.ejb.Startup; @@ -39,11 +40,20 @@ public class PizzaMobileProviderSingletonBean extends BaseDatabaseBean implement @Override @SuppressWarnings ("unchecked") public List allMobileProvider () { + // Trace message + this.getLoggerBeanLocal().logTrace("allMobileProvider: CALLED!"); //NOI18N + // Init query Query query = this.getEntityManager().createNamedQuery("AllMobileProvider", List.class); //NOI18N + // Get list + List list = query.getResultList(); + + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("allMobileProvider: list.size()={0} - EXIT!", list.size())); //NOI18N + // Return it - return query.getResultList(); + return list; } } diff --git a/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaAdminContactPhoneSessionBean.java b/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaAdminContactPhoneSessionBean.java index 69c0e89..92b867d 100644 --- a/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaAdminContactPhoneSessionBean.java +++ b/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaAdminContactPhoneSessionBean.java @@ -42,6 +42,9 @@ public class PizzaAdminContactPhoneSessionBean extends BaseDatabaseBean implemen @Override @SuppressWarnings ("unchecked") public List allContacts (final DialableCellphoneNumber cellPhone) { + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("allContacts: cellPhone={0} - CALLED!", cellPhone)); //NOI18N + // The parameter should be valid if (null == cellPhone) { // Throw NPE @@ -70,6 +73,9 @@ public class PizzaAdminContactPhoneSessionBean extends BaseDatabaseBean implemen // No results found } + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("allContacts: contacts={0} - EXIT!", contacts)); //NOI18N + // Return list return contacts; } diff --git a/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaPhoneSessionBean.java b/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaPhoneSessionBean.java index b903705..e1794e5 100644 --- a/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaPhoneSessionBean.java +++ b/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaPhoneSessionBean.java @@ -46,6 +46,9 @@ public class PizzaPhoneSessionBean extends BaseDatabaseBean implements PhoneSess @Override public DialableCellphoneNumber findCellphoneById (final Long cellphoneId) throws PhoneEntityNotFoundException { + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("findCellphoneById: cellphoneId={0} - CALLED!", cellphoneId)); //NOI18N + // The id number should be valid if (null == cellphoneId) { // Throw NPE @@ -73,6 +76,9 @@ public class PizzaPhoneSessionBean extends BaseDatabaseBean implements PhoneSess throw new PhoneEntityNotFoundException(cellphoneId, ex); } + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("findCellphoneById: cellphone={0} - EXIT!", cellphone)); //NOI18N + // Return found instance return cellphone; } -- 2.39.5