- java.lang.Object
-
- net.shibboleth.ext.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 org.slf4j.LoggerLOGLogger.static QNameSPRING_BEANS_ELEMENT_NAMESpring beans element name.
-
Constructor Summary
Constructors Modifier Constructor Description privateSpringSupport()Constructor.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static 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 AbstractBeanDefinitiongetStringValueAsBoolean(String string)Gets the value of a boolean-type string as a (ptentially 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 Detail
-
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.
-
-
Method Detail
-
parseCustomElements
@Nullable public static void parseCustomElements(@Nullable @NonnullElements 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 @NonnullElements 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
@Nullable public static void parseLazyInitCustomElements(@Nullable @NonnullElements 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(@Nullable 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
@Nullable 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, @Nullable BeanDefinitionRegistry registry)Parse the provided Element into the provided registry.- Parameters:
springBeans- the element to parseregistry- 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 fromclazz- 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 aBeanDefinitionBuilder.- Parameters:
attribute- attribute whose value will be turned into a list- Returns:
- a bean which will generate a list of the values.
-
getStringValueAsBoolean
@Nullable public static AbstractBeanDefinition getStringValueAsBoolean(@Nullable String string)
Gets the value of a boolean-type string as a (ptentially null)Boolean.- Parameters:
string- value will be turned into a boolean (or null) (after property replacement)- Returns:
- a bean which will generate a list of the values.
-
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
-
-