Class MessageSupport

java.lang.Object
org.apache.camel.support.MessageSupport
All Implemented Interfaces:
org.apache.camel.CamelContextAware, org.apache.camel.Message, org.apache.camel.spi.DataTypeAware, org.apache.camel.spi.HasCamelContext
Direct Known Subclasses:
DefaultMessage

public abstract class MessageSupport extends Object implements org.apache.camel.Message, org.apache.camel.CamelContextAware, org.apache.camel.spi.DataTypeAware
A base class for implementation inheritance providing the core Message body handling features but letting the derived class deal with headers. Unless a specific provider wishes to do something particularly clever with headers you probably want to just derive from DefaultMessage
  • Field Details

    • camelContext

      protected org.apache.camel.CamelContext camelContext
    • typeConverter

      protected org.apache.camel.TypeConverter typeConverter
  • Constructor Details

    • MessageSupport

      public MessageSupport()
  • Method Details

    • reset

      public void reset()
      Specified by:
      reset in interface org.apache.camel.Message
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getBody

      public Object getBody()
      Specified by:
      getBody in interface org.apache.camel.Message
    • getBody

      public <T> T getBody(Class<T> type)
      Specified by:
      getBody in interface org.apache.camel.Message
    • getMandatoryBody

      public Object getMandatoryBody() throws org.apache.camel.InvalidPayloadException
      Specified by:
      getMandatoryBody in interface org.apache.camel.Message
      Throws:
      org.apache.camel.InvalidPayloadException
    • getBody

      protected <T> T getBody(Class<T> type, Object body)
    • getMandatoryBody

      public <T> T getMandatoryBody(Class<T> type) throws org.apache.camel.InvalidPayloadException
      Specified by:
      getMandatoryBody in interface org.apache.camel.Message
      Throws:
      org.apache.camel.InvalidPayloadException
    • setBody

      public void setBody(Object body)
      Specified by:
      setBody in interface org.apache.camel.Message
    • setBody

      public <T> void setBody(Object value, Class<T> type)
      Specified by:
      setBody in interface org.apache.camel.Message
    • setBody

      public void setBody(Object body, org.apache.camel.spi.DataType type)
      Specified by:
      setBody in interface org.apache.camel.spi.DataTypeAware
    • getDataType

      public org.apache.camel.spi.DataType getDataType()
      Specified by:
      getDataType in interface org.apache.camel.spi.DataTypeAware
    • setDataType

      public void setDataType(org.apache.camel.spi.DataType type)
      Specified by:
      setDataType in interface org.apache.camel.spi.DataTypeAware
    • hasDataType

      public boolean hasDataType()
      Specified by:
      hasDataType in interface org.apache.camel.spi.DataTypeAware
    • copy

      public org.apache.camel.Message copy()
      Specified by:
      copy in interface org.apache.camel.Message
    • copyFrom

      public void copyFrom(org.apache.camel.Message that)
      Specified by:
      copyFrom in interface org.apache.camel.Message
    • copyFromWithNewBody

      public void copyFromWithNewBody(org.apache.camel.Message that, Object newBody)
      Specified by:
      copyFromWithNewBody in interface org.apache.camel.Message
    • getExchange

      public org.apache.camel.Exchange getExchange()
      Specified by:
      getExchange in interface org.apache.camel.Message
    • setExchange

      public void setExchange(org.apache.camel.Exchange exchange)
    • getCamelContext

      public org.apache.camel.CamelContext getCamelContext()
      Specified by:
      getCamelContext in interface org.apache.camel.spi.HasCamelContext
    • setCamelContext

      public void setCamelContext(org.apache.camel.CamelContext camelContext)
      Specified by:
      setCamelContext in interface org.apache.camel.CamelContextAware
    • newInstance

      public abstract org.apache.camel.Message newInstance()
      Returns a new instance
    • createBody

      protected Object createBody()
      A factory method to allow a provider to lazily create the message body for inbound messages from other sources
      Returns:
      the value of the message body or null if there is no value available
    • getMessageId

      public String getMessageId()
      Specified by:
      getMessageId in interface org.apache.camel.Message
    • getMessageTimestamp

      public long getMessageTimestamp()
      Specified by:
      getMessageTimestamp in interface org.apache.camel.Message
    • setMessageId

      public void setMessageId(String messageId)
      Specified by:
      setMessageId in interface org.apache.camel.Message
    • hasMessageId

      public boolean hasMessageId()
      Specified by:
      hasMessageId in interface org.apache.camel.Message
    • createMessageId

      protected String createMessageId()
      Allow implementations to auto-create a messageId
    • hasTrait

      public boolean hasTrait(org.apache.camel.trait.message.MessageTrait trait)
      Specified by:
      hasTrait in interface org.apache.camel.Message
    • getPayloadForTrait

      public Object getPayloadForTrait(org.apache.camel.trait.message.MessageTrait trait)
      Specified by:
      getPayloadForTrait in interface org.apache.camel.Message
    • setPayloadForTrait

      public void setPayloadForTrait(org.apache.camel.trait.message.MessageTrait trait, Object object)
      Specified by:
      setPayloadForTrait in interface org.apache.camel.Message