Class ExecutionContext.ApplicationData

  • Enclosing class:
    ExecutionContext

    public static class ExecutionContext.ApplicationData
    extends java.lang.Object
    Immutable class representing additional application specific data associated with the request for method execution represented by this ExecutionContext.

    The application data format is key-value pairs of Strings.

    This application data is provided by the client initiating the execution, it is then transported as is over the wire and is available for the provider-side service implementations on the server. This extra data is completely opaque for the infrastructure, in other words it is a contract between the client and the service implementation only.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String ACCEPT_LANGUAGE_KEY
      ApplicationData translation language preference property key.
      static java.lang.String FORMAT_LOCALE_KEY
      ApplicationData formatting locale property key.
      static java.lang.String TIMEZONE_KEY
      ApplicationData timezone preference property key.
      static java.lang.String USER_AGENT_KEY
      ApplicationData property key for user agent.
    • Constructor Summary

      Constructors 
      Constructor Description
      ApplicationData()
      Constructs an empty instance.
      ApplicationData​(java.lang.String key, java.lang.String value)
      Constructs an instance with a single property only.
      ApplicationData​(java.util.Map<java.lang.String,​java.lang.String> data)
      Constructs an instance with the specified data as a source.
    • Field Detail

      • USER_AGENT_KEY

        public static final java.lang.String USER_AGENT_KEY
        ApplicationData property key for user agent.
        See Also:
        Constant Field Values
      • TIMEZONE_KEY

        public static final java.lang.String TIMEZONE_KEY
        ApplicationData timezone preference property key.

        Optional Timezone ID from the IANA database to be used for rendering date and time values. When missing, UTC will be used.

        See Also:
        Constant Field Values
      • ACCEPT_LANGUAGE_KEY

        public static final java.lang.String ACCEPT_LANGUAGE_KEY
        ApplicationData translation language preference property key.

        Optional parameter following the format of the HTTP 1.1 Accept-Language header (RFC 7231 section 5.3.5) used for selecting localization bundle.

        When missing "en" will be used.

        See Also:
        Constant Field Values
      • FORMAT_LOCALE_KEY

        public static final java.lang.String FORMAT_LOCALE_KEY
        ApplicationData formatting locale property key.

        Optional parameter following the format of the HTTP 1.1 Accept-Language header (RFC 7231 section 5.3.5) used for overriding the value format locale. When missing, implementations will fall back to the accept-language parameter.

        If both parameters are missing, locale neutral formatting should be applied i.e. short date to use "yyyy-MM-dd".

        See Also:
        Constant Field Values
    • Constructor Detail

      • ApplicationData

        public ApplicationData()
        Constructs an empty instance.
      • ApplicationData

        public ApplicationData​(java.util.Map<java.lang.String,​java.lang.String> data)
        Constructs an instance with the specified data as a source.
        Parameters:
        data - key-value entries
        Throws:
        java.lang.NullPointerException - if data is null
      • ApplicationData

        public ApplicationData​(java.lang.String key,
                               java.lang.String value)
        Constructs an instance with a single property only.
        Parameters:
        key - the key of the property
        value - the value of the property
    • Method Detail

      • getProperty

        public java.lang.String getProperty​(java.lang.String key)
        Parameters:
        key - of the property
        Returns:
        value for the specified key or null if it is unavailable
      • getAllProperties

        public java.util.Map<java.lang.String,​java.lang.String> getAllProperties()
        Returns:
        an immutable Map representing all the properties; cannot be null
      • merge

        public static ExecutionContext.ApplicationData merge​(ExecutionContext.ApplicationData source,
                                                             java.util.Map<java.lang.String,​java.lang.String> data)
        Merges the specified source and data into a newly created ApplicationData instance. Any conflicts are resolved in favor of the specified data.
        Parameters:
        source - the source of data; may be null
        data - a collection of properties to merge with the source
        Returns:
        a new instance of ApplicationData combining the specified source and data
        Throws:
        java.lang.NullPointerException - if data is null
      • merge

        public static ExecutionContext.ApplicationData merge​(ExecutionContext.ApplicationData source,
                                                             java.lang.String key,
                                                             java.lang.String value)
        Merges the specified source and property into a newly created ApplicationData instance. The specified value will override the previous one, if a property with the specified key is already present in the source.
        Parameters:
        source - the source of data; may be null
        key - the key of the property to merge with the source
        value - the value of the property to merge with the source
        Returns:
        a new instance of ApplicationData combining the specified source and property