Navigation Menu

Skip to content
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

Upgrade 3.0 #164

Merged
merged 7 commits into from Jan 15, 2018
Merged

Upgrade 3.0 #164

merged 7 commits into from Jan 15, 2018

Conversation

cfogrady
Copy link
Collaborator

This PR attempts to make MongoJack usable with the Mongo 3.0 driver conventions. MongoCollection instead of DBCollection. Document instead DBObject, etc...

Rough pass and could use more testing before being considered production ready. Tried to keep most methods from JacksonDBCollection in JacksonMongoCollection to make upgrading easy.

Usage example can be found in TestJacksonMongoCollection.

* The object mapper to use to serialise values
* @return The object
*/
public Document serialiseAndGetAsDocument(ObjectMapper objectMapper,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo - serialize

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Darn. Will fix in the morning.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be noted this is also mispelled in the existing (DBObject) method, but I think seriazeAndGet is meant for internal use only.

import org.mongojack.internal.stream.JacksonDecoder;
import org.mongojack.internal.stream.JacksonEncoder;

import javax.swing.text.Document;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

swing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Darn will fix in the morning. Should definitely be Bson.Document

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was actually left in from earlier testing... Safe to remove entirely.

private static final ObjectMapper DEFAULT_OBJECT_MAPPER = MongoJackModule
.configure(new ObjectMapper());

private com.mongodb.client.MongoCollection<T> mongoCollection;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be final? do we need the fully specified package name or can we just import it instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't be final if we want to let users set WriteConcern or ReadConcern, unless we do the same thing as the Mongo driver here and return a new instance if the JacksonMongoCollection.

Fully specified package name is because there is already a class that has the same name in the package as the JacksonMongoCollection.

Remove unused items from JacksonCodecRegistry

public class JacksonEncoder<T> implements Encoder<T> {

private Class<T> clazz;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can these variables be made final?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why not. I'll do it.

@benmccann
Copy link
Contributor

This seems like a big enough change that we should add something about how to use it to the README

@cfogrady
Copy link
Collaborator Author

Adding to the README makes sense. I'll make a section, and add it to the PR.

@cfogrady
Copy link
Collaborator Author

README updated. Please review.

@benmccann benmccann merged commit 11c1d14 into mongojack:master Jan 15, 2018
@cfogrady cfogrady deleted the Upgrade-3.0 branch January 16, 2018 15:35
@inf3cti0n95
Copy link

Is this updated to the Maven repo ?

@inf3cti0n95 inf3cti0n95 mentioned this pull request Feb 13, 2018
@cfogrady
Copy link
Collaborator Author

Yes, as of 2.8.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants