com.google.inject.throwingproviders
Class ThrowingProviderBinder
java.lang.Object
com.google.inject.throwingproviders.ThrowingProviderBinder
public class ThrowingProviderBinder
- extends Object
Builds a binding for a 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() {
ThrowingProviderBinder.install(this, binder());
}
@CheckedProvides(RemoteProvider.class)
@RequestScope
Customer provideCustomer(FlakyCustomerCreator creator) throws RemoteException {
return creator.getCustomerOrThrow();
}
}
- Author:
- jmourits@google.com (Jerome Mourits), jessewilson@google.com (Jesse Wilson)
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
create
public static ThrowingProviderBinder create(Binder binder)
forModule
public static Module forModule(Module module)
- Returns a module that installs @
CheckedProvides
methods.
- Since:
- 3.0
bind
public <P extends CheckedProvider> ThrowingProviderBinder.SecondaryBinder<P> bind(Class<P> interfaceType,
Type valueType)
Copyright © 2006-2011 Google, Inc.. All Rights Reserved.