final Class rexsterExtensionClass = rexsterExtension.getClass();
final Method[] methods = rexsterExtensionClass.getMethods();
for (Method method : methods) {
// looks for the first method that matches. methods that multi-match will be ignored right now
final ExtensionDefinition extensionDefinition = method.getAnnotation(ExtensionDefinition.class);
final ExtensionDescriptor extensionDescriptor = method.getAnnotation(ExtensionDescriptor.class);
// checks if the extension point is graph, and if the method path matches the specified action on
// the uri (if it exists) or if the method has no path.
if (extensionDefinition != null && extensionDefinition.extensionPoint() == extensionPoint
&& (extensionDefinition.method() == HttpMethod.ANY || extensionDefinition.method() == httpMethodRequested)) {
if ((!extensionAction.isEmpty() && extensionDefinition.path().equals(extensionAction))
|| (extensionAction.isEmpty() && extensionDefinition.path().isEmpty())) {
methodToCall = new ExtensionMethod(method, extensionDefinition, extensionDescriptor, rexsterExtension);
break;
}
}
}
if (methodToCall == null) {
for (Method method : methods) {
final ExtensionDefinition extensionDefinition = method.getAnnotation(ExtensionDefinition.class);
final ExtensionDescriptor extensionDescriptor = method.getAnnotation(ExtensionDescriptor.class);
if (extensionDefinition != null && extensionDefinition.extensionPoint() == extensionPoint
&& (extensionDefinition.method() == HttpMethod.ANY || extensionDefinition.method() == httpMethodRequested)) {
if (!extensionAction.isEmpty() && extensionDefinition.path().isEmpty()) {
methodToCall = new ExtensionMethod(method, extensionDefinition, extensionDescriptor, rexsterExtension);
break;
}
}
}