Class TranscodingRuleLoader
java.lang.Object
net.shibboleth.idp.attribute.transcoding.impl.TranscodingRuleLoader
A mechanism for loading a set of
TranscodingRule objects from sources such as maps
or directories of property files.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final booleanWhether to rethrow exceptions during construction or populate empty.private org.slf4j.LoggerClass logger.private final Collection<TranscodingRule>Rules loaded. -
Constructor Summary
ConstructorsConstructorDescriptionEquivalent toTranscodingRuleLoader(Path, Collection, boolean)with null extensions and true fail fast behavior.TranscodingRuleLoader(Path dir, Collection<String> extensions) Equivalent toTranscodingRuleLoader(Path, Collection, boolean)with null extensions and true fail fast behavior.TranscodingRuleLoader(Path dir, Collection<String> extensions, boolean failFast) Load rules from all files found below a directory root.TranscodingRuleLoader(Collection<Map<String, Object>> maps) Constructor.TranscodingRuleLoader(Resource resource) Equivalent toTranscodingRuleLoader(Resource, Collection, boolean)with null extensions and true fail fast behavior.TranscodingRuleLoader(Resource resource, Collection<String> extensions) Equivalent toTranscodingRuleLoader(Resource, Collection, boolean)with true fail fast behavior.TranscodingRuleLoader(Resource resource, Collection<String> extensions, boolean failFast) Load rules from all files found below a directory root expressed as a Spring resource. -
Method Summary
Modifier and TypeMethodDescriptiongetRules()Get the rules loaded by this object.private Collection<TranscodingRule>load(Path dir, Collection<String> extensions) Performs the load step using the supplied parameters from the various constructors.
-
Field Details
-
log
@Nonnull private org.slf4j.Logger logClass logger. -
rules
Rules loaded. -
failOnErrors
private final boolean failOnErrorsWhether to rethrow exceptions during construction or populate empty.
-
-
Constructor Details
-
TranscodingRuleLoader
public TranscodingRuleLoader(@Nonnull @ParameterName(name="resource") Resource resource, @Nullable @ParameterName(name="extensions") Collection<String> extensions, @ParameterName(name="failFast") boolean failFast) throws IOException Load rules from all files found below a directory root expressed as a Spring resource.Files are assumed to be Java property files in text format.
Individual rules that fail to load will be skipped.
The file extensions must include the period, and only apply to files, while all directories will be examined.
- Parameters:
resource- root to searchextensions- file extensions to includefailFast- true iff I/O failures should be surfaced- Throws:
IOException- if an error occurs- Since:
- 5.3.0
-
TranscodingRuleLoader
public TranscodingRuleLoader(@Nonnull @ParameterName(name="resource") Resource resource, @Nullable @ParameterName(name="extensions") Collection<String> extensions) throws IOException Equivalent toTranscodingRuleLoader(Resource, Collection, boolean)with true fail fast behavior.- Parameters:
resource- root to searchextensions- file extensions to include- Throws:
IOException- if an error occurs- Since:
- 5.3.0
-
TranscodingRuleLoader
public TranscodingRuleLoader(@Nonnull @ParameterName(name="resource") Resource resource) throws IOException Equivalent toTranscodingRuleLoader(Resource, Collection, boolean)with null extensions and true fail fast behavior.- Parameters:
resource- root to search- Throws:
IOException- if an error occurs- Since:
- 5.3.0
-
TranscodingRuleLoader
public TranscodingRuleLoader(@Nonnull @ParameterName(name="dir") Path dir, @Nullable @ParameterName(name="extensions") Collection<String> extensions, @ParameterName(name="failFast") boolean failFast) throws IOException Load rules from all files found below a directory root.Files are assumed to be Java property files in text format.
Individual rules that fail to load will be skipped.
The file extensions must include the period, and only apply to files, while all directories will be examined.
- Parameters:
dir- root to searchextensions- file extensions to includefailFast- true iff I/O failures should be surfaced- Throws:
IOException- if an error occurs- Since:
- 5.3.0
-
TranscodingRuleLoader
public TranscodingRuleLoader(@Nonnull @ParameterName(name="dir") Path dir, @Nullable @ParameterName(name="extensions") Collection<String> extensions) throws IOException Equivalent toTranscodingRuleLoader(Path, Collection, boolean)with null extensions and true fail fast behavior.- Parameters:
dir- root to searchextensions- file extensions to include- Throws:
IOException- if an error occurs
-
TranscodingRuleLoader
Equivalent toTranscodingRuleLoader(Path, Collection, boolean)with null extensions and true fail fast behavior.- Parameters:
dir- root to search- Throws:
IOException- if an error occurs
-
TranscodingRuleLoader
public TranscodingRuleLoader(@Nonnull @ParameterName(name="maps") Collection<Map<String, Object>> maps) Constructor.- Parameters:
maps- a collection of maps to build rules around directly.
-
-
Method Details
-
load
@Nonnull @Unmodifiable @NotLive private Collection<TranscodingRule> load(@Nonnull @ParameterName(name="dir") Path dir, @Nullable @ParameterName(name="extensions") Collection<String> extensions) throws IOException Performs the load step using the supplied parameters from the various constructors.- Parameters:
dir- path to attempt load fromextensions- file extensions to include- Returns:
- the loaded rules
- Throws:
IOException- on failure- Since:
- 5.3.0
-
getRules
Get the rules loaded by this object.- Returns:
- collection of rules
-