Package org.restlet.ext.guice
Class RestletGuice.Module
- java.lang.Object
-
- com.google.inject.AbstractModule
-
- org.restlet.ext.guice.RestletGuice.Module
-
- All Implemented Interfaces:
com.google.inject.Module,FinderFactory
- Enclosing class:
- RestletGuice
public static class RestletGuice.Module extends com.google.inject.AbstractModule implements FinderFactory
A Guice module that implementsFinderFactory. On first use of the methods of this facility, if the module hasn't been used to create anInjector, this module creates its own Injector.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) classRestletGuice.Module.KeyFinder(package private) classRestletGuice.Module.ServerResourceKeyFinder
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.ThreadLocal<java.lang.Boolean>alreadyBoundprivate com.google.inject.Injectorinjectorprivate java.lang.Iterable<? extends com.google.inject.Module>modules
-
Constructor Summary
Constructors Constructor Description Module(com.google.inject.Module... modules)Creates a RestletGuice.Module that will install the given modules.Module(java.lang.Iterable<? extends com.google.inject.Module> modules)Creates a RestletGuice.Module that will install the given modules.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidclearAlreadyBound()If this module is used in more than one injector, we clear the thread-local boolean that prevents binding more than once in the same thread.protected voidconfigure()Finderfinder(java.lang.Class<?> cls)Returns aFinderthat will obtain a dependency-injected instance of the ServerResource subtype bound to the type associated with the given class.Finderfinder(java.lang.Class<?> cls, java.lang.Class<? extends java.lang.annotation.Annotation> qualifier)Returns aFinderthat will obtain a dependency-injected instance of the ServerResource subtype bound to the type and qualifier associated with the given class.protected com.google.inject.Provider<Application>newApplicationProvider()Creates aProviderr for the currentApplication.protected com.google.inject.Provider<Context>newContextProvider()Creates aProviderfor the currentContext.protected com.google.inject.Provider<Request>newRequestProvider()Creates aProviderfor the currentRequest.protected com.google.inject.Provider<Response>newResponseProvider()Creates aProviderfor the currentResponse.-
Methods inherited from class com.google.inject.AbstractModule
addError, addError, addError, bind, bind, bind, bindConstant, binder, bindInterceptor, bindListener, bindListener, bindScope, configure, convertToTypes, currentStage, getMembersInjector, getMembersInjector, getProvider, getProvider, install, requestInjection, requestInjection, requestStaticInjection, requireBinding, requireBinding
-
-
-
-
Method Detail
-
clearAlreadyBound
@Inject private void clearAlreadyBound()
If this module is used in more than one injector, we clear the thread-local boolean that prevents binding more than once in the same thread.
-
configure
protected final void configure()
- Overrides:
configurein classcom.google.inject.AbstractModule
-
finder
public Finder finder(java.lang.Class<?> cls)
Description copied from interface:FinderFactoryReturns aFinderthat will obtain a dependency-injected instance of the ServerResource subtype bound to the type associated with the given class.- Specified by:
finderin interfaceFinderFactory- Parameters:
cls- The class to instantiate.- Returns:
- An instance of
Finder.
-
finder
public Finder finder(java.lang.Class<?> cls, java.lang.Class<? extends java.lang.annotation.Annotation> qualifier)
Description copied from interface:FinderFactoryReturns aFinderthat will obtain a dependency-injected instance of the ServerResource subtype bound to the type and qualifier associated with the given class.- Specified by:
finderin interfaceFinderFactory- Parameters:
cls- The class to instantiate.qualifier- The qualifier associated with the given class.- Returns:
- An instance of
Finder.
-
newApplicationProvider
protected com.google.inject.Provider<Application> newApplicationProvider()
Creates aProviderr for the currentApplication. Override to use a custom Application provider.- Returns:
- A
Providerfor the currentApplication.
-
newContextProvider
protected com.google.inject.Provider<Context> newContextProvider()
Creates aProviderfor the currentContext. Override to use a custom Context provider.- Returns:
- A
Providerfor the currentContext.
-
newRequestProvider
protected com.google.inject.Provider<Request> newRequestProvider()
Creates aProviderfor the currentRequest. Override to use a custom Request provider.- Returns:
- A
Providerfor the currentRequest.
-
-