Package org.glassfish.contextpropagation
Interface ContextMap
-
public interface ContextMap
This is the primary API for application developers who want to use context propagation. The in-scope instance of this class is available in the jndi under the name: request/ContextMap. This class is used to retrieve and store contexts that will be automatically propagated depending on the protocol doing the propagation and the context's propagation mode. Each protocol has a unique propagation mode such as SOAP or RMI. Each context may be associated to one or more propagation mode. When a protocol exchange a message, each in-scope context associated to that protocol, via the propagation mode, will be transeferred along with the message.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T extends ViewCapable>
TcreateViewCapable(String prefix)
ViewCapable instances are custom contexts and are created by the context propagation framework by using a ContextViewFactory registered against the corresponding context's name prefix.<T> T
get(String name)
AccessControlledMap
getAccessControlledMap()
This method is used when one needs to propagate the ContextMap to another Thread.Location
getLocation()
EnumSet<PropagationMode>
getPropagationModes(String name)
Get the propagation modes of a the context with the specified name.boolean
isEmpty()
Iterator<String>
names()
<T> T
put(String name, Boolean context, EnumSet<PropagationMode> propagationModes)
Stores the specified context under the specified name into the in-scope ContextMap.<T> T
put(String name, Character context, EnumSet<PropagationMode> propagationModes)
Stores the specified context under the specified name into the in-scope ContextMap.<T> T
put(String name, String context, EnumSet<PropagationMode> propagationModes)
Stores the specified context under the specified name into the in-scope ContextMap.<T,U extends Number>
Tput(String name, U context, EnumSet<PropagationMode> propagationModes)
Stores the specified context under the specified name into the in-scope ContextMap.<T> T
remove(String name)
Removes the specified context under the specified name from the in-scope ContextMap.
-
-
-
Method Detail
-
getPropagationModes
EnumSet<PropagationMode> getPropagationModes(String name) throws InsufficientCredentialException
Get the propagation modes of a the context with the specified name.- Parameters:
name
- context name- Returns:
- A set of propagation modes supported by this context.
- Throws:
InsufficientCredentialException
-
isEmpty
boolean isEmpty()
- Returns:
- true if there are no context in the ContextMap
-
createViewCapable
<T extends ViewCapable> T createViewCapable(String prefix) throws InsufficientCredentialException
ViewCapable instances are custom contexts and are created by the context propagation framework by using a ContextViewFactory registered against the corresponding context's name prefix. This method creates an instance of a ViewCapable and adds it to the ContextMap under the specified prefix.- Parameters:
prefix
- It is the name associated to the ViewCapable instance in the ContextMap- Returns:
- The ViewCapableInstance
- Throws:
InsufficientCredentialException
-
getLocation
Location getLocation()
- Returns:
- The Location of the request relative to the original location where it was first submitted.
-
get
<T> T get(String name) throws InsufficientCredentialException
- Parameters:
name
- The name of the context sought.- Returns:
- The context associated to the specified name.
- Throws:
InsufficientCredentialException
- If the user has insufficient privileges to access that context.
-
put
<T> T put(String name, String context, EnumSet<PropagationMode> propagationModes) throws InsufficientCredentialException
Stores the specified context under the specified name into the in-scope ContextMap.- Parameters:
name
- The name to associate to the specified contextcontext
- a String context.propagationModes
- A set of propagation modes that determines over which protocol this context will be propagated.- Returns:
- The context being replaced.
- Throws:
InsufficientCredentialException
- If the user has insufficient privileges to access that context.
-
put
<T,U extends Number> T put(String name, U context, EnumSet<PropagationMode> propagationModes) throws InsufficientCredentialException
Stores the specified context under the specified name into the in-scope ContextMap.- Parameters:
name
- The name to associate to the specified contextcontext
- a Number context.propagationModes
- A set of propagation modes that determines over which protocol this context will be propagated.- Returns:
- The context being replaced.
- Throws:
InsufficientCredentialException
- If the user has insufficient privileges to access that context.
-
put
<T> T put(String name, Boolean context, EnumSet<PropagationMode> propagationModes) throws InsufficientCredentialException
Stores the specified context under the specified name into the in-scope ContextMap.- Parameters:
name
- The name to associate to the specified contextcontext
- an boolean String context.propagationModes
- A set of propagation modes that determines over which protocol this context will be propagated.- Returns:
- The context being replaced.
- Throws:
InsufficientCredentialException
- If the user has insufficient privileges to access that context.
-
put
<T> T put(String name, Character context, EnumSet<PropagationMode> propagationModes) throws InsufficientCredentialException
Stores the specified context under the specified name into the in-scope ContextMap.- Parameters:
name
- The name to associate to the specified contextcontext
- an char String context.propagationModes
- A set of propagation modes that determines over which protocol this context will be propagated.- Returns:
- The context being replaced.
- Throws:
InsufficientCredentialException
- If the user has insufficient privileges to access that context.
-
remove
<T> T remove(String name) throws InsufficientCredentialException
Removes the specified context under the specified name from the in-scope ContextMap.- Parameters:
name
- The name to which the context was associated- Returns:
- The context being replaced.
- Throws:
InsufficientCredentialException
- If the user has insufficient privileges to access that context.
-
getAccessControlledMap
AccessControlledMap getAccessControlledMap()
This method is used when one needs to propagate the ContextMap to another Thread.- Returns:
- The AccessControlledMap that is in scope for the current thread
-
-