From 7920e83ba35b53cd6dc6f9685ba88e7418cdef43 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 2 Sep 2017 21:52:41 +0200 Subject: [PATCH] Please rename/cherry-pick: - having to much session-scoped beans was a bad design idea anyway - on each new session, "tons" of EJB (JNDI lookup + business method invocation) will occur which will overrun the EJB container soon or later - also having JNDI lookup in PostConstruct-annotated methods was bad, too because it "confuses" the web container - while it is building proxy objects arround every managed class (like also now converters, JSF 2.3.x only) especially backing beans, there should be no JNDI lookup hapening - but initializing some lists for performance reasons is the right thing to do - maybe later some other annotation will be used instead, but for now it is fine - so let's make this painless and rename all session-scoped backing beans and re-annotate them with RequestScoped for now as this is also reduces memory foot-print MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- ...a => PizzaBusinessDataWebRequestBean.java} | 97 ++++++--- ...izzaBusinessDataWebRequestController.java} | 2 +- .../PizzaCompanyEmployeeWebRequestBean.java | 51 ++++- ...aCompanyEmployeeWebRequestController.java} | 2 +- .../checkout/PizzaCheckoutWebSessionBean.java | 8 +- .../PizzaAdminContactWebRequestBean.java | 18 +- ...n.java => PizzaContactWebRequestBean.java} | 100 +++++---- ... => PizzaContactWebRequestController.java} | 2 +- ...a => PizzaContactPhoneWebRequestBean.java} | 47 ++-- ...izzaContactPhoneWebRequestController.java} | 2 +- .../PizzaAdminCountryWebRequestBean.java | 8 +- ...n.java => PizzaCountryWebRequestBean.java} | 56 ++++- ... => PizzaCountryWebRequestController.java} | 2 +- .../customer/PizzaCustomerWebSessionBean.java | 2 +- .../helper/PizzaWebRequestHelperBean.java | 8 +- ...izzaAdminMobileProviderWebRequestBean.java | 2 +- .../PizzaMobileProviderWebRequestBean.java | 58 ++++- ...zzaMobileProviderWebRequestController.java | 2 +- .../phone/PizzaAdminPhoneWebRequestBean.java | 6 +- ...ean.java => PizzaPhoneWebRequestBean.java} | 131 +++++++++-- ...va => PizzaPhoneWebRequestController.java} | 4 +- .../PizzaUserProfileWebRequestBean.java | 4 +- ...n.java => PizzaReceiptWebRequestBean.java} | 4 +- ... => PizzaReceiptWebRequestController.java} | 2 +- .../user/PizzaAdminUserWebRequestBean.java | 11 +- ...Bean.java => PizzaUserWebRequestBean.java} | 205 +++++++++--------- ...ava => PizzaUserWebRequestController.java} | 2 +- ...a => PizzaUserActivityWebRequestBean.java} | 37 ++-- ...izzaUserActivityWebRequestController.java} | 2 +- .../PizzaConfirmationLinkWebRequestBean.java | 37 +--- ...va => PizzaEmailChangeWebRequestBean.java} | 59 +++-- ...PizzaEmailChangeWebRequestController.java} | 2 +- .../login/PizzaUserLoginWebSessionBean.java | 4 +- ...a => PizzaUserRegisterWebRequestBean.java} | 39 ++-- ...izzaUserRegisterWebRequestController.java} | 2 +- ...ava => PizzaResendLinkWebRequestBean.java} | 10 +- ... PizzaResendLinkWebRequestController.java} | 2 +- .../basicdata/PizzaCompanyNameValidator.java} | 4 +- web/guest/user/user_list.xhtml | 34 +-- 39 files changed, 662 insertions(+), 406 deletions(-) rename src/java/org/mxchange/pizzaapplication/beans/business/basicdata/{PizzaBusinessDataWebSessionBean.java => PizzaBusinessDataWebRequestBean.java} (73%) rename src/java/org/mxchange/pizzaapplication/beans/business/basicdata/{PizzaBusinessDataWebSessionController.java => PizzaBusinessDataWebRequestController.java} (93%) rename src/java/org/mxchange/pizzaapplication/beans/business/employee/{PizzaCompanyEmployeeWebSessionController.java => PizzaCompanyEmployeeWebRequestController.java} (93%) rename src/java/org/mxchange/pizzaapplication/beans/contact/{PizzaContactWebSessionBean.java => PizzaContactWebRequestBean.java} (93%) rename src/java/org/mxchange/pizzaapplication/beans/contact/{PizzaContactWebSessionController.java => PizzaContactWebRequestController.java} (97%) rename src/java/org/mxchange/pizzaapplication/beans/contact/phone/{PizzaContactPhoneWebSessionBean.java => PizzaContactPhoneWebRequestBean.java} (93%) rename src/java/org/mxchange/pizzaapplication/beans/contact/phone/{PizzaContactPhoneWebSessionController.java => PizzaContactPhoneWebRequestController.java} (93%) rename src/java/org/mxchange/pizzaapplication/beans/country/{PizzaCountryWebApplicationBean.java => PizzaCountryWebRequestBean.java} (66%) rename src/java/org/mxchange/pizzaapplication/beans/country/{PizzaCountryWebApplicationController.java => PizzaCountryWebRequestController.java} (93%) rename src/java/org/mxchange/pizzaapplication/beans/phone/{PizzaPhoneWebApplicationBean.java => PizzaPhoneWebRequestBean.java} (87%) rename src/java/org/mxchange/pizzaapplication/beans/phone/{PizzaPhoneWebApplicationController.java => PizzaPhoneWebRequestController.java} (93%) rename src/java/org/mxchange/pizzaapplication/beans/receipt/{PizzaReceiptWebSessionBean.java => PizzaReceiptWebRequestBean.java} (93%) rename src/java/org/mxchange/pizzaapplication/beans/receipt/{PizzaReceiptWebSessionController.java => PizzaReceiptWebRequestController.java} (94%) rename src/java/org/mxchange/pizzaapplication/beans/user/{PizzaUserWebSessionBean.java => PizzaUserWebRequestBean.java} (90%) rename src/java/org/mxchange/pizzaapplication/beans/user/{PizzaUserWebSessionController.java => PizzaUserWebRequestController.java} (98%) rename src/java/org/mxchange/pizzaapplication/beans/user/activity/{PizzaUserActivityWebApplicationBean.java => PizzaUserActivityWebRequestBean.java} (95%) rename src/java/org/mxchange/pizzaapplication/beans/user/activity/{PizzaUserActivityWebApplicationController.java => PizzaUserActivityWebRequestController.java} (91%) rename src/java/org/mxchange/pizzaapplication/beans/user/email_address/{PizzaEmailChangeWebSessionBean.java => PizzaEmailChangeWebRequestBean.java} (81%) rename src/java/org/mxchange/pizzaapplication/beans/user/email_address/{PizzaEmailChangeWebSessionController.java => PizzaEmailChangeWebRequestController.java} (94%) rename src/java/org/mxchange/pizzaapplication/beans/user/register/{PizzaUserRegisterWebSessionBean.java => PizzaUserRegisterWebRequestBean.java} (91%) rename src/java/org/mxchange/pizzaapplication/beans/user/register/{PizzaUserRegisterWebSessionController.java => PizzaUserRegisterWebRequestController.java} (93%) rename src/java/org/mxchange/pizzaapplication/beans/user/resendlink/{PizzaResendLinkWebSessionBean.java => PizzaResendLinkWebRequestBean.java} (95%) rename src/java/org/mxchange/pizzaapplication/beans/user/resendlink/{PizzaResendLinkWebSessionController.java => PizzaResendLinkWebRequestController.java} (93%) rename src/java/org/mxchange/{jfinancials/validator/business/basicdata/FinancialsCompanyNameValidator.java => pizzaapplication/validator/business/basicdata/PizzaCompanyNameValidator.java} (96%) diff --git a/src/java/org/mxchange/pizzaapplication/beans/business/basicdata/PizzaBusinessDataWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/business/basicdata/PizzaBusinessDataWebRequestBean.java similarity index 73% rename from src/java/org/mxchange/pizzaapplication/beans/business/basicdata/PizzaBusinessDataWebSessionBean.java rename to src/java/org/mxchange/pizzaapplication/beans/business/basicdata/PizzaBusinessDataWebRequestBean.java index 0df57860..2b40cfc3 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/business/basicdata/PizzaBusinessDataWebSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/business/basicdata/PizzaBusinessDataWebRequestBean.java @@ -17,18 +17,17 @@ package org.mxchange.pizzaapplication.beans.business.basicdata; import java.text.MessageFormat; +import java.util.Iterator; import java.util.LinkedList; import java.util.List; import javax.annotation.PostConstruct; import javax.ejb.EJB; -import javax.enterprise.context.SessionScoped; +import javax.enterprise.context.RequestScoped; import javax.enterprise.event.Observes; import javax.inject.Inject; import javax.inject.Named; -import org.mxchange.jcontactsbusiness.model.basicdata.AdminBasicCompanyDataSessionBeanRemote; -import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData; -import org.mxchange.jcontactsbusiness.model.basicdata.BasicCompanyDataSessionBeanRemote; import org.mxchange.jcontactsbusiness.events.basicdata.added.ObservableAdminAddedBusinessBasicDataEvent; +import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData; import org.mxchange.jcountry.model.data.Country; import org.mxchange.pizzaapplication.beans.BasePizzaController; import org.mxchange.pizzaapplication.beans.user.login.PizzaUserLoginWebSessionController; @@ -39,8 +38,8 @@ import org.mxchange.pizzaapplication.beans.user.login.PizzaUserLoginWebSessionCo * @author Roland Häder */ @Named ("companyDataController") -@SessionScoped -public class PizzaBusinessDataWebSessionBean extends BasePizzaController implements PizzaBusinessDataWebSessionController { +@RequestScoped +public class PizzaBusinessDataWebRequestBean extends BasePizzaController implements PizzaBusinessDataWebRequestController { /** * Serial number @@ -50,19 +49,21 @@ public class PizzaBusinessDataWebSessionBean extends BasePizzaController impleme /** * EJB for administrative basic business data purposes */ - @EJB (lookup = "java:global/addressbook-ejb/adminBasicCompanyData!org.mxchange.jcontactsbusiness.model.basicdata.AdminBasicCompanyDataSessionBeanRemote", description = "A stateless session bean for administrative purposes.") - private AdminBasicCompanyDataSessionBeanRemote adminBasicCompanyDataBean; + @EJB (lookup = "java:global/jfinancials-ejb/adminBusinessData!org.mxchange.jcontactsbusiness.basicdata.AdminBusinessDataSessionBeanRemote", description = "A stateless session bean for administrative purposes.") + private AdminBusinessDataSessionBeanRemote adminBusinessDataBean; /** * A list of all registered companies (globally) */ - private final List businessContacts; + @Inject + @Cached (cacheName = "basicDataCache") + private transient Cache basicDataCache; /** * EJB for general basic business data purposes */ - @EJB (lookup = "java:global/addressbook-ejb/basicCompanyData!org.mxchange.jcontactsbusiness.model.basicdata.BasicCompanyDataSessionBeanRemote", description = "A stateless session bean for general purposes.") - private BasicCompanyDataSessionBeanRemote businessDataBean; + @EJB (lookup = "java:global/jfinancials-ejb/businessData!org.mxchange.jcontactsbusiness.basicdata.BusinessDataSessionBeanRemote", description = "A stateless session bean for general purposes.") + private BusinessDataSessionBeanRemote businessDataBean; /** * Comments for this company @@ -75,7 +76,7 @@ public class PizzaBusinessDataWebSessionBean extends BasePizzaController impleme private String companyEmailAddress; /** - * Company name + * Company cacheName */ private String companyName; @@ -118,12 +119,9 @@ public class PizzaBusinessDataWebSessionBean extends BasePizzaController impleme /** * Constructor */ - public PizzaBusinessDataWebSessionBean () { + public PizzaBusinessDataWebRequestBean () { // Call super constructor super(); - - // Init list - this.businessContacts = new LinkedList<>(); } /** @@ -140,12 +138,12 @@ public class PizzaBusinessDataWebSessionBean extends BasePizzaController impleme } else if (event.getBasicData() == null) { // Throw NPE again throw new NullPointerException("event.basicData is null"); - } else if (event.getBasicData().getBasicDataId() == null) { + } else if (event.getBasicData().getCompanyDataId() == null) { // Throw NPE again - throw new NullPointerException("event.basicData.basicDataId is null"); - } else if (event.getBasicData().getBasicDataId() < 1) { + throw new NullPointerException("event.basicData.companyDataId is null"); + } else if (event.getBasicData().getCompanyDataId() < 1) { // Throw IAE - throw new IllegalArgumentException(MessageFormat.format("event.basicData.basicDataId={0} is invalid", event.getBasicData().getBasicDataId())); + throw new IllegalArgumentException(MessageFormat.format("event.basicData.companyDataId={0} is invalid", event.getBasicData().getCompanyDataId())); } else if (event.getBasicData().getCompanyName() == null) { // Throw NPE again throw new NullPointerException("event.basicData.companyName is null"); @@ -155,7 +153,7 @@ public class PizzaBusinessDataWebSessionBean extends BasePizzaController impleme } // Add it to list - this.businessContacts.add(event.getBasicData()); + this.basicDataCache.put(event.getBasicData().getCompanyDataId(), event.getBasicData()); } /** @@ -165,8 +163,23 @@ public class PizzaBusinessDataWebSessionBean extends BasePizzaController impleme */ @SuppressWarnings ("ReturnOfCollectionOrArrayField") public List allCompanyBasicData () { + // Init list + List list = new LinkedList<>(); + + // Get iterator + Iterator> iterator = this.basicDataCache.iterator(); + + // Loop over all + while (iterator.hasNext()) { + // Get next entry + final Cache.Entry next = iterator.next(); + + // Add value to list + list.add(next.getValue()); + } + // Return it - return this.businessContacts; + return list; } /** @@ -206,18 +219,18 @@ public class PizzaBusinessDataWebSessionBean extends BasePizzaController impleme } /** - * Getter for company name + * Getter for company cacheName *

