public T get(ViewContext context) {
    if (!viewSingletonObjects.containsKey(tClass)) {
      synchronized (viewSingletonObjects) {
        if (!viewSingletonObjects.containsKey(tClass)) {
          viewSingletonObjects.put(tClass, new ConcurrentHashMap<String, Object>());
        }
      }
    }

    Map<String, Object> instances = viewSingletonObjects.get(tClass);

    String key = getTagName(context);

    LOG.debug("looking for key : {}", key);
    if (!instances.containsKey(key)) {
      String lockKey = tClass.getName() + "_" + key;
      LOG.info("key {} not found. getting lock for {}", key,lockKey);

      ReentrantLock lock = getLockFor(lockKey);
      boolean gotLock = lock.tryLock();

      if( !gotLock ){
        LOG.error("Lock could not be obtained for {}. Throwing exception.",lockKey);
        throw new RuntimeException(String.format("Failed to initialize %s for %s. Try Again.", tClass.getName(), key));
      }
      else {
        try {
          T initValue = initialValue(context);
          LOG.info("Obtained initial value : {} for key : {}",initValue,key);
          instances.put(key, initValue);
        }finally{
          lock.unlock();
        }
      }
    }

    return (T) instances.get(key);
  }
Returns user-local instance.
If instance of class is not present yet for user, calls initialValue to create it.
@param context View context that provides instance and user names.
@return instance
contrib/views/utils/src/main/java/org/apache/ambari/view/utils/UserLocal.java