Package juzu.impl.router

Examples of juzu.impl.router.RouteMatch


    //
    String requestPath = bridge.getRequestContext().getRequestPath();

    // Determine first a possible match from the root route from the request path
    ControllerHandler requestTarget = null;
    RouteMatch requestMatch = null;
    Map<String, RequestParameter> requestParameters = Collections.emptyMap();
    if (requestPath.startsWith(bridge.getRequestContext().getPath())) {

      //
      HttpMethod requestMethod = bridge.getHttpContext().getMethod();
      Iterator<RouteMatch> matches = root.matcher(requestPath.substring(bridge.getRequestContext().getPath().length()), Collections.<String, String[]>emptyMap());

      // Determine a method
      while (matches.hasNext()) {
        RouteMatch match = matches.next();
        RouteDescriptor routeDesc = getMethods(match.getRoute());
        if (routeDesc != null) {
          ControllerHandler target = this.bridge.getApplication().resolveBean(ControllerService.class).getDescriptor().getMethodByHandle(routeDesc.handle);
          if (target.getPhase() == Phase.VIEW) {
            if (requestMethod == HttpMethod.POST) {
              requestTarget =  target;
View Full Code Here


          params.put(parameter.getName(), parameter.get(0));
        }
      }

      //
      final RouteMatch match = route.matches(params);
      if (match != null) {
        return new DispatchBridge() {

          public MethodHandle getTarget() {
            return target;
          }

          public Map<String, ResponseParameter> getParameters() {
            return parameters;
          }

          public <T> String checkPropertyValidity(PropertyType<T> propertyType, T propertyValue) {
            // For now we don't validate anything
            return null;
          }

          public void renderURL(PropertyMap properties, MimeType mimeType, Appendable appendable) throws IOException {

            // Render base URL
            http.renderRequestURL(appendable);

            // Render path
            UriBuilder writer = new UriBuilder(appendable, mimeType);
            match.render(writer);

            // Retain matched parameters for filtering later
            Set<String> matched = match.getMatched().isEmpty() ? Collections.<String>emptySet() : new HashSet<String>(match.getMatched().size());
            for (PathParam param : match.getMatched().keySet()) {
              matched.add(param.getName());
            }

            // Render remaining parameters which have not been rendered yet
            for (ResponseParameter parameter : parameters.values()) {
View Full Code Here

TOP

Related Classes of juzu.impl.router.RouteMatch

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.