code: public static void initServletRequest(ServletRequest servletRequest, URLTemplatesFactory templatesFactory)
      {
          assert servletRequest != null : "The ServletRequest cannot be null.";
  
          if (servletRequest == null) {
              throw new IllegalArgumentException("The ServletRequest cannot be null.");
          }
  
          servletRequest.setAttribute(URL_TEMPLATE_FACTORY_ATTR, templatesFactory);
      }
docs: Adds a given URLTemplatesFactory instance as an attribute on the ServletRequest.
  
  @param servletRequest   the current ServletRequest.
  @param templatesFactory the URLTemplatesFactory instance to add as an attribute of the request