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 Detail

      • isEmpty

        boolean isEmpty()
        Returns:
        true if there are no context in the ContextMap
      • names

        Iterator<String> names()
        Returns:
        An Iterator listing all the context names 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.
      • 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 context
        context - 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 context
        context - 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 context
        context - 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 context
        context - 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