Class BaseSpringNamespaceHandler

java.lang.Object
net.shibboleth.shared.spring.custom.BaseSpringNamespaceHandler
All Implemented Interfaces:
NamespaceHandler

public abstract class BaseSpringNamespaceHandler extends Object implements 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 Details

    • DEFAULT_SECONDARY_HANDLER_BASE_LOCATION

      @Nonnull @NotEmpty public static final String 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 log
      Class logger.
    • secondaryHandlerQualifier

      @Nullable @NotEmpty private final String secondaryHandlerQualifier
      Qualifier to include in resource path when looking for secondary handlers.
    • parsers

      @Nonnull private final Map<QName,BeanDefinitionParser> parsers
      Stores the BeanDefinitionParser implementations keyed by the local name of the Elements they 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:
      init in interface NamespaceHandler
    • decorate

      @Nonnull public BeanDefinitionHolder decorate(@Nonnull Node node, @Nonnull BeanDefinitionHolder definition, @Nonnull ParserContext parserContext)
      A no-op decorator, returns the input.
      Specified by:
      decorate in interface NamespaceHandler
      Parameters:
      node - the node decorating a the given bean definition
      definition - the bean being decorated
      parserContext - the current parser context
      Returns:
      the input bean definition
    • parse

      @Nullable public BeanDefinition parse(@Nonnull Element element, @Nonnull ParserContext parserContext)
      Parses the supplied Element by delegating to the BeanDefinitionParser that is registered for that Element.
      Specified by:
      parse in interface NamespaceHandler
      Parameters:
      element - the element to be parsed into a bean definition
      parserContext - 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 of SecondaryNamespaceHandler instances.
      Since:
      7.0.0
    • findParserForElement

      @Nonnull protected BeanDefinitionParser findParserForElement(@Nonnull Element element)
      Locates the BeanDefinitionParser from the register implementations using the local name of the supplied Element.
      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 supplied BeanDefinitionParser to 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 for
      parser - the parser to register
    • initSecondaryHandlers

      private void initSecondaryHandlers()
      Initializes any registered secondary handlers.

      Subclasses that allow for this feature should override doInit(), while existing/legacy handlers without this feature may continue to override init().