-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Introduce AnnotationConfigGenericWebApplicationContext #24236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
* A copy of Spring-boot 2.1.8 {@link AnnotationConfigServletWebServerApplicationContext}, * except that it does not use its own WebServer (other super class). * <p> * Also See {@link AnnotationConfigApplicationContext} (Same as this but uses * GenericApplicationContext instead of GenericWebApplicationContext) * <p> * In contrast to {@link org.springframework.web.context.support.AnnotationConfigWebApplicationContext}, * this class uses the GenericWebApplicationContext, which allows registering beans using a Supplier * {@link #registerBean(Class, Supplier, BeanDefinitionCustomizer...)} * <p> * See javadoc of superclass {@link GenericWebApplicationContext} for more information.
@bytewright Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@bytewright Thank you for signing the Contributor License Agreement! |
I noticed this flavor of WebApplicationContext was missing, or at least I couldn't find anything like it. |
...va/org/springframework/web/context/support/AnnotationConfigGenericWebApplicationContext.java
Show resolved
Hide resolved
...va/org/springframework/web/context/support/AnnotationConfigGenericWebApplicationContext.java
Show resolved
Hide resolved
I've edited your comment to improve the formatting. You might want to check out this Mastering Markdown guide for future reference. In particular please keep in mind that |
Hi @bytewright, Thanks for submitting your first PR to the Spring Framework, and sorry for taking so long to get back to you. You make a good point: it's not readily apparent how one can make use of However, it turns out that it's relatively easy to achieve as demonstrated in the following example. GenericWebApplicationContext context = new GenericWebApplicationContext();
AnnotatedBeanDefinitionReader annotatedBeanDefinitionReader = new AnnotatedBeanDefinitionReader(context);
context.registerBean("helloSpring", String.class, () -> "Hello, Spring!");
annotatedBeanDefinitionReader.register(UserService.class, UserRepository.class); By using By using After reviewing your proposal, the team has decided it does not wish to introduce In light of that, I am closing this PR. |
A copy of Spring-boot 2.1.8
AnnotationConfigServletWebServerApplicationContext
,except that it does not use its own WebServer (other super class).
Also See
AnnotationConfigApplicationContext
(Same as this but usesGenericApplicationContext instead of GenericWebApplicationContext)
In contrast to
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
,this class uses the GenericWebApplicationContext, which allows registering beans using a Supplier
#registerBean(Class, Supplier, BeanDefinitionCustomizer...)