Package net.shibboleth.shared.spring.util

# Class SpringSupport

java.lang.Object
net.shibboleth.shared.spring.util.SpringSupport

public final class SpringSupport extends Object
Helper class for performing some common Spring-related functions.

## Field Summary

Fields
Modifier and Type
Field
Description
`(package private) static final org.slf4j.Logger`
`LOG`
Logger.
`static final QName`
`SPRING_BEANS_ELEMENT_NAME`
Spring beans element name.

## Constructor Summary

Constructors
Modifier
Constructor
Description
`private`
`SpringSupport()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`static BeanFactory`
`createBeanFactory(Element springBeans)`
Creates a Spring bean factory from the supplied Spring beans element.
`static AbstractBeanDefinition`
`getAttributeValueAsList(Attr attribute)`
Gets the value of a list-type attribute as a `BeanDefinitionBuilder`.
`static <T> T`
`getBean(BeanFactory beanFactory, Class<T> clazz)`
Retrieves the bean of the supplied type from the supplied bean factory.
`static ManagedList<String>`
`getElementTextContentAsManagedList(Collection<Element> elements)`
Gets the text content of a list of `Element`s as a `ManagedList`.
`static List<Locale.LanguageRange>`
`getLanguageRange(HttpServletRequest request)`
Return the `Locale.LanguageRange` associated with this request prepended with the Spring preferred locale.
`static AbstractBeanDefinition`
`getStringValueAsBoolean(String string)`
Gets the value of a boolean-type string as a (potentially null) `Boolean`.
`static BeanDefinition`
`parseCustomElement(Element element, ParserContext parserContext, BeanDefinitionBuilder parentBuilder, boolean lazyInit)`
Root method for all parsing.
`static void`
`parseCustomElements(Collection<Element> elements, ParserContext parserContext)`
Parse list of elements into bean definitions which are inserted into the parent context.
`static ManagedList<BeanDefinition>`
`parseCustomElements(Collection<Element> elements, ParserContext parserContext, BeanDefinitionBuilder parentBuilder)`
Parse list of elements into bean definitions.
`static void`
`parseLazyInitCustomElement(Element element, ParserContext parserContext)`
Parse an element into a bean definition and set the lazy-init flag.
`static void`
`parseLazyInitCustomElements(Collection<Element> elements, ParserContext parserContext)`
Parse list of elements into bean definitions and set the lazy-init flag.
`static void`
`parseNativeElement(Element springBeans, BeanDefinitionRegistry registry)`
Parse the provided Element into the provided registry.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### SPRING_BEANS_ELEMENT_NAME

@Nonnull public static final QName SPRING_BEANS_ELEMENT_NAME
Spring beans element name.

### LOG

@Nonnull static final org.slf4j.Logger LOG
Logger.

## Constructor Details

### SpringSupport

private SpringSupport()
Constructor.

## Method Details

### parseCustomElements

public static void parseCustomElements(@Nullable Collection<Element> elements, @Nonnull ParserContext parserContext)
Parse list of elements into bean definitions which are inserted into the parent context.

Parameters:
  `elements` - list of elements to parse
  `parserContext` - current parsing context

### parseCustomElements

@Nullable @Live public static ManagedList<BeanDefinition> parseCustomElements(@Nullable Collection<Element> elements, @Nonnull ParserContext parserContext, @Nonnull BeanDefinitionBuilder parentBuilder)
Parse list of elements into bean definitions.

Parameters:
  `elements` - list of elements to parse
  `parserContext` - current parsing context
  `parentBuilder` - the builder we are going to insert into
Returns:
  list of bean definitions

### parseLazyInitCustomElements

public static void parseLazyInitCustomElements(@Nullable Collection<Element> elements, @Nonnull ParserContext parserContext)
Parse list of elements into bean definitions and set the lazy-init flag.

Parameters:
  `elements` - list of elements to parse
  `parserContext` - current parsing context
Since:
  6.0.0

### parseCustomElement

@Nullable public static BeanDefinition parseCustomElement(@Nonnull Element element, @Nonnull ParserContext parserContext, @Nullable BeanDefinitionBuilder parentBuilder, boolean lazyInit)
Root method for all parsing.

Parameters:
  `element` - the element to parse.

  This works in two scoping modes. If the parent builder is null then this bean is to be inserted into the provided parser context, in this case the parent builder is null. If the parent builder is provided then the scope is limited and the bean definition is returned.

  `parserContext` - current parsing context
  `parentBuilder` - the parent builder (for nested building).
  `lazyInit` - whether this is lazy initialized;
Returns:
  the bean definition, unless this is for a parent scoped bean

### parseLazyInitCustomElement

public static void parseLazyInitCustomElement(@Nullable Element element, @Nonnull ParserContext parserContext)
Parse an element into a bean definition and set the lazy-init flag.

Parameters:
  `element` - the element to parse
  `parserContext` - current parsing context
Since:
  6.0.0

### parseNativeElement

public static void parseNativeElement(@Nonnull Element springBeans, @Nonnull BeanDefinitionRegistry registry)
Parse the provided Element into the provided registry.

Parameters:
  `springBeans` - the element to parse
  `registry` - the registry to populate

### createBeanFactory

@Nonnull public static BeanFactory createBeanFactory(@Nonnull Element springBeans)
Creates a Spring bean factory from the supplied Spring beans element.

Parameters:
  `springBeans` - to create bean factory from
Returns:
  bean factory

### getBean

@Nullable public static <T> T getBean(@Nonnull BeanFactory beanFactory, @Nonnull Class<T> clazz)
Retrieves the bean of the supplied type from the supplied bean factory. Returns null if no bean definition is found.

Type Parameters:
  `T` - type of bean to return
Parameters:
  `beanFactory` - to get the bean from
  `clazz` - type of the bean to retrieve
Returns:
  spring bean

### getAttributeValueAsList

@Nonnull public static AbstractBeanDefinition getAttributeValueAsList(@Nonnull Attr attribute)
Gets the value of a list-type attribute as a `BeanDefinitionBuilder`.

Parameters:
  `attribute` - attribute whose value will be turned into a list
Returns:
  a bean which will generate a list of the values.

### getStringValueAsBoolean

@Nonnull public static AbstractBeanDefinition getStringValueAsBoolean(@Nullable String string)
Gets the value of a boolean-type string as a (potentially null) `Boolean`.

Parameters:
  `string` - value will be turned into a boolean (or null) (after property replacement)
Returns:
  a bean which will generate the underlying value

### getElementTextContentAsManagedList

@Nonnull public static ManagedList<String> getElementTextContentAsManagedList(@Nullable Collection<Element> elements)
Gets the text content of a list of `Element`s as a `ManagedList`.

Parameters:
  `elements` - the elements whose values will be turned into a list
Returns:
  list of values, never null

### getLanguageRange

@Nonnull @Unmodifiable @NotLive public static List<Locale.LanguageRange> getLanguageRange(@Nonnull HttpServletRequest request)
Return the `Locale.LanguageRange` associated with this request prepended with the Spring preferred locale. This allows external (non browser) control of the language.

Parameters:
  `request` - the request to process
Returns:
  range returned from the browser request with the active Spring locale prepended