-
Couldn't load subscription status.
- Fork 41.6k
Update MongoAutoConfiguration and MongoDataAutoConfiguration to support com.mongodb.client.MongoClient. #14176
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
65bea5d to
9d763f5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. I've made a few suggestions.
| @Retention(RetentionPolicy.RUNTIME) | ||
| @Documented | ||
| @Conditional(OnBeanCondition.class) | ||
| public @interface ConditionalOnAnyBean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have AnyNestedCondition for that. Have you considered using that instead?
I am not keen to expose yet another top level annotations for this feature if we can avoid it.
| mongoTemplate.getConverter()); | ||
| } | ||
|
|
||
| @Nullable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't use @Nullable in the code base (yet).
| private <T> T mongoClientOrNull(Class<T> mongoClientType) { | ||
|
|
||
| try { | ||
| return this.beanFactory.getBean(mongoClientType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than doing that, could you please inject an ObjectProvider and use its API. That would prevent from calling the BeanFactory directly.
|
thanks @snicoll will modify the PR according to your input. |
…rt com.mongodb.client.MongoClient. Next to com.mongodb.MongoClient the MongoDB Java driver offers the com.mongodb.client.MongoClient as entry point for database and collection operations. Spring Data MongoDB supports c.m.client.MongoClient via its MongoDbFactory using SimpleMongoClientDbFactory. The MongoAutoConfiguration now backs off if any of those two clients is already defined in the Application context allowing MongoDataAutoConfiguration to pick up the users driver implementation of choice.
9d763f5 to
ba16e58
Compare
|
@snicoll changes are in. |
Next to com.mongodb.MongoClient the MongoDB Java driver offers the com.mongodb.client.MongoClient as entry point for database and collection operations. Spring Data MongoDB supports c.m.client.MongoClient via its MongoDbFactory using SimpleMongoClientDbFactory. The MongoAutoConfiguration now backs off if any of those two clients is already defined in the Application context allowing MongoDataAutoConfiguration to pick up the users driver implementation of choice. See gh-14176
* pr/14176: Polish "Add support for com.mongodb.client.MongoClient" Add support for com.mongodb.client.MongoClient
|
Thanks Christoph, this is now merged with a polish commit (see 56329e6) |
Next to
com.mongodb.MongoClientthe MongoDB Java drivers offers thecom.mongodb.client.MongoClientas entry point for database and collection operations. Spring Data MongoDB supportsc.m.client.MongoClientvia itsMongoDbFactoryusingSimpleMongoClientDbFactory.The
MongoAutoConfigurationnow backs off if any of those two clients is already defined in theApplicationContextallowingMongoDataAutoConfigurationto pick up the users driver implementation of choice.