code: public static PortletApplicationContext getCurrentPortletApplicationContext() {
          ClassLoader ccl = Thread.currentThread().getContextClassLoader();
          if (ccl != null) {
              PortletApplicationContext ccpt = currentContextPerThread.get(ccl);
              if (ccpt != null) {
                  return ccpt;
              }
          }
          return currentContext;
      }
docs: Obtain the Spring root portlet application context for the current thread
  (i.e. for the current thread's context ClassLoader, which needs to be
  the web application's ClassLoader).
  
  @return the current root web application context, or <code>null</code>
  if none found
  @see org.springframework.web.context.support.SpringBeanAutowiringSupport