Interface Container

All Superinterfaces:
SharedResource, Timer

public interface Container extends 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
  • Method Details

    • resolveHandler

      RequestHandler resolveHandler(Request request)
      Attempts to find a RequestHandler in the current server- (if Request.isServerRequest() is true) or client- (if Request.isServerRequest() is false) BindingSet that matches the given URI. If no match can be found, this method returns null.
      Parameters:
      request - The Request to match against the bound RequestHandlers.
      Returns:
      The matching RequestHandler, or null if there is no match.
    • getInstance

      <T> T getInstance(Class<T> type)
      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.