From: Roland Haeder Date: Wed, 14 Oct 2015 09:33:20 +0000 (+0200) Subject: Cache flag whether the user is sharing address books to reduce EJB traffic X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=c329214fd2e5e503da3d7f2e0bf0cf11fc8264a3;p=addressbook-war.git Cache flag whether the user is sharing address books to reduce EJB traffic Signed-off-by:Roland Häder --- diff --git a/src/java/org/mxchange/addressbook/beans/shares/SharesWebBean.java b/src/java/org/mxchange/addressbook/beans/shares/SharesWebBean.java index ddb1df43..11caa318 100644 --- a/src/java/org/mxchange/addressbook/beans/shares/SharesWebBean.java +++ b/src/java/org/mxchange/addressbook/beans/shares/SharesWebBean.java @@ -51,6 +51,11 @@ public class SharesWebBean implements SharesWebController { */ private SharedAddressbooksSessionBeanRemote shareBean; + /** + * Cached flag whether the user is sharing address books + */ + private Boolean isUserSharing = null; + /** * Default constructor */ @@ -74,10 +79,16 @@ public class SharesWebBean implements SharesWebController { if (!this.loginController.isUserLoggedIn()) { // Not logged in throw new FaceletException("This method can only be called as logged-in user."); //NOI18N + } else if (this.isUserSharing instanceof Boolean) { + // Return cached value + return this.isUserSharing; } // Call the proper bean - return this.shareBean.isUserSharingAddressbooks(this.loginController.getLoggedInUser()); + this.isUserSharing = this.shareBean.isUserSharingAddressbooks(this.loginController.getLoggedInUser()); + + // Return it + return this.isUserSharing; } }