public Object get() {
try {
return future.get();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ProvisionException("interrupted during provision");
} catch (ExecutionException e) {
throw new RuntimeException(e.getCause());
}
}
});
}
}
// All dependencies are now being instantiated in parallel
// Fetch the arguments from the futures and put in an array to pass to newInstance
List<Object> params = Lists.newArrayListWithCapacity(deps.size());
for (Supplier<?> supplier: suppliers) {
params.add(supplier.get());
}
// All dependencies have been initialized
// Look for the @Inject constructor and invoke it.
try {
T obj = (T)constructor.newInstance(params.toArray());
long duration = System.nanoTime() - startTime;
for (LifecycleListener listener : listeners) {
listener.objectInjected((TypeLiteral<T>)TypeLiteral.get(type), obj, duration, TimeUnit.NANOSECONDS);
}
return obj;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
finally {
executor.shutdown();
}
}
}
try {
T obj = type.newInstance();
long duration = System.nanoTime() - startTime;
for (LifecycleListener listener : listeners) {
listener.objectInjected((TypeLiteral<T>)TypeLiteral.get(type), obj, duration, TimeUnit.NANOSECONDS);
}
return obj;
} catch (Exception e) {
e.printStackTrace();
throw new ProvisionException("Error constructing object of type " + type.getName(), e);
}
}
private boolean isConcurrent(Constructor<?> constructor, int parameterIndex) {
Annotation[] annots = constructor.getParameterAnnotations()[parameterIndex];