Package org.wicketstuff.rest.resource.urlsegments.visitor

Examples of org.wicketstuff.rest.resource.urlsegments.visitor.ScoreMethodAndExtractPathVars


    AttributesWrapper attributesWrapper = new AttributesWrapper(attributes);
    WebResponse response = attributesWrapper.getWebResponse();
    HttpMethod httpMethod = attributesWrapper.getHttpMethod();

    // select the best "candidate" method to serve the request
    ScoreMethodAndExtractPathVars mappedMethod = selectMostSuitedMethod(attributesWrapper);

    if (mappedMethod != null)
    {
      handleMethodExecution(attributesWrapper, mappedMethod);
    }
View Full Code Here


  {
    PageParameters pageParameters = attributesWrapper.getPageParameters();
    List<MethodMappingInfo> mappedMethodsCandidates = mappedMethods.get(pageParameters.getIndexedCount() +
      "_" + attributesWrapper.getHttpMethod());

    ScoreMethodAndExtractPathVars highiestScoredMethod = null;

    // no method mapped
    if (mappedMethodsCandidates == null || mappedMethodsCandidates.size() == 0)
      return null;

    /**
     * To select the "best" method, a score is assigned to every mapped method. To calculate the
     * score method calculateScore is executed for every segment.
     */
    int highestScore = 0;

    for (MethodMappingInfo mappedMethod : mappedMethodsCandidates)
    {
      ScoreMethodAndExtractPathVars scoredMethod =
        new ScoreMethodAndExtractPathVars(mappedMethod, pageParameters);
     
      for (AbstractURLSegment segment : mappedMethod.getSegments())
      {
        segment.accept(scoredMethod);
       
        if(!scoredMethod.isSegmentValid())
        {
          break;
        }
      }
     
      if(highestScore > 0 && scoredMethod.getScore() == highestScore)
      {
        // if we have more than one method with the highest score, throw
        // ambiguous exception.
        throwAmbiguousMethodsException(scoredMethod, highiestScoredMethod);
      }

      if (scoredMethod.getScore() >= highestScore)
      {
        highestScore = scoredMethod.getScore();
        highiestScoredMethod = scoredMethod;
      }
    }
       
    return highiestScoredMethod;
View Full Code Here

TOP

Related Classes of org.wicketstuff.rest.resource.urlsegments.visitor.ScoreMethodAndExtractPathVars

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.