code: public static NameService instance(HttpSession session)
      {
          if (session == null)
              throw new IllegalArgumentException("Session must not be null");
  
          // Synchronize on a session scoped mutex to ensure that only a single
          // NameService object is created within a specific user session
          Object sessionMutex = ServletUtils.getSessionMutex(session, NAME_SERVICE_MUTEX_ATTRIBUTE);
          synchronized (sessionMutex) {
              NameService nameService = (NameService) session.getAttribute(NAME_SERVICE);
              if (nameService == null) {
                  nameService = new NameService();
                  session.setAttribute(NAME_SERVICE,nameService);
              }
              return nameService;
          }
      }
docs: This will return the session specific instance of a NameService.  There
  will only be a single NameService per session.
  @param session the HttpSession that contains the NameService
  @return the NameService associated with the session.