use of com.navercorp.pinpoint.bootstrap.util.PathMatcher 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;
}
use of com.navercorp.pinpoint.bootstrap.util.PathMatcher in project pinpoint by naver.
the class TargetBeanFilter method isTarget.
public boolean isTarget(final SpringBeansTargetScope scope, final String beanName, final Class<?> clazz) {
if (scope == null || beanName == null || clazz == null) {
return false;
}
final String className = clazz.getName();
if (className == null) {
return false;
}
if (cache.contains(className)) {
return false;
}
for (SpringBeansTarget target : targets) {
// check scope.
if (target.getScope() != scope) {
continue;
}
boolean condition = false;
// check base packages.
final List<String> basePackages = target.getBasePackages();
if (CollectionUtils.hasLength(basePackages)) {
if (!isBasePackage(target, className)) {
continue;
}
condition = true;
}
// check bean name pattern.
final List<PathMatcher> namePatterns = target.getNamePatterns();
if (CollectionUtils.hasLength(namePatterns)) {
if (!isBeanNameTarget(target, beanName)) {
continue;
}
condition = true;
}
// check class name pattern.
final List<PathMatcher> classPatterns = target.getClassPatterns();
if (CollectionUtils.hasLength(classPatterns)) {
if (!isClassNameTarget(target, className)) {
continue;
}
condition = true;
}
// check class annotation.
final List<String> annotations = target.getAnnotations();
if (CollectionUtils.hasLength(annotations)) {
if (!isAnnotationTarget(target, clazz)) {
continue;
}
condition = true;
}
if (condition) {
// AND condition.
return true;
}
}
return false;
}
use of com.navercorp.pinpoint.bootstrap.util.PathMatcher in project pinpoint by naver.
the class TargetBeanFilter method isTarget.
public boolean isTarget(final SpringBeansTargetScope scope, final String beanName, final BeanDefinition beanDefinition) {
if (scope == null || beanName == null || beanDefinition == null) {
return false;
}
final String className = beanDefinition.getBeanClassName();
if (className == null) {
return false;
}
if (cache.contains(className)) {
return false;
}
for (SpringBeansTarget target : targets) {
// check scope.
if (target.getScope() != scope) {
continue;
}
boolean condition = false;
// check base packages.
final List<String> basePackages = target.getBasePackages();
if (CollectionUtils.hasLength(basePackages)) {
if (!isBasePackage(target, className)) {
continue;
}
condition = true;
}
// check bean name pattern.
final List<PathMatcher> namePatterns = target.getNamePatterns();
if (CollectionUtils.hasLength(namePatterns)) {
if (!isBeanNameTarget(target, beanName)) {
continue;
}
condition = true;
}
// check class name pattern.
final List<PathMatcher> classPatterns = target.getClassPatterns();
if (CollectionUtils.hasLength(classPatterns)) {
if (!isClassNameTarget(target, className)) {
continue;
}
condition = true;
}
// check class annotation.
final List<String> annotations = target.getAnnotations();
if (CollectionUtils.hasLength(annotations)) {
if (!(beanDefinition instanceof AnnotatedBeanDefinition) || !isAnnotationTarget(target, (AnnotatedBeanDefinition) beanDefinition)) {
continue;
}
condition = true;
}
if (condition) {
// AND condition.
return true;
}
}
return false;
}
Aggregations