]> git.mxchange.org Git - addressbook-war.git/commitdiff
Cache flag whether the user is sharing address books to reduce EJB traffic
authorRoland Haeder <roland@mxchange.org>
Wed, 14 Oct 2015 09:33:20 +0000 (11:33 +0200)
committerRoland Haeder <roland@mxchange.org>
Wed, 14 Oct 2015 09:33:20 +0000 (11:33 +0200)
Signed-off-by:Roland Häder <roland@mxchange.org>

src/java/org/mxchange/addressbook/beans/shares/SharesWebBean.java

index ddb1df43a24e3d852c2595fc7fef27ea04f54b73..11caa31830591f01b8ab49b3384dbf7fb86f93e9 100644 (file)
@@ -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;
        }
 
 }