Commit Graph

74 Commits

Author SHA1 Message Date
Niklas Herder
1dda492d57 Allow multiple ModuleFilter implementations 2023-07-22 14:37:23 +01:00
Niklas Herder
b202e964a2 Allow filtering of modules before initialization
Alternative for #111
2023-07-22 14:37:23 +01:00
Dave Syer
0c5828a864 Check if it works with Spring 6 2023-01-16 11:00:03 +00:00
Mehmet Mustafa Yilmaz
ce15b8e580 fix: Guice Cannot Inject Beans with Custom Annotations
SpringModule binds custom guice Providers for Spring managed beans so that Guice can inject beans from Spring Context.
Due to a bug in the Provider, Guice can only inject Spring beans that either don't have any qualifier annotations or only have Named annotation as a qualifier.

This fix enables Guice to inject beans with custom qualifier annotations as well.
Custom qualifier annotations do not need to be marker annotations (in other words, they can have attributes).

Other changes include:
Using factory method metadata of annotated bean definition rather than using custom code to retrieve factory method and its annotations

Added more test cases to validate various qualifier annotation scenarios.
2023-01-06 07:36:20 +00:00
Dave Syer
e133fee483 Add test for set binding autowire
Fixes #65
2022-10-06 10:08:57 +01:00
Danny Thomas
b363700e28 Address duplicate binding issues
- Deduplicate LinkedKeyBinding by key before falling back to the target key
- Rather than just dropping the Guice keys during deduplication, retains the original Guice key if possible. Otherwise bindings may fail to resolve, as is the case with map bindings
- Avoid duplicating beans for untargetted bindings
- Avoid duplicating multibindings
2022-09-23 11:35:13 +01:00
Stacey Watro
e39d980efb Always use the Named key when looking up a Guice object in the GuiceAutowireCandidateResolver. 2022-05-25 18:37:08 +01:00
Stacey Watro
9d163233f7 Allow Named Guice components to be used in Spring when using partial injection. 2022-05-17 10:22:05 +01:00
Michaël REMOND
43277ab746 Support Guice throwing providers
Support Guice throwing providers by filtering the bindings using
the Guice com.google.inject.internal.UniqueAnnotations
Add test
2022-03-21 17:30:35 +00:00
Dave Syer
e71d6aca56 Use static factory methods and proxyBeanMethods = false
It is better to be explicit about beans of type `Module` and make
sure they don't interfere with Spring trying to enhance
`@Configuration` classes. The tests are now clear of the pesky
warning logs, and there is a new section in the README.
2022-03-21 08:41:05 +00:00
Simon DeMartini
2722841925 Convert JUnit assertions to AssertJ to match spring-javaformat checkstyle rules 2022-03-20 16:29:28 +00:00
Simon DeMartini
99d7a7a268 Upgrade to JUnit 5 2022-03-20 16:29:28 +00:00
Simon DeMartini
57c54fad2f Add and enforce spring checkstyle configurations 2022-03-20 10:40:10 +00:00
Simon DeMartini
7254dc8be7 Apply and enforce spring-javaformat 2022-03-19 21:15:20 +00:00
Simon DeMartini
ad60397400 Upgrade to latest mockito 2022-03-18 08:25:14 +00:00
Asi Bross
7434f407b6 Delay injector creation until after registerBeanPostProcessors() phase is complete 2021-08-30 16:52:10 -07:00
Howard Yuan
e54c544afa Add more logic to the test 2021-04-20 07:06:05 +01:00
Howard Yuan
c6b5fd89f6 Add Unit Test for lazy init Guice providers 2021-04-20 07:06:05 +01:00
Taylor Wicksell
ebfdb1be8e #80 fix issue where SpringModule did not respect Spring prototype scope 2020-08-24 16:34:07 -07:00
Asi Bross
7567e57ee1 Respect @Lazy annotation in GuiceAutowireCandidateResolver 2020-01-10 13:14:37 -08:00
Dave Syer
f759e6e4ab Add test for binding to Map by generic signature
See #67
2019-11-19 10:57:34 +00:00
Kevin Wang
4277d3e0f5 Fix handling FactoryBean 2019-11-18 13:50:17 -08:00
Dave Syer
61b3ac9c8d Fix more compiler warnings 2019-10-25 17:42:51 +01:00
Dave Syer
0a64a06bbc Fix compiler warnings 2019-10-25 17:40:31 +01:00
Kevin Wang
dc2a0b6495 Bind to super types 2019-10-23 13:01:07 -07:00
Kevin Wang
368ebc4d36 Add property to enable/disable Guice just-in-time bindings and log just-in-time bindings usage 2019-10-15 15:59:47 -07:00
Kevin Wang
1e7cbb0e31 Support generic interfaces 2019-10-15 15:45:40 -07:00
Kevin Wang
4308f7498b Bind all super interfaces 2019-10-15 15:45:40 -07:00
Taylor Wicksell
741f6e3794 fixed issue where modules were only being filtered from AppContext and not the Injector 2019-08-07 09:53:58 -07:00
Taylor Wicksell
0ecc98d4cb ensure BindingAnnotations are treated as Qualifiers in Spring 2019-05-06 10:03:05 -07:00
Taylor Wicksell
6fec10d19c fixed issue where multibindings in guice cause duplicate beans in Spring 2019-05-06 10:02:53 -07:00
Spring Operator
3650197554 URL Cleanup
This commit updates URLs to prefer the https protocol. Redirects are not followed to avoid accidentally expanding intentionally shortened URLs (i.e. if using a URL shortener).

