[JAVA-2729] Refactor CRUD API implementations to reduce API surface exposure in driver-core Created: 09/Jan/18  Updated: 28/Oct/23  Resolved: 10/Jan/18

Status: Closed
Project: Java Driver
Component/s: Internal
Affects Version/s: None
Fix Version/s: 3.7.0

Type: Improvement Priority: Major - P3
Reporter: Jeffrey Yemin Assignee: Jeffrey Yemin
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

We already have two CRUD API implementations, and may soon add a third, that proxy to instances of ReadOperation/WriteOperation or AsyncReadOperation/AsyncWriteOperation. Two problem that causes:

  • There is duplicated code in the two implementations (for example, in converting from WriteModel to WriteRequest)
  • There is unnecessary exposure to the concrete implementations of the operation interfaces (e.g. FindOperation, MixedBulkWriteOperation)

Address this technical debt by:

  • Creating in core a SyncOperations and an AsyncOperations class, whose methods take the same parameters as the CRUD API but return instances, respectively of ReadOperation/WriteOperation and AsyncReadOperation/AsyncWriteOperation. These are both implemented in terms of a package-private Operations class that has the same methods, but which return instances of the concrete operation types. SyncOperations and AsyncOperations are in com.mongodb.internal currently, so are not considered part of the public API.
  • Re-implementing the sync and async CRUD API (MongoCollection and MongoIterable subclasses) in terms of SyncOperations (for the sync API) and AsyncOperations (for the async API).


 Comments   
Comment by Githook User [ 10/Jan/18 ]

Author:

{'email': 'jeff.yemin@10gen.com', 'name': 'Jeff Yemin', 'username': 'jyemin'}

Message: JAVA-2729: Refactor CRUD implementations to reduce API surface exposure to all the concrete operation types.
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/becd8fe02b09bf0d5832a3309824065bf5422795

Generated at Thu Feb 08 08:57:56 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.