From 2c9def5a7d0939bdffce3ad9b489e54874f1d9d6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 21 Apr 2017 22:17:19 +0200 Subject: [PATCH] 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 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- ...ancialsConfirmationLinkWebRequestBean.java | 10 +- .../FinancialsAdminContactWebRequestBean.java | 24 +-- .../FinancialsContactWebSessionBean.java | 170 +++++++++--------- .../FinancialsContactPhoneWebSessionBean.java | 29 +-- .../FinancialsAdminCountryWebRequestBean.java | 34 ++-- .../FinancialsCountryWebApplicationBean.java | 25 +-- .../FinancialsEmailChangeWebSessionBean.java | 38 ++-- .../FinancialsFeatureWebApplicationBean.java | 14 ++ .../FinancialsGenderWebApplicationBean.java | 10 +- .../helper/FinancialsWebRequestHelper.java | 10 +- .../FinancialsLocalizationSessionBean.java | 6 + .../FinancialsUserLoginWebSessionBean.java | 39 ++-- ...ialsAdminMobileProviderWebRequestBean.java | 32 ++-- ...inancialsMobileProviderWebRequestBean.java | 29 +-- .../FinancialsAdminPhoneWebRequestBean.java | 64 ++++--- ...ancialsAdminPhoneWebRequestController.java | 2 +- .../FinancialsUserProfileWebRequestBean.java | 24 ++- ...nancialsProfileModeWebApplicationBean.java | 9 + .../FinancialsUserRegisterWebSessionBean.java | 28 +-- .../FinancialsResendLinkWebSessionBean.java | 30 ++-- .../FinancialsAdminUserWebRequestBean.java | 36 ++-- .../user/FinancialsUserWebSessionBean.java | 36 ++-- .../FinancialsUserPasswordWebRequestBean.java | 41 +++-- ...cialsUserPasswordWebRequestController.java | 11 +- 24 files changed, 449 insertions(+), 302 deletions(-) diff --git a/src/java/org/mxchange/jfinancials/beans/confirmlink/FinancialsConfirmationLinkWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/confirmlink/FinancialsConfirmationLinkWebRequestBean.java index 3269e1a2..296c28c6 100644 --- a/src/java/org/mxchange/jfinancials/beans/confirmlink/FinancialsConfirmationLinkWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/confirmlink/FinancialsConfirmationLinkWebRequestBean.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; @@ -69,7 +70,7 @@ public class FinancialsConfirmationLinkWebRequestBean extends BaseFinancialsCont /** * Remote user bean */ - private final UserSessionBeanRemote userBean; + private UserSessionBeanRemote userBean; /** * Event being fired when a user has confirmed the account @@ -88,6 +89,13 @@ public class FinancialsConfirmationLinkWebRequestBean extends BaseFinancialsCont * Default constructor */ public FinancialsConfirmationLinkWebRequestBean () { + } + + /** + * Post-construction method + */ + @PostConstruct + public void init () { // Try it try { // Get initial context diff --git a/src/java/org/mxchange/jfinancials/beans/contact/FinancialsAdminContactWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/contact/FinancialsAdminContactWebRequestBean.java index c632274a..b723b6d2 100644 --- a/src/java/org/mxchange/jfinancials/beans/contact/FinancialsAdminContactWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/contact/FinancialsAdminContactWebRequestBean.java @@ -103,7 +103,7 @@ public class FinancialsAdminContactWebRequestBean extends BaseFinancialsControll /** * Remote contact bean */ - private final ContactSessionBeanRemote contactBean; + private ContactSessionBeanRemote contactBean; /** * General contact controller @@ -247,17 +247,6 @@ public class FinancialsAdminContactWebRequestBean extends BaseFinancialsControll * Default constructor */ public FinancialsAdminContactWebRequestBean () { - // Try it - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup - this.contactBean = (ContactSessionBeanRemote) context.lookup("java:global/jfinancials-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 FinancialsAdminContactWebRequestBean extends BaseFinancialsControll */ @PostConstruct public void init () { + // Try it + try { + // Get initial context + Context context = new InitialContext(); + + // Try to lookup + this.contactBean = (ContactSessionBeanRemote) context.lookup("java:global/jfinancials-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/jfinancials/beans/contact/FinancialsContactWebSessionBean.java b/src/java/org/mxchange/jfinancials/beans/contact/FinancialsContactWebSessionBean.java index f7e085ce..1aeb0cfe 100644 --- a/src/java/org/mxchange/jfinancials/beans/contact/FinancialsContactWebSessionBean.java +++ b/src/java/org/mxchange/jfinancials/beans/contact/FinancialsContactWebSessionBean.java @@ -78,16 +78,6 @@ public class FinancialsContactWebSessionBean extends BaseFinancialsController im */ private Date birthday; - /** - * Mobile number's carrier - */ - private MobileProvider mobileCarrier; - - /** - * Mobile number - */ - private Long mobileNumber; - /** * City */ @@ -101,7 +91,7 @@ public class FinancialsContactWebSessionBean extends BaseFinancialsController im /** * Remote contact bean */ - private final ContactSessionBeanRemote contactBean; + private ContactSessionBeanRemote contactBean; /** * Contact list @@ -168,20 +158,30 @@ public class FinancialsContactWebSessionBean extends BaseFinancialsController im */ 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 FinancialsContactWebSessionBean extends BaseFinancialsController im * Default constructor */ public FinancialsContactWebSessionBean () { - // Try it - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup - this.contactBean = (ContactSessionBeanRemote) context.lookup("java:global/jfinancials-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<>(); @@ -368,43 +356,6 @@ public class FinancialsContactWebSessionBean extends BaseFinancialsController im this.emailAddressList.add(event.getUpdatedContact().getContactEmailAddress()); } - /** - * 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. *

@@ -455,6 +406,43 @@ public class FinancialsContactWebSessionBean extends BaseFinancialsController im 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 () { @@ -613,26 +601,6 @@ public class FinancialsContactWebSessionBean extends BaseFinancialsController im 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; @@ -774,6 +742,26 @@ public class FinancialsContactWebSessionBean extends BaseFinancialsController im 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; @@ -835,10 +823,22 @@ public class FinancialsContactWebSessionBean extends BaseFinancialsController im } /** - * 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/jfinancials-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/jfinancials/beans/contact/phone/FinancialsContactPhoneWebSessionBean.java b/src/java/org/mxchange/jfinancials/beans/contact/phone/FinancialsContactPhoneWebSessionBean.java index cc9f9862..068d03d0 100644 --- a/src/java/org/mxchange/jfinancials/beans/contact/phone/FinancialsContactPhoneWebSessionBean.java +++ b/src/java/org/mxchange/jfinancials/beans/contact/phone/FinancialsContactPhoneWebSessionBean.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 FinancialsContactPhoneWebSessionBean extends BaseFinancialsControll * Default constructor */ public FinancialsContactPhoneWebSessionBean () { - // Try it - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup the beans - this.adminPhoneBean = (AdminPhoneSessionBeanRemote) context.lookup("java:global/jfinancials-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,22 @@ public class FinancialsContactPhoneWebSessionBean extends BaseFinancialsControll } } + @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/jfinancials-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/jfinancials/beans/country/FinancialsAdminCountryWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/country/FinancialsAdminCountryWebRequestBean.java index 6983e06f..94bde72f 100644 --- a/src/java/org/mxchange/jfinancials/beans/country/FinancialsAdminCountryWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/country/FinancialsAdminCountryWebRequestBean.java @@ -19,6 +19,7 @@ package org.mxchange.jfinancials.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; @@ -28,13 +29,13 @@ import javax.inject.Named; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; -import org.mxchange.jfinancials.beans.BaseFinancialsController; 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; +import org.mxchange.jfinancials.beans.BaseFinancialsController; /** * An administrative country bean @@ -102,17 +103,6 @@ public class FinancialsAdminCountryWebRequestBean extends BaseFinancialsControll * Default constructor */ public FinancialsAdminCountryWebRequestBean () { - // Try this - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup the bean - this.countryBean = (CountrySingletonBeanRemote) context.lookup("java:global/jfinancials-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 FinancialsAdminCountryWebRequestBean extends BaseFinancialsControll 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/jfinancials-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/jfinancials/beans/country/FinancialsCountryWebApplicationBean.java b/src/java/org/mxchange/jfinancials/beans/country/FinancialsCountryWebApplicationBean.java index af4bef91..aae836a1 100644 --- a/src/java/org/mxchange/jfinancials/beans/country/FinancialsCountryWebApplicationBean.java +++ b/src/java/org/mxchange/jfinancials/beans/country/FinancialsCountryWebApplicationBean.java @@ -59,17 +59,6 @@ public class FinancialsCountryWebApplicationBean extends BaseFinancialsControlle * Default constructor */ public FinancialsCountryWebApplicationBean () { - // Try this - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup the bean - this.countryBean = (CountrySingletonBeanRemote) context.lookup("java:global/jfinancials-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 FinancialsCountryWebApplicationBean extends BaseFinancialsControlle } /** - * 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/jfinancials-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/jfinancials/beans/email_address/FinancialsEmailChangeWebSessionBean.java b/src/java/org/mxchange/jfinancials/beans/email_address/FinancialsEmailChangeWebSessionBean.java index 145bfcd2..99a501b2 100644 --- a/src/java/org/mxchange/jfinancials/beans/email_address/FinancialsEmailChangeWebSessionBean.java +++ b/src/java/org/mxchange/jfinancials/beans/email_address/FinancialsEmailChangeWebSessionBean.java @@ -19,6 +19,7 @@ package org.mxchange.jfinancials.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 FinancialsEmailChangeWebSessionBean extends BaseFinancialsControlle /** * Remote email change bean */ - private final UserEmailChangeSessionBeanRemote emailBean; + private UserEmailChangeSessionBeanRemote emailBean; /** * Features controller @@ -87,20 +88,6 @@ public class FinancialsEmailChangeWebSessionBean extends BaseFinancialsControlle * Default constructor */ public FinancialsEmailChangeWebSessionBean () { - // Try it - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup - this.emailBean = (UserEmailChangeSessionBeanRemote) context.lookup("java:global/jfinancials-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 FinancialsEmailChangeWebSessionBean extends BaseFinancialsControlle 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/jfinancials-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/jfinancials/beans/features/FinancialsFeatureWebApplicationBean.java b/src/java/org/mxchange/jfinancials/beans/features/FinancialsFeatureWebApplicationBean.java index 2411781b..03e96e18 100644 --- a/src/java/org/mxchange/jfinancials/beans/features/FinancialsFeatureWebApplicationBean.java +++ b/src/java/org/mxchange/jfinancials/beans/features/FinancialsFeatureWebApplicationBean.java @@ -16,6 +16,7 @@ */ package org.mxchange.jfinancials.beans.features; +import javax.annotation.PostConstruct; import javax.enterprise.context.ApplicationScoped; import javax.inject.Named; import org.mxchange.jfinancials.beans.BaseFinancialsController; @@ -34,6 +35,19 @@ public class FinancialsFeatureWebApplicationBean extends BaseFinancialsControlle */ private static final long serialVersionUID = 64_237_512_690_168_674L; + /** + * Default constructor + */ + public FinancialsFeatureWebApplicationBean () { + } + + /** + * 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/jfinancials/beans/gender/FinancialsGenderWebApplicationBean.java b/src/java/org/mxchange/jfinancials/beans/gender/FinancialsGenderWebApplicationBean.java index 0883dbfa..ab117590 100644 --- a/src/java/org/mxchange/jfinancials/beans/gender/FinancialsGenderWebApplicationBean.java +++ b/src/java/org/mxchange/jfinancials/beans/gender/FinancialsGenderWebApplicationBean.java @@ -17,11 +17,12 @@ package org.mxchange.jfinancials.beans.gender; import java.util.List; +import javax.annotation.PostConstruct; import javax.enterprise.context.ApplicationScoped; import javax.inject.Named; -import org.mxchange.jfinancials.beans.BaseFinancialsController; import org.mxchange.jcontacts.contact.gender.Gender; import org.mxchange.jcontacts.contact.gender.GenderUtils; +import org.mxchange.jfinancials.beans.BaseFinancialsController; /** * A gender bean @@ -58,4 +59,11 @@ public class FinancialsGenderWebApplicationBean extends BaseFinancialsController return genders; } + /** + * Post-construction method + */ + @PostConstruct + public void init () { + } + } diff --git a/src/java/org/mxchange/jfinancials/beans/helper/FinancialsWebRequestHelper.java b/src/java/org/mxchange/jfinancials/beans/helper/FinancialsWebRequestHelper.java index ba416618..d496d369 100644 --- a/src/java/org/mxchange/jfinancials/beans/helper/FinancialsWebRequestHelper.java +++ b/src/java/org/mxchange/jfinancials/beans/helper/FinancialsWebRequestHelper.java @@ -17,6 +17,7 @@ package org.mxchange.jfinancials.beans.helper; import java.text.MessageFormat; +import javax.annotation.PostConstruct; import javax.enterprise.context.RequestScoped; import javax.inject.Inject; import javax.inject.Named; @@ -175,6 +176,13 @@ public class FinancialsWebRequestHelper implements FinancialsWebRequestControlle this.user = user; } + /** + * Post-construction method + */ + @PostConstruct + public void init () { + } + /** * Set's all given contact's phone instances: land-line, mobile and fax *

@@ -196,7 +204,7 @@ public class FinancialsWebRequestHelper implements FinancialsWebRequestControlle // Is mobile 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/jfinancials/beans/localization/FinancialsLocalizationSessionBean.java b/src/java/org/mxchange/jfinancials/beans/localization/FinancialsLocalizationSessionBean.java index 16f669f7..ca7e927f 100644 --- a/src/java/org/mxchange/jfinancials/beans/localization/FinancialsLocalizationSessionBean.java +++ b/src/java/org/mxchange/jfinancials/beans/localization/FinancialsLocalizationSessionBean.java @@ -49,6 +49,12 @@ public class FinancialsLocalizationSessionBean extends BaseFinancialsController */ private Locale locale; + /** + * Default constructor + */ + public FinancialsLocalizationSessionBean () { + } + /** * Event observer for logged-in user *

diff --git a/src/java/org/mxchange/jfinancials/beans/login/FinancialsUserLoginWebSessionBean.java b/src/java/org/mxchange/jfinancials/beans/login/FinancialsUserLoginWebSessionBean.java index edeca07b..8d6917e3 100644 --- a/src/java/org/mxchange/jfinancials/beans/login/FinancialsUserLoginWebSessionBean.java +++ b/src/java/org/mxchange/jfinancials/beans/login/FinancialsUserLoginWebSessionBean.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 FinancialsUserLoginWebSessionBean extends BaseFinancialsController * Default constructor */ public FinancialsUserLoginWebSessionBean () { - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup - this.userLoginBean = (UserLoginSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/login!org.mxchange.jusercore.model.login.UserLoginSessionBeanRemote"); //NOI18N - - // Also find this - this.userPasswordHistoryBean = (UserPasswordHistorySessionBeanRemote) context.lookup("java:global/jfinancials-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 FinancialsUserLoginWebSessionBean extends BaseFinancialsController 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/jfinancials-ejb/login!org.mxchange.jusercore.model.login.UserLoginSessionBeanRemote"); //NOI18N + + // Also find this + this.userPasswordHistoryBean = (UserPasswordHistorySessionBeanRemote) context.lookup("java:global/jfinancials-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/jfinancials/beans/mobileprovider/FinancialsAdminMobileProviderWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/mobileprovider/FinancialsAdminMobileProviderWebRequestBean.java index bc9b3613..6f6b8f64 100644 --- a/src/java/org/mxchange/jfinancials/beans/mobileprovider/FinancialsAdminMobileProviderWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/mobileprovider/FinancialsAdminMobileProviderWebRequestBean.java @@ -19,6 +19,7 @@ package org.mxchange.jfinancials.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; @@ -28,8 +29,8 @@ import javax.inject.Named; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; -import org.mxchange.jfinancials.beans.BaseFinancialsController; import org.mxchange.jcountry.data.Country; +import org.mxchange.jfinancials.beans.BaseFinancialsController; import org.mxchange.jphone.events.mobileprovider.added.AdminAddedMobileProviderEvent; import org.mxchange.jphone.events.mobileprovider.added.AdminMobileProviderAddedEvent; import org.mxchange.jphone.exceptions.MobileProviderAlreadyAddedException; @@ -93,17 +94,6 @@ public class FinancialsAdminMobileProviderWebRequestBean extends BaseFinancialsC * Default constructor */ public FinancialsAdminMobileProviderWebRequestBean () { - // Try it - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup the beans - this.adminRemoteBean = (AdminMobileProviderSessionBeanRemote) context.lookup("java:global/jfinancials-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 FinancialsAdminMobileProviderWebRequestBean extends BaseFinancialsC 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/jfinancials-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/jfinancials/beans/mobileprovider/FinancialsMobileProviderWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/mobileprovider/FinancialsMobileProviderWebRequestBean.java index 43f3684b..202abaa4 100644 --- a/src/java/org/mxchange/jfinancials/beans/mobileprovider/FinancialsMobileProviderWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/mobileprovider/FinancialsMobileProviderWebRequestBean.java @@ -59,17 +59,6 @@ public class FinancialsMobileProviderWebRequestBean extends BaseFinancialsContro * Default constructor */ public FinancialsMobileProviderWebRequestBean () { - // Try it - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup the beans - this.mobileRemoteBean = (MobileProviderSingletonBeanRemote) context.lookup("java:global/jfinancials-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 FinancialsMobileProviderWebRequestBean extends BaseFinancialsContro 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 FinancialsMobileProviderWebRequestBean extends BaseFinancialsContro } /** - * 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/jfinancials-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/jfinancials/beans/phone/FinancialsAdminPhoneWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/phone/FinancialsAdminPhoneWebRequestBean.java index 715ea6ea..87420a22 100644 --- a/src/java/org/mxchange/jfinancials/beans/phone/FinancialsAdminPhoneWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/phone/FinancialsAdminPhoneWebRequestBean.java @@ -16,17 +16,18 @@ */ package org.mxchange.jfinancials.beans.phone; +import javax.annotation.PostConstruct; import javax.enterprise.context.RequestScoped; import javax.faces.view.facelets.FaceletException; import javax.inject.Named; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; -import org.mxchange.jfinancials.beans.BaseFinancialsController; import org.mxchange.jcontacts.phone.AdminContactsPhoneSessionBeanRemote; -import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber; +import org.mxchange.jfinancials.beans.BaseFinancialsController; 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 FinancialsAdminPhoneWebRequestBean extends BaseFinancialsController */ private AdminContactsPhoneSessionBeanRemote adminPhoneBean; - /** - * Cell phone number - */ - private DialableMobileNumber cellPhone; - /** * Fax number */ @@ -62,31 +58,15 @@ public class FinancialsAdminPhoneWebRequestBean extends BaseFinancialsController */ private DialableLandLineNumber landLine; + /** + * Cell phone number + */ + private DialableMobileNumber mobileNumber; + /** * Default constructor */ public FinancialsAdminPhoneWebRequestBean () { - // Try it - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup the beans - this.adminPhoneBean = (AdminContactsPhoneSessionBeanRemote) context.lookup("java:global/jfinancials-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 FinancialsAdminPhoneWebRequestBean extends BaseFinancialsController 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/jfinancials-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/jfinancials/beans/phone/FinancialsAdminPhoneWebRequestController.java b/src/java/org/mxchange/jfinancials/beans/phone/FinancialsAdminPhoneWebRequestController.java index a93da68d..821d521f 100644 --- a/src/java/org/mxchange/jfinancials/beans/phone/FinancialsAdminPhoneWebRequestController.java +++ b/src/java/org/mxchange/jfinancials/beans/phone/FinancialsAdminPhoneWebRequestController.java @@ -36,7 +36,7 @@ public interface FinancialsAdminPhoneWebRequestController extends Serializable { *

* @param cellPhone Dialable mobile number instance */ - void setCellPhone (final DialableMobileNumber cellPhone); + void setMobileNumber (final DialableMobileNumber cellPhone); /** * Getter for dialable mobile number instance diff --git a/src/java/org/mxchange/jfinancials/beans/profile/FinancialsUserProfileWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/profile/FinancialsUserProfileWebRequestBean.java index 29a1f54e..795bd32e 100644 --- a/src/java/org/mxchange/jfinancials/beans/profile/FinancialsUserProfileWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/profile/FinancialsUserProfileWebRequestBean.java @@ -17,16 +17,17 @@ package org.mxchange.jfinancials.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; import javax.inject.Named; import org.mxchange.jfinancials.beans.BaseFinancialsController; +import org.mxchange.jfinancials.beans.login.FinancialsUserLoginWebSessionController; +import org.mxchange.jfinancials.beans.user.FinancialsUserWebSessionController; import org.mxchange.jusercore.exceptions.UserNotFoundException; import org.mxchange.jusercore.model.user.User; import org.mxchange.jusercore.model.user.profilemodes.ProfileMode; -import org.mxchange.jfinancials.beans.login.FinancialsUserLoginWebSessionController; -import org.mxchange.jfinancials.beans.user.FinancialsUserWebSessionController; /** * A web request bean for user profiles @@ -42,6 +43,12 @@ public class FinancialsUserProfileWebRequestBean extends BaseFinancialsControlle */ private static final long serialVersionUID = 187_687_145_286_710L; + /** + * User controller + */ + @Inject + private FinancialsUserWebSessionController userController; + /** * Login controller */ @@ -49,10 +56,17 @@ public class FinancialsUserProfileWebRequestBean extends BaseFinancialsControlle private FinancialsUserLoginWebSessionController userLoginController; /** - * User controller + * Default constructor */ - @Inject - private FinancialsUserWebSessionController userController; + public FinancialsUserProfileWebRequestBean () { + } + + /** + * Post-construction method + */ + @PostConstruct + public void init () { + } @Override public boolean isProfileLinkVisibleById (final Long userId) { diff --git a/src/java/org/mxchange/jfinancials/beans/profilemode/FinancialsProfileModeWebApplicationBean.java b/src/java/org/mxchange/jfinancials/beans/profilemode/FinancialsProfileModeWebApplicationBean.java index 57655b26..7e59be69 100644 --- a/src/java/org/mxchange/jfinancials/beans/profilemode/FinancialsProfileModeWebApplicationBean.java +++ b/src/java/org/mxchange/jfinancials/beans/profilemode/FinancialsProfileModeWebApplicationBean.java @@ -16,6 +16,7 @@ */ package org.mxchange.jfinancials.beans.profilemode; +import javax.annotation.PostConstruct; import javax.enterprise.context.ApplicationScoped; import javax.inject.Named; import org.mxchange.jfinancials.beans.BaseFinancialsController; @@ -46,4 +47,12 @@ public class FinancialsProfileModeWebApplicationBean extends BaseFinancialsContr // Return it return ProfileMode.values(); } + + /** + * Post-construction method + */ + @PostConstruct + public void init () { + } + } diff --git a/src/java/org/mxchange/jfinancials/beans/register/FinancialsUserRegisterWebSessionBean.java b/src/java/org/mxchange/jfinancials/beans/register/FinancialsUserRegisterWebSessionBean.java index 2ded159e..dc85ef50 100644 --- a/src/java/org/mxchange/jfinancials/beans/register/FinancialsUserRegisterWebSessionBean.java +++ b/src/java/org/mxchange/jfinancials/beans/register/FinancialsUserRegisterWebSessionBean.java @@ -17,6 +17,7 @@ package org.mxchange.jfinancials.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; @@ -98,16 +99,6 @@ public class FinancialsUserRegisterWebSessionBean extends BaseFinancialsControll * Default constructor */ public FinancialsUserRegisterWebSessionBean () { - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup - this.registerBean = (UserRegistrationSessionBeanRemote) context.lookup("java:global/jfinancials-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 FinancialsUserRegisterWebSessionBean extends BaseFinancialsControll 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/jfinancials-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/jfinancials/beans/resendlink/FinancialsResendLinkWebSessionBean.java b/src/java/org/mxchange/jfinancials/beans/resendlink/FinancialsResendLinkWebSessionBean.java index 843dbb54..2414d935 100644 --- a/src/java/org/mxchange/jfinancials/beans/resendlink/FinancialsResendLinkWebSessionBean.java +++ b/src/java/org/mxchange/jfinancials/beans/resendlink/FinancialsResendLinkWebSessionBean.java @@ -17,6 +17,7 @@ package org.mxchange.jfinancials.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 FinancialsResendLinkWebSessionBean extends BaseFinancialsController * Default constructor */ public FinancialsResendLinkWebSessionBean () { - // Try it - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup - this.emailBean = (ResendLinkSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/resendLink!org.mxchange.jfinancials.beans.resendlink.ResendLinkSessionBeanRemote"); //NOI18N - } catch (final NamingException e) { - // Throw again - throw new FaceletException(e); - } } @Override @@ -152,6 +142,24 @@ public class FinancialsResendLinkWebSessionBean extends BaseFinancialsController 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/jfinancials-ejb/resendLink!org.mxchange.jfinancials.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/jfinancials/beans/user/FinancialsAdminUserWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/user/FinancialsAdminUserWebRequestBean.java index 030e32eb..86542dae 100644 --- a/src/java/org/mxchange/jfinancials/beans/user/FinancialsAdminUserWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/user/FinancialsAdminUserWebRequestBean.java @@ -18,6 +18,7 @@ package org.mxchange.jfinancials.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 FinancialsAdminUserWebRequestBean extends BaseFinancialsController /** * Administrative user EJB */ - private final AdminUserSessionBeanRemote adminUserBean; + private AdminUserSessionBeanRemote adminUserBean; /** * Bean helper instance @@ -112,7 +113,7 @@ public class FinancialsAdminUserWebRequestBean extends BaseFinancialsController /** * General user EJB */ - private final UserSessionBeanRemote userBean; + private UserSessionBeanRemote userBean; /** * Regular user controller @@ -157,18 +158,6 @@ public class FinancialsAdminUserWebRequestBean extends BaseFinancialsController * Default constructor */ public FinancialsAdminUserWebRequestBean () { - // Try it - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup - this.userBean = (UserSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N - this.adminUserBean = (AdminUserSessionBeanRemote) context.lookup("java:global/jfinancials-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 FinancialsAdminUserWebRequestBean extends BaseFinancialsController 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/jfinancials-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N + this.adminUserBean = (AdminUserSessionBeanRemote) context.lookup("java:global/jfinancials-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/jfinancials/beans/user/FinancialsUserWebSessionBean.java b/src/java/org/mxchange/jfinancials/beans/user/FinancialsUserWebSessionBean.java index 29d95c4f..151c641e 100644 --- a/src/java/org/mxchange/jfinancials/beans/user/FinancialsUserWebSessionBean.java +++ b/src/java/org/mxchange/jfinancials/beans/user/FinancialsUserWebSessionBean.java @@ -33,7 +33,6 @@ import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import org.mxchange.jcontacts.contact.Contact; -import org.mxchange.jcontacts.contact.ContactSessionBeanRemote; import org.mxchange.jfinancials.beans.BaseFinancialsController; import org.mxchange.jfinancials.beans.contact.FinancialsContactWebSessionController; import org.mxchange.jfinancials.beans.features.FinancialsFeaturesWebApplicationController; @@ -70,11 +69,6 @@ public class FinancialsUserWebSessionBean extends BaseFinancialsController imple */ private static final long serialVersionUID = 542_145_347_916L; - /** - * Contact EJB - */ - private ContactSessionBeanRemote contactBean; - /** * General contact controller */ @@ -103,7 +97,7 @@ public class FinancialsUserWebSessionBean extends BaseFinancialsController imple /** * Remote user bean */ - private final UserSessionBeanRemote userBean; + private UserSessionBeanRemote userBean; /** * User id @@ -158,24 +152,10 @@ public class FinancialsUserWebSessionBean extends BaseFinancialsController imple * Default constructor */ public FinancialsUserWebSessionBean () { - // Try it - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup - this.userBean = (UserSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N - - // Try to lookup - this.contactBean = (ContactSessionBeanRemote) context.lookup("java:global/jfinancials-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 */ @@ -566,6 +546,18 @@ public class FinancialsUserWebSessionBean extends BaseFinancialsController imple */ @PostConstruct public void init () { + // Try it + try { + // Get initial context + Context context = new InitialContext(); + + // Try to lookup + this.userBean = (UserSessionBeanRemote) context.lookup("java:global/jfinancials-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/jfinancials/beans/user/password/FinancialsUserPasswordWebRequestBean.java b/src/java/org/mxchange/jfinancials/beans/user/password/FinancialsUserPasswordWebRequestBean.java index fc0f235a..38cdc506 100644 --- a/src/java/org/mxchange/jfinancials/beans/user/password/FinancialsUserPasswordWebRequestBean.java +++ b/src/java/org/mxchange/jfinancials/beans/user/password/FinancialsUserPasswordWebRequestBean.java @@ -17,6 +17,7 @@ package org.mxchange.jfinancials.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; @@ -26,8 +27,11 @@ import javax.inject.Named; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; -import org.mxchange.jfinancials.beans.BaseFinancialsController; import org.mxchange.jcoreee.utils.FacesUtils; +import org.mxchange.jfinancials.beans.BaseFinancialsController; +import org.mxchange.jfinancials.beans.features.FinancialsFeaturesWebApplicationController; +import org.mxchange.jfinancials.beans.login.FinancialsUserLoginWebSessionController; +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; @@ -37,9 +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.jfinancials.beans.features.FinancialsFeaturesWebApplicationController; -import org.mxchange.jfinancials.beans.login.FinancialsUserLoginWebSessionController; -import org.mxchange.jusercore.events.user.password_change.ObservableUpdatedUserPasswordEvent; /** * A user password (change) bean (controller) @@ -64,7 +65,7 @@ public class FinancialsUserPasswordWebRequestBean extends BaseFinancialsControll /** * Remote user bean */ - private final UserSessionBeanRemote userBean; + private UserSessionBeanRemote userBean; /** * Current password (for confirmation of password change) @@ -98,17 +99,6 @@ public class FinancialsUserPasswordWebRequestBean extends BaseFinancialsControll * Default constructor */ public FinancialsUserPasswordWebRequestBean () { - // Try it - try { - // Get initial context - Context context = new InitialContext(); - - // Try to lookup - this.userBean = (UserSessionBeanRemote) context.lookup("java:global/jfinancials-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 FinancialsUserPasswordWebRequestBean extends BaseFinancialsControll 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/jfinancials-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/jfinancials/beans/user/password/FinancialsUserPasswordWebRequestController.java b/src/java/org/mxchange/jfinancials/beans/user/password/FinancialsUserPasswordWebRequestController.java index 72c4de4d..9d47fbee 100644 --- a/src/java/org/mxchange/jfinancials/beans/user/password/FinancialsUserPasswordWebRequestController.java +++ b/src/java/org/mxchange/jfinancials/beans/user/password/FinancialsUserPasswordWebRequestController.java @@ -70,10 +70,19 @@ public interface FinancialsUserPasswordWebRequestController extends Serializable 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 (); + } -- 2.39.5