// If available, sort the references by service ranking.
Arrays.sort(refs, SERVICE_RANK_COMPARATOR);
// Check all referenced services to find one that matches our input.
ArtifactRecognizer recognizer = null;
String foundMimetype = null;
for (ServiceReference ref : refs) {
ArtifactRecognizer candidate = (ArtifactRecognizer) m_context.getService(ref);
if (mimetype != null) {
if (candidate.canHandle(mimetype)) {
recognizer = candidate;
break;
}
}
else {
String candidateMime = candidate.recognize(url);
if (candidateMime != null) {
foundMimetype = candidateMime;
recognizer = candidate;
break;
}