@Override
  public Url mapHandler(IRequestHandler requestHandler) {
    Url url = systemMapper.mapHandler(requestHandler);
    if (ThreadPortletContext.getPortletRequest() == null) {
      return url;
    }

    if (requestHandler instanceof RenderPageRequestHandler) {
      if (ThreadPortletContext.isAjax()) {
        url = encodeRenderUrl(url, true);
      }
    } else if (requestHandler instanceof SharedResourceReference) {
      url = encodeSharedResourceUrl(url);
    } else if (requestHandler instanceof ResourceReferenceRequestHandler) {
      ResourceReferenceRequestHandler resourceReferenceRequestHandler =
          (ResourceReferenceRequestHandler) requestHandler;
      IResource resource = resourceReferenceRequestHandler.getResource();

      if (resource instanceof PackageResource) {
        url = encodeSharedResourceUrl(url);
      } else {
        url = encodeResourceUrl(url);
      }
    } else if (requestHandler instanceof BookmarkablePageRequestHandler) {
      url = encodeRenderUrl(url, true);
    } else if (requestHandler instanceof ListenerInterfaceRequestHandler) {
      ListenerInterfaceRequestHandler listenerInterfaceRequestHandler =
          (ListenerInterfaceRequestHandler) requestHandler;

      RequestListenerInterface listenerInterface =
          listenerInterfaceRequestHandler.getListenerInterface();
      Class<?> listenerClass = listenerInterface.getMethod().getDeclaringClass();

      if ((IResourceListener.class.isAssignableFrom(listenerClass))
          || (IBehaviorListener.class.isAssignableFrom(listenerClass))) {
        url = encodeResourceUrl(url);
      } else if (IRedirectListener.class.isAssignableFrom(listenerClass)) {
        if (ThreadPortletContext.isAjax()) {
          url = encodeRenderUrl(url, true);
        } else {
          url = encodeRenderUrl(url, false);
        }
      } else {
        if (ThreadPortletContext.isAjax()) {
          url = encodeActionUrl(url, true);
        } else {
          url = encodeActionUrl(url, false);
        }
      }
    }

    return url;
  }
 @Override
 public int getCompatibilityScore(Request request) {
   return systemMapper.getCompatibilityScore(request);
 }
 @Override
 public IRequestHandler mapRequest(Request request) {
   return systemMapper.mapRequest(request);
 }