Class AttachmentPrefetcher
java.lang.Object
com.atlassian.confluence.impl.content.render.prefetch.AttachmentPrefetcher
- All Implemented Interfaces:
ResourcePrefetcher<AttachmentResourceIdentifier>
public class AttachmentPrefetcher
extends Object
implements ResourcePrefetcher<AttachmentResourceIdentifier>
Responsible for pre-fetching attachments and storing them in the conversion context for later retrieval by the
rendering pipeline.
- Since:
- 5.10
-
Constructor Summary
ConstructorDescriptionAttachmentPrefetcher
(AttachmentManager attachmentManager, com.atlassian.event.api.EventPublisher eventPublisher, ImageDetailsPrefetchDao imageDetailsPrefetcher) -
Method Summary
Modifier and TypeMethodDescriptionvoid
prefetch
(Set<AttachmentResourceIdentifier> attachmentIdentifiers, ConversionContext conversionContext) Fetch the attachments for the given set of identifiers, and store them in the given conversion context.static @NonNull Function<AttachmentResourceIdentifier,
Optional<Attachment>> prefetchedAttachments
(ConversionContext conversionContext)
-
Constructor Details
-
AttachmentPrefetcher
public AttachmentPrefetcher(AttachmentManager attachmentManager, com.atlassian.event.api.EventPublisher eventPublisher, ImageDetailsPrefetchDao imageDetailsPrefetcher)
-
-
Method Details
-
prefetchedAttachments
public static @NonNull Function<AttachmentResourceIdentifier,Optional<Attachment>> prefetchedAttachments(ConversionContext conversionContext) - Returns:
- a function that can be used to retrieve pre-fetched attachments for the given conversion context
-
getResourceItentifierType
- Specified by:
getResourceItentifierType
in interfaceResourcePrefetcher<AttachmentResourceIdentifier>
- Returns:
- The type of resource identifier which this prefetcher can handle
-
prefetch
public void prefetch(Set<AttachmentResourceIdentifier> attachmentIdentifiers, ConversionContext conversionContext) Fetch the attachments for the given set of identifiers, and store them in the given conversion context.It is possible and valid that some of the attachment identifiers refer to attachments on pages other than the page being rendered. However, this is expected to be a relatively unusual case. In the interests of simplicity, and given that this stuff is just an optimization, we only pre-fetch attachments for the current page. Any attachments from other pages will therefore need to be fetched on-demand by the renderer as usual.
- Specified by:
prefetch
in interfaceResourcePrefetcher<AttachmentResourceIdentifier>
- Parameters:
attachmentIdentifiers
- The set of attachment identifiers that should be prefetched if possible
-