result = new AddonLifecycleProviderEntry(dependency, provider);
}
if (result != null && iterator.hasNext())
{
throw new ContainerException(
"Expected only one ["
+ AddonLifecycleProvider.class.getName()
+ "] but found multiple. Remove all but one redundant container implementations: "
+
Iterators.asList(serviceLoader));
}
}
}
if (result != null)
results.add(result);
}
catch (Throwable e)
{
// FIXME Figure out why ServiceLoader is trying to load things from the wrong ClassLoader
logger.log(Level.FINEST, "ServiceLoader misbehaved when loading AddonLifecycleProvider instances.", e);
}
}
if (results.size() > 1)
{
throw new ContainerException("Expected only one [" + AddonLifecycleProvider.class.getName()
+ "] but found multiple. Remove all but one redundant container implementations: " +
results);
}
return results.isEmpty() ? null : results.get(0);