use of com.newrelic.agent.extension.beans.Extension.Instrumentation.Pointcut.Method.Parameters in project newrelic-java-agent by newrelic.
the class MethodMatcherUtility method createMethodMatcher.
public static MethodMatcher createMethodMatcher(String className, Method method, Map<String, MethodMapper> classesToMethods, String extName) throws NoSuchMethodException, XmlException {
if (method == null) {
throw new XmlException("A method must be specified for a point cut in the extension.");
}
if (method.getReturnType() != null) {
if (Utils.isPrimitiveType(method.getReturnType())) {
throw new XmlException("The return type '" + method.getReturnType() + "' is not valid. Primitive types are not allowed.");
}
Type returnType = Type.getObjectType(method.getReturnType().replace('.', '/'));
if (!ExtensionConversionUtility.isReturnTypeOkay(returnType)) {
throw new XmlException("The return type '" + returnType.getClassName() + "' is not valid. Primitive types are not allowed.");
}
return new ExactReturnTypeMethodMatcher(returnType);
}
validateMethod(method, extName);
String methodName = method.getName();
if (methodName == null) {
throw new XmlException("A method name must be specified for a point cut in the extension.");
}
methodName = methodName.trim();
if (methodName.length() == 0) {
throw new XmlException("A method must be specified for a point cut in the extension.");
}
Parameters mParams = method.getParameters();
if (mParams == null || mParams.getType() == null) {
if (!isDuplicateMethod(className, methodName, null, classesToMethods)) {
return new NameMethodMatcher(methodName);
} else {
throw new NoSuchMethodException("Method " + methodName + " has already been added to a point cut and will " + "not be added again.");
}
} else {
String descriptor = MethodParameters.getDescriptor(mParams);
if (descriptor == null) {
throw new XmlException("Descriptor not being calculated correctly.");
}
String mDescriptor = descriptor.trim();
if (!isDuplicateMethod(className, methodName, mDescriptor, classesToMethods)) {
return ExactParamsMethodMatcher.createExactParamsMethodMatcher(methodName, descriptor);
} else {
throw new NoSuchMethodException("Method " + methodName + " has already been added to a point cut and will " + "not be added again.");
}
}
}
Aggregations