]> git.mxchange.org Git - addressbook-lib.git/commitdiff
use static, then it will remain there
authorRoland Haeder <roland@mxchange.org>
Thu, 15 Oct 2015 11:56:03 +0000 (13:56 +0200)
committerRoland Haeder <roland@mxchange.org>
Thu, 15 Oct 2015 11:56:03 +0000 (13:56 +0200)
Signed-off-by:Roland Häder <roland@mxchange.org>

src/org/mxchange/addressbook/validator/user/UserIdValidator.java

index ddd1ef76c1803c8a64aaf6a057a0656a70e1b999..17f76a7e809bfba5ee67f6984ce2bd594846b405 100644 (file)
@@ -54,15 +54,7 @@ public class UserIdValidator extends BaseLongValidator implements Validator {
        /**
         * Cached user status
         */
-       private final ConcurrentMap<Long, Boolean> cachedStatus;
-
-       /**
-        * Default constructor
-        */
-       public UserIdValidator () {
-               // Init map
-               this.cachedStatus = new ConcurrentHashMap<>(0);
-       }
+       private static final ConcurrentMap<Long, Boolean> cachedStatus = new ConcurrentHashMap<>(0);
 
        @Override
        public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException {
@@ -82,15 +74,15 @@ public class UserIdValidator extends BaseLongValidator implements Validator {
                Boolean ifUserExists = false;
 
                // Is a map entry there?
-               if (this.cachedStatus.containsKey(userId)) {
+               if (UserIdValidator.cachedStatus.containsKey(userId)) {
                        // Get from cache
-                       ifUserExists = this.cachedStatus.get(userId);
+                       ifUserExists = UserIdValidator.cachedStatus.get(userId);
                } else {
                        // Get status
                        ifUserExists = this.userBean.ifUserIdExists(userId);
 
                        // Add to cache
-                       this.cachedStatus.put(userId, ifUserExists);
+                       UserIdValidator.cachedStatus.put(userId, ifUserExists);
                }
 
                // Is the address book id valid?
@@ -128,6 +120,6 @@ public class UserIdValidator extends BaseLongValidator implements Validator {
                User registeredUser = event.getUser();
 
                // Update cache
-               this.cachedStatus.put(registeredUser.getUserId(), Boolean.TRUE);
+               UserIdValidator.cachedStatus.put(registeredUser.getUserId(), Boolean.TRUE);
        }
 }