Package jodd.petite.scope
Class ThreadLocalScope
- java.lang.Object
-
- jodd.petite.scope.ThreadLocalScope
-
- All Implemented Interfaces:
Scope
public class ThreadLocalScope extends java.lang.Object implements Scope
Thread local Petite bean scope. Holds beans in thread local scopes. Be careful with this scope, if you do not have control on threads! For example, app servers may have a thread pools, so threads may not finish when expected. ThreadLocalScope can not invoke destroy methods.
-
-
Constructor Summary
Constructors Constructor Description ThreadLocalScope(PetiteContainer pc)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaccept(Scope referenceScope)Defines allowed referenced scopes that can be injected into the thread-local scoped bean.java.lang.Objectlookup(java.lang.String name)Lookups for bean name.voidregister(BeanDefinition beanDefinition, java.lang.Object bean)Registers the bean within the current scope.voidremove(java.lang.String name)Removes the bean from the scope entirely.voidshutdown()Shutdowns the scope by removing all beans and calling destroy methods.
-
-
-
Field Detail
-
context
protected static java.lang.ThreadLocal<java.util.Map<java.lang.String,BeanData>> context
-
-
Constructor Detail
-
ThreadLocalScope
public ThreadLocalScope(PetiteContainer pc)
-
-
Method Detail
-
lookup
public java.lang.Object lookup(java.lang.String name)
Description copied from interface:ScopeLookups for bean name. Returnsnullif bean is not found or yet registered.
-
register
public void register(BeanDefinition beanDefinition, java.lang.Object bean)
Description copied from interface:ScopeRegisters the bean within the current scope. Usually registers it by its name fromBeanDefinition. Also it may register destroy methods of a bean within this scope.
-
remove
public void remove(java.lang.String name)
Description copied from interface:ScopeRemoves the bean from the scope entirely. Destroy methods are not called as it is assumed that bean is destroyed manually.
-
accept
public boolean accept(Scope referenceScope)
Defines allowed referenced scopes that can be injected into the thread-local scoped bean.
-
-