org.guiceyfruit.util
Class CloseableScope

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

public class CloseableScope
extends java.lang.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:
$Revision: 1.1 $

Constructor Summary
CloseableScope(java.lang.Class<? extends java.lang.annotation.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
 java.lang.Class<? extends java.lang.annotation.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(java.lang.Class<? extends java.lang.annotation.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 java.lang.Class<? extends java.lang.annotation.Annotation> getScopeAnnotation()
Description copied from interface: HasScopeAnnotation
Returns the scope annotation associated with this object

Specified by:
getScopeAnnotation in interface HasScopeAnnotation


Copyright © 2011. All Rights Reserved.