Skip to content

Conversation

@christophstrobl
Copy link
Member

Next to com.mongodb.MongoClient the MongoDB Java drivers 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 ApplicationContext allowing MongoDataAutoConfiguration to pick up the users driver implementation of choice.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 23, 2018
@christophstrobl christophstrobl force-pushed the issue/datamongo_autoconfig_for_com.mongodb.client.Client branch from 65bea5d to 9d763f5 Compare August 23, 2018 06:24
Copy link
Member

@snicoll snicoll left a 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 {
Copy link
Member

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
Copy link
Member

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);
Copy link
Member

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.

@snicoll snicoll added the status: waiting-for-feedback We need additional information before we can continue label Aug 23, 2018
@christophstrobl
Copy link
Member Author

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.
@christophstrobl christophstrobl force-pushed the issue/datamongo_autoconfig_for_com.mongodb.client.Client branch from 9d763f5 to ba16e58 Compare August 23, 2018 11:42
@christophstrobl
Copy link
Member Author

@snicoll changes are in.

@philwebb philwebb added type: enhancement A general enhancement and removed status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged labels Aug 27, 2018
@philwebb philwebb added this to the Backlog milestone Aug 27, 2018
@snicoll snicoll self-assigned this Aug 28, 2018
@snicoll snicoll modified the milestones: Backlog, 2.1.0.M3 Aug 28, 2018
snicoll pushed a commit that referenced this pull request Aug 28, 2018
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
@snicoll snicoll closed this in 56329e6 Aug 28, 2018
snicoll added a commit that referenced this pull request Aug 28, 2018
* pr/14176:
  Polish "Add support for com.mongodb.client.MongoClient"
  Add support for com.mongodb.client.MongoClient
@snicoll
Copy link
Member

snicoll commented Aug 28, 2018

Thanks Christoph, this is now merged with a polish commit (see 56329e6)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: enhancement A general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants