/** * Gets {@link AssignmentFilterProvider#getClassSensorAssignmentFilter()}. * * @return {@link AssignmentFilterProvider#getClassSensorAssignmentFilter()} */ protected ClassSensorAssignmentFilter getClassSensorAssignmentFilter() { return assignmentFilterProvider.getClassSensorAssignmentFilter(); }
/** * Gets {@link AssignmentFilterProvider#getMethodsSensorAssignmentFilter()}. * * @return {@link AssignmentFilterProvider#getMethodSensorAssignmentFilter()} */ protected MethodSensorAssignmentFilter getMethodSensorAssignmentFilter() { return assignmentFilterProvider.getMethodSensorAssignmentFilter(); }
/** * Gets {@link AssignmentFilterProvider#getJmxSensorAssignmentFilter()}. * * @return {@link AssignmentFilterProvider#getJmxSensorAssignmentFilter()} */ protected JmxSensorAssignmentFilter getJmxSensorAssignmentFilter() { return assignmentFilterProvider.getJmxSensorAssignmentFilter(); }
@BeforeMethod public void setup() { applier = new MethodSensorInstrumentationApplier(assignment, environment, registrationService); applier.assignmentFilterProvider = filterProvider; // filters to true by default when(filterProvider.getClassSensorAssignmentFilter()).thenReturn(classFilter); when(filterProvider.getMethodSensorAssignmentFilter()).thenReturn(methodFilter); when(methodFilter.matches(Matchers.<MethodSensorAssignment> any(), Matchers.<MethodType> any())).thenReturn(true); when(classFilter.matches(Matchers.<AbstractClassSensorAssignment<?>> any(), Matchers.<ClassType> any(), Matchers.eq(false))).thenReturn(true); // class to return one method when(classType.getMethods()).thenReturn(Collections.singleton(methodType)); }
/** * Checks if the {@link MethodType} matches the the {@link MethodSensorAssignment}. * * @param methodSensorAssignment * {@link MethodSensorAssignment}. * @param methodType * method type to check * @return <code>true</code> if the method matches the {@link MethodSensorAssignment} */ public boolean matches(MethodSensorAssignment methodSensorAssignment, ImmutableMethodType methodType) { if (!matchesMethodName(methodSensorAssignment, methodType)) { return false; } if (!matchesParameters(methodSensorAssignment, methodType)) { return false; } if (!matchesModifiers(methodSensorAssignment, methodType)) { return false; } if (!matchesAnnotation(methodSensorAssignment, methodType)) { return false; } return true; }
/** * Tests if the given {@link ImmutableClassType} matches the class sensor assignment. Same as * calling {@link #matches(AbstractClassSensorAssignment, ImmutableClassType, true)}. * * @param classSensorAssignment * assignment. * @param classType * classType * @return <code>true</code> if class type matches the assignment. */ public boolean matches(AbstractClassSensorAssignment<?> classSensorAssignment, ImmutableClassType classType) { return matches(classSensorAssignment, classType, true); }
/** * {@inheritDoc} */ @Override protected boolean matches(MethodType methodType) { return getMethodSensorAssignmentFilter().matches(methodSensorAssignment, methodType); }
/** * Tests if the given {@link ImmutableClassType} matches the class sensor assignment. This * method allows option for non-checking the annotation, which can be helpful with method sensor * assignments as the annotation matching must be also done on the method level. * * @param classSensorAssignment * assignment. * @param classType * classType * @param checkAnnotation * if annotation matching has to be checked on the {@link ClassType} * @return <code>true</code> if class type matches the assignment. */ public boolean matches(AbstractClassSensorAssignment<?> classSensorAssignment, ImmutableClassType classType, boolean checkAnnotation) { if (!matchesClassName(classSensorAssignment, classType)) { return false; } if (checkAnnotation && !matchesAnnotation(classSensorAssignment, classType)) { return false; } return true; }
/** * If the assignment matches the {@link JmxAttributeDescriptor}. * <p> * By default uses filter provided by {@link #getJmxSensorAssignmentFilter()}. * * @param jmxAttributeDescriptor * Descriptor to check. * @return True if the assignment matches the descriptor. */ protected boolean matches(JmxAttributeDescriptor jmxAttributeDescriptor) { return getJmxSensorAssignmentFilter().matches(jmxSensorAssignment, jmxAttributeDescriptor); }
/** * Checks if the given {@link ImmutableClassType} or any of it's super classes have an * annotation that matches given annotation pattern. * * @param classType * Type to check. * @param annotationPattern * Pattern to test annotation FQNs with. * @return <code>true</code> if class or any super-classes have annotation that matches the * pattern. */ private boolean checkClassAndSuperClassForAnnotation(ImmutableClassType classType, IMatchPattern annotationPattern) { if (checkAnnotations(classType.getImmutableAnnotations(), annotationPattern)) { return true; } for (ImmutableClassType superClassType : classType.getImmutableSuperClasses()) { if (checkClassAndSuperClassForAnnotation(superClassType, annotationPattern)) { return true; } } return false; }
/** * Checks if the given {@link ImmutableInterfaceType} or any of it's super interfaces have an * annotation that matches given annotation pattern. * * @param interfaceType * Type to check. * @param annotationPattern * Pattern to test annotation FQNs with. * @return <code>true</code> if interface or any super-interfaces have annotation that matches * the pattern. */ private boolean checkInterfaceAndSuperInterfaceForAnnotation(ImmutableInterfaceType interfaceType, IMatchPattern annotationPattern) { if (checkAnnotations(interfaceType.getImmutableAnnotations(), annotationPattern)) { return true; } for (ImmutableInterfaceType superInterfaceType : interfaceType.getImmutableSuperInterfaces()) { if (checkInterfaceAndSuperInterfaceForAnnotation(superInterfaceType, annotationPattern)) { return true; } } return false; }
@BeforeMethod public void init() { filter = new MethodSensorAssignmentFilter(); }
@BeforeMethod public void init() { filter = new ClassSensorAssignmentFilter(); }
@BeforeMethod public void setup() { applier = new InvocationStartMethodSensorInstrumentationApplier(assignment, environment, registrationService); applier.assignmentFilterProvider = filterProvider; // filters to true by default when(filterProvider.getClassSensorAssignmentFilter()).thenReturn(classFilter); when(filterProvider.getMethodSensorAssignmentFilter()).thenReturn(methodFilter); when(methodFilter.matches(Matchers.<MethodSensorAssignment> any(), Matchers.<MethodType> any())).thenReturn(true); when(classFilter.matches(Matchers.<AbstractClassSensorAssignment<?>> any(), Matchers.<ClassType> any(), Matchers.eq(false))).thenReturn(true); // class to return one method when(classType.getMethods()).thenReturn(Collections.singleton(methodType)); }
/** * {@inheritDoc} */ @Override protected boolean matches(ClassType classType) { return getClassSensorAssignmentFilter().matches(methodSensorAssignment, classType, false); }
/** * {@inheritDoc} * <p> * We only support method instrumentation with special assignments for now. No constructors of * any kind. */ @Override protected boolean matches(MethodType methodType) { return MethodType.Character.METHOD.equals(methodType.getMethodCharacter()) && getMethodSensorAssignmentFilter().matches(functionalAssignment, methodType); }
@BeforeMethod public void setup() { applier = new TimerMethodSensorInstrumentationApplier(assignment, environment, registrationService); applier.assignmentFilterProvider = filterProvider; // filters to true by default when(filterProvider.getClassSensorAssignmentFilter()).thenReturn(classFilter); when(filterProvider.getMethodSensorAssignmentFilter()).thenReturn(methodFilter); when(methodFilter.matches(Matchers.<MethodSensorAssignment> any(), Matchers.<MethodType> any())).thenReturn(true); when(classFilter.matches(Matchers.<AbstractClassSensorAssignment<?>> any(), Matchers.<ClassType> any(), Matchers.eq(false))).thenReturn(true); // class to return one method when(classType.getMethods()).thenReturn(Collections.singleton(methodType)); }
/** * {@inheritDoc} */ @Override protected boolean matches(ClassType classType) { return getClassSensorAssignmentFilter().matches(functionalAssignment, classType, false); }
@BeforeMethod public void setup() { applier = new SpecialInstrumentationApplier(assignment, environment, registrationService); applier.assignmentFilterProvider = filterProvider; // filters to true by default when(filterProvider.getClassSensorAssignmentFilter()).thenReturn(classFilter); when(filterProvider.getMethodSensorAssignmentFilter()).thenReturn(methodFilter); when(methodFilter.matches(Matchers.<MethodSensorAssignment> any(), Matchers.<MethodType> any())).thenReturn(true); when(classFilter.matches(Matchers.<AbstractClassSensorAssignment<?>> any(), Matchers.<ClassType> any(), Matchers.eq(false))).thenReturn(true); // class to return one method when(classType.getMethods()).thenReturn(Collections.singleton(methodType)); when(methodType.getMethodCharacter()).thenReturn(Character.METHOD); }
/** * {@inheritDoc} */ @Override protected boolean matches(ClassType classType) { return classType.isException() && getClassSensorAssignmentFilter().matches(exceptionSensorAssignment, classType); }