# Fixed URLs

## Fixed Success
These URLs were switched to an https URL with a 2xx status. While the status was successful, your review is still recommended.

* [ ] http://www.apache.org/licenses/LICENSE-2.0 with 25 occurrences migrated to:
  https://www.apache.org/licenses/LICENSE-2.0 ([https](https://www.apache.org/licenses/LICENSE-2.0) result 200).
2019-03-27 15:32:41 +00:00
Taylor Wicksell
ea8e68674c map all non-singleton bindings as prototype scoped beans 2019-03-13 15:38:34 -07:00
Asi Bross
0bc99b690a Ignore Collection types from GuiceAutowireCandidateResolver 2019-03-06 14:05:44 -07:00
Taylor Wicksell
697d2ede55 add property spring.guice.modules.exclude to filter guice modules by name 2019-03-06 14:04:44 -07:00
Dave Syer
fd835487d3 Ensure *Aware contracts can be satisfied in ModuleRegistryConfiguration
If the BeanFactoryProvider is used there is a partially refreshed
ApplicationContext floating around. It works better if it is able to
inject Environment etc. via the Aware interfaces into early beans
like post processors.
2019-01-10 09:21:51 +00:00
Dave Syer
af2497c6d8 Polish 2019-01-10 09:21:24 +00:00
Howard Yuan
4398a3389a Fix lost Supplier<T> type info in Guice2Spring direction 2018-11-09 14:36:57 -08:00
Taylor Wicksell
2207c4f1d9 make bean names unique when considering binding annotations
translate binding annotations into Spring @Qualifiers
2018-11-09 10:55:53 -08:00
Taylor Wicksell
0153079327 use Key<?> for binding dedupe check in SpringModule to include annotations
fix issues where @Named was not considered when fetching beans of the same type
2018-11-09 10:55:53 -08:00
Taylor Wicksell
b2a767e51a support Guice binding annotations in SpringModule 2018-03-28 09:35:48 -07:00
Taylor Wicksell
1680610faf create injector before embedded server initialization, after other BeanPostProcessors 2018-03-01 11:51:06 -06:00
Taylor Wicksell
5e3603c29d remove check for Tool stage from SpringModule as it is no longer required 2018-03-01 11:10:40 +00:00
Taylor Wicksell
a098f7854b Added an option to deduplicate bindings in favor of Spring
User can set Environment property spring.guice.dedup=true.
2018-03-01 09:53:31 +00:00
Taylor Wicksell
e94c94837f Restore support for Guice PrivateModule's
See #32
2018-02-28 18:04:41 +00:00
Taylor Wicksell
aae2e1fc47 support multiple stages, as can occur when using ElementVisitors 2018-02-27 16:50:46 +00:00
Taylor Wicksell
bd30107666 Ensure bean post processors are applied before injector is created
In this way, Guice modules can declare bindings asEagerSingleton()
2018-02-22 16:14:35 +00:00
Dave Syer
8e26ec0f3c Add a test for generic bean type
Fixes gh-26
2018-02-01 09:04:32 +00:00
Dave Syer
9a8af0efd6 Add another test
See gh-26
2017-12-21 16:18:05 +00:00
Dave Syer
becf90b951 Add another test for @EnableGuiceModules
See gh-22
2017-12-21 16:14:47 +00:00