From c329214fd2e5e503da3d7f2e0bf0cf11fc8264a3 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Wed, 14 Oct 2015 11:33:20 +0200 Subject: [PATCH] =?utf8?q?Cache=20flag=20whether=20the=20user=20is=20shari?= =?utf8?q?ng=20address=20books=20to=20reduce=20EJB=20traffic=20Signed-off-?= =?utf8?q?by:Roland=20H=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../addressbook/beans/shares/SharesWebBean.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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; } } -- 2.39.5