From: Roland Haeder Date: Mon, 15 Feb 2016 19:28:15 +0000 (+0100) Subject: init() and @PostConstruct is the wrong place for checking logged-in user status,... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=ba3852417436a0684edf9a0268f06f6253b4a773;p=jjobs-war.git init() and @PostConstruct is the wrong place for checking logged-in user status, better use the new event --- diff --git a/lib/addressbook-lib.jar b/lib/addressbook-lib.jar index a8382ba7..a63b5630 100644 Binary files a/lib/addressbook-lib.jar and b/lib/addressbook-lib.jar differ diff --git a/src/java/org/mxchange/addressbook/beans/shares/SharesWebSessionBean.java b/src/java/org/mxchange/addressbook/beans/shares/SharesWebSessionBean.java index 30760580..988b25ca 100644 --- a/src/java/org/mxchange/addressbook/beans/shares/SharesWebSessionBean.java +++ b/src/java/org/mxchange/addressbook/beans/shares/SharesWebSessionBean.java @@ -39,6 +39,7 @@ import org.mxchange.addressbook.exceptions.UserAlreadySharingAddressbookExceptio import org.mxchange.addressbook.model.addressbook.Addressbook; import org.mxchange.addressbook.model.addressbook.shared.ShareableAddressbook; import org.mxchange.addressbook.model.shared.SharedAddressbooksSessionBeanRemote; +import org.mxchange.jusercore.events.login.UserLoggedInEvent; import org.mxchange.jusercore.model.user.User; import org.mxchange.jusercore.model.user.profilemodes.ProfileMode; @@ -153,6 +154,21 @@ public class SharesWebSessionBean implements SharesWebSessionController { this.sharedAddressbooks.add(event.getShareableAddressbook()); } + @Override + public void afterLoginEvent (final @Observes UserLoggedInEvent event) { + // Is the user logged in? + if (null == event) { + // Is null + throw new NullPointerException("event is null"); //NOI18N + } else if (event.getUser() == null) { + // user is null + throw new NullPointerException("event.user is null"); //NOI18N + } + + // Init share list + this.sharedAddressbooks = this.shareBean.allSharedAddressbooks(event.getUser()); + } + @Override public List allShares () { // Is the user logged in? diff --git a/src/java/org/mxchange/addressbook/beans/shares/SharesWebSessionController.java b/src/java/org/mxchange/addressbook/beans/shares/SharesWebSessionController.java index 1be32834..d2a96f5c 100644 --- a/src/java/org/mxchange/addressbook/beans/shares/SharesWebSessionController.java +++ b/src/java/org/mxchange/addressbook/beans/shares/SharesWebSessionController.java @@ -21,6 +21,7 @@ import java.util.List; import org.mxchange.addressbook.events.sharing.AddressbookSharingEvent; import org.mxchange.addressbook.model.addressbook.Addressbook; import org.mxchange.addressbook.model.addressbook.shared.ShareableAddressbook; +import org.mxchange.jusercore.events.login.UserLoggedInEvent; import org.mxchange.jusercore.model.user.User; /** @@ -44,6 +45,14 @@ public interface SharesWebSessionController extends Serializable { */ void afterAdressbookShareStarted (final AddressbookSharingEvent event); + /** + * This method is called when a user has successfully logged in his/her + * account. + *

+ * @param event + */ + void afterLoginEvent (final UserLoggedInEvent event); + /** * Returns a list of all address books the user is sharing with others. *