- * @return Company name + * @return Company cacheName */ public String getCompanyName () { return this.companyName; } /** - * Setter for company name + * Setter for company cacheName *

- * @param companyName Company name + * @param companyName Company cacheName */ public void setCompanyName (final String companyName) { this.companyName = companyName; @@ -336,8 +349,36 @@ public class PizzaBusinessDataWebSessionBean extends BasePizzaController impleme */ @PostConstruct public void initializeList () { - // Init user's contact list - this.businessContacts.addAll(this.adminBasicCompanyDataBean.allCompanyBasicData()); + // Is cache there? + if (!this.basicDataCache.iterator().hasNext()) { + // Get whole list + List list = this.businessDataBean.allCompanyBasicData(); + + // Add all + for (final Iterator iterator = list.iterator(); iterator.hasNext();) { + // Get next element + final BusinessBasicData next = iterator.next(); + + // Add it to cache + this.basicDataCache.put(next.getCompanyDataId(), next); + } + } + } + + /** + * Clears this bean + */ + private void clear () { + // Clear all data: + this.setCompanyComments(null); + this.setCompanyEmailAddress(null); + this.setCompanyName(null); + this.setFaxAreaCode(null); + this.setFaxCountry(null); + this.setFaxNumber(null); + this.setLandLineAreaCode(null); + this.setLandLineCountry(null); + this.setLandLineNumber(null); } } diff --git a/src/java/org/mxchange/pizzaapplication/beans/business/basicdata/PizzaBusinessDataWebSessionController.java b/src/java/org/mxchange/pizzaapplication/beans/business/basicdata/PizzaBusinessDataWebRequestController.java similarity index 93% rename from src/java/org/mxchange/pizzaapplication/beans/business/basicdata/PizzaBusinessDataWebSessionController.java rename to src/java/org/mxchange/pizzaapplication/beans/business/basicdata/PizzaBusinessDataWebRequestController.java index 0f9b5b6a..f6e4d4b3 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/business/basicdata/PizzaBusinessDataWebSessionController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/business/basicdata/PizzaBusinessDataWebRequestController.java @@ -23,6 +23,6 @@ import java.io.Serializable; *

* @author Roland Häder */ -public interface PizzaBusinessDataWebSessionController extends Serializable { +public interface PizzaBusinessDataWebRequestController extends Serializable { } diff --git a/src/java/org/mxchange/pizzaapplication/beans/business/employee/PizzaCompanyEmployeeWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/business/employee/PizzaCompanyEmployeeWebRequestBean.java index 43f1ebaa..5ab3a04f 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/business/employee/PizzaCompanyEmployeeWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/business/employee/PizzaCompanyEmployeeWebRequestBean.java @@ -16,11 +16,14 @@ */ package org.mxchange.pizzaapplication.beans.business.employee; +import java.util.Iterator; import java.util.LinkedList; import java.util.List; import javax.annotation.PostConstruct; +import javax.cache.Cache; import javax.ejb.EJB; -import javax.enterprise.context.SessionScoped; +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; import javax.inject.Named; import org.mxchange.jcontactsbusiness.model.employee.CompanyEmployeeSessionBeanRemote; import org.mxchange.jcontactsbusiness.model.employee.Employee; @@ -32,8 +35,8 @@ import org.mxchange.pizzaapplication.beans.BasePizzaController; * @author Roland Häder */ @Named ("companyEmployeeController") -@SessionScoped -public class PizzaCompanyEmployeeWebRequestBean extends BasePizzaController implements PizzaCompanyEmployeeWebSessionController { +@RequestScoped +public class PizzaCompanyEmployeeWebRequestBean extends BasePizzaController implements PizzaCompanyEmployeeWebRequestController { /** * Serial number @@ -49,7 +52,9 @@ public class PizzaCompanyEmployeeWebRequestBean extends BasePizzaController impl /** * List of all company employees */ - private final List companyEmployees; + @Inject + @Cached(cacheName = "companyEmployeeCache") + private transient Cache companyEmployeeCache; /** * Default constructor @@ -57,9 +62,6 @@ public class PizzaCompanyEmployeeWebRequestBean extends BasePizzaController impl public PizzaCompanyEmployeeWebRequestBean () { // Call super constructor super(); - - // Init list instance - this.companyEmployees = new LinkedList<>(); } /** @@ -69,7 +71,23 @@ public class PizzaCompanyEmployeeWebRequestBean extends BasePizzaController impl */ @SuppressWarnings ("ReturnOfCollectionOrArrayField") public List allCompanyEmployees () { - return this.companyEmployees; + // Init list + List list = new LinkedList<>(); + + // Get iterator + Iterator> iterator = this.companyEmployeeCache.iterator(); + + // Loop over all + while (iterator.hasNext()) { + // Get next entry + final Cache.Entry next = iterator.next(); + + // Add value to list + list.add(next.getValue()); + } + + // Return it + return list; } /** @@ -77,11 +95,20 @@ public class PizzaCompanyEmployeeWebRequestBean extends BasePizzaController impl */ @PostConstruct public void init () { - // Get all entries from remote bean - List employees = this.companyEmployeeBean.allCompanyEmployees(); + // Is cache there? + if (!this.companyEmployeeCache.iterator().hasNext()) { + // Get whole list + List list = this.companyEmployeeBean.allCompanyEmployees(); + + // Add all + for (final Iterator iterator = list.iterator(); iterator.hasNext();) { + // Get next element + final Employee next = iterator.next(); - // Copy it to main list - this.companyEmployees.addAll(employees); + // Add it to cache + this.companyEmployeeCache.put(next.getEmployeeId(), next); + } + } } } diff --git a/src/java/org/mxchange/pizzaapplication/beans/business/employee/PizzaCompanyEmployeeWebSessionController.java b/src/java/org/mxchange/pizzaapplication/beans/business/employee/PizzaCompanyEmployeeWebRequestController.java similarity index 93% rename from src/java/org/mxchange/pizzaapplication/beans/business/employee/PizzaCompanyEmployeeWebSessionController.java rename to src/java/org/mxchange/pizzaapplication/beans/business/employee/PizzaCompanyEmployeeWebRequestController.java index cf39402e..19faf5bd 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/business/employee/PizzaCompanyEmployeeWebSessionController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/business/employee/PizzaCompanyEmployeeWebRequestController.java @@ -23,6 +23,6 @@ import java.io.Serializable; *

* @author Roland Häder */ -public interface PizzaCompanyEmployeeWebSessionController extends Serializable { +public interface PizzaCompanyEmployeeWebRequestController extends Serializable { } diff --git a/src/java/org/mxchange/pizzaapplication/beans/checkout/PizzaCheckoutWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/checkout/PizzaCheckoutWebSessionBean.java index 7a38bce3..45a22202 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/checkout/PizzaCheckoutWebSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/checkout/PizzaCheckoutWebSessionBean.java @@ -42,10 +42,10 @@ import org.mxchange.jshopcore.wrapper.CheckoutWrapper; import org.mxchange.jshopcore.wrapper.WrapableCheckout; import org.mxchange.pizzaapplication.beans.BasePizzaController; import org.mxchange.pizzaapplication.beans.basket.PizzaBasketWebSessionController; -import org.mxchange.pizzaapplication.beans.contact.PizzaContactWebSessionController; import org.mxchange.pizzaapplication.beans.customer.PizzaCustomerWebSessionController; import org.mxchange.pizzaapplication.beans.helper.PizzaWebRequestHelperController; -import org.mxchange.pizzaapplication.beans.receipt.PizzaReceiptWebSessionController; +import org.mxchange.pizzaapplication.beans.contact.PizzaContactWebRequestController; +import org.mxchange.pizzaapplication.beans.receipt.PizzaReceiptWebRequestController; /** * Checkout controller @@ -89,7 +89,7 @@ public class PizzaCheckoutWebSessionBean extends BasePizzaController implements * Contact controller */ @Inject - private PizzaContactWebSessionController contactController; + private PizzaContactWebRequestController contactController; /** * Customer bean @@ -116,7 +116,7 @@ public class PizzaCheckoutWebSessionBean extends BasePizzaController implements * Receipt bean */ @Inject - private PizzaReceiptWebSessionController receiptController; + private PizzaReceiptWebRequestController receiptController; /** * Session instance diff --git a/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaAdminContactWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaAdminContactWebRequestBean.java index c451b0e0..59993f97 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaAdminContactWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaAdminContactWebRequestBean.java @@ -27,27 +27,27 @@ import javax.enterprise.inject.Any; import javax.faces.view.facelets.FaceletException; import javax.inject.Inject; import javax.inject.Named; -import org.mxchange.jcontacts.model.contact.AdminContactSessionBeanRemote; -import org.mxchange.jcontacts.model.contact.Contact; -import org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote; -import org.mxchange.jcontacts.model.contact.ContactUtils; -import org.mxchange.jcontacts.model.contact.UserContact; -import org.mxchange.jcontacts.model.contact.title.PersonalTitle; import org.mxchange.jcontacts.events.contact.add.AdminAddedContactEvent; import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent; import org.mxchange.jcontacts.events.contact.created.ObservableCreatedContactEvent; import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent; import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent; import org.mxchange.jcontacts.exceptions.ContactAlreadyAddedException; +import org.mxchange.jcontacts.model.contact.AdminContactSessionBeanRemote; +import org.mxchange.jcontacts.model.contact.Contact; +import org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote; +import org.mxchange.jcontacts.model.contact.ContactUtils; +import org.mxchange.jcontacts.model.contact.UserContact; +import org.mxchange.jcontacts.model.contact.title.PersonalTitle; import org.mxchange.jcountry.model.data.Country; import org.mxchange.jphone.model.phonenumbers.DialableNumber; import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; import org.mxchange.jphone.model.phonenumbers.fax.FaxNumber; import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber; import org.mxchange.jphone.model.phonenumbers.landline.LandLineNumber; -import org.mxchange.jphone.model.phonenumbers.model.mobile.DialableMobileNumber; +import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber; import org.mxchange.jphone.model.phonenumbers.mobile.MobileNumber; -import org.mxchange.jphone.model.phonenumbers.model.mobileprovider.MobileProvider; +import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider; import org.mxchange.pizzaapplication.beans.BasePizzaController; /** @@ -107,7 +107,7 @@ public class PizzaAdminContactWebRequestBean extends BasePizzaController impleme * General contact controller */ @Inject - private PizzaContactWebSessionController contactController; + private PizzaContactWebRequestController contactController; /** * Country instance diff --git a/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebRequestBean.java similarity index 93% rename from src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebSessionBean.java rename to src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebRequestBean.java index d01cc6d6..a6b79abd 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebRequestBean.java @@ -30,21 +30,22 @@ import javax.enterprise.event.Observes; import javax.faces.view.facelets.FaceletException; import javax.inject.Inject; import javax.inject.Named; +import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent; +import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent; import org.mxchange.jcontacts.model.contact.Contact; import org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote; import org.mxchange.jcontacts.model.contact.ContactUtils; import org.mxchange.jcontacts.model.contact.UserContact; import org.mxchange.jcontacts.model.contact.title.PersonalTitle; -import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent; -import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent; import org.mxchange.jcountry.model.data.Country; +import org.mxchange.jfinancials.beans.user.PizzaUserWebRequestController; import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; import org.mxchange.jphone.model.phonenumbers.fax.FaxNumber; import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber; import org.mxchange.jphone.model.phonenumbers.landline.LandLineNumber; -import org.mxchange.jphone.model.phonenumbers.model.mobile.DialableMobileNumber; +import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber; import org.mxchange.jphone.model.phonenumbers.mobile.MobileNumber; -import org.mxchange.jphone.model.phonenumbers.model.mobileprovider.MobileProvider; +import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider; import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent; import org.mxchange.jusercore.events.user.linked.ObservableAdminLinkedUserEvent; import org.mxchange.jusercore.model.user.User; @@ -53,7 +54,6 @@ import org.mxchange.juserlogincore.events.login.ObservableUserLoggedInEvent; import org.mxchange.juserlogincore.events.registration.ObservableUserRegisteredEvent; import org.mxchange.juserlogincore.exceptions.UserPasswordMismatchException; import org.mxchange.pizzaapplication.beans.BasePizzaController; -import org.mxchange.pizzaapplication.beans.user.PizzaUserWebSessionController; import org.mxchange.pizzaapplication.beans.user.login.PizzaUserLoginWebSessionController; /** @@ -63,7 +63,7 @@ import org.mxchange.pizzaapplication.beans.user.login.PizzaUserLoginWebSessionCo */ @Named ("contactController") @SessionScoped -public class PizzaContactWebSessionBean extends BasePizzaController implements PizzaContactWebSessionController { +public class PizzaContactWebRequestBean extends BasePizzaController implements PizzaContactWebRequestController { /** * Serial number @@ -93,13 +93,15 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P /** * EJB for general contact purposes */ - @EJB (lookup = "java:global/pizzaservice-ejb/contact!org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote") + @EJB (lookup = "java:global/jfinancials-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote") private ContactSessionBeanRemote contactBean; /** * Contact list */ - private final List contactList; + @Inject + @Cached (cacheName = "contactsCache") + private transient Cache contactsCache; /** * Country instance @@ -114,7 +116,9 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P /** * Email address list */ - private final List emailAddressList; + @Inject + @Cached (cacheName = "emailAddressCache") + private transient Cache emailAddressCache; /** * Email address repeated @@ -215,7 +219,7 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P * Regular user controller */ @Inject - private PizzaUserWebSessionController userController; + private PizzaUserWebRequestController userController; /** * Login bean (controller) @@ -231,13 +235,9 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P /** * Default constructor */ - public PizzaContactWebSessionBean () { + public PizzaContactWebRequestBean () { // Call super constructor super(); - - // Init lists/maps - this.contactList = new LinkedList<>(); - this.emailAddressList = new LinkedList<>(); } /** @@ -354,7 +354,7 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P this.uniqueAddContact(event.getUpdatedContact()); // Add email address to list - this.emailAddressList.add(event.getUpdatedContact().getContactEmailAddress()); + this.emailAddressCache.put(event.getUpdatedContact().getContactId(), event.getUpdatedContact().getContactEmailAddress()); } /** @@ -447,8 +447,23 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P @Override @SuppressWarnings ("ReturnOfCollectionOrArrayField") public List allContacts () { - // Return un-modified list - return this.contactList; + // Init list + List list = new LinkedList<>(); + + // Get iterator + Iterator> iterator = this.contactsCache.iterator(); + + // Loop over all + while (iterator.hasNext()) { + // Get next entry + final Cache.Entry next = iterator.next(); + + // Add value to list + list.add(next.getValue()); + } + + // Return it + return list; } @Override @@ -1008,20 +1023,31 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P */ @PostConstruct public void init () { - // Get full email address list for reducing EJB calls - this.emailAddressList.addAll(this.contactBean.getEmailAddressList()); - // Get all contacts - List allContacts = this.contactBean.getAllContacts(); - - // Get full contact list - this.contactList.addAll(allContacts); + final List selectable = new LinkedList<>(); + + // Is cache there? + if (!this.contactsCache.iterator().hasNext()) { + // Get whole list + List list = this.contactBean.allContacts(); + + // Add all + for (final Iterator iterator = list.iterator(); iterator.hasNext();) { + // Get next element + final Contact next = iterator.next(); + + // Add it to cache + this.contactsCache.put(next.getContactId(), next); + this.emailAddressCache.put(next.getContactId(), next.getContactEmailAddress()); + selectable.add(next); + } + } // Get all users List allUsers = this.userController.allUsers(); // Get iterator - Iterator iterator = allContacts.iterator(); + Iterator iterator = selectable.iterator(); // Loop through it while (iterator.hasNext()) { @@ -1046,7 +1072,7 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P } // Set contact list - this.selectableContacts = allContacts; + this.selectableContacts = selectable; } @Override @@ -1064,7 +1090,7 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P } // Determine it - return ((this.emailAddressList instanceof List) && (this.emailAddressList.contains(contact.getContactEmailAddress()))); + return ((this.emailAddressCache instanceof List) && (this.emailAddressCache.containsKey(contact.getContactId()))); } @Override @@ -1131,13 +1157,13 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P */ private void addUserNameEmailAddress (final Contact contact) { // Make sure the entry is not added yet - if (this.emailAddressList.contains(contact.getContactEmailAddress())) { + if (this.emailAddressCache.containsKey(contact.getContactId())) { // Already added throw new IllegalArgumentException(MessageFormat.format("Email address {0} already added.", contact.getContactEmailAddress())); //NOI18N } // Add email addres - this.emailAddressList.add(contact.getContactEmailAddress()); + this.emailAddressCache.put(contact.getContactId(), contact.getContactEmailAddress()); } /** @@ -1250,13 +1276,13 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P } // Remove from general list - if (!this.contactList.remove(contact)) { + if (!this.contactsCache.remove(contact.getContactId())) { // Did not remove contact throw new IllegalStateException(MessageFormat.format("contact {0} was not removed.", contact.getContactId())); //NOI18N } // Remove from other lists - this.emailAddressList.remove(contact.getContactEmailAddress()); + this.emailAddressCache.remove(contact.getContactId()); } /** @@ -1279,23 +1305,23 @@ public class PizzaContactWebSessionBean extends BasePizzaController implements P } // Get iterator from list - Iterator iterator = this.contactList.iterator(); + Iterator> iterator = this.contactsCache.iterator(); // "Walk" through all entries while (iterator.hasNext()) { // Get next element - Contact next = iterator.next(); + Cache.Entry next = iterator.next(); // Is id number the same? - if (Objects.equals(contact.getContactId(), next.getContactId())) { + if (Objects.equals(contact.getContactId(), next.getKey())) { // Found entry, so remove it and abort - this.removeContact(next); + this.removeContact(next.getValue()); break; } } // Add contact to list - this.contactList.add(contact); + this.contactsCache.put(contact.getContactId(), contact); } } diff --git a/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebSessionController.java b/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebRequestController.java similarity index 97% rename from src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebSessionController.java rename to src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebRequestController.java index 47271d4b..96e6ffad 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebSessionController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebRequestController.java @@ -25,7 +25,7 @@ import org.mxchange.jcontacts.model.contact.Contact; *

* @author Roland Häder */ -public interface PizzaContactWebSessionController extends Serializable { +public interface PizzaContactWebRequestController extends Serializable { /** * Minimum password length diff --git a/src/java/org/mxchange/pizzaapplication/beans/contact/phone/PizzaContactPhoneWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/contact/phone/PizzaContactPhoneWebRequestBean.java similarity index 93% rename from src/java/org/mxchange/pizzaapplication/beans/contact/phone/PizzaContactPhoneWebSessionBean.java rename to src/java/org/mxchange/pizzaapplication/beans/contact/phone/PizzaContactPhoneWebRequestBean.java index dfc4a19c..3de41314 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/contact/phone/PizzaContactPhoneWebSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/contact/phone/PizzaContactPhoneWebRequestBean.java @@ -17,31 +17,29 @@ package org.mxchange.pizzaapplication.beans.contact.phone; import java.text.MessageFormat; -import java.util.HashMap; import java.util.LinkedList; import java.util.List; -import java.util.Map; import java.util.Objects; import javax.enterprise.context.SessionScoped; import javax.enterprise.event.Observes; import javax.inject.Inject; import javax.inject.Named; -import org.mxchange.jcontacts.model.contact.Contact; import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent; import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent; import org.mxchange.jcontacts.events.fax.unlinked.ObservableAdminUnlinkedFaxNumberEvent; import org.mxchange.jcontacts.events.landline.unlinked.ObservableAdminUnlinkedLandLineNumberEvent; import org.mxchange.jcontacts.events.mobile.unlinked.ObservableAdminUnlinkedMobileNumberEvent; +import org.mxchange.jcontacts.model.contact.Contact; import org.mxchange.jphone.events.fax.created.ObservableCreatedFaxNumberEvent; import org.mxchange.jphone.events.landline.created.ObservableCreatedLandLineNumberEvent; import org.mxchange.jphone.events.mobile.created.ObservableCreatedMobileNumberEvent; import org.mxchange.jphone.model.phonenumbers.DialableNumber; import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber; -import org.mxchange.jphone.model.phonenumbers.model.mobile.DialableMobileNumber; +import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber; import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent; import org.mxchange.pizzaapplication.beans.BasePizzaController; -import org.mxchange.pizzaapplication.beans.contact.PizzaContactWebSessionController; +import org.mxchange.pizzaapplication.beans.contact.PizzaContactWebRequestController; /** * A general contact bean (controller) @@ -50,7 +48,7 @@ import org.mxchange.pizzaapplication.beans.contact.PizzaContactWebSessionControl */ @Named ("contactPhoneController") @SessionScoped -public class PizzaContactPhoneWebSessionBean extends BasePizzaController implements PizzaContactPhoneWebSessionController { +public class PizzaContactPhoneWebRequestBean extends BasePizzaController implements PizzaContactPhoneWebRequestController { /** * Serial number @@ -61,14 +59,16 @@ public class PizzaContactPhoneWebSessionBean extends BasePizzaController impleme * General contact controller */ @Inject - private PizzaContactWebSessionController contactController; + private PizzaContactWebRequestController contactController; /** * "Cache" for contact's mobile, land-line and fax numbers. Currently one * per each type is supported. Maybe later this will change into a OneToMany * relationship (one contact, many numbers). */ - private final Map> contacts; + @Inject + @Cached(cacheName = "contactsPhoneCache") + private transient Cache> contactsPhoneCache; /** * fax number @@ -88,12 +88,9 @@ public class PizzaContactPhoneWebSessionBean extends BasePizzaController impleme /** * Default constructor */ - public PizzaContactPhoneWebSessionBean () { + public PizzaContactPhoneWebRequestBean () { // Call super constructor super(); - - // Init lists/maps - this.contacts = new HashMap<>(10); } /** @@ -169,7 +166,7 @@ public class PizzaContactPhoneWebSessionBean extends BasePizzaController impleme } // Remove it from list - this.contacts.remove(event.getUnlinkedFaxNumber()); + this.contactsPhoneCache.remove(event.getUnlinkedFaxNumber()); // Clear all data this.clear(); @@ -197,7 +194,7 @@ public class PizzaContactPhoneWebSessionBean extends BasePizzaController impleme } // Remove it from list - this.contacts.remove(event.getUnlinkedLandLineNumber()); + this.contactsPhoneCache.remove(event.getUnlinkedLandLineNumber()); // Clear all data this.clear(); @@ -225,7 +222,7 @@ public class PizzaContactPhoneWebSessionBean extends BasePizzaController impleme } // Remove it from list - this.contacts.remove(event.getUnlinkedMobileNumber()); + this.contactsPhoneCache.remove(event.getUnlinkedMobileNumber()); // Clear all data this.clear(); @@ -344,9 +341,9 @@ public class PizzaContactPhoneWebSessionBean extends BasePizzaController impleme DialableFaxNumber number = this.getFaxNumber(); // Is cache there? - if (this.contacts.containsKey(number)) { + if (this.contactsPhoneCache.containsKey(number)) { // Return cached version - return this.contacts.get(number); + return this.contactsPhoneCache.get(number); } else { // Ask bean List list = new LinkedList<>(); @@ -361,7 +358,7 @@ public class PizzaContactPhoneWebSessionBean extends BasePizzaController impleme } // Store result in cache - this.contacts.put(number, list); + this.contactsPhoneCache.put(number, list); // Return now-cached list return list; @@ -378,9 +375,9 @@ public class PizzaContactPhoneWebSessionBean extends BasePizzaController impleme DialableLandLineNumber number = this.getLandLineNumber(); // Is cache there? - if (this.contacts.containsKey(number)) { + if (this.contactsPhoneCache.containsKey(number)) { // Return cached version - return this.contacts.get(number); + return this.contactsPhoneCache.get(number); } else { // Ask bean List list = new LinkedList<>(); @@ -395,7 +392,7 @@ public class PizzaContactPhoneWebSessionBean extends BasePizzaController impleme } // Store result in cache - this.contacts.put(number, list); + this.contactsPhoneCache.put(number, list); // Return now-cached list return list; @@ -412,9 +409,9 @@ public class PizzaContactPhoneWebSessionBean extends BasePizzaController impleme DialableMobileNumber number = this.getMobileNumber(); // Is cache there? - if (this.contacts.containsKey(number)) { + if (this.contactsPhoneCache.containsKey(number)) { // Return cached version - return this.contacts.get(number); + return this.contactsPhoneCache.get(number); } else { // Ask bean List list = new LinkedList<>(); @@ -429,7 +426,7 @@ public class PizzaContactPhoneWebSessionBean extends BasePizzaController impleme } // Store result in cache - this.contacts.put(number, list); + this.contactsPhoneCache.put(number, list); // Return now-cached list return list; @@ -494,7 +491,7 @@ public class PizzaContactPhoneWebSessionBean extends BasePizzaController impleme * Clears this bean */ private void clear () { - // @TODO Clear all data + // Clear all data } } diff --git a/src/java/org/mxchange/pizzaapplication/beans/contact/phone/PizzaContactPhoneWebSessionController.java b/src/java/org/mxchange/pizzaapplication/beans/contact/phone/PizzaContactPhoneWebRequestController.java similarity index 93% rename from src/java/org/mxchange/pizzaapplication/beans/contact/phone/PizzaContactPhoneWebSessionController.java rename to src/java/org/mxchange/pizzaapplication/beans/contact/phone/PizzaContactPhoneWebRequestController.java index b9ae0042..da2919a9 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/contact/phone/PizzaContactPhoneWebSessionController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/contact/phone/PizzaContactPhoneWebRequestController.java @@ -23,6 +23,6 @@ import java.io.Serializable; *

* @author Roland Häder */ -public interface PizzaContactPhoneWebSessionController extends Serializable { +public interface PizzaContactPhoneWebRequestController extends Serializable { } diff --git a/src/java/org/mxchange/pizzaapplication/beans/country/PizzaAdminCountryWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/country/PizzaAdminCountryWebRequestBean.java index 80d76183..c9d5917c 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/country/PizzaAdminCountryWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/country/PizzaAdminCountryWebRequestBean.java @@ -26,12 +26,12 @@ import javax.enterprise.inject.Any; import javax.faces.view.facelets.FaceletException; import javax.inject.Inject; import javax.inject.Named; -import org.mxchange.jcountry.model.data.Country; -import org.mxchange.jcountry.model.data.CountryData; -import org.mxchange.jcountry.model.data.CountrySingletonBeanRemote; import org.mxchange.jcountry.events.AdminAddedCountryEvent; import org.mxchange.jcountry.events.ObservableAdminAddedCountryEvent; import org.mxchange.jcountry.exceptions.CountryAlreadyAddedException; +import org.mxchange.jcountry.model.data.Country; +import org.mxchange.jcountry.model.data.CountryData; +import org.mxchange.jcountry.model.data.CountrySingletonBeanRemote; import org.mxchange.pizzaapplication.beans.BasePizzaController; /** @@ -75,7 +75,7 @@ public class PizzaAdminCountryWebRequestBean extends BasePizzaController impleme * Regular country controller */ @Inject - private PizzaCountryWebApplicationController countryController; + private PizzaCountryWebRequestController countryController; /** * Local dial prefix diff --git a/src/java/org/mxchange/pizzaapplication/beans/country/PizzaCountryWebApplicationBean.java b/src/java/org/mxchange/pizzaapplication/beans/country/PizzaCountryWebRequestBean.java similarity index 66% rename from src/java/org/mxchange/pizzaapplication/beans/country/PizzaCountryWebApplicationBean.java rename to src/java/org/mxchange/pizzaapplication/beans/country/PizzaCountryWebRequestBean.java index bb077688..fb4e088e 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/country/PizzaCountryWebApplicationBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/country/PizzaCountryWebRequestBean.java @@ -17,15 +17,18 @@ package org.mxchange.pizzaapplication.beans.country; import java.text.MessageFormat; +import java.util.Iterator; +import java.util.LinkedList; import java.util.List; import javax.annotation.PostConstruct; import javax.ejb.EJB; -import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.context.RequestScoped; import javax.enterprise.event.Observes; +import javax.inject.Inject; import javax.inject.Named; +import org.mxchange.jcountry.events.ObservableAdminAddedCountryEvent; import org.mxchange.jcountry.model.data.Country; import org.mxchange.jcountry.model.data.CountrySingletonBeanRemote; -import org.mxchange.jcountry.events.ObservableAdminAddedCountryEvent; import org.mxchange.pizzaapplication.beans.BasePizzaController; /** @@ -34,8 +37,8 @@ import org.mxchange.pizzaapplication.beans.BasePizzaController; * @author Roland Häder */ @Named ("countryController") -@ApplicationScoped -public class PizzaCountryWebApplicationBean extends BasePizzaController implements PizzaCountryWebApplicationController { +@RequestScoped +public class PizzaCountryWebRequestBean extends BasePizzaController implements PizzaCountryWebRequestController { /** * Serial number @@ -45,18 +48,20 @@ public class PizzaCountryWebApplicationBean extends BasePizzaController implemen /** * Remote country EJB */ - @EJB (lookup = "java:global/pizzaservice-ejb/country!org.mxchange.jcountry.model.data.CountrySingletonBeanRemote") + @EJB (lookup = "java:global/jfinancials-ejb/country!org.mxchange.jcountry.data.CountrySingletonBeanRemote") private CountrySingletonBeanRemote countryBean; /** * List of all countries */ - private List countryList; + @Inject + @Cached (cacheName = "countryCache") + private transient Cache countryCache; /** * Default constructor */ - public PizzaCountryWebApplicationBean () { + public PizzaCountryWebRequestBean () { // Call super constructor super(); } @@ -84,14 +89,29 @@ public class PizzaCountryWebApplicationBean extends BasePizzaController implemen } // Add the event - this.countryList.add(event.getAddedCountry()); + this.countryCache.put(event.getAddedCountry().getCountryId(), event.getAddedCountry()); } @Override @SuppressWarnings ("ReturnOfCollectionOrArrayField") public List allCountries () { - // Return "cached" version - return this.countryList; + // Init list + List list = new LinkedList<>(); + + // Get iterator + Iterator> iterator = this.countryCache.iterator(); + + // Loop over all + while (iterator.hasNext()) { + // Get next entry + final Cache.Entry next = iterator.next(); + + // Add value to list + list.add(next.getValue()); + } + + // Return it + return list; } /** @@ -99,8 +119,20 @@ public class PizzaCountryWebApplicationBean extends BasePizzaController implemen */ @PostConstruct public void init () { - // "Cache" country list as this will not change so often. - this.countryList = this.countryBean.allCountries(); + // Is cache there? + if (!this.countryCache.iterator().hasNext()) { + // Get whole list + List list = this.countryBean.allCountries(); + + // Add all + for (final Iterator iterator = list.iterator(); iterator.hasNext();) { + // Get next element + final Country next = iterator.next(); + + // Add it to cache + this.countryCache.put(next.getCountryId(), next); + } + } } } diff --git a/src/java/org/mxchange/pizzaapplication/beans/country/PizzaCountryWebApplicationController.java b/src/java/org/mxchange/pizzaapplication/beans/country/PizzaCountryWebRequestController.java similarity index 93% rename from src/java/org/mxchange/pizzaapplication/beans/country/PizzaCountryWebApplicationController.java rename to src/java/org/mxchange/pizzaapplication/beans/country/PizzaCountryWebRequestController.java index 57f60d0d..df626071 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/country/PizzaCountryWebApplicationController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/country/PizzaCountryWebRequestController.java @@ -25,7 +25,7 @@ import org.mxchange.jcountry.model.data.Country; *

* @author Roland Häder */ -public interface PizzaCountryWebApplicationController extends Serializable { +public interface PizzaCountryWebRequestController extends Serializable { /** * A list of all countries diff --git a/src/java/org/mxchange/pizzaapplication/beans/customer/PizzaCustomerWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/customer/PizzaCustomerWebSessionBean.java index 1d9cf931..190c9082 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/customer/PizzaCustomerWebSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/customer/PizzaCustomerWebSessionBean.java @@ -30,9 +30,9 @@ import javax.inject.Named; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; +import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent; import org.mxchange.jcontacts.model.contact.Contact; import org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote; -import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent; import org.mxchange.jcustomercore.events.customer.added.ObservableAdminAddedCustomerEvent; import org.mxchange.jcustomercore.model.customer.Customer; import org.mxchange.pizzaapplication.beans.BasePizzaController; diff --git a/src/java/org/mxchange/pizzaapplication/beans/helper/PizzaWebRequestHelperBean.java b/src/java/org/mxchange/pizzaapplication/beans/helper/PizzaWebRequestHelperBean.java index 138a093a..67ba8f44 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/helper/PizzaWebRequestHelperBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/helper/PizzaWebRequestHelperBean.java @@ -22,9 +22,9 @@ import javax.enterprise.event.Event; import javax.enterprise.inject.Any; import javax.inject.Inject; import javax.inject.Named; -import org.mxchange.jcontacts.model.contact.Contact; import org.mxchange.jcontacts.events.contact.created.CreatedContactEvent; import org.mxchange.jcontacts.events.contact.created.ObservableCreatedContactEvent; +import org.mxchange.jcontacts.model.contact.Contact; import org.mxchange.jcustomercore.events.customer.created.CreatedCustomerEvent; import org.mxchange.jcustomercore.events.customer.created.ObservableCreatedCustomerEvent; import org.mxchange.jcustomercore.model.customer.Customer; @@ -36,7 +36,7 @@ import org.mxchange.jphone.events.mobile.created.CreatedMobileNumberEvent; import org.mxchange.jphone.events.mobile.created.ObservableCreatedMobileNumberEvent; import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber; -import org.mxchange.jphone.model.phonenumbers.model.mobile.DialableMobileNumber; +import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber; import org.mxchange.jusercore.events.user.created.CreatedUserEvent; import org.mxchange.jusercore.events.user.created.ObservableCreatedUserEvent; import org.mxchange.jusercore.model.user.User; @@ -44,7 +44,7 @@ import org.mxchange.pizzaapplication.beans.contact.PizzaAdminContactWebRequestCo import org.mxchange.pizzaapplication.beans.customer.PizzaAdminCustomerWebRequestController; import org.mxchange.pizzaapplication.beans.customer.PizzaCustomerWebSessionController; import org.mxchange.pizzaapplication.beans.phone.PizzaAdminPhoneWebRequestController; -import org.mxchange.pizzaapplication.beans.user.PizzaUserWebSessionController; +import org.mxchange.pizzaapplication.beans.user.PizzaUserWebRequestController; /** * A general helper for beans @@ -158,7 +158,7 @@ public class PizzaWebRequestHelperBean implements PizzaWebRequestHelperControlle * Regular user controller */ @Inject - private PizzaUserWebSessionController userController; + private PizzaUserWebRequestController userController; /** * Event for when a user instance was created diff --git a/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaAdminMobileProviderWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaAdminMobileProviderWebRequestBean.java index 5c71a1f8..779708e1 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaAdminMobileProviderWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaAdminMobileProviderWebRequestBean.java @@ -32,7 +32,7 @@ import org.mxchange.jphone.events.mobileprovider.added.AdminMobileProviderAddedE import org.mxchange.jphone.exceptions.MobileProviderAlreadyAddedException; import org.mxchange.jphone.model.phonenumbers.mobileprovider.AdminMobileProviderSessionBeanRemote; import org.mxchange.jphone.model.phonenumbers.mobileprovider.CellphoneProvider; -import org.mxchange.jphone.model.phonenumbers.model.mobileprovider.MobileProvider; +import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider; import org.mxchange.pizzaapplication.beans.BasePizzaController; /** diff --git a/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaMobileProviderWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaMobileProviderWebRequestBean.java index b42f1bc1..d623fd7d 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaMobileProviderWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaMobileProviderWebRequestBean.java @@ -17,14 +17,18 @@ package org.mxchange.pizzaapplication.beans.mobileprovider; import java.text.MessageFormat; +import java.util.Iterator; +import java.util.LinkedList; import java.util.List; import javax.annotation.PostConstruct; +import javax.cache.Cache; import javax.ejb.EJB; -import javax.enterprise.context.SessionScoped; +import javax.enterprise.context.RequestScoped; import javax.enterprise.event.Observes; +import javax.inject.Inject; import javax.inject.Named; import org.mxchange.jphone.events.mobileprovider.added.AdminAddedMobileProviderEvent; -import org.mxchange.jphone.model.phonenumbers.model.mobileprovider.MobileProvider; +import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider; import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote; import org.mxchange.pizzaapplication.beans.BasePizzaController; @@ -34,7 +38,7 @@ import org.mxchange.pizzaapplication.beans.BasePizzaController; * @author Roland Häder */ @Named ("mobileProviderController") -@SessionScoped +@RequestScoped public class PizzaMobileProviderWebRequestBean extends BasePizzaController implements PizzaMobileProviderWebRequestController { /** @@ -43,15 +47,17 @@ public class PizzaMobileProviderWebRequestBean extends BasePizzaController imple private static final long serialVersionUID = 15_869_423_671_950_276L; /** - * "Cached" list of mobile providers + * Remote EJB for mobile providers (regular) */ - private List mobileProviders; + @EJB (lookup = "java:global/jfinancials-ejb/mobileprovider!org.mxchange.jphone.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote") + private MobileProviderSingletonBeanRemote mobileProviderBean; /** - * Remote EJB for mobile providers (regular) + * "Cached" list of mobile providers */ - @EJB (lookup = "java:global/pizzaservice-ejb/mobileProvider!org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote") - private MobileProviderSingletonBeanRemote mobileRemoteBean; + @Inject + @Cached (cacheName = "mobileProviderCache") + private transient Cache mobileProviderCache; /** * Default constructor @@ -84,13 +90,29 @@ public class PizzaMobileProviderWebRequestBean extends BasePizzaController imple } // Add it to the list - this.mobileProviders.add(event.getAddedMobileProvider()); + this.mobileProviderCache.put(event.getAddedMobileProvider().getProviderId(), event.getAddedMobileProvider()); } @Override @SuppressWarnings ("ReturnOfCollectionOrArrayField") public List allMobileProviders () { - return this.mobileProviders; + // Init list + List list = new LinkedList<>(); + + // Get iterator + Iterator> iterator = this.mobileProviderCache.iterator(); + + // Loop over all + while (iterator.hasNext()) { + // Get next entry + final Cache.Entry next = iterator.next(); + + // Add value to list + list.add(next.getValue()); + } + + // Return it + return list; } /** @@ -98,8 +120,20 @@ public class PizzaMobileProviderWebRequestBean extends BasePizzaController imple */ @PostConstruct public void init () { - // Init list of mobile providers - this.mobileProviders = this.mobileRemoteBean.allMobileProvider(); + // Is cache there? + if (!this.mobileProviderCache.iterator().hasNext()) { + // Get whole list + List list = this.mobileProviderBean.allMobileProviders(); + + // Add all + for (final Iterator iterator = list.iterator(); iterator.hasNext();) { + // Get next element + final MobileProvider next = iterator.next(); + + // Add it to cache + this.mobileProviderCache.put(next.getProviderId(), next); + } + } } } diff --git a/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaMobileProviderWebRequestController.java b/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaMobileProviderWebRequestController.java index c944e311..47d0a55b 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaMobileProviderWebRequestController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaMobileProviderWebRequestController.java @@ -18,7 +18,7 @@ package org.mxchange.pizzaapplication.beans.mobileprovider; import java.io.Serializable; import java.util.List; -import org.mxchange.jphone.model.phonenumbers.model.mobileprovider.MobileProvider; +import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider; /** * An interface for general mobile provider controller diff --git a/src/java/org/mxchange/pizzaapplication/beans/phone/PizzaAdminPhoneWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/phone/PizzaAdminPhoneWebRequestBean.java index 7d3db5ab..5af8cb6b 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/phone/PizzaAdminPhoneWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/phone/PizzaAdminPhoneWebRequestBean.java @@ -53,9 +53,9 @@ import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; import org.mxchange.jphone.model.phonenumbers.fax.FaxNumber; import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber; import org.mxchange.jphone.model.phonenumbers.landline.LandLineNumber; -import org.mxchange.jphone.model.phonenumbers.model.mobile.DialableMobileNumber; +import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber; import org.mxchange.jphone.model.phonenumbers.mobile.MobileNumber; -import org.mxchange.jphone.model.phonenumbers.model.mobileprovider.MobileProvider; +import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider; import org.mxchange.jphone.model.phonenumbers.phone.AdminPhoneSessionBeanRemote; import org.mxchange.pizzaapplication.beans.BasePizzaController; @@ -155,7 +155,7 @@ public class PizzaAdminPhoneWebRequestBean extends BasePizzaController implement * Generic hone controller */ @Inject - private PizzaPhoneWebApplicationController phoneController; + private PizzaPhoneWebRequestController phoneController; /** * Country (for dial prefix) diff --git a/src/java/org/mxchange/pizzaapplication/beans/phone/PizzaPhoneWebApplicationBean.java b/src/java/org/mxchange/pizzaapplication/beans/phone/PizzaPhoneWebRequestBean.java similarity index 87% rename from src/java/org/mxchange/pizzaapplication/beans/phone/PizzaPhoneWebApplicationBean.java rename to src/java/org/mxchange/pizzaapplication/beans/phone/PizzaPhoneWebRequestBean.java index 9ae6aead..5c5e2a96 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/phone/PizzaPhoneWebApplicationBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/phone/PizzaPhoneWebRequestBean.java @@ -17,6 +17,7 @@ package org.mxchange.pizzaapplication.beans.phone; import java.text.MessageFormat; +import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Objects; @@ -24,13 +25,14 @@ import javax.annotation.PostConstruct; import javax.ejb.EJB; import javax.enterprise.context.ApplicationScoped; import javax.enterprise.event.Observes; +import javax.inject.Inject; import javax.inject.Named; -import org.mxchange.jcontacts.model.contact.Contact; import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent; import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent; import org.mxchange.jcontacts.events.fax.linked.ObservableAdminLinkedFaxNumberEvent; import org.mxchange.jcontacts.events.landline.linked.ObservableAdminLinkedLandLineNumberEvent; import org.mxchange.jcontacts.events.mobile.linked.ObservableAdminLinkedMobileNumberEvent; +import org.mxchange.jcontacts.model.contact.Contact; import org.mxchange.jphone.events.fax.deleted.AdminDeletedFaxNumberEvent; import org.mxchange.jphone.events.fax.updated.AdminUpdatedFaxNumberEvent; import org.mxchange.jphone.events.landline.deleted.AdminDeletedLandLineNumberEvent; @@ -39,7 +41,7 @@ import org.mxchange.jphone.events.mobile.deleted.AdminDeletedMobileNumberEvent; import org.mxchange.jphone.events.mobile.updated.AdminUpdatedMobileNumberEvent; import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber; -import org.mxchange.jphone.model.phonenumbers.model.mobile.DialableMobileNumber; +import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber; import org.mxchange.jphone.model.phonenumbers.phone.PhoneSessionBeanRemote; import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent; import org.mxchange.pizzaapplication.beans.BasePizzaController; @@ -51,7 +53,7 @@ import org.mxchange.pizzaapplication.beans.BasePizzaController; */ @Named ("phoneController") @ApplicationScoped -public class PizzaPhoneWebApplicationBean extends BasePizzaController implements PizzaPhoneWebApplicationController { +public class PizzaPhoneWebRequestBean extends BasePizzaController implements PizzaPhoneWebRequestController { /** * Serial number @@ -61,35 +63,36 @@ public class PizzaPhoneWebApplicationBean extends BasePizzaController implements /** * All fax numbers */ - private final List faxNumbers; + @Inject + @Cached(cacheName = "faxNumberCache") + private transient Cache faxNumberCache; /** * All land-line numbers */ - private final List landLineNumbers; + @Inject + @Cached(cacheName = "landLineNumberCache") + private transient Cache landLineNumberCache; /** * All mobile numbers */ - private final List mobileNumbers; + @Inject + @Cached(cacheName = "mobileNumberCache") + private transient Cache mobileNumberCache; /** * General EJB for phone numbers */ - @EJB (lookup = "java:global/pizzaservice-ejb/phone!org.mxchange.jphone.model.phonenumbers.phone.PhoneSessionBeanRemote") + @EJB (lookup = "java:global/jfinancials-ejb/phone!org.mxchange.jphone.phonenumbers.phone.PhoneSessionBeanRemote") private PhoneSessionBeanRemote phoneBean; /** * Default constructor */ - public PizzaPhoneWebApplicationBean () { + public PizzaPhoneWebRequestBean () { // Call super constructor super(); - - // Init all lists - this.mobileNumbers = new LinkedList<>(); - this.faxNumbers = new LinkedList<>(); - this.landLineNumbers = new LinkedList<>(); } /** @@ -478,19 +481,67 @@ public class PizzaPhoneWebApplicationBean extends BasePizzaController implements @Override @SuppressWarnings ("ReturnOfCollectionOrArrayField") public List allFaxNumbers () { - return this.faxNumbers; + // Init list + List list = new LinkedList<>(); + + // Get iterator + Iterator> iterator = this.faxNumberCache.iterator(); + + // Loop over all + while (iterator.hasNext()) { + // Get next entry + final Cache.Entry next = iterator.next(); + + // Add value to list + list.add(next.getValue()); + } + + // Return it + return list; } @Override @SuppressWarnings ("ReturnOfCollectionOrArrayField") public List allLandLineNumbers () { - return this.landLineNumbers; + // Init list + List list = new LinkedList<>(); + + // Get iterator + Iterator> iterator = this.landLineNumberCache.iterator(); + + // Loop over all + while (iterator.hasNext()) { + // Get next entry + final Cache.Entry next = iterator.next(); + + // Add value to list + list.add(next.getValue()); + } + + // Return it + return list; } @Override @SuppressWarnings ("ReturnOfCollectionOrArrayField") public List allMobileNumbers () { - return this.mobileNumbers; + // Init list + List list = new LinkedList<>(); + + // Get iterator + Iterator> iterator = this.mobileNumberCache.iterator(); + + // Loop over all + while (iterator.hasNext()) { + // Get next entry + final Cache.Entry next = iterator.next(); + + // Add value to list + list.add(next.getValue()); + } + + // Return it + return list; } /** @@ -498,10 +549,50 @@ public class PizzaPhoneWebApplicationBean extends BasePizzaController implements */ @PostConstruct public void init () { - // All phone numbers - this.allMobileNumbers().addAll(this.phoneBean.allMobileNumbers()); - this.allFaxNumbers().addAll(this.phoneBean.allFaxNumbers()); - this.allLandLineNumbers().addAll(this.phoneBean.allLandLineNumbers()); + // Is cache there? + if (!this.faxNumberCache.iterator().hasNext()) { + // Get whole list + List list = this.phoneBean.allFaxNumbers(); + + // Add all + for (final Iterator iterator = list.iterator(); iterator.hasNext();) { + // Get next element + final DialableFaxNumber next = iterator.next(); + + // Add it to cache + this.faxNumberCache.put(next.getPhoneId(), next); + } + } + + // Is cache there? + if (!this.landLineNumberCache.iterator().hasNext()) { + // Get whole list + List list = this.phoneBean.allLandLineNumbers(); + + // Add all + for (final Iterator iterator = list.iterator(); iterator.hasNext();) { + // Get next element + final DialableLandLineNumber next = iterator.next(); + + // Add it to cache + this.landLineNumberCache.put(next.getPhoneId(), next); + } + } + + // Is cache there? + if (!this.mobileNumberCache.iterator().hasNext()) { + // Get whole list + List list = this.phoneBean.allMobileNumbers(); + + // Add all + for (final Iterator iterator = list.iterator(); iterator.hasNext();) { + // Get next element + final DialableMobileNumber next = iterator.next(); + + // Add it to cache + this.mobileNumberCache.put(next.getPhoneId(), next); + } + } } /** diff --git a/src/java/org/mxchange/pizzaapplication/beans/phone/PizzaPhoneWebApplicationController.java b/src/java/org/mxchange/pizzaapplication/beans/phone/PizzaPhoneWebRequestController.java similarity index 93% rename from src/java/org/mxchange/pizzaapplication/beans/phone/PizzaPhoneWebApplicationController.java rename to src/java/org/mxchange/pizzaapplication/beans/phone/PizzaPhoneWebRequestController.java index 3d630a6b..4630f472 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/phone/PizzaPhoneWebApplicationController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/phone/PizzaPhoneWebRequestController.java @@ -20,7 +20,7 @@ import java.io.Serializable; import java.util.List; import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber; -import org.mxchange.jphone.model.phonenumbers.model.mobile.DialableMobileNumber; +import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber; /** * An interface for a request web controller (bean) for administrative phone @@ -28,7 +28,7 @@ import org.mxchange.jphone.model.phonenumbers.model.mobile.DialableMobileNumber; *

* @author Roland Häder */ -public interface PizzaPhoneWebApplicationController extends Serializable { +public interface PizzaPhoneWebRequestController extends Serializable { /** * Returns a list of all mobile numbers. For performance reasons, the diff --git a/src/java/org/mxchange/pizzaapplication/beans/profile/PizzaUserProfileWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/profile/PizzaUserProfileWebRequestBean.java index 91e0c438..863614f4 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/profile/PizzaUserProfileWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/profile/PizzaUserProfileWebRequestBean.java @@ -26,7 +26,7 @@ import org.mxchange.jusercore.exceptions.UserNotFoundException; import org.mxchange.jusercore.model.user.User; import org.mxchange.jusercore.model.user.profilemodes.ProfileMode; import org.mxchange.pizzaapplication.beans.BasePizzaController; -import org.mxchange.pizzaapplication.beans.user.PizzaUserWebSessionController; +import org.mxchange.pizzaapplication.beans.user.PizzaUserWebRequestController; import org.mxchange.pizzaapplication.beans.user.login.PizzaUserLoginWebSessionController; /** @@ -47,7 +47,7 @@ public class PizzaUserProfileWebRequestBean extends BasePizzaController implemen * User controller */ @Inject - private PizzaUserWebSessionController userController; + private PizzaUserWebRequestController userController; /** * Login controller diff --git a/src/java/org/mxchange/pizzaapplication/beans/receipt/PizzaReceiptWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/receipt/PizzaReceiptWebRequestBean.java similarity index 93% rename from src/java/org/mxchange/pizzaapplication/beans/receipt/PizzaReceiptWebSessionBean.java rename to src/java/org/mxchange/pizzaapplication/beans/receipt/PizzaReceiptWebRequestBean.java index fdc1185b..8d17abec 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/receipt/PizzaReceiptWebSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/receipt/PizzaReceiptWebRequestBean.java @@ -35,7 +35,7 @@ import org.mxchange.pizzaapplication.beans.helper.PizzaWebRequestHelperControlle */ @Named ("receiptController") @SessionScoped -public class PizzaReceiptWebSessionBean extends BasePizzaController implements PizzaReceiptWebSessionController { +public class PizzaReceiptWebRequestBean extends BasePizzaController implements PizzaReceiptWebRequestController { /** * Serial number @@ -56,7 +56,7 @@ public class PizzaReceiptWebSessionBean extends BasePizzaController implements P /** * Default constructor */ - public PizzaReceiptWebSessionBean () { + public PizzaReceiptWebRequestBean () { } @Override diff --git a/src/java/org/mxchange/pizzaapplication/beans/receipt/PizzaReceiptWebSessionController.java b/src/java/org/mxchange/pizzaapplication/beans/receipt/PizzaReceiptWebRequestController.java similarity index 94% rename from src/java/org/mxchange/pizzaapplication/beans/receipt/PizzaReceiptWebSessionController.java rename to src/java/org/mxchange/pizzaapplication/beans/receipt/PizzaReceiptWebRequestController.java index 078ed09a..cba7666e 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/receipt/PizzaReceiptWebSessionController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/receipt/PizzaReceiptWebRequestController.java @@ -23,7 +23,7 @@ import java.io.Serializable; *

* @author Roland Häder */ -public interface PizzaReceiptWebSessionController extends Serializable { +public interface PizzaReceiptWebRequestController extends Serializable { /** * Fetches last access key for given customer instance diff --git a/src/java/org/mxchange/pizzaapplication/beans/user/PizzaAdminUserWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/user/PizzaAdminUserWebRequestBean.java index 81df24ab..7f6240f1 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/user/PizzaAdminUserWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/user/PizzaAdminUserWebRequestBean.java @@ -62,7 +62,7 @@ import org.mxchange.juserlogincore.exceptions.UserPasswordRepeatMismatchExceptio import org.mxchange.juserlogincore.login.UserLoginUtils; import org.mxchange.pizzaapplication.beans.BasePizzaController; import org.mxchange.pizzaapplication.beans.contact.PizzaAdminContactWebRequestController; -import org.mxchange.pizzaapplication.beans.contact.PizzaContactWebSessionController; +import org.mxchange.pizzaapplication.beans.contact.PizzaContactWebRequestController; import org.mxchange.pizzaapplication.beans.localization.PizzaLocalizationSessionController; /** @@ -107,7 +107,7 @@ public class PizzaAdminUserWebRequestBean extends BasePizzaController implements * Regular contact controller */ @Inject - private PizzaContactWebSessionController contactController; + private PizzaContactWebRequestController contactController; /** * Event being fired when administrator has deleted user @@ -144,7 +144,7 @@ public class PizzaAdminUserWebRequestBean extends BasePizzaController implements * Regular user controller */ @Inject - private PizzaUserWebSessionController userController; + private PizzaUserWebRequestController userController; /** * Delete reason @@ -214,7 +214,6 @@ public class PizzaAdminUserWebRequestBean extends BasePizzaController implements * @return Redirect outcome */ public String addUser () { - System.out.println("addUser: this.contact=" + this.getContact()); // As the form cannot validate the data (required="true"), check it here if (this.getUserName() == null) { // Throw NPE @@ -277,7 +276,7 @@ public class PizzaAdminUserWebRequestBean extends BasePizzaController implements return ""; //NOI18N } else if ((this.getUserPassword() == null && (this.getUserPasswordRepeat() == null)) || ((this.getUserPassword().isEmpty()) && (this.getUserPasswordRepeat().isEmpty()))) { // Empty password entered, then generate one - password = UserLoginUtils.createRandomPassword(PizzaUserWebSessionController.MINIMUM_PASSWORD_LENGTH); + password = UserLoginUtils.createRandomPassword(PizzaUserWebRequestController.MINIMUM_PASSWORD_LENGTH); } else if (!this.isSamePasswordEntered()) { // Both passwords don't match throw new FaceletException(new UserPasswordRepeatMismatchException(newUser)); @@ -288,7 +287,7 @@ public class PizzaAdminUserWebRequestBean extends BasePizzaController implements // The password should not be null and at least 5 characters long assert (password != null) : "password is null"; //NOI18N - assert (password.length() >= PizzaUserWebSessionController.MINIMUM_PASSWORD_LENGTH) : "Password is not long enough."; //NOI18N + assert (password.length() >= PizzaUserWebRequestController.MINIMUM_PASSWORD_LENGTH) : "Password is not long enough."; //NOI18N // Encrypt password and set it newUser.setUserEncryptedPassword(UserLoginUtils.encryptPassword(password)); diff --git a/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebRequestBean.java similarity index 90% rename from src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionBean.java rename to src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebRequestBean.java index 7d648ae4..24cc2a1c 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebRequestBean.java @@ -18,6 +18,7 @@ package org.mxchange.pizzaapplication.beans.user; import java.text.MessageFormat; import java.util.Iterator; +import java.util.LinkedList; import java.util.List; import java.util.Locale; import java.util.Objects; @@ -33,7 +34,10 @@ import javax.inject.Inject; import javax.inject.Named; import org.mxchange.jcontacts.model.contact.Contact; import org.mxchange.jcoreee.events.locale.ObservableLocaleChangeEvent; +import org.mxchange.jfinancials.beans.user.PizzaUserWebRequestController; import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent; +import org.mxchange.jusercore.events.user.clear.password.ObservableClearUserPasswordEvent; +import org.mxchange.jusercore.events.user.clear.username.ObservableClearUserNameEvent; import org.mxchange.jusercore.events.user.created.ObservableCreatedUserEvent; import org.mxchange.jusercore.events.user.delete.ObservableAdminDeletedUserEvent; import org.mxchange.jusercore.events.user.linked.ObservableAdminLinkedUserEvent; @@ -55,7 +59,7 @@ import org.mxchange.juserlogincore.events.user.password_change.ObservableUpdated import org.mxchange.juserlogincore.exceptions.UserPasswordMismatchException; import org.mxchange.juserlogincore.login.UserLoginUtils; import org.mxchange.pizzaapplication.beans.BasePizzaController; -import org.mxchange.pizzaapplication.beans.contact.PizzaContactWebSessionController; +import org.mxchange.pizzaapplication.beans.contact.PizzaContactWebRequestController; import org.mxchange.pizzaapplication.beans.features.PizzaFeaturesWebApplicationController; import org.mxchange.pizzaapplication.beans.localization.PizzaLocalizationSessionController; import org.mxchange.pizzaapplication.beans.user.login.PizzaUserLoginWebSessionController; @@ -67,7 +71,7 @@ import org.mxchange.pizzaapplication.beans.user.login.PizzaUserLoginWebSessionCo */ @Named ("userController") @SessionScoped -public class PizzaUserWebSessionBean extends BasePizzaController implements PizzaUserWebSessionController { +public class PizzaUserWebRequestBean extends BasePizzaController implements PizzaUserWebRequestController { /** * Serial number @@ -78,7 +82,7 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz * General contact controller */ @Inject - private PizzaContactWebSessionController contactController; + private PizzaContactWebRequestController contactController; /** * Features controller @@ -107,7 +111,7 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz /** * Remote user bean */ - @EJB (lookup = "java:global/pizzaservice-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote") + @EJB (lookup = "java:global/jfinancials-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote") private UserSessionBeanRemote userBean; /** @@ -118,7 +122,9 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz /** * A list of all user profiles */ - private List userList; + @Inject + @Cached (cacheName = "userCache") + private transient Cache userCache; /** * Login controller (bean) @@ -134,7 +140,9 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz /** * User name list */ - private List userNameList; + @Inject + @Cached (cacheName = "userNameCache") + private transient Cache userNameCache; /** * User password (clear-text from web form) @@ -151,18 +159,10 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz */ private ProfileMode userProfileMode; - /** - * A list of all public user profiles - *

- * @TODO Hmm, makes that sense? Having visible user list in current - * (session-scoped) user's visible user list? - */ - private List visibleUserList; - /** * Default constructor */ - public PizzaUserWebSessionBean () { + public PizzaUserWebRequestBean () { // Call super constructor super(); } @@ -436,12 +436,6 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz // Copy all data to this bean this.copyUser(loggedInUser); - - // Is the user visible? - if (Objects.equals(loggedInUser.getUserProfileMode(), ProfileMode.PUBLIC)) { - // Yes, then add user - this.visibleUserList.add(loggedInUser); - } } /** @@ -503,12 +497,6 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz // Add user name this.addUserName(registeredUser); - // Is the account public? - if (Objects.equals(registeredUser.getUserProfileMode(), ProfileMode.PUBLIC)) { - // Also add it to this list - this.visibleUserList.add(registeredUser); - } - // Set user id again this.setUserId(registeredUser.getUserId()); } @@ -567,28 +555,55 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz @Override @SuppressWarnings ("ReturnOfCollectionOrArrayField") public List allUsers () { - // Return it - return this.userList; - } + // Init list + List list = new LinkedList<>(); + + // Get iterator + Iterator> iterator = this.userCache.iterator(); + + // Loop over all + while (iterator.hasNext()) { + // Get next entry + final Cache.Entry next = iterator.next(); + + // Add value to list + list.add(next.getValue()); + } - @Override - @SuppressWarnings ("ReturnOfCollectionOrArrayField") - public List allVisibleUsers () { // Return it - return this.visibleUserList; + return list; } - @Override - public void clearUserName () { + /** + * Event observer for when a user name should be cleared + *

+ * @param event Event being fired + */ + public void clearUserNameEvent (@Observes final ObservableClearUserNameEvent event) { + // Is it valid? + if (null == event) { + // Throw NPE + throw new NullPointerException("event is null"); + } + // Clear it - this.setUserName(null); + this.clearUserName(); } - @Override - public void clearUserPasswords () { - // Clear both - this.setUserPassword(null); - this.setUserPasswordRepeat(null); + /** + * Event observer for when both user passwords should be cleared + *

+ * @param event Event being fired + */ + public void clearUserPasswordEvent (@Observes final ObservableClearUserPasswordEvent event) { + // Is it valid? + if (null == event) { + // Throw NPE + throw new NullPointerException("event is null"); + } + + // Clear it + this.clearUserPasswords(); } @Override @@ -612,7 +627,7 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz this.setUserProfileMode(ProfileMode.INVISIBLE); // Generate random password - String randomPassword = UserLoginUtils.createRandomPassword(PizzaUserWebSessionController.MINIMUM_PASSWORD_LENGTH); + String randomPassword = UserLoginUtils.createRandomPassword(PizzaUserWebRequestController.MINIMUM_PASSWORD_LENGTH); // Set random password this.setUserPassword(randomPassword); @@ -810,19 +825,20 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz */ @PostConstruct public void init () { - // Initialize user list - this.userList = this.userBean.allUsers(); - - // Get full user name list for reducing EJB calls - this.userNameList = this.userBean.getUserNameList(); - - // Is the user logged-in? - if (this.userLoginController.isUserLoggedIn()) { - // Is logged-in, so load also users visible to memebers - this.visibleUserList = this.userBean.allMemberPublicVisibleUsers(); - } else { - // Initialize user list - this.visibleUserList = this.userBean.allPublicUsers(); + // Is cache there? + if (!this.userCache.iterator().hasNext()) { + // Get whole list + List list = this.userBean.allUsers(); + + // Add all + for (final Iterator iterator = list.iterator(); iterator.hasNext();) { + // Get next element + final User next = iterator.next(); + + // Add it to cache + this.userCache.put(next.getUserId(), next); + this.userNameCache.put(next.getUserId(), next.getUserName()); + } } } @@ -915,7 +931,7 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz @Override public boolean isUserNameRegistered (final User user) { - return ((this.userNameList instanceof List) && (this.userNameList.contains(user.getUserName()))); + return ((this.userNameCache instanceof List) && (this.userNameCache.containsKey(user.getUserId()))); } @Override @@ -930,11 +946,6 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz return isRequired; } - @Override - public boolean isVisibleUserFound () { - return ((this.visibleUserList instanceof List) && (this.visibleUserList.size() > 0)); - } - @Override public User lookupUserByEmailAddress (final String emailAddress) throws UserEmailAddressNotFoundException { // Parameter must be valid @@ -950,23 +961,23 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz User user = null; // Try to lookup it in visible user list - for (final Iterator iterator = this.userList.iterator(); iterator.hasNext();) { + for (final Iterator> iterator = this.userCache.iterator(); iterator.hasNext();) { // Get next user - User next = iterator.next(); + Cache.Entry next = iterator.next(); // Contact should be set - if (next.getUserContact() == null) { + if (next.getValue().getUserContact() == null) { // Contact is null - throw new NullPointerException(MessageFormat.format("next.userContact is null for user id {0}", next.getUserId())); //NOI18N - } else if (next.getUserContact().getContactEmailAddress() == null) { + throw new NullPointerException(MessageFormat.format("next.userContact is null for user id {0}", next.getKey())); //NOI18N + } else if (next.getValue().getUserContact().getContactEmailAddress() == null) { // Email address should be set - throw new NullPointerException(MessageFormat.format("next.userContact.contactEmailAddress is null for user id {0}", next.getUserId())); //NOI18N + throw new NullPointerException(MessageFormat.format("next.userContact.contactEmailAddress is null for user id {0}", next.getKey())); //NOI18N } // Is the email address found? - if (Objects.equals(next.getUserContact().getContactEmailAddress(), emailAddress)) { + if (Objects.equals(next.getValue().getUserContact().getContactEmailAddress(), emailAddress)) { // Copy to other variable - user = next; + user = next.getValue(); break; } } @@ -996,14 +1007,14 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz User user = null; // Try to lookup it in visible user list - for (final Iterator iterator = this.userList.iterator(); iterator.hasNext();) { + for (final Iterator> iterator = this.userCache.iterator(); iterator.hasNext();) { // Get next user - User next = iterator.next(); + Cache.Entry next = iterator.next(); // Is the user id found? - if (Objects.equals(next.getUserId(), userId)) { + if (Objects.equals(next.getKey(), userId)) { // Copy to other variable - user = next; + user = next.getValue(); break; } } @@ -1026,13 +1037,13 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz */ private void addUserName (final User user) { // Make sure the entry is not added yet - if (this.userNameList.contains(user.getUserName())) { + if (this.userNameCache.containsKey(user.getUserId())) { // Abort here throw new IllegalArgumentException(MessageFormat.format("User name {0} already added.", user.getUserName())); //NOI18N } // Add user name - this.userNameList.add(user.getUserName()); + this.userNameCache.put(user.getUserId(), user.getUserName()); } /** @@ -1050,6 +1061,23 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz this.setLocale(null); } + /** + * Clears user name + */ + private void clearUserName () { + // Clear it + this.setUserName(null); + } + + /** + * Clears both user passwords + */ + private void clearUserPasswords () { + // Clear both + this.setUserPassword(null); + this.setUserPasswordRepeat(null); + } + /** * Copies given user into the controller *

@@ -1108,11 +1136,10 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz } // Remove it from lists - this.userList.remove(user); - this.visibleUserList.remove(user); + this.userCache.remove(user.getUserId()); // Remove name from list - this.userNameList.remove(user.getUserName()); + this.userNameCache.remove(user.getUserId()); } /** @@ -1142,24 +1169,8 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz throw new NullPointerException(MessageFormat.format("user.userContact.contactId={0} is invalid.", user.getUserContact().getContactId())); //NOI18N } - // Get iterator from list - Iterator iterator = this.userList.iterator(); - - // "Walk" through all entries - while (iterator.hasNext()) { - // Get next element - User next = iterator.next(); - - // Is user id number the same? - if (Objects.equals(user.getUserId(), next.getUserId())) { - // Found entry, so remove it and abort - this.userList.remove(next); - break; - } - } - - // Re-add user - this.userList.add(user); + // Add/update user + this.userCache.put(user.getUserId(), user); } } diff --git a/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionController.java b/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebRequestController.java similarity index 98% rename from src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionController.java rename to src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebRequestController.java index 0f39f1c6..d3d0dec7 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebRequestController.java @@ -28,7 +28,7 @@ import org.mxchange.jusercore.model.user.User; *

* @author Roland Häder */ -public interface PizzaUserWebSessionController extends Serializable { +public interface PizzaUserWebRequestController extends Serializable { /** * Minimum password length diff --git a/src/java/org/mxchange/pizzaapplication/beans/user/activity/PizzaUserActivityWebApplicationBean.java b/src/java/org/mxchange/pizzaapplication/beans/user/activity/PizzaUserActivityWebRequestBean.java similarity index 95% rename from src/java/org/mxchange/pizzaapplication/beans/user/activity/PizzaUserActivityWebApplicationBean.java rename to src/java/org/mxchange/pizzaapplication/beans/user/activity/PizzaUserActivityWebRequestBean.java index 35d46174..7cfdde38 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/user/activity/PizzaUserActivityWebApplicationBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/user/activity/PizzaUserActivityWebRequestBean.java @@ -19,14 +19,13 @@ package org.mxchange.pizzaapplication.beans.user.activity; import java.text.MessageFormat; import java.util.Collections; import java.util.GregorianCalendar; -import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; -import java.util.Map; import javax.annotation.PostConstruct; import javax.ejb.EJB; -import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.context.RequestScoped; import javax.enterprise.event.Observes; +import javax.inject.Inject; import javax.inject.Named; import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent; import org.mxchange.jusercore.events.user.created.ObservableCreatedUserEvent; @@ -55,8 +54,8 @@ import org.mxchange.pizzaapplication.beans.BasePizzaController; * @author Roland Häder */ @Named ("userActivityController") -@ApplicationScoped -public class PizzaUserActivityWebApplicationBean extends BasePizzaController implements PizzaUserActivityWebApplicationController { +@RequestScoped +public class PizzaUserActivityWebRequestBean extends BasePizzaController implements PizzaUserActivityWebRequestController { /** * Serial number @@ -71,21 +70,23 @@ public class PizzaUserActivityWebApplicationBean extends BasePizzaController imp /** * EJB for user activity log */ - @EJB (lookup = "java:global/pizzaservice-ejb/userActivity!org.mxchange.jusercore.model.user.activity.UserActivityLogSessionBeanRemote") + @EJB (lookup = "java:global/jfinancials-ejb/userActivity!org.mxchange.jusercore.model.user.activity.UserActivityLogSessionBeanRemote") private UserActivityLogSessionBeanRemote userActivityBean; /** * "Cache" for activity log per user */ - private final Map> usersActivity; + @Inject + @Cached(cacheName = "usersActivityCache") + private transient Cache> usersActivityCache; /** * Default constructor */ @SuppressWarnings ("CollectionWithoutInitialCapacity") - public PizzaUserActivityWebApplicationBean () { - // Init cache - this.usersActivity = new LinkedHashMap<>(); + public PizzaUserActivityWebRequestBean () { + // Call super constructor + super(); } /** @@ -505,9 +506,9 @@ public class PizzaUserActivityWebApplicationBean extends BasePizzaController imp List list = new LinkedList<>(); // Is the user set? - if (this.usersActivity.containsKey(this.getUser())) { + if (this.usersActivityCache.containsKey(this.getUser())) { // Return it - list.addAll(this.usersActivity.get(this.getUser())); + list.addAll(this.usersActivityCache.get(this.getUser())); // Sort list and reverse it Collections.sort(list, new UserActivityLogTimestampComparator()); @@ -547,13 +548,13 @@ public class PizzaUserActivityWebApplicationBean extends BasePizzaController imp // Put all in map, per-user for (final LogableUserActivity userActivity : list) { // Is the list there? - if (!this.usersActivity.containsKey(userActivity.getActivityUser())) { + if (!this.usersActivityCache.containsKey(userActivity.getActivityUser())) { // Init list - this.usersActivity.put(userActivity.getActivityUser(), new LinkedList()); + this.usersActivityCache.put(userActivity.getActivityUser(), new LinkedList()); } // Add by user instance - boolean added = this.usersActivity.get(userActivity.getActivityUser()).add(userActivity); + boolean added = this.usersActivityCache.get(userActivity.getActivityUser()).add(userActivity); // Should be added assert (added) : "Activity log not added"; //NOI18N @@ -662,13 +663,13 @@ public class PizzaUserActivityWebApplicationBean extends BasePizzaController imp } // Is it there? - if (!this.usersActivity.containsKey(userActivity.getActivityUser())) { + if (!this.usersActivityCache.containsKey(userActivity.getActivityUser())) { // Init it - this.usersActivity.put(userActivity.getActivityUser(), new LinkedList()); + this.usersActivityCache.put(userActivity.getActivityUser(), new LinkedList()); } // Add activity to log - this.usersActivity.get(userActivity.getActivityUser()).add(userActivity); + this.usersActivityCache.get(userActivity.getActivityUser()).add(userActivity); } } diff --git a/src/java/org/mxchange/pizzaapplication/beans/user/activity/PizzaUserActivityWebApplicationController.java b/src/java/org/mxchange/pizzaapplication/beans/user/activity/PizzaUserActivityWebRequestController.java similarity index 91% rename from src/java/org/mxchange/pizzaapplication/beans/user/activity/PizzaUserActivityWebApplicationController.java rename to src/java/org/mxchange/pizzaapplication/beans/user/activity/PizzaUserActivityWebRequestController.java index d03b07b9..1cde42e2 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/user/activity/PizzaUserActivityWebApplicationController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/user/activity/PizzaUserActivityWebRequestController.java @@ -23,6 +23,6 @@ import java.io.Serializable; *

* @author Roland Häder */ -public interface PizzaUserActivityWebApplicationController extends Serializable { +public interface PizzaUserActivityWebRequestController extends Serializable { } diff --git a/src/java/org/mxchange/pizzaapplication/beans/user/confirmlink/PizzaConfirmationLinkWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/user/confirmlink/PizzaConfirmationLinkWebRequestBean.java index 9d615b41..c88c4c15 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/user/confirmlink/PizzaConfirmationLinkWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/user/confirmlink/PizzaConfirmationLinkWebRequestBean.java @@ -40,7 +40,7 @@ import org.mxchange.jusercore.model.user.status.UserAccountStatus; import org.mxchange.juserlogincore.events.confirmation.ObservableUserConfirmedAccountEvent; import org.mxchange.juserlogincore.events.confirmation.UserConfirmedAccountEvent; import org.mxchange.pizzaapplication.beans.BasePizzaController; -import org.mxchange.pizzaapplication.beans.user.PizzaUserWebSessionController; +import org.mxchange.pizzaapplication.beans.user.PizzaUserWebRequestController; /** * A web request bean for confirmation link handling @@ -85,7 +85,7 @@ public class PizzaConfirmationLinkWebRequestBean extends BasePizzaController imp * User controller */ @Inject - private PizzaUserWebSessionController userController; + private PizzaUserWebRequestController userController; /** * Event for when a user instance was created @@ -114,9 +114,6 @@ public class PizzaConfirmationLinkWebRequestBean extends BasePizzaController imp @Override public void maybeConfirmUserAccount () { - // Trace message - System.out.println(MessageFormat.format("{0}.maybeConfirmAccount: CALLED!", this.getClass().getSimpleName())); //NOI18N - // Is the confirmation key set? if (this.getConfirmationKey() == null) { // May be null if not set @@ -129,9 +126,6 @@ public class PizzaConfirmationLinkWebRequestBean extends BasePizzaController imp // Now try to find the user in user list, first get the whole list List users = this.userController.allUsers(); - // Debug message - System.out.println(MessageFormat.format("{0}.maybeConfirmAccount: users.size()={1}", this.getClass().getSimpleName(), users.size())); //NOI18N - // Get iterator from it Iterator iterator = users.iterator(); @@ -143,23 +137,14 @@ public class PizzaConfirmationLinkWebRequestBean extends BasePizzaController imp // Get next user User next = iterator.next(); - // Debug message - System.out.println(MessageFormat.format("{0}.maybeConfirmAccount: this.confirmationKey={1},next.confirmationKey={2}", this.getClass().getSimpleName(), this.getConfirmationKey(), next.getUserConfirmKey())); //NOI18N - // Same confirmation key? if (Objects.equals(this.getConfirmationKey(), next.getUserConfirmKey())) { - // Debug message - System.out.println(MessageFormat.format("{0}.maybeConfirmAccount: next={1} - Aborting ...", this.getClass().getSimpleName(), next)); //NOI18N - // Found it, then set it and abort loop user = next; break; } } - // Debug message - System.out.println(MessageFormat.format("{0}.maybeConfirmAccount: user={1}", this.getClass().getSimpleName(), user)); //NOI18N - // Is the user instance null? if ((null == user) || (user.getUserAccountStatus() != UserAccountStatus.UNCONFIRMED)) { // Then clear this bean and the helper @@ -168,9 +153,6 @@ public class PizzaConfirmationLinkWebRequestBean extends BasePizzaController imp // Try to confirm it this.confirmUserAccount(user); } - - // Trace message - System.out.println(MessageFormat.format("{0}.maybeConfirmAccount: EXIT!", this.getClass().getSimpleName())); //NOI18N } /** @@ -179,9 +161,6 @@ public class PizzaConfirmationLinkWebRequestBean extends BasePizzaController imp * @param user User instance */ private void confirmUserAccount (final User user) { - // Trace message - System.out.println(MessageFormat.format("{0}.confirmUserAccount: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N - // Should be set if (null == user) { // Throw NPE @@ -213,14 +192,8 @@ public class PizzaConfirmationLinkWebRequestBean extends BasePizzaController imp // Get base URL String baseUrl = FacesUtils.generateBaseUrl(); - // Debug message - System.out.println(MessageFormat.format("{0}.confirmUserAccount: baseUrl={1}", this.getClass().getSimpleName(), baseUrl)); //NOI18N - // Confirm account updatedUser = this.userBean.confirmAccount(user, baseUrl); - - // Debug message - System.out.println(MessageFormat.format("{0}.confirmUserAccount: updatedUser={1} - Returned from EJB", this.getClass().getSimpleName(), updatedUser)); //NOI18N } catch (final UserStatusConfirmedException | UserStatusLockedException ex) { // Something unexpected happened throw new FaceletException(MessageFormat.format("Cannot confirm user account {0}", user.getUserName()), ex); //NOI18N @@ -229,14 +202,8 @@ public class PizzaConfirmationLinkWebRequestBean extends BasePizzaController imp // Fire event that the user has confirmed account this.userConfirmedEvent.fire(new UserConfirmedAccountEvent(updatedUser)); - // Debug message - System.out.println(MessageFormat.format("{0}.confirmUserAccount: updatedUser={1}", this.getClass().getSimpleName(), updatedUser)); //NOI18N - // Fire event this.userCreatedEvent.fire(new CreatedUserEvent(updatedUser)); - - // Trace message - System.out.println(MessageFormat.format("{0}.confirmUserAccount: EXIT!", this.getClass().getSimpleName())); //NOI18N } } diff --git a/src/java/org/mxchange/pizzaapplication/beans/user/email_address/PizzaEmailChangeWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/user/email_address/PizzaEmailChangeWebRequestBean.java similarity index 81% rename from src/java/org/mxchange/pizzaapplication/beans/user/email_address/PizzaEmailChangeWebSessionBean.java rename to src/java/org/mxchange/pizzaapplication/beans/user/email_address/PizzaEmailChangeWebRequestBean.java index 15977f3f..a94f08d0 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/user/email_address/PizzaEmailChangeWebSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/user/email_address/PizzaEmailChangeWebRequestBean.java @@ -17,6 +17,7 @@ package org.mxchange.pizzaapplication.beans.user.email_address; import java.text.MessageFormat; +import java.util.Iterator; import java.util.List; import java.util.Objects; import javax.annotation.PostConstruct; @@ -43,7 +44,7 @@ import org.mxchange.pizzaapplication.beans.user.login.PizzaUserLoginWebSessionCo */ @Named ("userEmailChangeController") @SessionScoped -public class PizzaEmailChangeWebSessionBean extends BasePizzaController implements PizzaEmailChangeWebSessionController { +public class PizzaEmailChangeWebRequestBean extends BasePizzaController implements PizzaEmailChangeWebRequestController { /** * Serial number @@ -60,15 +61,10 @@ public class PizzaEmailChangeWebSessionBean extends BasePizzaController implemen */ private String emailAddressRepeat; - /** - * Local list of already queued email addresses - */ - private List emailAddresses; - /** * Remote email change bean */ - @EJB (lookup = "java:global/pizzaservice-ejb/userEmailChange!org.mxchange.jusercore.model.user.email_address.UserEmailChangeSessionBeanRemote") + @EJB (lookup = "java:global/jfinancials-ejb/userEmailChange!org.mxchange.jusercore.model.user.email_address.UserEmailChangeSessionBeanRemote") private UserEmailChangeSessionBeanRemote emailChangeBean; /** @@ -78,7 +74,14 @@ public class PizzaEmailChangeWebSessionBean extends BasePizzaController implemen private PizzaFeaturesWebApplicationController featureController; /** - * Login bean (controller) + * Local list of already queued email addresses + */ + @Inject + @Cached (cacheName = "queuedEmailCache") + private transient Cache queuedEmailCache; + + /** + * Login controller (bean) */ @Inject private PizzaUserLoginWebSessionController userLoginController; @@ -86,7 +89,7 @@ public class PizzaEmailChangeWebSessionBean extends BasePizzaController implemen /** * Default constructor */ - public PizzaEmailChangeWebSessionBean () { + public PizzaEmailChangeWebRequestBean () { // Call super constructor super(); } @@ -101,19 +104,20 @@ public class PizzaEmailChangeWebSessionBean extends BasePizzaController implemen if (!this.userLoginController.isUserLoggedIn()) { // Not logged-in throw new IllegalStateException("User is not logged-in"); //NOI18N + } else if (!this.featureController.isFeatureEnabled("user_change_email_address")) { //NOI18N + // Editing is not allowed + throw new IllegalStateException("User tried to change email address"); //NOI18N } else if (!this.isRequiredChangeEmailAddressSet()) { // Not all required fields are set throw new FaceletException("Not all required fields are set."); //NOI18N } else if (!Objects.equals(this.getEmailAddress(), this.getEmailAddressRepeat())) { // Email address 1+2 mismatch - throw new FaceletException("Email address 1/2 are mismatching."); //NOI18N + this.showFacesMessage("form_user_change_email_address:emailAddressRepeat", "ERROR_USER_EMAIL_ADDRESSES_MISMATCH"); //NOI18N + return ""; //NOI18N } else if (!this.userLoginController.ifCurrentPasswordMatches()) { // Password not matching this.showFacesMessage("form_login_user_change_email_address:currentPassword", new UserPasswordMismatchException(this.userLoginController.getLoggedInUser())); //NOI18N return ""; //NOI18N - } else if (!this.featureController.isFeatureEnabled("edit_user_data")) { //NOI18N - // Editing is not allowed - throw new IllegalStateException("User tried to edit personal data"); //NOI18N } // Get user instance @@ -129,8 +133,13 @@ public class PizzaEmailChangeWebSessionBean extends BasePizzaController implemen // Check if the email address is already enqueued if (this.isEmailAddressQueued(this.getEmailAddress())) { + // Clear both email addresses + this.setEmailAddress(null); + this.setEmailAddressRepeat(null); + // Yes, then abort here - return "login_email_already_added"; //NOI18N + this.showFacesMessage("form_user_change_email_address:emailAddress", "ERROR_USER_CHANGE_EMAIL_ADDRESS_ALREADY_QUEUED"); //NOI18N + return ""; //NOI18N } // Create change object, to save EJB calls, the hash is not generated here @@ -146,7 +155,7 @@ public class PizzaEmailChangeWebSessionBean extends BasePizzaController implemen this.clear(); // All fine - return "login_email_change_queued"; //NOI18N + return "user_login_email_change_queued"; //NOI18N } /** @@ -190,8 +199,20 @@ public class PizzaEmailChangeWebSessionBean extends BasePizzaController implemen */ @PostConstruct public void init () { - // Init list - this.emailAddresses = this.emailChangeBean.allQueuedAddresses(); + // Is cache there? + if (!this.queuedEmailCache.iterator().hasNext()) { + // Get whole list + List list = this.emailChangeBean.allQueuedAddresses(); + + // Add all + for (final Iterator iterator = list.iterator(); iterator.hasNext();) { + // Get next element + final String next = iterator.next(); + + // Add it to cache + this.queuedEmailCache.put(next, Boolean.TRUE); + } + } } @Override @@ -224,7 +245,7 @@ public class PizzaEmailChangeWebSessionBean extends BasePizzaController implemen assert (!emailAddress.trim().isEmpty()) : "emailAddress should not be empty"; //NOI18N // Check list - if (this.emailAddresses.contains(emailAddress)) { + if (this.queuedEmailCache.containsKey(emailAddress)) { // Okay, found it return true; } @@ -235,7 +256,7 @@ public class PizzaEmailChangeWebSessionBean extends BasePizzaController implemen // Is it there? if (isQueued) { // Add to list - this.emailAddresses.add(emailAddress); + this.queuedEmailCache.put(emailAddress, Boolean.TRUE); } // Return status diff --git a/src/java/org/mxchange/pizzaapplication/beans/user/email_address/PizzaEmailChangeWebSessionController.java b/src/java/org/mxchange/pizzaapplication/beans/user/email_address/PizzaEmailChangeWebRequestController.java similarity index 94% rename from src/java/org/mxchange/pizzaapplication/beans/user/email_address/PizzaEmailChangeWebSessionController.java rename to src/java/org/mxchange/pizzaapplication/beans/user/email_address/PizzaEmailChangeWebRequestController.java index bd26aaf5..267d2e6a 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/user/email_address/PizzaEmailChangeWebSessionController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/user/email_address/PizzaEmailChangeWebRequestController.java @@ -23,7 +23,7 @@ import java.io.Serializable; *

* @author Roland Häder */ -public interface PizzaEmailChangeWebSessionController extends Serializable { +public interface PizzaEmailChangeWebRequestController extends Serializable { /** * Checks whether all required are set for changing email address diff --git a/src/java/org/mxchange/pizzaapplication/beans/user/login/PizzaUserLoginWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/user/login/PizzaUserLoginWebSessionBean.java index dc5d2d6d..8789c3a5 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/user/login/PizzaUserLoginWebSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/user/login/PizzaUserLoginWebSessionBean.java @@ -47,7 +47,7 @@ import org.mxchange.juserlogincore.exceptions.UserPasswordMismatchException; import org.mxchange.juserlogincore.login.UserLoginUtils; import org.mxchange.juserlogincore.model.user.login.UserLoginSessionBeanRemote; import org.mxchange.pizzaapplication.beans.BasePizzaController; -import org.mxchange.pizzaapplication.beans.user.PizzaUserWebSessionController; +import org.mxchange.pizzaapplication.beans.user.PizzaUserWebRequestController; /** * A web bean for user registration @@ -95,7 +95,7 @@ public class PizzaUserLoginWebSessionBean extends BasePizzaController implements * User controller */ @Inject - private PizzaUserWebSessionController userController; + private PizzaUserWebRequestController userController; /** * Current password diff --git a/src/java/org/mxchange/pizzaapplication/beans/user/register/PizzaUserRegisterWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/user/register/PizzaUserRegisterWebRequestBean.java similarity index 91% rename from src/java/org/mxchange/pizzaapplication/beans/user/register/PizzaUserRegisterWebSessionBean.java rename to src/java/org/mxchange/pizzaapplication/beans/user/register/PizzaUserRegisterWebRequestBean.java index 5505a9d3..44b682af 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/user/register/PizzaUserRegisterWebSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/user/register/PizzaUserRegisterWebRequestBean.java @@ -17,7 +17,7 @@ package org.mxchange.pizzaapplication.beans.user.register; import javax.ejb.EJB; -import javax.enterprise.context.SessionScoped; +import javax.enterprise.context.RequestScoped; import javax.enterprise.event.Event; import javax.enterprise.inject.Any; import javax.faces.view.facelets.FaceletException; @@ -26,7 +26,10 @@ import javax.inject.Named; import org.mxchange.jcontacts.model.contact.Contact; import org.mxchange.jcontacts.model.contact.UserContact; import org.mxchange.jcoreee.utils.FacesUtils; +import org.mxchange.jfinancials.beans.user.PizzaUserWebRequestController; +import org.mxchange.jusercore.events.user.clear.password.ClearUserPasswordEvent; import org.mxchange.jusercore.events.user.clear.password.ObservableClearUserPasswordEvent; +import org.mxchange.jusercore.events.user.clear.username.ClearUserNameEvent; import org.mxchange.jusercore.events.user.clear.username.ObservableClearUserNameEvent; import org.mxchange.jusercore.exceptions.DataRepeatMismatchException; import org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException; @@ -42,10 +45,9 @@ import org.mxchange.juserlogincore.events.user.password_change.UpdatedUserPasswo import org.mxchange.juserlogincore.login.UserLoginUtils; import org.mxchange.juserlogincore.model.user.register.UserRegistrationSessionBeanRemote; import org.mxchange.pizzaapplication.beans.BasePizzaController; -import org.mxchange.pizzaapplication.beans.contact.PizzaContactWebSessionController; +import org.mxchange.pizzaapplication.beans.contact.PizzaContactWebRequestController; import org.mxchange.pizzaapplication.beans.features.PizzaFeaturesWebApplicationController; import org.mxchange.pizzaapplication.beans.user.PizzaAdminUserWebRequestController; -import org.mxchange.pizzaapplication.beans.user.PizzaUserWebSessionController; /** * A web bean for user registration @@ -53,8 +55,8 @@ import org.mxchange.pizzaapplication.beans.user.PizzaUserWebSessionController; * @author Roland Häder */ @Named ("userRegistrationController") -@SessionScoped -public class PizzaUserRegisterWebSessionBean extends BasePizzaController implements PizzaUserRegisterWebSessionController { +@RequestScoped +public class PizzaUserRegisterWebRequestBean extends BasePizzaController implements PizzaUserRegisterWebRequestController { /** * Serial number @@ -62,7 +64,7 @@ public class PizzaUserRegisterWebSessionBean extends BasePizzaController impleme private static final long serialVersionUID = 47_828_986_719_691_592L; /** - * User controller + * Administrative user controller */ @Inject private PizzaAdminUserWebRequestController adminUserController; @@ -85,7 +87,7 @@ public class PizzaUserRegisterWebSessionBean extends BasePizzaController impleme * Contact controller */ @Inject - private PizzaContactWebSessionController contactController; + private PizzaContactWebRequestController contactController; /** * Features controller @@ -96,14 +98,14 @@ public class PizzaUserRegisterWebSessionBean extends BasePizzaController impleme /** * Remote register session-scoped bean */ - @EJB (lookup = "java:global/addressbook-ejb/userRegistration!org.mxchange.juserlogincore.model.user.register.UserRegistrationSessionBeanRemote") + @EJB (lookup = "java:global/jfinancials-ejb/userRegistration!org.mxchange.juserlogincore.model.user.register.UserRegistrationSessionBeanRemote") private UserRegistrationSessionBeanRemote registerBean; /** * User controller */ @Inject - private PizzaUserWebSessionController userController; + private PizzaUserWebRequestController userController; /** * An event being fired when a user password was changed @@ -122,7 +124,7 @@ public class PizzaUserRegisterWebSessionBean extends BasePizzaController impleme /** * Default constructor */ - public PizzaUserRegisterWebSessionBean () { + public PizzaUserRegisterWebRequestBean () { // Call super constructor super(); } @@ -159,8 +161,10 @@ public class PizzaUserRegisterWebSessionBean extends BasePizzaController impleme // User name is already used, should not happen here throw new FaceletException(new UserNameAlreadyRegisteredException(user)); } else { - // May happen here, reset field - this.userController.clearUserName(); + // May happen here, fire event + this.clearUserNameEvent.fire(new ClearUserNameEvent()); + + // Output message this.showFacesMessage("form_register_single:userName", "ERROR_USER_NAME_ALREADY_USED"); //NOI18N return ""; //NOI18N } @@ -193,7 +197,7 @@ public class PizzaUserRegisterWebSessionBean extends BasePizzaController impleme throw new FaceletException(new DataRepeatMismatchException("Passwords not matching.")); //NOI18N } else if (this.userController.ifBothPasswordsEmptyAllowed()) { // Both passwords are left empty and is allowed, then generate a random password - randomPassword = UserLoginUtils.createRandomPassword(PizzaUserWebSessionController.MINIMUM_PASSWORD_LENGTH); + randomPassword = UserLoginUtils.createRandomPassword(PizzaUserWebRequestController.MINIMUM_PASSWORD_LENGTH); // Generate (ignored) password-history PasswordHistory passwordHistory = new UserPasswordHistory(randomPassword, user); @@ -268,7 +272,9 @@ public class PizzaUserRegisterWebSessionBean extends BasePizzaController impleme throw new NullPointerException("user is null after createUserInstance() was called"); //NOI18N } else if ((this.featureController.isFeatureEnabled("user_login_require_user_name")) && (this.userController.isUserNameRegistered(user))) { //NOI18N // User name is already used, so clear it - this.userController.clearUserName(); + this.clearUserNameEvent.fire(new ClearUserNameEvent()); + + // Output message this.showFacesMessage("form_register_page1:userName", "ERROR_USER_NAME_ALREADY_USED"); //NOI18N return ""; //NOI18N } else if (!this.contactController.isSameEmailAddressEntered()) { @@ -280,7 +286,7 @@ public class PizzaUserRegisterWebSessionBean extends BasePizzaController impleme // Is multi-page enabled? if (this.featureController.isFeatureEnabled("user_register_multiple_page")) { //NOI18N // Unset both - this.userController.clearUserPasswords(); + this.clearUserPasswordEvent.fire(new ClearUserPasswordEvent()); // Output faces message this.showFacesMessage("form_register_page1:userPassword", "ERROR_USER_PASSWORD_EMPTY"); //NOI18N @@ -288,7 +294,7 @@ public class PizzaUserRegisterWebSessionBean extends BasePizzaController impleme return ""; //NOI18N } else if (this.userController.ifBothPasswordsEmptyAllowed()) { // Both passwords are left empty and is allowed, then generate a random password - String randomPassword = UserLoginUtils.createRandomPassword(PizzaUserWebSessionController.MINIMUM_PASSWORD_LENGTH); + String randomPassword = UserLoginUtils.createRandomPassword(PizzaUserWebRequestController.MINIMUM_PASSWORD_LENGTH); // Generate (ignored) password-history PasswordHistory passwordHistory = new UserPasswordHistory(randomPassword, user); @@ -317,4 +323,5 @@ public class PizzaUserRegisterWebSessionBean extends BasePizzaController impleme return "user_register_page2"; //NOI18N } + } diff --git a/src/java/org/mxchange/pizzaapplication/beans/user/register/PizzaUserRegisterWebSessionController.java b/src/java/org/mxchange/pizzaapplication/beans/user/register/PizzaUserRegisterWebRequestController.java similarity index 93% rename from src/java/org/mxchange/pizzaapplication/beans/user/register/PizzaUserRegisterWebSessionController.java rename to src/java/org/mxchange/pizzaapplication/beans/user/register/PizzaUserRegisterWebRequestController.java index 20e39c5a..f6c37698 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/user/register/PizzaUserRegisterWebSessionController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/user/register/PizzaUserRegisterWebRequestController.java @@ -23,6 +23,6 @@ import java.io.Serializable; *

* @author Roland Häder */ -public interface PizzaUserRegisterWebSessionController extends Serializable { +public interface PizzaUserRegisterWebRequestController extends Serializable { } diff --git a/src/java/org/mxchange/pizzaapplication/beans/user/resendlink/PizzaResendLinkWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/user/resendlink/PizzaResendLinkWebRequestBean.java similarity index 95% rename from src/java/org/mxchange/pizzaapplication/beans/user/resendlink/PizzaResendLinkWebSessionBean.java rename to src/java/org/mxchange/pizzaapplication/beans/user/resendlink/PizzaResendLinkWebRequestBean.java index 66ef8003..63d428bc 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/user/resendlink/PizzaResendLinkWebSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/user/resendlink/PizzaResendLinkWebRequestBean.java @@ -26,6 +26,7 @@ import javax.inject.Inject; import javax.inject.Named; import org.mxchange.jcoreee.events.locale.ObservableLocaleChangeEvent; import org.mxchange.jcoreee.utils.FacesUtils; +import org.mxchange.jfinancials.beans.user.PizzaUserWebRequestController; import org.mxchange.jusercore.exceptions.UserEmailAddressNotFoundException; import org.mxchange.jusercore.exceptions.UserNotFoundException; import org.mxchange.jusercore.exceptions.UserStatusConfirmedException; @@ -37,7 +38,6 @@ import org.mxchange.juserlogincore.events.resendlink.UserResendLinkAccountEvent; import org.mxchange.juserlogincore.model.user.resendlink.ResendLinkSessionBeanRemote; import org.mxchange.pizzaapplication.beans.BasePizzaController; import org.mxchange.pizzaapplication.beans.localization.PizzaLocalizationSessionController; -import org.mxchange.pizzaapplication.beans.user.PizzaUserWebSessionController; /** * A web session-scoped bean for resending confirmation link @@ -46,7 +46,7 @@ import org.mxchange.pizzaapplication.beans.user.PizzaUserWebSessionController; */ @Named ("userResendConfirmationController") @SessionScoped -public class PizzaResendLinkWebSessionBean extends BasePizzaController implements PizzaResendLinkWebSessionController { +public class PizzaResendLinkWebRequestBean extends BasePizzaController implements PizzaResendLinkWebRequestController { /** * Serial number @@ -72,14 +72,14 @@ public class PizzaResendLinkWebSessionBean extends BasePizzaController implement /** * EJB for resending confirmation link */ - @EJB (lookup = "java:global/addressbook-ejb/userResendConfirmationLink!org.mxchange.juserlogincore.model.user.resendlink.ResendLinkSessionBeanRemote") + @EJB (lookup = "java:global/jfinancials-ejb/userResendConfirmationLink!org.mxchange.juserlogincore.model.user.resendlink.ResendLinkSessionBeanRemote") private ResendLinkSessionBeanRemote resendLinkBean; /** * Regular user controller */ @Inject - private PizzaUserWebSessionController userController; + private PizzaUserWebRequestController userController; /** * Event being fired after confirmation link is being sent @@ -91,7 +91,7 @@ public class PizzaResendLinkWebSessionBean extends BasePizzaController implement /** * Default constructor */ - public PizzaResendLinkWebSessionBean () { + public PizzaResendLinkWebRequestBean () { // Call super constructor super(); } diff --git a/src/java/org/mxchange/pizzaapplication/beans/user/resendlink/PizzaResendLinkWebSessionController.java b/src/java/org/mxchange/pizzaapplication/beans/user/resendlink/PizzaResendLinkWebRequestController.java similarity index 93% rename from src/java/org/mxchange/pizzaapplication/beans/user/resendlink/PizzaResendLinkWebSessionController.java rename to src/java/org/mxchange/pizzaapplication/beans/user/resendlink/PizzaResendLinkWebRequestController.java index 7819ec57..76652332 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/user/resendlink/PizzaResendLinkWebSessionController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/user/resendlink/PizzaResendLinkWebRequestController.java @@ -23,6 +23,6 @@ import java.io.Serializable; *

* @author Roland Häder */ -public interface PizzaResendLinkWebSessionController extends Serializable { +public interface PizzaResendLinkWebRequestController extends Serializable { } diff --git a/src/java/org/mxchange/jfinancials/validator/business/basicdata/FinancialsCompanyNameValidator.java b/src/java/org/mxchange/pizzaapplication/validator/business/basicdata/PizzaCompanyNameValidator.java similarity index 96% rename from src/java/org/mxchange/jfinancials/validator/business/basicdata/FinancialsCompanyNameValidator.java rename to src/java/org/mxchange/pizzaapplication/validator/business/basicdata/PizzaCompanyNameValidator.java index e1f1b854..155d0d60 100644 --- a/src/java/org/mxchange/jfinancials/validator/business/basicdata/FinancialsCompanyNameValidator.java +++ b/src/java/org/mxchange/pizzaapplication/validator/business/basicdata/PizzaCompanyNameValidator.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package org.mxchange.jfinancials.validator.business.basicdata; +package org.mxchange.pizzaapplication.validator.business.basicdata; import java.text.MessageFormat; import javax.ejb.EJB; @@ -31,7 +31,7 @@ import org.mxchange.jcoreee.validator.string.BaseStringValidator; * @author Roland Häder */ @FacesValidator (value = "CompanyNameValidator", managed = true) -public class FinancialsCompanyNameValidator extends BaseStringValidator { +public class PizzaCompanyNameValidator extends BaseStringValidator { /** * Serial number diff --git a/web/guest/user/user_list.xhtml b/web/guest/user/user_list.xhtml index ba2287d6..b1726a33 100644 --- a/web/guest/user/user_list.xhtml +++ b/web/guest/user/user_list.xhtml @@ -22,22 +22,24 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + > -- 2.39.5