Interface Container
- All Superinterfaces:
SharedResource
,Timer
This is the immutable Container. An instance of this class is attached to every Request
, and as long as
the AbstractResource.release()
method has not been called, that Container instance is actively kept alive to prevent
any race conditions during reconfiguration or shutdown. At any time there is only a single active Container in the
running Application
, and the only way to retrieve a reference to that Container is by calling CurrentContainer.newReference(URI)
. Instead of holding a local Container object inside a ServerProvider
(which will eventually become stale), use the appropriate Request
constructor
instead.
The only way to create a new instance of this class is to 1) create and configure a ContainerBuilder
, and 2) pass that to the ContainerActivator.activateContainer(ContainerBuilder)
method.
- Author:
- Simon Thoresen Hult
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.yahoo.jdisc.SharedResource
SharedResource.Debug
Nested classes/interfaces inherited from interface com.yahoo.jdisc.Timer
Timer.ClockAdapter
-
Field Summary
Fields inherited from interface com.yahoo.jdisc.SharedResource
DEBUG, SYSTEM_PROPERTY_NAME_DEBUG
-
Method Summary
Modifier and TypeMethodDescription<T> T
getInstance
(Class<T> type) Returns the appropriate instance for the given injection type.resolveHandler
(Request request) Attempts to find aRequestHandler
in the current server- (ifRequest.isServerRequest()
is true) or client- (ifRequest.isServerRequest()
is false)BindingSet
that matches the givenURI
.Methods inherited from interface com.yahoo.jdisc.SharedResource
refer, refer, release
Methods inherited from interface com.yahoo.jdisc.Timer
currentTime, currentTimeMillis, toUtcClock
-
Method Details
-
resolveHandler
Attempts to find aRequestHandler
in the current server- (ifRequest.isServerRequest()
is true) or client- (ifRequest.isServerRequest()
is false)BindingSet
that matches the givenURI
. If no match can be found, this method returns null.- Parameters:
request
- The Request to match against the boundRequestHandler
s.- Returns:
- The matching RequestHandler, or null if there is no match.
-
getInstance
Returns the appropriate instance for the given injection type. When feasible, avoid using this method in favor of having Guice inject your dependencies ahead of time.- Type Parameters:
T
- The class of the instance to return.- Parameters:
type
- The class object of the instance to return.- Returns:
- The appropriate instance of the given class.
- Throws:
com.google.inject.ConfigurationException
- If this injector cannot find or create the provider.com.google.inject.ProvisionException
- If there was a runtime failure while providing an instance.
-