public class ThrowingProviderBinder
extends java.lang.Object
CheckedProvider
.
You can use a fluent API and custom providers:
ThrowingProviderBinder.create(binder())
.bind(RemoteProvider.class, Customer.class)
.to(RemoteCustomerProvider.class)
.in(RequestScope.class);
or, you can use throwing provider methods:
class MyModule extends AbstractModule {
configure() {
install(ThrowingProviderBinder.forModule(this));
}
@CheckedProvides(RemoteProvider.class)
@RequestScope
Customer provideCustomer(FlakyCustomerCreator creator) throws RemoteException {
return creator.getCustomerOrThrow();
}
}
You also can declare that a CheckedProvider construct a particular class whose constructor throws
an exception:
ThrowingProviderBinder.create(binder())
.bind(RemoteProvider.class, Customer.class)
.providing(CustomerImpl.class)
.in(RequestScope.class);
Modifier and Type | Class and Description |
---|---|
class |
ThrowingProviderBinder.SecondaryBinder<P extends CheckedProvider,T> |
Modifier and Type | Method and Description |
---|---|
<P extends CheckedProvider,T> |
bind(java.lang.Class<P> interfaceType,
java.lang.Class<T> clazz) |
<P extends CheckedProvider> |
bind(java.lang.Class<P> interfaceType,
java.lang.reflect.Type clazz)
Deprecated.
Use
bind(Class, Class) or bind(Class, TypeLiteral) instead. |
<P extends CheckedProvider,T> |
bind(java.lang.Class<P> interfaceType,
TypeLiteral<T> typeLiteral) |
static ThrowingProviderBinder |
create(Binder binder) |
static Module |
forModule(Module module)
Returns a module that installs @
CheckedProvides methods. |
public static ThrowingProviderBinder create(Binder binder)
public static Module forModule(Module module)
CheckedProvides
methods.@Deprecated public <P extends CheckedProvider> ThrowingProviderBinder.SecondaryBinder<P,?> bind(java.lang.Class<P> interfaceType, java.lang.reflect.Type clazz)
bind(Class, Class)
or bind(Class, TypeLiteral)
instead.public <P extends CheckedProvider,T> ThrowingProviderBinder.SecondaryBinder<P,T> bind(java.lang.Class<P> interfaceType, java.lang.Class<T> clazz)
public <P extends CheckedProvider,T> ThrowingProviderBinder.SecondaryBinder<P,T> bind(java.lang.Class<P> interfaceType, TypeLiteral<T> typeLiteral)