SearchResult result = context.getAttribute(SearchResult.class);
ResourceInstance resource = result.getResource();
SubResourceRecord subResourceRecord = subResourceInstance.getRecord();
String pattern = subResourceRecord.getTemplateProcessor().getPatternString();
// dispatch to one of the sub-resource methods.
SubResourceInstance method = null;
try {
// if no method is found then a RequestMatchingException exception
// is thrown
method = registry.findSubResourceMethod(pattern, subResources, resource, context);
} catch (WebApplicationException e) {
// couldn't find a method
result.setError(e);
return;
}
UriTemplateMatcher matcher = method.getMatcher();
saveFoundMethod(result, matcher, method, context);
// continue the chain to invoke the method
if (logger.isTraceEnabled()) {
MethodMetadata metadata = (method == null) ? null : method.getMetadata();
logger.trace("Found subresource method to invoke: {} ", metadata); //$NON-NLS-1$
}
chain.doChain(context);
}