Class ThreadLocalMimeBodyPartRecorder
- java.lang.Object
-
- com.atlassian.confluence.mail.embed.ThreadLocalMimeBodyPartRecorder
-
- All Implemented Interfaces:
MimeBodyPartRecorder
public class ThreadLocalMimeBodyPartRecorder extends Object implements MimeBodyPartRecorder
This implementation relies on aThreadLocal
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
Constructors Constructor Description ThreadLocalMimeBodyPartRecorder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
isRecording()
<T> io.atlassian.fugue.Pair<Optional<T>,Iterable<MimeBodyPartReference>>
startRecording(Callable<T> callback)
Activate the recorder so that it can recordMimeBodyPartRecorder.trackSource(DataSource)
calls.Optional<MimeBodyPartReference>
trackSource(javax.activation.DataSource source)
Track the given image source.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.atlassian.confluence.mail.embed.MimeBodyPartRecorder
record, track
-
-
-
-
Method Detail
-
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
public Optional<MimeBodyPartReference> trackSource(javax.activation.DataSource source)
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
-
-