|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Scope
Strategy interface used by a ConfigurableBeanFactory
,
representing a target scope to hold beans in.
Provides the ability to get and put objects from whatever underlying
storage mechanism, such as HTTP session or request. The name passed into
this class's get
and put
methods will identify
the target attribute in the scope.
Scope
implementations are expected to be thread-safe.
One Scope
can be used with multiple bean factories, if desired.
An example of a possible underlying storage mechanism would be a session
API such as the Servlet API's HttpSession
interface.
ConfigurableBeanFactory.registerScope(java.lang.String, org.springframework.beans.factory.config.Scope)
,
ScopedProxyFactoryBean
,
CustomScopeConfigurer
Method Summary | |
---|---|
Object |
get(String name,
ObjectFactory objectFactory)
Return the object with the given name from the underlying scope, creating it
if not found in the underlying storage mechanism. |
String |
getConversationId()
Return the conversation id for the current underlying scope, if any. |
void |
registerDestructionCallback(String name,
Runnable callback)
Register a callback to be executed at destruction of the specified object (or at destruction of the entire scope, if the scope does not destroy individual objects but rather only terminate in its entirety). |
Object |
remove(String name)
Remove the object with the given name from the underlying scope. |
Method Detail |
---|
String getConversationId()
The exact value of the converation id is totally dependent on the
underlying storage mechanism (of course). In the case of session scoped
beans a good conversation id probably would be the
session id
; in the case
of a JCache scope a good conversation id probably would be the name of
the associated cache.
It is perfectly valid to return null
in an
implementation of this method if the underlying storage mechanism has
no obvious good candidate for a conversation id.
null
if there is no
conversation id for this scopeObject get(String name, ObjectFactory objectFactory)
creating it
if not found in the underlying storage mechanism.
name
- the name of the object to retrieveobjectFactory
- the ObjectFactory
to use to create the scoped object if it is not present in the
underlying storage mechanism
Object remove(String name)
name
from the underlying scope.
Returns null
if no object was found; otherwise
returns the removed Object
.
name
- the name of the object to remove
void registerDestructionCallback(String name, Runnable callback)
Implementations should do their best to execute the callback at the appropriate time. If such a callback is not supported by the underlying runtime environment, the callback must be ignored and a corresponding warning should be logged.
name
- the name of the object to execute the destruction callback forcallback
- the destruction callback to be executed
|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |