Package de.aristaflow.adept2.model.mail
Class SerialisableAttachmentDataSource
- java.lang.Object
-
- de.aristaflow.adept2.model.mail.SerialisableAttachmentDataSource
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,javax.activation.DataSource
public class SerialisableAttachmentDataSource extends Object implements javax.activation.DataSource, Closeable
This class wraps aSerialisableAttachment
in aDataSource
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 Summary
Fields Modifier and Type Field Description protected SerialisableAttachment
att
The wrapped serialisable attachment.protected Cleanup<IOException>
cleanup
The clean-up for closing theSerialisableAttachment
satt
as post-mortem task for this instance.
-
Constructor Summary
Constructors Constructor Description SerialisableAttachmentDataSource(SerialisableAttachment att)
Creates a new wrapper for aSerialisableAttachment
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
String
getContentType()
InputStream
getInputStream()
String
getName()
OutputStream
getOutputStream()
-
-
-
Field Detail
-
att
protected final SerialisableAttachment att
The wrapped serialisable attachment.
-
cleanup
protected final Cleanup<IOException> cleanup
The clean-up for closing theSerialisableAttachment
satt
as post-mortem task for this instance.
-
-
Constructor Detail
-
SerialisableAttachmentDataSource
public SerialisableAttachmentDataSource(SerialisableAttachment att)
Creates a new wrapper for aSerialisableAttachment
.- Parameters:
att
- The wrapped serialisable attachment.
-
-
Method Detail
-
getName
public String getName()
- Specified by:
getName
in interfacejavax.activation.DataSource
-
getContentType
public String getContentType()
- Specified by:
getContentType
in interfacejavax.activation.DataSource
-
getInputStream
public InputStream getInputStream() throws IOException
- Specified by:
getInputStream
in interfacejavax.activation.DataSource
- Throws:
IOException
-
getOutputStream
public OutputStream getOutputStream() throws IOException
- Specified by:
getOutputStream
in interfacejavax.activation.DataSource
- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
-