Search in sources :

Example 1 with AntPathMatcher

use of com.navercorp.pinpoint.bootstrap.util.AntPathMatcher in project pinpoint by naver.

the class SpringBeansTarget method compilePattern.

List<PathMatcher> compilePattern(List<String> patternStrings, final String separator) {
    if (CollectionUtils.isEmpty(patternStrings)) {
        return null;
    }
    final List<PathMatcher> pathMatchers = new ArrayList<>(patternStrings.size());
    for (String patternString : patternStrings) {
        final int prefixEnd = patternString.indexOf(":");
        if (prefixEnd != -1) {
            final String prefix = patternString.substring(0, prefixEnd).trim();
            if (prefix.equals(ANT_STYLE_PATTERN_PREFIX)) {
                final String trimmed = patternString.substring(prefixEnd + 1).trim();
                if (!trimmed.isEmpty()) {
                    pathMatchers.add(new AntPathMatcher(trimmed, separator));
                }
                continue;
            } else if (prefix.equals(REGEX_PATTERN_PREFIX)) {
                final String trimmed = patternString.substring(prefixEnd + 1).trim();
                if (!trimmed.isEmpty()) {
                    final Pattern pattern = Pattern.compile(trimmed);
                    pathMatchers.add(new RegexPathMatcher(pattern));
                }
                continue;
            }
        }
        final Pattern pattern = Pattern.compile(patternString);
        pathMatchers.add(new RegexPathMatcher(pattern));
    }
    return pathMatchers;
}
Also used : Pattern(java.util.regex.Pattern) PathMatcher(com.navercorp.pinpoint.bootstrap.util.PathMatcher) RegexPathMatcher(com.navercorp.pinpoint.bootstrap.util.RegexPathMatcher) AntPathMatcher(com.navercorp.pinpoint.bootstrap.util.AntPathMatcher) ArrayList(java.util.ArrayList) RegexPathMatcher(com.navercorp.pinpoint.bootstrap.util.RegexPathMatcher) AntPathMatcher(com.navercorp.pinpoint.bootstrap.util.AntPathMatcher)

Aggregations

AntPathMatcher (com.navercorp.pinpoint.bootstrap.util.AntPathMatcher)1 PathMatcher (com.navercorp.pinpoint.bootstrap.util.PathMatcher)1 RegexPathMatcher (com.navercorp.pinpoint.bootstrap.util.RegexPathMatcher)1 ArrayList (java.util.ArrayList)1 Pattern (java.util.regex.Pattern)1