Class CloudEventContextUtils

java.lang.Object
io.cloudevents.spring.messaging.CloudEventContextUtils

public class CloudEventContextUtils extends Object
Utility class for copying message headers to and from CloudEventContext.
Author:
Dave Syer
  • Constructor Details

    • CloudEventContextUtils

      public CloudEventContextUtils()
  • Method Details

    • fromMap

      public static io.cloudevents.CloudEventContext fromMap(Map<String,Object> headers) throws io.cloudevents.rw.CloudEventRWException
      Helper method for converting MessageHeaders to a CloudEventContext. The input headers must represent a valid event in "binary" form, i.e. it must have headers ce-id, ce-specversion etc.
      Parameters:
      headers - the input message headers
      Returns:
      a CloudEventContext that can be used to create a new CloudEvent
      Throws:
      io.cloudevents.rw.CloudEventRWException - if something goes wrong while converting the headers to CloudEventContext
    • toMap

      public static Map<String,Object> toMap(io.cloudevents.CloudEventContext context) throws io.cloudevents.rw.CloudEventRWException
      Helper method for extracting MessageHeaders from a CloudEventContext. The result will contain headers canonicalized with a ce- prefix, analogous to the "binary" message format in Cloud Events.
      Parameters:
      context - the input CloudEventContext
      Returns:
      the response headers represented by the event
      Throws:
      io.cloudevents.rw.CloudEventRWException - if something goes wrong while converting the CloudEventContext to headers