ServiceReference[] references = null;
try {
references = context.getAllServiceReferences(InitialContextFactory.class.getName(), filter);
} catch (InvalidSyntaxException e) {
NamingException ex = new NamingException("Bad filter: " + filter);
ex.initCause(e);
throw ex;
}
if (references != null) {
Context initialContext = null;
Arrays.sort(references, Utils.SERVICE_REFERENCE_COMPARATOR);