Package org.opensaml.core.xml.config
Class XMLConfigurator
java.lang.Object
org.opensaml.core.xml.config.XMLConfigurator
Reads in an XML configuration and configures the XMLTooling library accordingly.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate SchemaSchema used to validate configuration files.private final org.slf4j.LoggerClass logger.private BasicParserPoolPool of parsers used to read and validate configurations.private final XMLObjectProviderRegistryThe provider registry instance to use.static final StringConfiguration namespace.static final StringConfiguration namespace prefix.static final StringName of the object provider used for objects that don't have a registered object provider.static final StringLocation, on the classpath, of the XMLTooling configuration schema. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectcreateClassInstance(Element configuration) Constructs an instance of the given class.protected XMLObjectProviderRegistryGet the XMLObject provider registry instance to use.protected voidinitializeIDAttributes(Element idAttributesElement) Registers the global ID attributes specified in the configuration file.protected voidinitializeObjectProviders(Element objectProviders) Initializes the object providers defined in the configuration file.voidLoads the configuration file(s) from the given file.voidload(InputStream configurationStream) Loads a configuration file from an input stream.voidLoads the configuration document.protected voidLoads a configuration after it's been schema validated.protected voidvalidateConfiguration(Document configuration) Schema validates the given configuration.
-
Field Details
-
XMLTOOLING_CONFIG_NS
Configuration namespace.- See Also:
-
XMLTOOLING_CONFIG_PREFIX
Configuration namespace prefix.- See Also:
-
XMLTOOLING_DEFAULT_OBJECT_PROVIDER
Name of the object provider used for objects that don't have a registered object provider.- See Also:
-
XMLTOOLING_SCHEMA_LOCATION
Location, on the classpath, of the XMLTooling configuration schema.- See Also:
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
parserPool
Pool of parsers used to read and validate configurations. -
configurationSchema
Schema used to validate configuration files. -
registry
The provider registry instance to use.
-
-
Constructor Details
-
XMLConfigurator
Constructor.- Throws:
XMLConfigurationException- thrown if the validation schema for configuration files cannot be created
-
-
Method Details
-
load
Loads the configuration file(s) from the given file. If the file is a directory each file within the directory is loaded.- Parameters:
configurationFile- the configuration file(s) to be loaded- Throws:
XMLConfigurationException- thrown if the configuration file(s) cannot be read or invalid
-
load
Loads a configuration file from an input stream.- Parameters:
configurationStream- configuration stream- Throws:
XMLConfigurationException- thrown if the given configuration is invalid or cannot be read
-
load
Loads the configuration document.- Parameters:
configuration- the configuration document- Throws:
XMLConfigurationException- thrown if the configuration file(s) cannot be read or invalid
-
load
Loads a configuration after it's been schema validated.- Parameters:
configurationRoot- root of the configuration- Throws:
XMLConfigurationException- thrown if there is a problem processing the configuration
-
initializeObjectProviders
protected void initializeObjectProviders(@Nonnull Element objectProviders) throws XMLConfigurationException Initializes the object providers defined in the configuration file.- Parameters:
objectProviders- the configuration for the various object providers- Throws:
XMLConfigurationException- thrown if the configuration elements are invalid
-
initializeIDAttributes
protected void initializeIDAttributes(@Nonnull Element idAttributesElement) throws XMLConfigurationException Registers the global ID attributes specified in the configuration file.- Parameters:
idAttributesElement- the IDAttributes element from the configuration file- Throws:
XMLConfigurationException- thrown if there is a problem with a parsing or registering the ID attribute
-
createClassInstance
@Nonnull protected Object createClassInstance(@Nonnull Element configuration) throws XMLConfigurationException Constructs an instance of the given class.- Parameters:
configuration- the current configuration element- Returns:
- an instance of the given class
- Throws:
XMLConfigurationException- thrown if the class can not be instantiated
-
validateConfiguration
protected void validateConfiguration(@Nonnull Document configuration) throws XMLConfigurationException Schema validates the given configuration.- Parameters:
configuration- the configuration to validate- Throws:
XMLConfigurationException- thrown if the configuration is not schema-valid
-
getRegistry
Get the XMLObject provider registry instance to use.- Returns:
- the registry instance
-