示例#1
0
  @Override
  public IRequestHandler mapRequest(final Request request) {
    Url url = decryptUrl(request, request.getUrl());

    if (url == null) {
      return null;
    }

    return wrappedMapper.mapRequest(request.cloneWithUrl(url));
  }
示例#2
0
  @Override
  public Url mapHandler(final IRequestHandler requestHandler) {
    final Url url = wrappedMapper.mapHandler(requestHandler);

    if (url == null) {
      return null;
    }

    return encryptUrl(url);
  }
示例#3
0
  /**
   * Creates a url for the handler. Modifies it with the correct {@link Scheme} if necessary.
   *
   * @param handler
   * @param request
   * @return url
   */
  final Url mapHandler(IRequestHandler handler, Request request) {
    Url url = delegate.mapHandler(handler);

    Scheme desired = getDesiredSchemeFor(handler);
    Scheme current = getSchemeOf(request);
    if (!desired.isCompatibleWith(current)) {
      // the generated url does not have the correct scheme, set it (which in turn will cause
      // the url to be rendered in its full representation)
      url.setProtocol(desired.urlName());
      if (url.getPort() != null || !desired.usesStandardPort(config)) {
        url.setPort(desired.getPort(config));
      }
    }
    return url;
  }
示例#4
0
  @Override
  public IRequestHandler mapRequest(Request request) {
    IRequestHandler handler = delegate.mapRequest(request);

    Scheme desired = getDesiredSchemeFor(handler);
    Scheme current = getSchemeOf(request);
    if (!desired.isCompatibleWith(current)) {
      // we are currently on the wrong scheme for this handler

      // construct a url for the handler on the correct scheme
      String url = createRedirectUrl(handler, request, desired);

      // replace handler with one that will redirect to the created url
      handler = createRedirectHandler(url);
    }
    return handler;
  }
示例#5
0
 /**
  * Returns URL for the request handler or <code>null</code> if the handler couldn't have been
  * encoded.
  *
  * @param handler
  * @return Url instance or <code>null</code>
  */
 public Url mapUrlFor(IRequestHandler handler) {
   final Url url = requestMapper.mapHandler(handler);
   listeners.onUrlMapped(this, handler, url);
   return url;
 }
示例#6
0
 /**
  * Resolves current request to a {@link IRequestHandler}.
  *
  * @return RequestHandler instance
  */
 protected IRequestHandler resolveRequestHandler() {
   return requestMapper.mapRequest(request);
 }
示例#7
0
 @Override
 public int getCompatibilityScore(Request request) {
   return delegate.getCompatibilityScore(request);
 }