Package org.opensaml.core.xml.config
Class XMLConfigurator
- java.lang.Object
-
- org.opensaml.core.xml.config.XMLConfigurator
-
public class XMLConfigurator extends Object
Reads in an XML configuration and configures the XMLTooling library accordingly.
-
-
Field Summary
Fields Modifier and Type Field Description private SchemaconfigurationSchemaSchema used to validate configuration files.private org.slf4j.LoggerlogClass logger.private BasicParserPoolparserPoolPool of parsers used to read and validate configurations.private XMLObjectProviderRegistryregistryThe provider registry instance to use.static StringXMLTOOLING_CONFIG_NSConfiguration namespace.static StringXMLTOOLING_CONFIG_PREFIXConfiguration namespace prefix.static StringXMLTOOLING_DEFAULT_OBJECT_PROVIDERName of the object provider used for objects that don't have a registered object provider.static StringXMLTOOLING_SCHEMA_LOCATIONLocation, on the classpath, of the XMLTooling configuration schema.
-
Constructor Summary
Constructors Constructor Description XMLConfigurator()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ObjectcreateClassInstance(Element configuration)Constructs an instance of the given class.protected XMLObjectProviderRegistrygetRegistry()Get 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.voidload(File configurationFile)Loads the configuration file(s) from the given file.voidload(InputStream configurationStream)Loads a configuration file from an input stream.voidload(Document configuration)Loads the configuration document.protected voidload(Element configurationRoot)Loads a configuration after it's been schema validated.protected voidvalidateConfiguration(Document configuration)Schema validates the given configuration.
-
-
-
Field Detail
-
XMLTOOLING_CONFIG_NS
@Nonnull @NotEmpty public static final String XMLTOOLING_CONFIG_NS
Configuration namespace.- See Also:
- Constant Field Values
-
XMLTOOLING_CONFIG_PREFIX
@Nonnull @NotEmpty public static final String XMLTOOLING_CONFIG_PREFIX
Configuration namespace prefix.- See Also:
- Constant Field Values
-
XMLTOOLING_DEFAULT_OBJECT_PROVIDER
@Nonnull @NotEmpty public static final String XMLTOOLING_DEFAULT_OBJECT_PROVIDER
Name of the object provider used for objects that don't have a registered object provider.- See Also:
- Constant Field Values
-
XMLTOOLING_SCHEMA_LOCATION
@Nonnull @NotEmpty public static final String XMLTOOLING_SCHEMA_LOCATION
Location, on the classpath, of the XMLTooling configuration schema.- See Also:
- Constant Field Values
-
log
@Nonnull private final org.slf4j.Logger log
Class logger.
-
parserPool
private BasicParserPool parserPool
Pool of parsers used to read and validate configurations.
-
configurationSchema
private Schema configurationSchema
Schema used to validate configuration files.
-
registry
@Nonnull private final XMLObjectProviderRegistry registry
The provider registry instance to use.
-
-
Constructor Detail
-
XMLConfigurator
public XMLConfigurator() throws XMLConfigurationExceptionConstructor.- Throws:
XMLConfigurationException- thrown if the validation schema for configuration files cannot be created
-
-
Method Detail
-
load
public void load(@Nullable File configurationFile) throws XMLConfigurationExceptionLoads 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
public void load(@Nonnull InputStream configurationStream) throws XMLConfigurationExceptionLoads 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
public void load(@Nonnull Document configuration) throws XMLConfigurationExceptionLoads the configuration document.- Parameters:
configuration- the configuration document- Throws:
XMLConfigurationException- thrown if the configuration file(s) cannot be read or invalid
-
load
protected void load(@Nonnull Element configurationRoot) throws XMLConfigurationExceptionLoads 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(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(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
protected Object createClassInstance(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(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
protected XMLObjectProviderRegistry getRegistry()
Get the XMLObject provider registry instance to use.- Returns:
- the registry instance
-
-