001package io.avaje.inject; 002 003import javax.inject.Provider; 004 005import java.io.Closeable; 006import java.util.List; 007import java.util.Optional; 008import java.util.Set; 009 010/** 011 * Provides request scoped beans in addition to beans from the underlying bean scope. 012 */ 013public interface RequestScope extends Closeable { 014 015 /** 016 * Get a dependency. 017 */ 018 <T> T get(Class<T> type); 019 020 /** 021 * Get a named dependency. 022 */ 023 <T> T get(Class<T> type, String name); 024 025 /** 026 * Get an optional dependency. 027 */ 028 <T> Optional<T> getOptional(Class<T> type); 029 030 /** 031 * Get an optional named dependency. 032 */ 033 <T> Optional<T> getOptional(Class<T> type, String name); 034 035 /** 036 * Get an optional dependency potentially returning null. 037 */ 038 <T> T getNullable(Class<T> type); 039 040 /** 041 * Get an optional named dependency potentially returning null. 042 */ 043 <T> T getNullable(Class<T> type, String name); 044 045 /** 046 * Return Provider of T given the type. 047 */ 048 <T> Provider<T> getProvider(Class<T> type); 049 050 /** 051 * Return Provider of T given the type and name. 052 */ 053 <T> Provider<T> getProvider(Class<T> type, String name); 054 055 /** 056 * Get a list of dependencies for the interface type . 057 */ 058 <T> List<T> list(Class<T> interfaceType); 059 060 /** 061 * Get a set of dependencies for the interface type . 062 */ 063 <T> Set<T> set(Class<T> interfaceType); 064 065 /** 066 * Register a closable with the request scope. 067 * <p> 068 * All closable's registered here are closed at the end of the request scope. 069 */ 070 void addClosable(Closeable closeable); 071 072 /** 073 * Close the scope firing any <code>@PreDestroy</code> methods. 074 */ 075 void close(); 076 077}