code: private Application getMyfacesApplicationInstance()
      {
          FacesContext facesContext = FacesContext.getCurrentInstance();
          if (facesContext != null)
          {
              ExternalContext externalContext = facesContext.getExternalContext();
              if (externalContext != null)
              {
                  return (Application) externalContext.getApplicationMap().get(
                                  "org.apache.myfaces.application.ApplicationImpl");
              }
          }
          return null;
      }
docs: Retrieve the current Myfaces Application Instance, lookup
  on the application map. All methods introduced on jsf 1.2
  for Application interface should thrown by default
  UnsupportedOperationException, but the ri scan and find the
  original Application impl, and redirect the call to that
  method instead throwing it, allowing application implementations
  created before jsf 1.2 continue working.
  
  Note: every method, which uses getMyfacesApplicationInstance() to
  delegate itself to the current ApplicationImpl MUST be
  overriden by the current ApplicationImpl to prevent infinite loops.