/**
* 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 {
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?
User registeredUser = event.getUser();
// Update cache
- this.cachedStatus.put(registeredUser.getUserId(), Boolean.TRUE);
+ UserIdValidator.cachedStatus.put(registeredUser.getUserId(), Boolean.TRUE);
}
}