/** * <p>Returns the appropriate instance for the given injection type. Note that this DOES NOT call {@link * SharedResource#refer()}. This is the equivalent of doing:</p> * <pre> * t = containerBuilder.getInstance(type); * resourcePool.add(t); * </pre> * * <p>When this ResourcePool is destroyed, it will release the main reference to the resource * (by calling {@link SharedResource#release()}).</p> * * @param type The injection type to return. * @param <T> The class of the injection type. * @return The appropriate instance of T. * @throws NullPointerException If this pool was constructed without a ContainerBuilder. */ public <T extends SharedResource> T get(Class<T> type) { return add(builder.getInstance(type)); }
/** * <p>Returns the appropriate instance for the given injection key. Note that this DOES NOT call {@link * SharedResource#refer()}. This is the equivalent of doing:</p> * <pre> * t = containerBuilder.getInstance(key); * resourcePool.add(t); * </pre> * * <p>When this ResourcePool is destroyed, it will release the main reference to the resource * (by calling {@link SharedResource#release()}).</p> * * @param key The injection key to return. * @param <T> The class of the injection type. * @return The appropriate instance of T. * @throws NullPointerException If this pool was constructed without a ContainerBuilder. */ public <T extends SharedResource> T get(Key<T> key) { return add(builder.getInstance(key)); }