All Downloads are FREE. Search and download functionalities are using the official Maven repository.

public.javadoc.org.spincast.core.guice.SpincastRequestScope.html Maven / Gradle / Ivy

There is a newer version: 2.2.0
Show newest version






SpincastRequestScope (org.spincast:spincast-framework 1.0.0 API)












org.spincast.core.guice

Class SpincastRequestScope

  • All Implemented Interfaces:
    com.google.inject.Scope


    public class SpincastRequestScope
    extends Object
    implements com.google.inject.Scope
    Guice scope for a request.

    Modified from: https://github.com/google/guice/wiki/CustomScopes:

    Scopes a single execution of a block of code. Apply this scope with a try/finally block:

    
       scope.enter();
       try {
         // explicitly seed some seed objects...
         scope.seed(Key.get(SomeObject.class), someObject);
         // create and access scoped objects
       } finally {
         scope.exit();
       }
     
    The scope can be initialized with one or more seed values by calling seed(key, value) before the injector will be called upon to provide for this key. A typical use is for a servlet filter to enter/exit the scope, representing a Request Scope, and seed HttpServletRequest and HttpServletResponse. For each key inserted with seed(), you must include a corresponding binding:
       bind(key)
           .toProvider(SimpleScope.<KeyClass>seededKeyProvider())
           .in(ScopeAnnotation.class);
     

    Author:
    Jesse Wilson, Fedor Karpelevitch
    • Field Detail

      • logger

        protected final org.slf4j.Logger logger
    • Constructor Detail

      • SpincastRequestScope

        public SpincastRequestScope()
    • Method Detail

      • enter

        public void enter()
      • exit

        public void exit()
      • seed

        public <T> void seed(com.google.inject.Key<T> key,
                             T value)
      • seed

        public <T> void seed(Class<T> clazz,
                             T value)
      • scope

        public <T> com.google.inject.Provider<T> scope(com.google.inject.Key<T> key,
                                                       com.google.inject.Provider<T> unscoped)
        Specified by:
        scope in interface com.google.inject.Scope
      • getScopedObjectMap

        protected <T> Map<com.google.inject.Key<?>,Object> getScopedObjectMap(com.google.inject.Key<T> key)
      • getSeedErrorProvider

        public static <T> com.google.inject.Provider<T> getSeedErrorProvider(com.google.inject.Key key)
        Returns a provider that always throws exception complaining that the object in question must be seeded before it can be injected.
        Returns:
        typed provider

Copyright © 2019. All rights reserved.





© 2015 - 2024 Weber Informatics LLC | Privacy Policy