Class BaseSpringNamespaceHandler
java.lang.Object
net.shibboleth.shared.spring.custom.BaseSpringNamespaceHandler
- All Implemented Interfaces:
NamespaceHandler
A base class for
NamespaceHandler implementations.
This code is heavily based on Spring's NamespaceHandlerSupport. The largest difference is that bean
definition parsers may be registered against either an elements name or schema type. During parser lookup the schema
type is preferred.
This code also now supports a notion of one or more "secondary" handlers that can be registered to supplement or override the mappings in the main subclass.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe base location to look for the secondary mapping files.private final org.slf4j.LoggerClass logger.private final Map<QName,BeanDefinitionParser> Stores theBeanDefinitionParserimplementations keyed by the local name of theElementsthey handle.private final StringQualifier to include in resource path when looking for secondary handlers. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondecorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext) A no-op decorator, returns the input.protected voiddoInit()Subclasses should override this method to allow for installation ofSecondaryNamespaceHandlerinstances.protected BeanDefinitionParserfindParserForElement(Element element) Locates theBeanDefinitionParserfrom the register implementations using the local name of the suppliedElement.voidinit()private voidInitializes any registered secondary handlers.parse(Element element, ParserContext parserContext) Parses the suppliedElementby delegating to theBeanDefinitionParserthat is registered for thatElement.protected voidregisterBeanDefinitionParser(QName elementNameOrType, BeanDefinitionParser parser) Subclasses can call this to register the suppliedBeanDefinitionParserto handle the specified element.
-
Field Details
-
DEFAULT_SECONDARY_HANDLER_BASE_LOCATION
The base location to look for the secondary mapping files. Can be present in multiple JAR files.- See Also:
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
secondaryHandlerQualifier
Qualifier to include in resource path when looking for secondary handlers. -
parsers
Stores theBeanDefinitionParserimplementations keyed by the local name of theElementsthey handle.
-
-
Constructor Details
-
BaseSpringNamespaceHandler
public BaseSpringNamespaceHandler()Constructor. -
BaseSpringNamespaceHandler
public BaseSpringNamespaceHandler(@Nullable @NotEmpty @ParameterName(name="qualifier") String qualifier) Constructor.- Parameters:
qualifier- qualifier added to secondary handler resource path- Since:
- 7.0.0
-
-
Method Details
-
init
public void init()- Specified by:
initin interfaceNamespaceHandler
-
decorate
@Nonnull public BeanDefinitionHolder decorate(@Nonnull Node node, @Nonnull BeanDefinitionHolder definition, @Nonnull ParserContext parserContext) A no-op decorator, returns the input.- Specified by:
decoratein interfaceNamespaceHandler- Parameters:
node- the node decorating a the given bean definitiondefinition- the bean being decoratedparserContext- the current parser context- Returns:
- the input bean definition
-
parse
@Nullable public BeanDefinition parse(@Nonnull Element element, @Nonnull ParserContext parserContext) Parses the suppliedElementby delegating to theBeanDefinitionParserthat is registered for thatElement.- Specified by:
parsein interfaceNamespaceHandler- Parameters:
element- the element to be parsed into a bean definitionparserContext- the context within which the bean definition is created- Returns:
- the bean definition created from the given element
-
doInit
protected void doInit()Subclasses should override this method to allow for installation ofSecondaryNamespaceHandlerinstances.- Since:
- 7.0.0
-
findParserForElement
Locates theBeanDefinitionParserfrom the register implementations using the local name of the suppliedElement.- Parameters:
element- the element to locate the bean definition parser for- Returns:
- the parser for the given bean element
-
registerBeanDefinitionParser
protected void registerBeanDefinitionParser(@Nonnull QName elementNameOrType, @Nonnull BeanDefinitionParser parser) Subclasses can call this to register the suppliedBeanDefinitionParserto handle the specified element. The element name is the local (non-namespace qualified) name.- Parameters:
elementNameOrType- the element name or schema type the parser is forparser- the parser to register
-
initSecondaryHandlers
private void initSecondaryHandlers()
-