P - the type of the parent builder (when calling AbstractParent.and()
method)public class ClassPathResolutionBuilder<P> extends AbstractSingleResolutionBuilder<ClassPathResolutionBuilder<P>,P> implements PrefixSuffixBuilder<ClassPathResolutionBuilder<P>>
You 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("bar");
This will use the classpath resolver and the real path is
foo/bar.html.buildContext, lookups, myself, pathPrefixValueBuilder, pathSuffixValueBuilderparent| Constructor and Description |
|---|
ClassPathResolutionBuilder(P parent,
BuildContext buildContext)
Initializes with the parent builder and the
EnvironmentBuilder. |
| Modifier and Type | Method and Description |
|---|---|
protected ResourceResolver |
createResolver() |
ConfigurationValueBuilder<ClassPathResolutionBuilder<P>,String> |
pathPrefix()
You can set the path prefix for resource resolution.
|
ClassPathResolutionBuilder<P> |
pathPrefix(String prefix)
You can set the path prefix for resource resolution.
|
ConfigurationValueBuilder<ClassPathResolutionBuilder<P>,String> |
pathSuffix()
You can set the path suffix for resource resolution.
|
ClassPathResolutionBuilder<P> |
pathSuffix(String suffix)
You can set the path suffix for resource resolution.
|
build, getLookups, lookup, lookupandpublic ClassPathResolutionBuilder(P parent, BuildContext buildContext)
EnvironmentBuilder.
The parent builder is used when calling the AbstractParent.and() method. The
EnvironmentBuilder is used when calling AbstractSingleResolutionBuilder.build() method
in order to evaluate property values.parent - the parent builderbuildContext - for property resolutionprotected ResourceResolver createResolver()
createResolver in class AbstractSingleResolutionBuilder<ClassPathResolutionBuilder<P>,P>public ClassPathResolutionBuilder<P> pathPrefix(String prefix)
PrefixSuffixBuilder/foo/template/createAccount.html/foo/template/resetPassword.html/foo/template/. You can
now reference the templates using the file name:
createAccount.htmlresetPassword.html
The value set using this method takes precedence over any property and
default value configured using PrefixSuffixBuilder.pathPrefix().
.pathPrefix("/foo/template/")
.pathPrefix()
.properties("${custom.property.high-priority}", "${custom.property.low-priority}")
.defaultValue("/template/")
.pathPrefix("/foo/template/")
.pathPrefix()
.properties("${custom.property.high-priority}", "${custom.property.low-priority}")
.defaultValue("/template/")
In both cases, pathPrefix("/foo/template/") is used.
If this method is called several times, only the last value is used.
If null value is set, it is like not setting a value at all. The
property/default value configuration is applied.
pathPrefix in interface PrefixSuffixBuilder<ClassPathResolutionBuilder<P>>prefix - the path prefixpublic ConfigurationValueBuilder<ClassPathResolutionBuilder<P>,String> pathPrefix()
PrefixSuffixBuilder/foo/template/createAccount.html/foo/template/resetPassword.html/foo/template/. You can
now reference the templates using the file name:
createAccount.htmlresetPassword.html
This method is mainly used by Configurers to register some property keys and/or a default value.
The aim is to let developer be able to externalize its configuration (using system properties, configuration file or anything else).
If the developer doesn't configure any value for the registered properties, the default value is used (if set).
.pathPrefix()
.properties("${custom.property.high-priority}", "${custom.property.low-priority}")
.defaultValue("/template/")
Non-null value set using PrefixSuffixBuilder.pathPrefix(String) takes
precedence over property values and default value.
.pathPrefix("/foo/template/")
.pathPrefix()
.properties("${custom.property.high-priority}", "${custom.property.low-priority}")
.defaultValue("/template/")
The value "/foo/template/" is used regardless of the value of the properties
and default value.
See ConfigurationValueBuilder for more information.
pathPrefix in interface PrefixSuffixBuilder<ClassPathResolutionBuilder<P>>public ClassPathResolutionBuilder<P> pathSuffix(String suffix)
PrefixSuffixBuildercreateAccount.htmlresetPassword.html.html. You can now
reference the templates using the file name:
createAccountresetPassword
The value set using this method takes precedence over any property and
default value configured using PrefixSuffixBuilder.pathSuffix().
.pathSuffix(".html")
.pathSuffix()
.properties("${custom.property.high-priority}", "${custom.property.low-priority}")
.defaultValue(".txt")
.pathSuffix(".html")
.pathSuffix()
.properties("${custom.property.high-priority}", "${custom.property.low-priority}")
.defaultValue(".txt")
In both cases, pathSuffix(".html") is used.
If this method is called several times, only the last value is used.
If null value is set, it is like not setting a value at all. The
property/default value configuration is applied.
pathSuffix in interface PrefixSuffixBuilder<ClassPathResolutionBuilder<P>>suffix - the path suffixpublic ConfigurationValueBuilder<ClassPathResolutionBuilder<P>,String> pathSuffix()
PrefixSuffixBuildercreateAccount.htmlresetPassword.html.html. You can now
reference the templates using the file name:
createAccountresetPassword
This method is mainly used by Configurers to register some property keys and/or a default value.
The aim is to let developer be able to externalize its configuration (using system properties, configuration file or anything else).
If the developer doesn't configure any value for the registered properties, the default value is used (if set).
.pathSuffix()
.properties("${custom.property.high-priority}", "${custom.property.low-priority}")
.defaultValue(".txt")
Non-null value set using PrefixSuffixBuilder.pathSuffix(String) takes
precedence over property values and default value.
.pathSuffix(".html")
.pathSuffix()
.properties("${custom.property.high-priority}", "${custom.property.low-priority}")
.defaultValue(".txt")
The value ".html" is used regardless of the value of the properties
and default value.
See ConfigurationValueBuilder for more information.
pathSuffix in interface PrefixSuffixBuilder<ClassPathResolutionBuilder<P>>Copyright © 2021. All rights reserved.