Class SerialisableAttachmentDataSource

java.lang.Object
de.aristaflow.adept2.model.mail.SerialisableAttachmentDataSource
All Implemented Interfaces:
jakarta.activation.DataSource, Closeable, AutoCloseable

public class SerialisableAttachmentDataSource extends Object implements jakarta.activation.DataSource, Closeable
This class wraps a SerialisableAttachment in a DataSource to allow for easily attaching to messages created with Commons Mail. Name, content and content type will be taken over, getOutputStream() will not work since writing to an attachment does not make sense – at least at the time this data source is being used.
  • Field Details

    • att

      protected final SerialisableAttachment att
      The wrapped serialisable attachment.
    • cleanup

      protected final Cleanup<IOException> cleanup
      The clean-up for closing the SerialisableAttachments att as post-mortem task for this instance.
  • Constructor Details

    • SerialisableAttachmentDataSource

      public SerialisableAttachmentDataSource(SerialisableAttachment att)
      Creates a new wrapper for a SerialisableAttachment.
      Parameters:
      att - The wrapped serialisable attachment.
  • Method Details

    • getName

      public String getName()
      Specified by:
      getName in interface jakarta.activation.DataSource
    • getContentType

      public String getContentType()
      Specified by:
      getContentType in interface jakarta.activation.DataSource
    • getInputStream

      public InputStream getInputStream() throws IOException
      Specified by:
      getInputStream in interface jakarta.activation.DataSource
      Throws:
      IOException
    • getOutputStream

      public OutputStream getOutputStream() throws IOException
      Specified by:
      getOutputStream in interface jakarta.activation.DataSource
      Throws:
      IOException
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException