public class AttachmentHandlingBuilder extends AbstractParent<EmailBuilder> implements ResourceResolutionBuilder<AttachmentHandlingBuilder>, Builder<AttachmentResourceTranslator>
Attachments are handled.
Attachment resolution consists of finding a file:
parent| Constructor and Description |
|---|
AttachmentHandlingBuilder(EmailBuilder parent,
BuildContext buildContext)
Initializes the builder with a parent builder.
|
| Modifier and Type | Method and Description |
|---|---|
AttachmentResourceTranslator |
build()
Instantiate and configures the instance.
|
ClassPathResolutionBuilder<AttachmentHandlingBuilder> |
classpath()
Configure resource resolution based on classpath.
|
FileResolutionBuilder<AttachmentHandlingBuilder> |
file()
Configure resource resolution based on filesystem.
|
AttachmentHandlingBuilder |
resolver(ResourceResolver resolver)
Register a custom resolver.
|
StringResolutionBuilder<AttachmentHandlingBuilder> |
string()
Configure lookup to use for direct string (when you provide directly the
content of a file as string).
|
andpublic AttachmentHandlingBuilder(EmailBuilder parent, BuildContext buildContext)
AbstractParent.and() method. The EnvironmentBuilder is
used to evaluate properties when build() method is called.parent - the parent builderbuildContext - for registering instances and property evaluationpublic ClassPathResolutionBuilder<AttachmentHandlingBuilder> classpath()
ResourceResolutionBuilderYou can define the lookup (the prefix that indicates that classpath resolution must be used). For example:
.classpath().lookup("classpath:");
// path prefixed by classpath: matches
// then classpath resolver is used
resourceResolver.getResource("classpath:foo/bar.html");
// path is not prefixed (or using another prefix) doesn't match
// then classpath resolver is not used
resourceResolver.getResource("foo/bar.html");
You can define a path prefix and suffix for finding resources:
.classpath().lookup("classpath:").pathPrefix("foo/").pathSuffix(".html");
resourceResolver.getResource("classpath:bar");
This will use the classpath resolver and the real path is
foo/bar.html.classpath in interface ResourceResolutionBuilder<AttachmentHandlingBuilder>public FileResolutionBuilder<AttachmentHandlingBuilder> file()
ResourceResolutionBuilderYou can define the lookup (the prefix that indicates that filesystem resolution must be used). For example:
.file().lookup("file:");
// path prefixed by file: matches
// then file resolver is used
resourceResolver.getResource("file:foo/bar.html");
// path is not prefixed (or using another prefix) doesn't match
// then file resolver is not used
resourceResolver.getResource("foo/bar.html");
You can define a path prefix and suffix for finding resources:
.file().lookup("file:").pathPrefix("foo/").pathSuffix(".html");
resourceResolver.getResource("file:bar");
This will use the file resolver and the real path is
foo/bar.html.file in interface ResourceResolutionBuilder<AttachmentHandlingBuilder>public StringResolutionBuilder<AttachmentHandlingBuilder> string()
ResourceResolutionBuilderYou can define the lookup (the prefix that indicates that direct string must be used). For example:
.string().lookup("string:", "s:");
// path prefixed by string: matches
// then string is used
resourceResolver.getResource("string:hello world");
// path is not prefixed (or using another prefix) doesn't match
// then string resolver is not used
resourceResolver.getResource("foo/bar.html");
string in interface ResourceResolutionBuilder<AttachmentHandlingBuilder>public AttachmentHandlingBuilder resolver(ResourceResolver resolver)
ResourceResolutionBuilderThis may be useful to use a custom implementation that is able to load file content from anywhere.
The implementation may be aware of the lookup prefix (see
AbstractPrefixedLookupPathResolver). The implementation may also
use pathPrefix and pathSuffixes (see RelativeResolver and
RelativisableResourceResolver).
resolver in interface ResourceResolutionBuilder<AttachmentHandlingBuilder>resolver - the custom resolver instancepublic AttachmentResourceTranslator build()
Builderbuild in interface Builder<AttachmentResourceTranslator>Copyright © 2021. All rights reserved.