org.apache.camel.guice.util
Class CloseableScope

java.lang.Object
  extended by org.apache.camel.guice.util.CloseableScope
All Implemented Interfaces:
com.google.inject.Scope, HasScopeAnnotation

public class CloseableScope
extends Object
implements com.google.inject.Scope, HasScopeAnnotation

Represents a scope which caches objects around until the scope is closed. The scope can be closed as many times as required - there is no need to recreate the scope instance each time a scope goes out of scope.

Version:

Constructor Summary
CloseableScope(Class<? extends Annotation> scopeAnnotation)
           
 
Method Summary
 void close()
          Closes all of the objects within this scope using the given injector and scope annotation and clears the scope
 void close(com.google.inject.Injector injector)
          Closes all of the objects within the given injector of the specified scope and clears the scope
 Class<? extends Annotation> getScopeAnnotation()
          Returns the scope annotation associated with this object
<T> com.google.inject.Provider<T>
scope(com.google.inject.Key<T> key, com.google.inject.Provider<T> creator)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.google.inject.Scope
toString
 

Constructor Detail

CloseableScope

public CloseableScope(Class<? extends Annotation> scopeAnnotation)
Method Detail

scope

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

close

public void close()
           throws CloseFailedException
Closes all of the objects within this scope using the given injector and scope annotation and clears the scope

Throws:
CloseFailedException

close

public void close(com.google.inject.Injector injector)
           throws CloseFailedException
Closes all of the objects within the given injector of the specified scope and clears the scope

Throws:
CloseFailedException

getScopeAnnotation

public Class<? extends Annotation> getScopeAnnotation()
Description copied from interface: HasScopeAnnotation
Returns the scope annotation associated with this object

Specified by:
getScopeAnnotation in interface HasScopeAnnotation


Apache Camel