Search in sources :

Example 1 with SpringBeansTarget

use of com.navercorp.pinpoint.plugin.spring.beans.SpringBeansTarget 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;
}
Also used : SpringBeansTarget(com.navercorp.pinpoint.plugin.spring.beans.SpringBeansTarget) PathMatcher(com.navercorp.pinpoint.bootstrap.util.PathMatcher)

Example 2 with SpringBeansTarget

use of com.navercorp.pinpoint.plugin.spring.beans.SpringBeansTarget 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;
}
Also used : SpringBeansTarget(com.navercorp.pinpoint.plugin.spring.beans.SpringBeansTarget) PathMatcher(com.navercorp.pinpoint.bootstrap.util.PathMatcher) AnnotatedBeanDefinition(org.springframework.beans.factory.annotation.AnnotatedBeanDefinition)

Aggregations

PathMatcher (com.navercorp.pinpoint.bootstrap.util.PathMatcher)2 SpringBeansTarget (com.navercorp.pinpoint.plugin.spring.beans.SpringBeansTarget)2 AnnotatedBeanDefinition (org.springframework.beans.factory.annotation.AnnotatedBeanDefinition)1