public T next() {
Class<T> nextClass = (Class<T>) it.next();
try {
return serviceClass.cast(nextClass.newInstance());
} catch (Exception ex) {
ServiceConfigurationError sce = new ServiceConfigurationError(serviceName + ": "
+ SpiMessages.PROVIDER_COULD_NOT_BE_CREATED(nextClass.getName(), serviceClass,
ex.getLocalizedMessage()));
sce.initCause(ex);
throw sce;
}
}
@Override