Class DataSourceAttachment

java.lang.Object
de.aristaflow.adept2.model.mail.SerialisableAttachment
de.aristaflow.adept2.model.mail.DataSourceAttachment
All Implemented Interfaces:
Closeable, Serializable, AutoCloseable

public class DataSourceAttachment extends SerialisableAttachment
A SerialisableAttachment having a datasource as content. If this attachment is serialised, it will become a ByteArrayDataSource.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final jakarta.activation.DataSource
    The data source providing the content.

    Fields inherited from class de.aristaflow.adept2.model.mail.SerialisableAttachment

    contentType, description, inlineName, name
  • Constructor Summary

    Constructors
    Constructor
    Description
    DataSourceAttachment(jakarta.activation.DataSource dataSource, String description)
    Creates an attachment having the designated data source (content, name and content type).
    DataSourceAttachment(jakarta.activation.DataSource dataSource, String description, boolean inline)
    Creates an attachment having the designated data source (content, name and content type).
    DataSourceAttachment(jakarta.activation.DataSource dataSource, String description, String inlineName)
    Creates an attachment having the designated data source (content, name and content type).
    DataSourceAttachment(String name, String description, jakarta.activation.DataSource dataSource)
    Creates an attachment having the designated name and description retrieving the content from the designated data source.
    DataSourceAttachment(String name, String description, String contentType, jakarta.activation.DataSource dataSource)
    Creates an attachment having the designated name, description and content type retrieving the content from the designated data source.
    DataSourceAttachment(String name, String description, String contentType, jakarta.activation.DataSource dataSource, boolean inline)
    Creates an attachment having the designated name, description and content type retrieving the content from the designated data source.
    DataSourceAttachment(String name, String description, String contentType, jakarta.activation.DataSource dataSource, String inlineName)
    Creates an attachment having the designated name, description and content type retrieving the content from the designated data source.
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the content of the attachment represented as InputStream.

    Methods inherited from class de.aristaflow.adept2.model.mail.SerialisableAttachment

    close, getContentType, getDescription, getInlineName, getName

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • dataSource

      protected final jakarta.activation.DataSource dataSource
      The data source providing the content.
  • Constructor Details

    • DataSourceAttachment

      public DataSourceAttachment(String name, String description, jakarta.activation.DataSource dataSource)
      Creates an attachment having the designated name and description retrieving the content from the designated data source. The content type is set to "application/octet-stream". This allows to override name and content type of the data source.
      Parameters:
      name - The name of the attachment.
      description - The description of the attachment.
      dataSource - The data source providing the content (only).
    • DataSourceAttachment

      public DataSourceAttachment(jakarta.activation.DataSource dataSource, String description)
      Creates an attachment having the designated data source (content, name and content type).
      Parameters:
      dataSource - The data source providing the content (and the name and the content type).
      description - The description of the attachment.
    • DataSourceAttachment

      public DataSourceAttachment(String name, String description, String contentType, jakarta.activation.DataSource dataSource)
      Creates an attachment having the designated name, description and content type retrieving the content from the designated data source. This allows to override name and content type of the data source.
      Parameters:
      name - The name of the attachment.
      description - The description of the attachment.
      contentType - The content type (MIME) of the attachment.
      dataSource - The data source providing the content (only).
    • DataSourceAttachment

      public DataSourceAttachment(jakarta.activation.DataSource dataSource, String description, boolean inline)
      Creates an attachment having the designated data source (content, name and content type).
      Parameters:
      dataSource - The data source providing the content (and the name and the content type).
      description - The description of the attachment.
      inline - Whether to inline this attachment in case of an HTML message using the designated name.
    • DataSourceAttachment

      public DataSourceAttachment(String name, String description, String contentType, jakarta.activation.DataSource dataSource, boolean inline)
      Creates an attachment having the designated name, description and content type retrieving the content from the designated data source. This allows to override name and content type of the data source.
      Parameters:
      name - The name of the attachment.
      description - The description of the attachment.
      contentType - The content type (MIME) of the attachment.
      dataSource - The data source providing the content (only).
      inline - Whether to inline this attachment in case of an HTML message using the designated name.
    • DataSourceAttachment

      public DataSourceAttachment(jakarta.activation.DataSource dataSource, String description, String inlineName)
      Creates an attachment having the designated data source (content, name and content type).
      Parameters:
      dataSource - The data source providing the content (and the name and the content type).
      description - The description of the attachment.
      inlineName - The name used in the corresponding HTML message to refer to this attachment to be inlined. Use null to not inline the attachment.
    • DataSourceAttachment

      public DataSourceAttachment(String name, String description, String contentType, jakarta.activation.DataSource dataSource, String inlineName)
      Creates an attachment having the designated name, description and content type retrieving the content from the designated data source. This allows to override name and content type of the data source.
      Parameters:
      name - The name of the attachment.
      description - The description of the attachment.
      contentType - The content type (MIME) of the attachment.
      dataSource - The data source providing the content (only).
      inlineName - The name used in the corresponding HTML message to refer to this attachment to be inlined. Use null to not inline the attachment.
  • Method Details

    • getContent

      public InputStream getContent() throws IOException
      Description copied from class: SerialisableAttachment
      Gets the content of the attachment represented as InputStream.
      Note that this should only be called by the receiving service since the InputStream cannot be serialised.
      Specified by:
      getContent in class SerialisableAttachment
      Returns:
      The actual data of the attachment. The caller is responsible for closing.
      Throws:
      IOException - If there are problems retrieving the content, for instance converting the transferred serialisable data to an InputStream, an IOException will be thrown.