Class ThreadLocalMimeBodyPartRecorder
java.lang.Object
com.atlassian.confluence.mail.embed.ThreadLocalMimeBodyPartRecorder
- All Implemented Interfaces:
MimeBodyPartRecorder
This implementation relies on a
ThreadLocal
to keep track of embeddable images.
A single instance can be distributed amongst the application under the downside of having to track in the same thread as the caller of record.
If the log level is set to debug, this implementation will perform a check for binary equality of
DataSources
with the same name.
- Since:
- 5.4
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
<T> io.atlassian.fugue.Pair<Optional<T>,
Iterable<MimeBodyPartReference>> startRecording
(Callable<T> callback) Activate the recorder so that it can recordMimeBodyPartRecorder.trackSource(DataSource)
calls.trackSource
(javax.activation.DataSource source) Track the given image source.
-
Constructor Details
-
ThreadLocalMimeBodyPartRecorder
public ThreadLocalMimeBodyPartRecorder()
-
-
Method Details
-
startRecording
public <T> io.atlassian.fugue.Pair<Optional<T>,Iterable<MimeBodyPartReference>> startRecording(Callable<T> callback) throws Exception Description copied from interface:MimeBodyPartRecorder
Activate the recorder so that it can recordMimeBodyPartRecorder.trackSource(DataSource)
calls.- Specified by:
startRecording
in interfaceMimeBodyPartRecorder
- Type Parameters:
T
- the return type of the callback- Parameters:
callback
- the code eligible for recording- Returns:
- a pair of the result of the callback and the recorded references of the embeddable images
- Throws:
Exception
- if the callback escapes
-
isRecording
public boolean isRecording()- Specified by:
isRecording
in interfaceMimeBodyPartRecorder
- Returns:
- true if the current thread is being recorded.
-
trackSource
Description copied from interface:MimeBodyPartRecorder
Track the given image source.- Specified by:
trackSource
in interfaceMimeBodyPartRecorder
- Parameters:
source
- aDataSource
encapsulating the access to the image data- Returns:
- maybe a reference to the given image, will be empty if the recorder is not recording
-