From: Roland Häder Date: Fri, 21 Apr 2017 20:17:19 +0000 (+0200) Subject: Please cherry-pick: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=0ebc3146228c0087fff5668f188d8e5ab7c07abc;p=addressbook-war.git Please cherry-pick: - let's move EJB-lookup into post-construct method and out of constructors as this seems to tricker a bug in Glassfish: https://github.com/payara/Payara/issues/1035 Signed-off-by: Roland Häder --- diff --git a/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebSessionBean.java b/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebSessionBean.java index 4fd8efaf..967e2cb1 100644 --- a/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebSessionBean.java +++ b/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebSessionBean.java @@ -39,14 +39,14 @@ import org.mxchange.addressbook.beans.BaseAddressbookController; import org.mxchange.addressbook.beans.login.AddressbookUserLoginWebSessionController; import org.mxchange.addressbook.model.addressbook.AddressbookSessionBeanRemote; import org.mxchange.jaddressbookcore.events.addressbook.AddressbookLoadedEvent; +import org.mxchange.jaddressbookcore.events.addressbook.ObservableAddressbookLoadedEvent; import org.mxchange.jaddressbookcore.exceptions.AddressbookNameAlreadyUsedException; import org.mxchange.jaddressbookcore.exceptions.AddressbookNotFoundException; import org.mxchange.jaddressbookcore.model.addressbook.Addressbook; import org.mxchange.jaddressbookcore.model.addressbook.UserAddressbook; import org.mxchange.jaddressbookcore.model.addressbook.entry.AddressbookEntry; -import org.mxchange.jusercore.model.user.User; -import org.mxchange.jaddressbookcore.events.addressbook.ObservableAddressbookLoadedEvent; import org.mxchange.jusercore.events.login.ObservableUserLoggedInEvent; +import org.mxchange.jusercore.model.user.User; /** * An address book bean (controller) @@ -119,18 +119,6 @@ public class AddressbookWebSessionBean extends BaseAddressbookController impleme * Default constructor */ public AddressbookWebSessionBean () { - // Try it - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup - this.addressbookBean = (AddressbookSessionBeanRemote) context.lookup("java:global/addressbook-ejb/addressbook!org.mxchange.addressbook.model.addressbook.AddressbookSessionBeanRemote"); //NOI18N - } catch (final NamingException e) { - // Throw again - throw new FaceletException(e); - } - // Init list AddressbookWebSessionBean.countSharesList = new ConcurrentHashMap<>(0); } @@ -297,11 +285,13 @@ public class AddressbookWebSessionBean extends BaseAddressbookController impleme } @Override + @SuppressWarnings ("ReturnOfDateField") public Calendar getAddressbookCreated () { return this.addressbookCreated; } @Override + @SuppressWarnings ("AssignmentToDateFieldFromParameter") public void setAddressbookCreated (final Calendar addressbookCreated) { this.addressbookCreated = addressbookCreated; } @@ -353,6 +343,18 @@ public class AddressbookWebSessionBean extends BaseAddressbookController impleme */ @PostConstruct public void init () { + // Try it + try { + // Get initial context + Context context = new InitialContext(); + + // Try to lookup + this.addressbookBean = (AddressbookSessionBeanRemote) context.lookup("java:global/addressbook-ejb/addressbook!org.mxchange.addressbook.model.addressbook.AddressbookSessionBeanRemote"); //NOI18N + } catch (final NamingException e) { + // Throw again + throw new FaceletException(e); + } + // Init list this.usersAddressbooks = new LinkedList<>(); diff --git a/src/java/org/mxchange/addressbook/beans/confirmlink/AddressbookConfirmationLinkWebRequestBean.java b/src/java/org/mxchange/addressbook/beans/confirmlink/AddressbookConfirmationLinkWebRequestBean.java index d7cb4792..d64437b4 100644 --- a/src/java/org/mxchange/addressbook/beans/confirmlink/AddressbookConfirmationLinkWebRequestBean.java +++ b/src/java/org/mxchange/addressbook/beans/confirmlink/AddressbookConfirmationLinkWebRequestBean.java @@ -20,6 +20,7 @@ import java.text.MessageFormat; import java.util.Iterator; import java.util.List; import java.util.Objects; +import javax.annotation.PostConstruct; import javax.enterprise.context.RequestScoped; import javax.enterprise.event.Event; import javax.enterprise.inject.Any; @@ -33,13 +34,13 @@ import org.mxchange.addressbook.beans.BaseAddressbookController; import org.mxchange.addressbook.beans.helper.AddressbookWebRequestController; import org.mxchange.addressbook.beans.user.AddressbookUserWebSessionController; import org.mxchange.jcoreee.utils.FacesUtils; +import org.mxchange.jusercore.events.confirmation.ObservableUserConfirmedAccountEvent; import org.mxchange.jusercore.events.confirmation.UserConfirmedAccountEvent; import org.mxchange.jusercore.exceptions.UserStatusConfirmedException; import org.mxchange.jusercore.exceptions.UserStatusLockedException; import org.mxchange.jusercore.model.user.User; import org.mxchange.jusercore.model.user.UserSessionBeanRemote; import org.mxchange.jusercore.model.user.status.UserAccountStatus; -import org.mxchange.jusercore.events.confirmation.ObservableUserConfirmedAccountEvent; /** * A web request bean for confirmation link handling @@ -69,7 +70,7 @@ public class AddressbookConfirmationLinkWebRequestBean extends BaseAddressbookCo /** * Remote user bean */ - private final UserSessionBeanRemote userBean; + private UserSessionBeanRemote userBean; /** * User controller @@ -88,6 +89,13 @@ public class AddressbookConfirmationLinkWebRequestBean extends BaseAddressbookCo * Default constructor */ public AddressbookConfirmationLinkWebRequestBean () { + } + + /** + * Post-construction method + */ + @PostConstruct + public void init () { // Try it try { // Get initial context diff --git a/src/java/org/mxchange/addressbook/beans/contact/AddressbookAdminContactWebRequestBean.java b/src/java/org/mxchange/addressbook/beans/contact/AddressbookAdminContactWebRequestBean.java index 62482450..0ca0188a 100644 --- a/src/java/org/mxchange/addressbook/beans/contact/AddressbookAdminContactWebRequestBean.java +++ b/src/java/org/mxchange/addressbook/beans/contact/AddressbookAdminContactWebRequestBean.java @@ -39,7 +39,9 @@ import org.mxchange.jcontacts.contact.UserContact; import org.mxchange.jcontacts.contact.gender.Gender; import org.mxchange.jcontacts.contact.utils.ContactUtils; import org.mxchange.jcontacts.events.contact.add.AdminAddedContactEvent; +import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent; 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.jcountry.data.Country; import org.mxchange.jphone.phonenumbers.DialableNumber; @@ -50,8 +52,6 @@ import org.mxchange.jphone.phonenumbers.landline.LandLineNumber; import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber; import org.mxchange.jphone.phonenumbers.mobile.MobileNumber; import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider; -import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent; -import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent; /** * An administrative user bean (controller) @@ -103,7 +103,7 @@ public class AddressbookAdminContactWebRequestBean extends BaseAddressbookContro /** * Remote contact bean */ - private final ContactSessionBeanRemote contactBean; + private ContactSessionBeanRemote contactBean; /** * General contact controller @@ -247,17 +247,6 @@ public class AddressbookAdminContactWebRequestBean extends BaseAddressbookContro * Default constructor */ public AddressbookAdminContactWebRequestBean () { - // Try it - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup - this.contactBean = (ContactSessionBeanRemote) context.lookup("java:global/addressbook-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote"); //NOI18N - } catch (final NamingException e) { - // Throw again - throw new FaceletException(e); - } } @Override @@ -733,6 +722,17 @@ public class AddressbookAdminContactWebRequestBean extends BaseAddressbookContro */ @PostConstruct public void init () { + // Try it + try { + // Get initial context + Context context = new InitialContext(); + + // Try to lookup + this.contactBean = (ContactSessionBeanRemote) context.lookup("java:global/addressbook-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote"); //NOI18N + } catch (final NamingException e) { + // Throw again + throw new FaceletException(e); + } } @Override diff --git a/src/java/org/mxchange/addressbook/beans/contact/AddressbookContactWebSessionBean.java b/src/java/org/mxchange/addressbook/beans/contact/AddressbookContactWebSessionBean.java index d69694df..2e1fe76a 100644 --- a/src/java/org/mxchange/addressbook/beans/contact/AddressbookContactWebSessionBean.java +++ b/src/java/org/mxchange/addressbook/beans/contact/AddressbookContactWebSessionBean.java @@ -78,16 +78,6 @@ public class AddressbookContactWebSessionBean extends BaseAddressbookController */ private Date birthday; - /** - * Mobile number's carrier - */ - private MobileProvider mobileCarrier; - - /** - * Mobile number - */ - private Long mobileNumber; - /** * City */ @@ -101,7 +91,7 @@ public class AddressbookContactWebSessionBean extends BaseAddressbookController /** * Remote contact bean */ - private final ContactSessionBeanRemote contactBean; + private ContactSessionBeanRemote contactBean; /** * Contact list @@ -168,20 +158,30 @@ public class AddressbookContactWebSessionBean extends BaseAddressbookController */ private String houseNumberExtension; + /** + * Whether a fax entry has been unlinked + */ + private boolean isFaxUnlinked; + + /** + * Whether a land-line number has been unlinked + */ + private boolean isLandLineUnlinked; + /** * Whether a mobile entry has been unlinked */ private boolean isMobileUnlinked; /** - * Whether a fax entry has been unlinked + * Mobile number's carrier */ - private boolean isFaxUnlinked; + private MobileProvider mobileCarrier; /** - * Whether a land-line number has been unlinked + * Mobile number */ - private boolean isLandLineUnlinked; + private Long mobileNumber; /** * Phone number area code @@ -234,18 +234,6 @@ public class AddressbookContactWebSessionBean extends BaseAddressbookController * Default constructor */ public AddressbookContactWebSessionBean () { - // Try it - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup - this.contactBean = (ContactSessionBeanRemote) context.lookup("java:global/addressbook-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote"); //NOI18N - } catch (final NamingException e) { - // Throw again - throw new FaceletException(e); - } - // Init lists/maps this.contactList = new LinkedList<>(); this.emailAddressList = new LinkedList<>(); @@ -374,43 +362,6 @@ public class AddressbookContactWebSessionBean extends BaseAddressbookController //* NOISY-DEBUG: */ System.out.println("contactController.afterAdminUpdatedContactDataEvent(): EXIT!"); //NOI18N } - /** - * Event observer for new user registrations - *

- * @param event User registration event - */ - public void afterUserRegistrationEvent (@Observes final ObservableUserRegisteredEvent event) { - // event should not be null - if (null == event) { - // Throw NPE - throw new NullPointerException("event is null"); //NOI18N - } else if (event.getRegisteredUser() == null) { - // Throw NPE again - throw new NullPointerException("event.registeredUser is null"); //NOI18N - } else if (event.getRegisteredUser().getUserId() == null) { - // userId is null - throw new NullPointerException("event.registeredUser.userId is null"); //NOI18N - } else if (event.getRegisteredUser().getUserId() < 1) { - // Not avalid id - throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getRegisteredUser(), event.getRegisteredUser().getUserId())); //NOI18N - } - - // Get user instance - Contact registeredContact = event.getRegisteredUser().getUserContact(); - - // Copy all data from registered->user - this.copyContact(registeredContact); - - // Add contact instance only once - this.uniqueAddContact(registeredContact); - - // Add user name and email address - this.addUserNameEmailAddress(registeredContact); - - // Clear all data - this.clear(); - } - /** * Event observer when user confirmed account. *

@@ -461,6 +412,43 @@ public class AddressbookContactWebSessionBean extends BaseAddressbookController this.copyContact(event.getLoggedInUser().getUserContact()); } + /** + * Event observer for new user registrations + *

+ * @param event User registration event + */ + public void afterUserRegistrationEvent (@Observes final ObservableUserRegisteredEvent event) { + // event should not be null + if (null == event) { + // Throw NPE + throw new NullPointerException("event is null"); //NOI18N + } else if (event.getRegisteredUser() == null) { + // Throw NPE again + throw new NullPointerException("event.registeredUser is null"); //NOI18N + } else if (event.getRegisteredUser().getUserId() == null) { + // userId is null + throw new NullPointerException("event.registeredUser.userId is null"); //NOI18N + } else if (event.getRegisteredUser().getUserId() < 1) { + // Not avalid id + throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getRegisteredUser(), event.getRegisteredUser().getUserId())); //NOI18N + } + + // Get user instance + Contact registeredContact = event.getRegisteredUser().getUserContact(); + + // Copy all data from registered->user + this.copyContact(registeredContact); + + // Add contact instance only once + this.uniqueAddContact(registeredContact); + + // Add user name and email address + this.addUserNameEmailAddress(registeredContact); + + // Clear all data + this.clear(); + } + @Override @SuppressWarnings ("ReturnOfCollectionOrArrayField") public List allContacts () { @@ -631,26 +619,6 @@ public class AddressbookContactWebSessionBean extends BaseAddressbookController this.birthday = birthday; } - @Override - public MobileProvider getMobileCarrier () { - return this.mobileCarrier; - } - - @Override - public void setMobileCarrier (final MobileProvider mobileCarrier) { - this.mobileCarrier = mobileCarrier; - } - - @Override - public Long getMobileNumber () { - return this.mobileNumber; - } - - @Override - public void setMobileNumber (final Long mobileNumber) { - this.mobileNumber = mobileNumber; - } - @Override public String getCity () { return this.city; @@ -792,6 +760,26 @@ public class AddressbookContactWebSessionBean extends BaseAddressbookController this.houseNumberExtension = houseNumberExtension; } + @Override + public MobileProvider getMobileCarrier () { + return this.mobileCarrier; + } + + @Override + public void setMobileCarrier (final MobileProvider mobileCarrier) { + this.mobileCarrier = mobileCarrier; + } + + @Override + public Long getMobileNumber () { + return this.mobileNumber; + } + + @Override + public void setMobileNumber (final Long mobileNumber) { + this.mobileNumber = mobileNumber; + } + @Override public Integer getPhoneAreaCode () { return this.phoneAreaCode; @@ -853,10 +841,22 @@ public class AddressbookContactWebSessionBean extends BaseAddressbookController } /** - * Post-initialization of this class + * Post-construction method */ @PostConstruct public void init () { + // Try it + try { + // Get initial context + Context context = new InitialContext(); + + // Try to lookup + this.contactBean = (ContactSessionBeanRemote) context.lookup("java:global/addressbook-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote"); //NOI18N + } catch (final NamingException e) { + // Throw again + throw new FaceletException(e); + } + // Get full email address list for reducing EJB calls this.emailAddressList.addAll(this.contactBean.getEmailAddressList()); diff --git a/src/java/org/mxchange/addressbook/beans/contact/phone/AddressbookContactPhoneWebSessionBean.java b/src/java/org/mxchange/addressbook/beans/contact/phone/AddressbookContactPhoneWebSessionBean.java index 96219458..faebb4a6 100644 --- a/src/java/org/mxchange/addressbook/beans/contact/phone/AddressbookContactPhoneWebSessionBean.java +++ b/src/java/org/mxchange/addressbook/beans/contact/phone/AddressbookContactPhoneWebSessionBean.java @@ -22,6 +22,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Objects; +import javax.annotation.PostConstruct; import javax.enterprise.context.SessionScoped; import javax.enterprise.event.Observes; import javax.faces.view.facelets.FaceletException; @@ -80,18 +81,6 @@ public class AddressbookContactPhoneWebSessionBean extends BaseAddressbookContro * Default constructor */ public AddressbookContactPhoneWebSessionBean () { - // Try it - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup the beans - this.adminPhoneBean = (AdminPhoneSessionBeanRemote) context.lookup("java:global/addressbook-ejb/adminphone!org.mxchange.jphone.phonenumbers.phone.AdminPhoneSessionBeanRemote"); //NOI18N - } catch (final NamingException e) { - // Throw again - throw new FaceletException(e); - } - // Init lists/maps this.contacts = new HashMap<>(10); } @@ -199,6 +188,21 @@ public class AddressbookContactPhoneWebSessionBean extends BaseAddressbookContro } } + @PostConstruct + public void init () { + // Try it + try { + // Get initial context + Context context = new InitialContext(); + + // Try to lookup the beans + this.adminPhoneBean = (AdminPhoneSessionBeanRemote) context.lookup("java:global/addressbook-ejb/adminphone!org.mxchange.jphone.phonenumbers.phone.AdminPhoneSessionBeanRemote"); //NOI18N + } catch (final NamingException e) { + // Throw again + throw new FaceletException(e); + } + } + /** * Clears this bean */ diff --git a/src/java/org/mxchange/addressbook/beans/country/AddressbookAdminCountryWebRequestBean.java b/src/java/org/mxchange/addressbook/beans/country/AddressbookAdminCountryWebRequestBean.java index 28991e3a..3ed5fb32 100644 --- a/src/java/org/mxchange/addressbook/beans/country/AddressbookAdminCountryWebRequestBean.java +++ b/src/java/org/mxchange/addressbook/beans/country/AddressbookAdminCountryWebRequestBean.java @@ -19,6 +19,7 @@ package org.mxchange.addressbook.beans.country; import java.util.Iterator; import java.util.List; import java.util.Objects; +import javax.annotation.PostConstruct; import javax.enterprise.context.RequestScoped; import javax.enterprise.event.Event; import javax.enterprise.inject.Any; @@ -33,8 +34,8 @@ import org.mxchange.jcountry.data.Country; import org.mxchange.jcountry.data.CountryData; import org.mxchange.jcountry.data.CountrySingletonBeanRemote; import org.mxchange.jcountry.events.AdminAddedCountryEvent; -import org.mxchange.jcountry.exceptions.CountryAlreadyAddedException; import org.mxchange.jcountry.events.ObservableAdminAddedCountryEvent; +import org.mxchange.jcountry.exceptions.CountryAlreadyAddedException; /** * An administrative country bean @@ -102,17 +103,6 @@ public class AddressbookAdminCountryWebRequestBean extends BaseAddressbookContro * Default constructor */ public AddressbookAdminCountryWebRequestBean () { - // Try this - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup the bean - this.countryBean = (CountrySingletonBeanRemote) context.lookup("java:global/addressbook-ejb/country!org.mxchange.jcountry.data.CountrySingletonBeanRemote"); //NOI18N - } catch (final NamingException ex) { - // Continue to throw - throw new FaceletException(ex); - } } @Override @@ -215,6 +205,24 @@ public class AddressbookAdminCountryWebRequestBean extends BaseAddressbookContro this.countryPhoneCode = countryPhoneCode; } + /** + * Post-construction method + */ + @PostConstruct + public void init () { + // Try this + try { + // Get initial context + Context context = new InitialContext(); + + // Try to lookup the bean + this.countryBean = (CountrySingletonBeanRemote) context.lookup("java:global/addressbook-ejb/country!org.mxchange.jcountry.data.CountrySingletonBeanRemote"); //NOI18N + } catch (final NamingException ex) { + // Continue to throw + throw new FaceletException(ex); + } + } + /** * Clears this bean's data. This should be called after a form has been * submitted and the processing of the form was successful. diff --git a/src/java/org/mxchange/addressbook/beans/country/AddressbookCountryWebApplicationBean.java b/src/java/org/mxchange/addressbook/beans/country/AddressbookCountryWebApplicationBean.java index 5265fe0e..68366ba0 100644 --- a/src/java/org/mxchange/addressbook/beans/country/AddressbookCountryWebApplicationBean.java +++ b/src/java/org/mxchange/addressbook/beans/country/AddressbookCountryWebApplicationBean.java @@ -59,17 +59,6 @@ public class AddressbookCountryWebApplicationBean extends BaseAddressbookControl * Default constructor */ public AddressbookCountryWebApplicationBean () { - // Try this - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup the bean - this.countryBean = (CountrySingletonBeanRemote) context.lookup("java:global/addressbook-ejb/country!org.mxchange.jcountry.data.CountrySingletonBeanRemote"); //NOI18N - } catch (final NamingException ex) { - // Continue to throw - throw new FaceletException(ex); - } } /** @@ -106,10 +95,22 @@ public class AddressbookCountryWebApplicationBean extends BaseAddressbookControl } /** - * Post-initialization of this class + * Post-construction method */ @PostConstruct public void init () { + // Try this + try { + // Get initial context + Context context = new InitialContext(); + + // Try to lookup the bean + this.countryBean = (CountrySingletonBeanRemote) context.lookup("java:global/addressbook-ejb/country!org.mxchange.jcountry.data.CountrySingletonBeanRemote"); //NOI18N + } catch (final NamingException ex) { + // Continue to throw + throw new FaceletException(ex); + } + // "Cache" country list as this will not change so often. this.countryList = this.countryBean.allCountries(); } diff --git a/src/java/org/mxchange/addressbook/beans/email_address/AddressbookEmailChangeWebSessionBean.java b/src/java/org/mxchange/addressbook/beans/email_address/AddressbookEmailChangeWebSessionBean.java index 0f3dbf1f..cc88e110 100644 --- a/src/java/org/mxchange/addressbook/beans/email_address/AddressbookEmailChangeWebSessionBean.java +++ b/src/java/org/mxchange/addressbook/beans/email_address/AddressbookEmailChangeWebSessionBean.java @@ -19,6 +19,7 @@ package org.mxchange.addressbook.beans.email_address; import java.text.MessageFormat; import java.util.List; import java.util.Objects; +import javax.annotation.PostConstruct; import javax.enterprise.context.SessionScoped; import javax.faces.view.facelets.FaceletException; import javax.inject.Inject; @@ -69,7 +70,7 @@ public class AddressbookEmailChangeWebSessionBean extends BaseAddressbookControl /** * Remote email change bean */ - private final UserEmailChangeSessionBeanRemote emailBean; + private UserEmailChangeSessionBeanRemote emailBean; /** * Features controller @@ -87,20 +88,6 @@ public class AddressbookEmailChangeWebSessionBean extends BaseAddressbookControl * Default constructor */ public AddressbookEmailChangeWebSessionBean () { - // Try it - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup - this.emailBean = (UserEmailChangeSessionBeanRemote) context.lookup("java:global/addressbook-ejb/email-change!org.mxchange.jusercore.model.email_address.EmailChangeSessionBeanRemote"); //NOI18N - - // Init list - this.emailAddresses = this.emailBean.allQueuedAddresses(); - } catch (final NamingException e) { - // Throw again - throw new FaceletException(e); - } } @Override @@ -177,6 +164,27 @@ public class AddressbookEmailChangeWebSessionBean extends BaseAddressbookControl this.emailAddressRepeat = emailAddressRepeat; } + /** + * Post-construction method + */ + @PostConstruct + public void init () { + // Try it + try { + // Get initial context + Context context = new InitialContext(); + + // Try to lookup + this.emailBean = (UserEmailChangeSessionBeanRemote) context.lookup("java:global/addressbook-ejb/email-change!org.mxchange.jusercore.model.email_address.EmailChangeSessionBeanRemote"); //NOI18N + + // Init list + this.emailAddresses = this.emailBean.allQueuedAddresses(); + } catch (final NamingException e) { + // Throw again + throw new FaceletException(e); + } + } + @Override public boolean isRequiredChangeEmailAddressSet () { return ((this.getEmailAddress() != null) && diff --git a/src/java/org/mxchange/addressbook/beans/features/AddressbookFeatureWebApplicationBean.java b/src/java/org/mxchange/addressbook/beans/features/AddressbookFeatureWebApplicationBean.java index d0dc07b5..09ddd617 100644 --- a/src/java/org/mxchange/addressbook/beans/features/AddressbookFeatureWebApplicationBean.java +++ b/src/java/org/mxchange/addressbook/beans/features/AddressbookFeatureWebApplicationBean.java @@ -16,6 +16,7 @@ */ package org.mxchange.addressbook.beans.features; +import javax.annotation.PostConstruct; import javax.enterprise.context.ApplicationScoped; import javax.inject.Named; import org.mxchange.addressbook.beans.BaseAddressbookController; @@ -34,6 +35,19 @@ public class AddressbookFeatureWebApplicationBean extends BaseAddressbookControl */ private static final long serialVersionUID = 64_237_512_690_168_674L; + /** + * Default constructor + */ + public AddressbookFeatureWebApplicationBean () { + } + + /** + * Post-construction method + */ + @PostConstruct + public void init () { + } + @Override public boolean isFeatureEnabled (final String feature) { // The parameter must be set diff --git a/src/java/org/mxchange/addressbook/beans/gender/AddressbookGenderWebApplicationBean.java b/src/java/org/mxchange/addressbook/beans/gender/AddressbookGenderWebApplicationBean.java index 048441ec..5e6c65c4 100644 --- a/src/java/org/mxchange/addressbook/beans/gender/AddressbookGenderWebApplicationBean.java +++ b/src/java/org/mxchange/addressbook/beans/gender/AddressbookGenderWebApplicationBean.java @@ -17,6 +17,7 @@ package org.mxchange.addressbook.beans.gender; import java.util.List; +import javax.annotation.PostConstruct; import javax.enterprise.context.ApplicationScoped; import javax.inject.Named; import org.mxchange.addressbook.beans.BaseAddressbookController; @@ -58,4 +59,11 @@ public class AddressbookGenderWebApplicationBean extends BaseAddressbookControll return genders; } + /** + * Post-construction method + */ + @PostConstruct + public void init () { + } + } diff --git a/src/java/org/mxchange/addressbook/beans/helper/AddressbookWebRequestHelper.java b/src/java/org/mxchange/addressbook/beans/helper/AddressbookWebRequestHelper.java index 71392464..347f5301 100644 --- a/src/java/org/mxchange/addressbook/beans/helper/AddressbookWebRequestHelper.java +++ b/src/java/org/mxchange/addressbook/beans/helper/AddressbookWebRequestHelper.java @@ -17,6 +17,7 @@ package org.mxchange.addressbook.beans.helper; import java.text.MessageFormat; +import javax.annotation.PostConstruct; import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import javax.inject.Named; @@ -176,7 +177,14 @@ public class AddressbookWebRequestHelper implements AddressbookWebRequestControl } /** - * Set's all given contact's phone instances: land-line, cellphone and fax + * Post-construction method + */ + @PostConstruct + public void init () { + } + + /** + * Set's all given contact's phone instances: land-line, mobile and fax *

* @param contact Contact to set phone instances for */ @@ -196,7 +204,7 @@ public class AddressbookWebRequestHelper implements AddressbookWebRequestControl // Is cellphone set? if (contact.getContactMobileNumber() instanceof DialableMobileNumber) { // Yes, then set it in admin controller - this.adminPhoneController.setCellPhone(contact.getContactMobileNumber()); + this.adminPhoneController.setMobileNumber(contact.getContactMobileNumber()); } // Is land-line set? diff --git a/src/java/org/mxchange/addressbook/beans/localization/AddressbookLocalizationSessionBean.java b/src/java/org/mxchange/addressbook/beans/localization/AddressbookLocalizationSessionBean.java index 4b8dbb84..11bb92d7 100644 --- a/src/java/org/mxchange/addressbook/beans/localization/AddressbookLocalizationSessionBean.java +++ b/src/java/org/mxchange/addressbook/beans/localization/AddressbookLocalizationSessionBean.java @@ -49,6 +49,12 @@ public class AddressbookLocalizationSessionBean extends BaseAddressbookControlle */ private Locale locale; + /** + * Default constructor + */ + public AddressbookLocalizationSessionBean () { + } + /** * Event observer for logged-in user *

diff --git a/src/java/org/mxchange/addressbook/beans/login/AddressbookUserLoginWebSessionBean.java b/src/java/org/mxchange/addressbook/beans/login/AddressbookUserLoginWebSessionBean.java index 43ad2912..d2d405bb 100644 --- a/src/java/org/mxchange/addressbook/beans/login/AddressbookUserLoginWebSessionBean.java +++ b/src/java/org/mxchange/addressbook/beans/login/AddressbookUserLoginWebSessionBean.java @@ -20,6 +20,7 @@ import java.text.MessageFormat; import java.util.Collections; import java.util.List; import java.util.Objects; +import javax.annotation.PostConstruct; import javax.enterprise.context.SessionScoped; import javax.enterprise.event.Event; import javax.enterprise.event.Observes; @@ -136,22 +137,8 @@ public class AddressbookUserLoginWebSessionBean extends BaseAddressbookControlle * Default constructor */ public AddressbookUserLoginWebSessionBean () { - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup - this.userLoginBean = (UserLoginSessionBeanRemote) context.lookup("java:global/addressbook-ejb/login!org.mxchange.jusercore.model.login.UserLoginSessionBeanRemote"); //NOI18N - - // Also find this - this.userPasswordHistoryBean = (UserPasswordHistorySessionBeanRemote) context.lookup("java:global/addressbook-ejb/userPasswordHistory!org.mxchange.jusercore.model.user.password_history.UserPasswordHistorySessionBeanRemote"); //NOI18N - - // Defaul template is guest - this.baseTemplatePathName = GUEST_BASE_TEMPLATE_NAME; - } catch (final NamingException ex) { - // Continue to throw - throw new FaceletException(ex); - } + // Defaul template is guest + this.baseTemplatePathName = GUEST_BASE_TEMPLATE_NAME; } /** @@ -324,6 +311,26 @@ public class AddressbookUserLoginWebSessionBean extends BaseAddressbookControlle return (this.isUserLoggedIn() && this.getLoggedInUser().getUserMustChangePassword()); } + /** + * Post-construction method + */ + @PostConstruct + public void init () { + try { + // Get initial context + Context context = new InitialContext(); + + // Try to lookup + this.userLoginBean = (UserLoginSessionBeanRemote) context.lookup("java:global/addressbook-ejb/login!org.mxchange.jusercore.model.login.UserLoginSessionBeanRemote"); //NOI18N + + // Also find this + this.userPasswordHistoryBean = (UserPasswordHistorySessionBeanRemote) context.lookup("java:global/addressbook-ejb/userPasswordHistory!org.mxchange.jusercore.model.user.password_history.UserPasswordHistorySessionBeanRemote"); //NOI18N + } catch (final NamingException ex) { + // Continue to throw + throw new FaceletException(ex); + } + } + @Override public boolean isInvisible () { // Check on login diff --git a/src/java/org/mxchange/addressbook/beans/mobileprovider/AddressbookAdminMobileProviderWebRequestBean.java b/src/java/org/mxchange/addressbook/beans/mobileprovider/AddressbookAdminMobileProviderWebRequestBean.java index b8b98152..3cdee2aa 100644 --- a/src/java/org/mxchange/addressbook/beans/mobileprovider/AddressbookAdminMobileProviderWebRequestBean.java +++ b/src/java/org/mxchange/addressbook/beans/mobileprovider/AddressbookAdminMobileProviderWebRequestBean.java @@ -19,6 +19,7 @@ package org.mxchange.addressbook.beans.mobileprovider; import java.util.Iterator; import java.util.List; import java.util.Objects; +import javax.annotation.PostConstruct; import javax.enterprise.context.RequestScoped; import javax.enterprise.event.Event; import javax.enterprise.inject.Any; @@ -93,17 +94,6 @@ public class AddressbookAdminMobileProviderWebRequestBean extends BaseAddressboo * Default constructor */ public AddressbookAdminMobileProviderWebRequestBean () { - // Try it - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup the beans - this.adminRemoteBean = (AdminMobileProviderSessionBeanRemote) context.lookup("java:global/addressbook-ejb/adminMobileProvider!org.mxchange.jphone.phonenumbers.mobileprovider.AdminMobileProviderSessionBeanRemote"); //NOI18N - } catch (final NamingException e) { - // Throw it again - throw new FaceletException(e); - } } @Override @@ -176,6 +166,24 @@ public class AddressbookAdminMobileProviderWebRequestBean extends BaseAddressboo this.providerName = providerName; } + /** + * Post-construction method + */ + @PostConstruct + public void init () { + // Try it + try { + // Get initial context + Context context = new InitialContext(); + + // Try to lookup the beans + this.adminRemoteBean = (AdminMobileProviderSessionBeanRemote) context.lookup("java:global/addressbook-ejb/adminMobileProvider!org.mxchange.jphone.phonenumbers.mobileprovider.AdminMobileProviderSessionBeanRemote"); //NOI18N + } catch (final NamingException e) { + // Throw it again + throw new FaceletException(e); + } + } + /** * Checks whether if the given mobile provider is already created by * checking both dial prefix and country. diff --git a/src/java/org/mxchange/addressbook/beans/mobileprovider/AddressbookMobileProviderWebRequestBean.java b/src/java/org/mxchange/addressbook/beans/mobileprovider/AddressbookMobileProviderWebRequestBean.java index 90f094f6..2b2f8b54 100644 --- a/src/java/org/mxchange/addressbook/beans/mobileprovider/AddressbookMobileProviderWebRequestBean.java +++ b/src/java/org/mxchange/addressbook/beans/mobileprovider/AddressbookMobileProviderWebRequestBean.java @@ -59,17 +59,6 @@ public class AddressbookMobileProviderWebRequestBean extends BaseAddressbookCont * Default constructor */ public AddressbookMobileProviderWebRequestBean () { - // Try it - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup the beans - this.mobileRemoteBean = (MobileProviderSingletonBeanRemote) context.lookup("java:global/addressbook-ejb/mobileprovider!org.mxchange.jphone.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote"); //NOI18N - } catch (final NamingException e) { - // Throw it again - throw new FaceletException(e); - } } /** @@ -83,10 +72,10 @@ public class AddressbookMobileProviderWebRequestBean extends BaseAddressbookCont if (null == event) { // Throw NPE throw new NullPointerException("event is null"); //NOI18N - } else if (event.getAddedMobileProvider()== null) { + } else if (event.getAddedMobileProvider() == null) { // Throw again ... throw new NullPointerException("event.addedMobileProvider is null"); //NOI18N - } else if (event.getAddedMobileProvider().getProviderId()== null) { + } else if (event.getAddedMobileProvider().getProviderId() == null) { // And again ... throw new NullPointerException("event.addedMobileProvider.providerId is null"); //NOI18N } else if (event.getAddedMobileProvider().getProviderId() < 1) { @@ -105,10 +94,22 @@ public class AddressbookMobileProviderWebRequestBean extends BaseAddressbookCont } /** - * Initializer method + * Post-construction method */ @PostConstruct public void init () { + // Try it + try { + // Get initial context + Context context = new InitialContext(); + + // Try to lookup the beans + this.mobileRemoteBean = (MobileProviderSingletonBeanRemote) context.lookup("java:global/addressbook-ejb/mobileprovider!org.mxchange.jphone.phonenumbers.mobileprovider.MobileProviderSingletonBeanRemote"); //NOI18N + } catch (final NamingException e) { + // Throw it again + throw new FaceletException(e); + } + // Init list of mobile providers this.mobileProviders = this.mobileRemoteBean.allMobileProvider(); } diff --git a/src/java/org/mxchange/addressbook/beans/phone/AddressbookAdminPhoneWebRequestBean.java b/src/java/org/mxchange/addressbook/beans/phone/AddressbookAdminPhoneWebRequestBean.java index df484bcf..2d3811ac 100644 --- a/src/java/org/mxchange/addressbook/beans/phone/AddressbookAdminPhoneWebRequestBean.java +++ b/src/java/org/mxchange/addressbook/beans/phone/AddressbookAdminPhoneWebRequestBean.java @@ -16,6 +16,7 @@ */ package org.mxchange.addressbook.beans.phone; +import javax.annotation.PostConstruct; import javax.enterprise.context.RequestScoped; import javax.faces.view.facelets.FaceletException; import javax.inject.Named; @@ -24,9 +25,9 @@ import javax.naming.InitialContext; import javax.naming.NamingException; import org.mxchange.addressbook.beans.BaseAddressbookController; import org.mxchange.jcontacts.phone.AdminContactsPhoneSessionBeanRemote; -import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber; import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; +import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber; /** * Administrative bean (controller) for phone numbers @@ -47,11 +48,6 @@ public class AddressbookAdminPhoneWebRequestBean extends BaseAddressbookControll */ private AdminContactsPhoneSessionBeanRemote adminPhoneBean; - /** - * Cell phone number - */ - private DialableMobileNumber cellPhone; - /** * Fax number */ @@ -62,31 +58,15 @@ public class AddressbookAdminPhoneWebRequestBean extends BaseAddressbookControll */ private DialableLandLineNumber landLine; + /** + * Cell phone number + */ + private DialableMobileNumber mobileNumber; + /** * Default constructor */ public AddressbookAdminPhoneWebRequestBean () { - // Try it - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup the beans - this.adminPhoneBean = (AdminContactsPhoneSessionBeanRemote) context.lookup("java:global/addressbook-ejb/admincontactphone!org.mxchange.jcontacts.phone.AdminContactsPhoneSessionBeanRemote"); //NOI18N - } catch (final NamingException e) { - // Throw it again - throw new FaceletException(e); - } - } - - @Override - public DialableMobileNumber getMobileNumber () { - return this.cellPhone; - } - - @Override - public void setCellPhone (final DialableMobileNumber cellPhone) { - this.cellPhone = cellPhone; } @Override @@ -109,4 +89,32 @@ public class AddressbookAdminPhoneWebRequestBean extends BaseAddressbookControll this.landLine = landLine; } + @Override + public DialableMobileNumber getMobileNumber () { + return this.mobileNumber; + } + + @Override + public void setMobileNumber (final DialableMobileNumber mobileNumber) { + this.mobileNumber = mobileNumber; + } + + /** + * Post-construction method + */ + @PostConstruct + public void init () { + // Try it + try { + // Get initial context + Context context = new InitialContext(); + + // Try to lookup the beans + this.adminPhoneBean = (AdminContactsPhoneSessionBeanRemote) context.lookup("java:global/addressbook-ejb/admincontactphone!org.mxchange.jcontacts.phone.AdminContactsPhoneSessionBeanRemote"); //NOI18N + } catch (final NamingException e) { + // Throw it again + throw new FaceletException(e); + } + } + } diff --git a/src/java/org/mxchange/addressbook/beans/phone/AddressbookAdminPhoneWebRequestController.java b/src/java/org/mxchange/addressbook/beans/phone/AddressbookAdminPhoneWebRequestController.java index 7e068bc5..79730853 100644 --- a/src/java/org/mxchange/addressbook/beans/phone/AddressbookAdminPhoneWebRequestController.java +++ b/src/java/org/mxchange/addressbook/beans/phone/AddressbookAdminPhoneWebRequestController.java @@ -36,7 +36,7 @@ public interface AddressbookAdminPhoneWebRequestController extends Serializable *

* @param cellPhone Dialable cellphone number instance */ - void setCellPhone (final DialableMobileNumber cellPhone); + void setMobileNumber (final DialableMobileNumber cellPhone); /** * Getter for dialable cellphone number instance diff --git a/src/java/org/mxchange/addressbook/beans/profile/AddressbookUserProfileWebRequestBean.java b/src/java/org/mxchange/addressbook/beans/profile/AddressbookUserProfileWebRequestBean.java index 569f63d6..1aae30fc 100644 --- a/src/java/org/mxchange/addressbook/beans/profile/AddressbookUserProfileWebRequestBean.java +++ b/src/java/org/mxchange/addressbook/beans/profile/AddressbookUserProfileWebRequestBean.java @@ -17,6 +17,7 @@ package org.mxchange.addressbook.beans.profile; import java.text.MessageFormat; +import javax.annotation.PostConstruct; import javax.enterprise.context.RequestScoped; import javax.faces.view.facelets.FaceletException; import javax.inject.Inject; @@ -42,6 +43,12 @@ public class AddressbookUserProfileWebRequestBean extends BaseAddressbookControl */ private static final long serialVersionUID = 187_687_145_286_710L; + /** + * User controller + */ + @Inject + private AddressbookUserWebSessionController userController; + /** * Login controller */ @@ -49,10 +56,17 @@ public class AddressbookUserProfileWebRequestBean extends BaseAddressbookControl private AddressbookUserLoginWebSessionController userLoginController; /** - * User controller + * Default constructor */ - @Inject - private AddressbookUserWebSessionController userController; + public AddressbookUserProfileWebRequestBean () { + } + + /** + * Post-construction method + */ + @PostConstruct + public void init () { + } @Override public boolean isProfileLinkVisibleById (final Long userId) { diff --git a/src/java/org/mxchange/addressbook/beans/profilemode/AddressbookProfileModeWebApplicationBean.java b/src/java/org/mxchange/addressbook/beans/profilemode/AddressbookProfileModeWebApplicationBean.java index 8292e882..b0ee1649 100644 --- a/src/java/org/mxchange/addressbook/beans/profilemode/AddressbookProfileModeWebApplicationBean.java +++ b/src/java/org/mxchange/addressbook/beans/profilemode/AddressbookProfileModeWebApplicationBean.java @@ -16,6 +16,7 @@ */ package org.mxchange.addressbook.beans.profilemode; +import javax.annotation.PostConstruct; import javax.enterprise.context.ApplicationScoped; import javax.inject.Named; import org.mxchange.addressbook.beans.BaseAddressbookController; @@ -46,4 +47,12 @@ public class AddressbookProfileModeWebApplicationBean extends BaseAddressbookCon // Return it return ProfileMode.values(); } + + /** + * Post-construction method + */ + @PostConstruct + public void init () { + } + } diff --git a/src/java/org/mxchange/addressbook/beans/register/AddressbookUserRegisterWebSessionBean.java b/src/java/org/mxchange/addressbook/beans/register/AddressbookUserRegisterWebSessionBean.java index b0b38d78..6ff49fe3 100644 --- a/src/java/org/mxchange/addressbook/beans/register/AddressbookUserRegisterWebSessionBean.java +++ b/src/java/org/mxchange/addressbook/beans/register/AddressbookUserRegisterWebSessionBean.java @@ -17,6 +17,7 @@ package org.mxchange.addressbook.beans.register; import java.text.MessageFormat; +import javax.annotation.PostConstruct; import javax.enterprise.context.SessionScoped; import javax.enterprise.event.Event; import javax.enterprise.inject.Any; @@ -34,6 +35,7 @@ import org.mxchange.addressbook.beans.user.AddressbookUserWebSessionController; import org.mxchange.jcontacts.contact.Contact; import org.mxchange.jcontacts.contact.UserContact; import org.mxchange.jcoreee.utils.FacesUtils; +import org.mxchange.jusercore.events.registration.ObservableUserRegisteredEvent; import org.mxchange.jusercore.events.registration.UserRegisteredEvent; import org.mxchange.jusercore.exceptions.DataRepeatMismatchException; import org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException; @@ -42,7 +44,6 @@ import org.mxchange.jusercore.model.register.UserRegistrationSessionBeanRemote; import org.mxchange.jusercore.model.user.User; import org.mxchange.jusercore.model.user.UserUtils; import org.mxchange.jusercore.model.user.status.UserAccountStatus; -import org.mxchange.jusercore.events.registration.ObservableUserRegisteredEvent; /** * A web bean for user registration @@ -98,16 +99,6 @@ public class AddressbookUserRegisterWebSessionBean extends BaseAddressbookContro * Default constructor */ public AddressbookUserRegisterWebSessionBean () { - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup - this.registerBean = (UserRegistrationSessionBeanRemote) context.lookup("java:global/addressbook-ejb/register!org.mxchange.jusercore.model.register.UserRegistrationSessionBeanRemote"); //NOI18N - } catch (final NamingException ex) { - // Continue to throw - throw new FaceletException(ex); - } } @Override @@ -224,4 +215,21 @@ public class AddressbookUserRegisterWebSessionBean extends BaseAddressbookContro return "user_register_page2"; //NOI18N } + /** + * Post-construction method + */ + @PostConstruct + public void init () { + try { + // Get initial context + Context context = new InitialContext(); + + // Try to lookup + this.registerBean = (UserRegistrationSessionBeanRemote) context.lookup("java:global/addressbook-ejb/register!org.mxchange.jusercore.model.register.UserRegistrationSessionBeanRemote"); //NOI18N + } catch (final NamingException ex) { + // Continue to throw + throw new FaceletException(ex); + } + } + } diff --git a/src/java/org/mxchange/addressbook/beans/resendlink/AddressbookResendLinkWebSessionBean.java b/src/java/org/mxchange/addressbook/beans/resendlink/AddressbookResendLinkWebSessionBean.java index 21e9e05a..2da5a7b7 100644 --- a/src/java/org/mxchange/addressbook/beans/resendlink/AddressbookResendLinkWebSessionBean.java +++ b/src/java/org/mxchange/addressbook/beans/resendlink/AddressbookResendLinkWebSessionBean.java @@ -17,6 +17,7 @@ package org.mxchange.addressbook.beans.resendlink; import java.text.MessageFormat; +import javax.annotation.PostConstruct; import javax.enterprise.context.SessionScoped; import javax.faces.view.facelets.FaceletException; import javax.inject.Inject; @@ -74,17 +75,6 @@ public class AddressbookResendLinkWebSessionBean extends BaseAddressbookControll * Default constructor */ public AddressbookResendLinkWebSessionBean () { - // Try it - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup - this.emailBean = (ResendLinkSessionBeanRemote) context.lookup("java:global/addressbook-ejb/resendLink!org.mxchange.addressbook.beans.resendlink.ResendLinkSessionBeanRemote"); //NOI18N - } catch (final NamingException e) { - // Throw again - throw new FaceletException(e); - } } @Override @@ -152,6 +142,24 @@ public class AddressbookResendLinkWebSessionBean extends BaseAddressbookControll this.emailAddress = emailAddress; } + /** + * Post-construction method + */ + @PostConstruct + public void init () { + // Try it + try { + // Get initial context + Context context = new InitialContext(); + + // Try to lookup + this.emailBean = (ResendLinkSessionBeanRemote) context.lookup("java:global/addressbook-ejb/resendLink!org.mxchange.addressbook.beans.resendlink.ResendLinkSessionBeanRemote"); //NOI18N + } catch (final NamingException e) { + // Throw again + throw new FaceletException(e); + } + } + /** * Clears email address fields so the user has to re-enter them */ diff --git a/src/java/org/mxchange/addressbook/beans/user/AddressbookAdminUserWebRequestBean.java b/src/java/org/mxchange/addressbook/beans/user/AddressbookAdminUserWebRequestBean.java index 1bd9b687..78f07c3c 100644 --- a/src/java/org/mxchange/addressbook/beans/user/AddressbookAdminUserWebRequestBean.java +++ b/src/java/org/mxchange/addressbook/beans/user/AddressbookAdminUserWebRequestBean.java @@ -18,6 +18,7 @@ package org.mxchange.addressbook.beans.user; import java.text.MessageFormat; import java.util.Objects; +import javax.annotation.PostConstruct; import javax.enterprise.context.RequestScoped; import javax.enterprise.event.Event; import javax.enterprise.event.Observes; @@ -88,7 +89,7 @@ public class AddressbookAdminUserWebRequestBean extends BaseAddressbookControlle /** * Administrative user EJB */ - private final AdminUserSessionBeanRemote adminUserBean; + private AdminUserSessionBeanRemote adminUserBean; /** * Bean helper instance @@ -112,7 +113,7 @@ public class AddressbookAdminUserWebRequestBean extends BaseAddressbookControlle /** * General user EJB */ - private final UserSessionBeanRemote userBean; + private UserSessionBeanRemote userBean; /** * Regular user controller @@ -157,18 +158,6 @@ public class AddressbookAdminUserWebRequestBean extends BaseAddressbookControlle * Default constructor */ public AddressbookAdminUserWebRequestBean () { - // Try it - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup - this.userBean = (UserSessionBeanRemote) context.lookup("java:global/addressbook-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N - this.adminUserBean = (AdminUserSessionBeanRemote) context.lookup("java:global/addressbook-ejb/adminUser!org.mxchange.jusercore.model.user.AdminUserSessionBeanRemote"); //NOI18N - } catch (final NamingException e) { - // Throw again - throw new FaceletException(e); - } } @Override @@ -441,6 +430,25 @@ public class AddressbookAdminUserWebRequestBean extends BaseAddressbookControlle this.userPasswordRepeat = userPasswordRepeat; } + /** + * Post-construction method + */ + @PostConstruct + public void init () { + // Try it + try { + // Get initial context + Context context = new InitialContext(); + + // Try to lookup + this.userBean = (UserSessionBeanRemote) context.lookup("java:global/addressbook-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N + this.adminUserBean = (AdminUserSessionBeanRemote) context.lookup("java:global/addressbook-ejb/adminUser!org.mxchange.jusercore.model.user.AdminUserSessionBeanRemote"); //NOI18N + } catch (final NamingException e) { + // Throw again + throw new FaceletException(e); + } + } + @Override public String lockUserAccount (final User user) { // Is the user instance valid and CONFIRMED? diff --git a/src/java/org/mxchange/addressbook/beans/user/AddressbookUserWebSessionBean.java b/src/java/org/mxchange/addressbook/beans/user/AddressbookUserWebSessionBean.java index 07d12cf2..26f9dd10 100644 --- a/src/java/org/mxchange/addressbook/beans/user/AddressbookUserWebSessionBean.java +++ b/src/java/org/mxchange/addressbook/beans/user/AddressbookUserWebSessionBean.java @@ -38,7 +38,6 @@ import org.mxchange.addressbook.beans.features.AddressbookFeaturesWebApplication import org.mxchange.addressbook.beans.localization.AddressbookLocalizationSessionController; import org.mxchange.addressbook.beans.login.AddressbookUserLoginWebSessionController; import org.mxchange.jcontacts.contact.Contact; -import org.mxchange.jcontacts.contact.ContactSessionBeanRemote; import org.mxchange.jusercore.events.confirmation.ObservableUserConfirmedAccountEvent; import org.mxchange.jusercore.events.login.ObservableUserLoggedInEvent; import org.mxchange.jusercore.events.registration.ObservableUserRegisteredEvent; @@ -70,11 +69,6 @@ public class AddressbookUserWebSessionBean extends BaseAddressbookController imp */ private static final long serialVersionUID = 542_145_347_916L; - /** - * Contact EJB - */ - private ContactSessionBeanRemote contactBean; - /** * General contact controller */ @@ -103,7 +97,7 @@ public class AddressbookUserWebSessionBean extends BaseAddressbookController imp /** * Remote user bean */ - private final UserSessionBeanRemote userBean; + private UserSessionBeanRemote userBean; /** * User id @@ -158,24 +152,10 @@ public class AddressbookUserWebSessionBean extends BaseAddressbookController imp * Default constructor */ public AddressbookUserWebSessionBean () { - // Try it - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup - this.userBean = (UserSessionBeanRemote) context.lookup("java:global/addressbook-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N - - // Try to lookup - this.contactBean = (ContactSessionBeanRemote) context.lookup("java:global/addressbook-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote"); //NOI18N - } catch (final NamingException e) { - // Throw again - throw new FaceletException(e); - } } /** - * Event observer for newly added users by adminstrator + * Event observer for newly added users by administrator *

* @param event Event being fired */ @@ -602,6 +582,18 @@ public class AddressbookUserWebSessionBean extends BaseAddressbookController imp */ @PostConstruct public void init () { + // Try it + try { + // Get initial context + Context context = new InitialContext(); + + // Try to lookup + this.userBean = (UserSessionBeanRemote) context.lookup("java:global/addressbook-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N + } catch (final NamingException e) { + // Throw again + throw new FaceletException(e); + } + // Initialize user list this.userList = this.userBean.allUsers(); diff --git a/src/java/org/mxchange/addressbook/beans/user/password/AddressbookUserPasswordWebRequestBean.java b/src/java/org/mxchange/addressbook/beans/user/password/AddressbookUserPasswordWebRequestBean.java index 04f61277..63e0de0f 100644 --- a/src/java/org/mxchange/addressbook/beans/user/password/AddressbookUserPasswordWebRequestBean.java +++ b/src/java/org/mxchange/addressbook/beans/user/password/AddressbookUserPasswordWebRequestBean.java @@ -17,6 +17,7 @@ package org.mxchange.addressbook.beans.user.password; import java.util.Objects; +import javax.annotation.PostConstruct; import javax.enterprise.context.RequestScoped; import javax.enterprise.event.Event; import javax.enterprise.inject.Any; @@ -30,6 +31,7 @@ import org.mxchange.addressbook.beans.BaseAddressbookController; import org.mxchange.addressbook.beans.features.AddressbookFeaturesWebApplicationController; import org.mxchange.addressbook.beans.login.AddressbookUserLoginWebSessionController; import org.mxchange.jcoreee.utils.FacesUtils; +import org.mxchange.jusercore.events.user.password_change.ObservableUpdatedUserPasswordEvent; import org.mxchange.jusercore.events.user.password_change.UpdatedUserPasswordEvent; import org.mxchange.jusercore.exceptions.UserNotFoundException; import org.mxchange.jusercore.exceptions.UserPasswordMismatchException; @@ -39,7 +41,6 @@ import org.mxchange.jusercore.model.user.User; import org.mxchange.jusercore.model.user.UserSessionBeanRemote; import org.mxchange.jusercore.model.user.UserUtils; import org.mxchange.jusercore.model.user.password_history.PasswordHistory; -import org.mxchange.jusercore.events.user.password_change.ObservableUpdatedUserPasswordEvent; /** * A user password (change) bean (controller) @@ -64,7 +65,7 @@ public class AddressbookUserPasswordWebRequestBean extends BaseAddressbookContro /** * Remote user bean */ - private final UserSessionBeanRemote userBean; + private UserSessionBeanRemote userBean; /** * Current password (for confirmation of password change) @@ -98,17 +99,6 @@ public class AddressbookUserPasswordWebRequestBean extends BaseAddressbookContro * Default constructor */ public AddressbookUserPasswordWebRequestBean () { - // Try it - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup - this.userBean = (UserSessionBeanRemote) context.lookup("java:global/addressbook-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N - } catch (final NamingException e) { - // Throw again - throw new FaceletException(e); - } } @Override @@ -227,6 +217,25 @@ public class AddressbookUserPasswordWebRequestBean extends BaseAddressbookContro this.userPasswordRepeat = userPasswordRepeat; } + /** + * Post-initialization of this class + */ + @PostConstruct + public void init () { + // Try it + try { + // Get initial context + Context context = new InitialContext(); + + // Try to lookup + this.userBean = (UserSessionBeanRemote) context.lookup("java:global/addressbook-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N + } catch (final NamingException e) { + // Throw again + throw new FaceletException(e); + } + } + + @Override public boolean isRequiredChangePasswordSet () { // Is all data set? return ((this.getUserCurrentPassword() != null) && diff --git a/src/java/org/mxchange/addressbook/beans/user/password/AddressbookUserPasswordWebRequestController.java b/src/java/org/mxchange/addressbook/beans/user/password/AddressbookUserPasswordWebRequestController.java index 01fc52a5..c8bfd45f 100644 --- a/src/java/org/mxchange/addressbook/beans/user/password/AddressbookUserPasswordWebRequestController.java +++ b/src/java/org/mxchange/addressbook/beans/user/password/AddressbookUserPasswordWebRequestController.java @@ -70,10 +70,19 @@ public interface AddressbookUserPasswordWebRequestController extends Serializabl void setUserPasswordRepeat (final String userPasswordRepeat); /** - * Changes logged-in user's password. It must not match with current password and should not appear in password history list for X (configurable) entries. + * Changes logged-in user's password. It must not match with current + * password and should not appear in password history list for X + * (configurable) entries. *

* @return Redirect outcome */ String doChangePassword (); + /** + * Checks if all 3 passwords are set: old password, 2x new password + *

+ * @return Whether all passwords are set + */ + boolean isRequiredChangePasswordSet (); + }