Package org.springframework.util

Examples of org.springframework.util.PathMatcher


      if (startsWithSlash) {
        pkg = FOLDER_SEPARATOR + pkg;
      }

      PathMatcher matcher = getPathMatcher();
      // if the imported package matches the path
      if (matcher.matchStart(path, pkg)) {
        // start the JAR analysis
        Enumeration entries = importedBundle.getBundle().getEntryPaths(pkg);
        while (entries != null && entries.hasMoreElements()) {
          String entry = (String) entries.nextElement();
          if (startsWithSlash)
            entry = FOLDER_SEPARATOR + entry;

          if (matcher.match(path, entry))
            foundPaths.add(entry);
        }
      }
    }
  }
View Full Code Here


      return response.getOutputStream();
    }
  }

  private boolean matchesCompressedMimeTypes(String mimeType) {
    PathMatcher pathMatcher = new AntPathMatcher();
    for (String compressedMimeType : compressedMimeTypes) {
      if (pathMatcher.match(compressedMimeType, mimeType)) {
        return true;
      }
    }
    return false;
  }
View Full Code Here

  private boolean isAllowed(String resourcePath) {
    if (resourcePath.matches(protectedPath)) {
      return false;
    }
    PathMatcher pathMatcher = new AntPathMatcher();
    for (String pattern : allowedResourcePaths) {
      if (pathMatcher.match(pattern, resourcePath)) {
        return true;
      }
    }
    return false;
  }
View Full Code Here

   * Returns {@code true} if the interceptor applies to the given request path.
   * @param lookupPath the current request path
   * @param pathMatcher a path matcher for path pattern matching
   */
  public boolean matches(String lookupPath, PathMatcher pathMatcher) {
    PathMatcher pathMatcherToUse = (this.pathMatcher != null) ? this.pathMatcher : pathMatcher;
    if (this.excludePatterns != null) {
      for (String pattern : this.excludePatterns) {
        if (pathMatcherToUse.match(pattern, lookupPath)) {
          return false;
        }
      }
    }
    if (this.includePatterns == null) {
      return true;
    }
    else {
      for (String pattern : this.includePatterns) {
        if (pathMatcherToUse.match(pattern, lookupPath)) {
          return true;
        }
      }
      return false;
    }
View Full Code Here

    ResourceUrlProvider urlProvider = new ResourceUrlProvider();
    UrlPathHelper pathHelper = getPathMatchConfigurer().getUrlPathHelper();
    if (pathHelper != null) {
      urlProvider.setUrlPathHelper(pathHelper);
    }
    PathMatcher pathMatcher = getPathMatchConfigurer().getPathMatcher();
    if (pathMatcher != null) {
      urlProvider.setPathMatcher(pathMatcher);
    }
    return urlProvider;
  }
View Full Code Here

    verifyWebInterceptor(interceptors.get(1), this.webInterceptor2);
  }

  @Test
  public void addInterceptorsWithCustomPathMatcher() {
    PathMatcher pathMatcher = Mockito.mock(PathMatcher.class);
    this.registry.addInterceptor(interceptor1).addPathPatterns("/path1/**").pathMatcher(pathMatcher);

    MappedInterceptor mappedInterceptor = (MappedInterceptor) this.registry.getInterceptors().get(0);
    assertSame(pathMatcher, mappedInterceptor.getPathMatcher());
  }
View Full Code Here

    assertEquals(Collections.emptyList(), getInterceptorsForPath("/path1/secret"));
  }


  private List<HandlerInterceptor> getInterceptorsForPath(String lookupPath) {
    PathMatcher pathMatcher = new AntPathMatcher();
    List<HandlerInterceptor> result = new ArrayList<HandlerInterceptor>();
    for (Object interceptor : this.registry.getInterceptors()) {
      if (interceptor instanceof MappedInterceptor) {
        MappedInterceptor mappedInterceptor = (MappedInterceptor) interceptor;
        if (mappedInterceptor.matches(lookupPath, pathMatcher)) {
View Full Code Here

  @Test
  public void defaultPathMatchConfiguration() throws Exception {
    ApplicationContext context = initContext(WebConfig.class);
    UrlPathHelper urlPathHelper = context.getBean(UrlPathHelper.class);
    PathMatcher pathMatcher = context.getBean(PathMatcher.class);

    assertNotNull(urlPathHelper);
    assertNotNull(pathMatcher);
    assertEquals(AntPathMatcher.class, pathMatcher.getClass());
  }
View Full Code Here

    assertEquals("Only one custom converter is expected", 1, composite.getExceptionResolvers().size());
  }

  @Test
  public void configurePathMatch() throws Exception {
    final PathMatcher pathMatcher = mock(PathMatcher.class);
    final UrlPathHelper pathHelper = mock(UrlPathHelper.class);

    List<WebMvcConfigurer> configurers = new ArrayList<WebMvcConfigurer>();
    configurers.add(new WebMvcConfigurerAdapter() {
      @Override
View Full Code Here

    List<HandlerMethodReturnValueHandler> returnValueHandlers = new ArrayList<HandlerMethodReturnValueHandler>();
    addReturnValueHandlers(returnValueHandlers);
    handler.setCustomReturnValueHandlers(returnValueHandlers);

    PathMatcher pathMatcher = this.getBrokerRegistry().getPathMatcher();
    if (pathMatcher != null) {
      handler.setPathMatcher(pathMatcher);
    }
    return handler;
  }
View Full Code Here

TOP

Related Classes of org.springframework.util.PathMatcher

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.