Java Code Examples for org.springframework.beans.factory.ObjectProvider

Following code examples demonstrate how to use org.springframework.beans.factory.ObjectProviderfrom spring-framework. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use org.springframework.beans.factory.ObjectProviderand various code implementation of this class.

    @Bean
    public MyErrorController basicErrorController(ErrorAttributes errorAttributes,
                                                  ServerProperties serverProperties,
                                                  ObjectProvider<List<ErrorViewResolver>> errorViewResolversProvider) {
        return new MyErrorController(errorAttributes, serverProperties.getError(),
                errorViewResolversProvider.getIfAvailable());
    } 


Advertisement
Javadoc
A variant of ObjectFactory designed specifically for injection points, allowing for programmatic opt

ionality and lenient not-unique handling.

As of 5.1, this interface extends Iterable and provides Stream support. It can be therefore be used in for loops, provides #forEach iteration and allows for collection-style #stream access. @author Juergen Hoeller @since 4.3 @param the object type @see BeanFactory#getBeanProvider @see org.springframework.beans.factory.annotation.Autowired

Read More
Advertisement