Class SpringSupport
java.lang.Object
net.shibboleth.shared.spring.util.SpringSupport
Helper class for performing some common Spring-related functions.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final org.slf4j.LoggerLogger.static final QNameSpring beans element name. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic BeanFactorycreateBeanFactory(Element springBeans) Creates a Spring bean factory from the supplied Spring beans element.static AbstractBeanDefinitiongetAttributeValueAsList(Attr attribute) Gets the value of a list-type attribute as aBeanDefinitionBuilder.static <T> TgetBean(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 ofElements as aManagedList.static List<Locale.LanguageRange>getLanguageRange(HttpServletRequest request) Return theLocale.LanguageRangeassociated with this request prepended with the Spring preferred locale.static AbstractBeanDefinitiongetStringValueAsBoolean(String string) Gets the value of a boolean-type string as a (potentially null)Boolean.static BeanDefinitionparseCustomElement(Element element, ParserContext parserContext, BeanDefinitionBuilder parentBuilder, boolean lazyInit) Root method for all parsing.static voidparseCustomElements(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 voidparseLazyInitCustomElement(Element element, ParserContext parserContext) Parse an element into a bean definition and set the lazy-init flag.static voidparseLazyInitCustomElements(Collection<Element> elements, ParserContext parserContext) Parse list of elements into bean definitions and set the lazy-init flag.static voidparseNativeElement(Element springBeans, BeanDefinitionRegistry registry) Parse the provided Element into the provided registry.
-
Field Details
-
SPRING_BEANS_ELEMENT_NAME
Spring beans element name. -
LOG
@Nonnull static final org.slf4j.Logger LOGLogger.
-
-
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 parseparserContext- current parsing context
-
parseCustomElements
@Nullable 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 parseparserContext- current parsing contextparentBuilder- 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 parseparserContext- 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 contextparentBuilder- 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 parseparserContext- 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 parseregistry- the registry to populate
-
createBeanFactory
Creates a Spring bean factory from the supplied Spring beans element.- Parameters:
springBeans- to create bean factory from- Returns:
- bean factory
-
getBean
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 fromclazz- type of the bean to retrieve- Returns:
- spring bean
-
getAttributeValueAsList
Gets the value of a list-type attribute as aBeanDefinitionBuilder.- Parameters:
attribute- attribute whose value will be turned into a list- Returns:
- a bean which will generate a list of the values.
-
getStringValueAsBoolean
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 ofElements as aManagedList.- 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 theLocale.LanguageRangeassociated 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
-