{"id":19010795,"url":"https://github.com/meltmedia/dropwizard-mongo","last_synced_at":"2025-04-22T23:23:00.496Z","repository":{"id":23983137,"uuid":"27366267","full_name":"meltmedia/dropwizard-mongo","owner":"meltmedia","description":"A Dropwizard bundle for MongoDB","archived":false,"fork":false,"pushed_at":"2018-10-31T21:36:00.000Z","size":97,"stargazers_count":19,"open_issues_count":6,"forks_count":14,"subscribers_count":3,"default_branch":"develop","last_synced_at":"2025-04-17T14:38:59.482Z","etag":null,"topics":["dropwizard","dropwizard-bundle","java","mongodb","oplog","rxjava"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/meltmedia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-12-01T06:38:13.000Z","updated_at":"2023-09-08T16:52:34.000Z","dependencies_parsed_at":"2022-07-10T10:21:07.650Z","dependency_job_id":null,"html_url":"https://github.com/meltmedia/dropwizard-mongo","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meltmedia%2Fdropwizard-mongo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meltmedia%2Fdropwizard-mongo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meltmedia%2Fdropwizard-mongo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meltmedia%2Fdropwizard-mongo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/meltmedia","download_url":"https://codeload.github.com/meltmedia/dropwizard-mongo/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250338602,"owners_count":21414214,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dropwizard","dropwizard-bundle","java","mongodb","oplog","rxjava"],"created_at":"2024-11-08T19:12:31.041Z","updated_at":"2025-04-22T23:23:00.455Z","avatar_url":"https://github.com/meltmedia.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dropwizard Mongo\n\nA Dropwizard bundle for MongoDB.\n\n[![Build Status](https://travis-ci.org/meltmedia/dropwizard-mongo.svg)](https://travis-ci.org/meltmedia/dropwizard-mongo)\n\n## Usage\n\n### Maven\n\nReleases of this project are available on Maven Central.  You can include the project with this dependency:\n\n```\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.meltmedia.dropwizard\u003c/groupId\u003e\n  \u003cartifactId\u003edropwizard-mongo\u003c/artifactId\u003e\n  \u003cversion\u003e0.5.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nTo use SNAPSHOTs of this project, you will need to include the sonatype repository in your POM.\n\n```\n\u003crepositories\u003e\n    \u003crepository\u003e\n        \u003csnapshots\u003e\n        \u003cenabled\u003etrue\u003c/enabled\u003e\n        \u003c/snapshots\u003e\n        \u003cid\u003esonatype-nexus-snapshots\u003c/id\u003e\n        \u003cname\u003eSonatype Nexus Snapshots\u003c/name\u003e\n        \u003curl\u003ehttps://oss.sonatype.org/content/repositories/snapshots\u003c/url\u003e\n    \u003c/repository\u003e\n\u003c/repositories\u003e\n```\n\nYou will also need to include the project in your dependencies.\n\n```\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.meltmedia.dropwizard\u003c/groupId\u003e\n  \u003cartifactId\u003edropwizard-mongo\u003c/artifactId\u003e\n  \u003cversion\u003e0.6.0-SNAPSHOT\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n### Java\n\nDefine the MongoConfiguration class somewhere in your applications configuration.\n\n```\nimport com.meltmedia.dropwizard.mongo.MongoConfiguration;\n\n...\n\n  @JsonProperty\n  protected MongoConfiguration mongo;\n\n  public MongoConfiguration getMongo() {\n    return mongo;\n  }\n```\n\nThen include the bundle in the `initialize` method of your application.\n\n```\nimport com.meltmedia.dropwizard.mongo.MongoBundle;\n\n...\nMongoBundle\u003cExampleConfiguration\u003e mongoBundle;\n\n@Override\npublic void initialize(Bootstrap\u003cExampleConfiguration\u003e bootstrap) {\n  bootstrap.addBundle(mongoBundle = MongoBundle.\u003cExampleConfiguration\u003ebuilder()\n    .withConfiguration(ExampleConfiguration::getMongo)\n    .build());\n}\n```\n\nFinally, use the bundle to access the client and database in your `run` method.\n\n```\n@Override\npublic void run(ExampleConfiguration config, Environment env) throws Exception {\n  MongoClient client = mongoBundle.getClient();\n  DB db = mongoBundle.getDB();\n  // do something cool.\n}\n```\n\n### Configuration\n\nAdd the mongo configuraiton block to your applications config.\n\n```\nmongo:\n  seeds:\n  - host: localhost\n    port: 27017\n  database: example\n  credentials:\n    userName: example\n    password: example\n```\n\n### RxJava2 Oplog Service\n\nStarting with version 0.4.0, this service provides an oplog watching service.  It provides a hot, sharable observable, suitable for restarting processors on collection changes.\n\nTo use the service, include the JavaRx2 dependency.\n\n```\n\u003cdependency\u003e\n  \u003cgroupId\u003eio.reactivex.rxjava2\u003c/groupId\u003e\n  \u003cartifactId\u003erxjava\u003c/artifactId\u003e\n  \u003cversion\u003e2.0.4\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nThen include the bundle in the `initialize` method of your application, after the bundle for the client.\n\n```\nimport com.meltmedia.dropwizard.mongo.MongoBundle;\nimport com.meltmedia.dropwizard.mongo.rxoplog.RxOplogBundle;\n\n...\nMongoBundle\u003cExampleConfiguration\u003e mongoBundle;\nRxOplogBundle\u003cExampleConfiguration\u003e oplogBundle;\n\n@Override\npublic void initialize(Bootstrap\u003cExampleConfiguration\u003e bootstrap) {\n  bootstrap.addBundle(mongoBundle = MongoBundle.\u003cExampleConfiguration\u003ebuilder()\n    .withConfiguration(ExampleConfiguration::getMongo)\n    .build());\n  bootstrap.addBundle(oplogBundle = RxOplogBundle.\u003cExampleConfiguration\u003ebuilder()\n    .with(config-\u003eserviceBuilder-\u003eserviceBuilder\n      .withMongoClient(mongoBundle::getClient)\n      .matchDatabase(config.getMongo().getDatabase()))\n    .build());\n}\n```\n\nThen you can access the service in the `run` method.\n\n```\n@Override\npublic void run(ExampleConfiguration config, Environment env) throws Exception {\n  RxOplogService oplog = oplogBundle.getOplogService();\n  \n  env.lifecycle().manage(new Managed() {\n    Disposable disposable;\n    @Override\n    public void start() throws Exception {\n      disposable = oplogBundle.getOplogService()\n        .getOplog()\n        .forEach(doc-\u003e{\n          // do something cool\n        });\n    }\n\n    @Override\n    public void stop() throws Exception {\n      if( disposable != null ) disposable.dispose();\n    }\n  });\n}\n```\n\n## Building\n\nThis project builds with Java8 and Maven 3.  After cloning the repo, install the bundle from the root of the project.\n\n```\nmvn clean install\n```\n\n### Integration Tests\n\nYou can also run integration tests while running the build.  First, you will need to\nmake sure the configuration passphrase is in the environment.\n\n```\nexport EXAMPLE_PASSPHRASE='correct horse battery staple'\n```\nSecond you need to install vagrant in version 1.5 and above.\n\nThen run the build with the `integration-tests` profile.\n\n```\nmvn clean install -P integration-tests\n```\n\n## Contributing\n\nThis project accepts PRs, so feel free to fork the project and send contributions back.\n\n### Formatting\n\nThis project contains formatters to help keep the code base consistent.  The formatter will update Java source files and add headers to other files.  When running the formatter, I suggest the following procedure:\n\n1. Make sure any outstanding stages are staged.  This will prevent the formatter from destroying your code.\n2. Run `mvn format`, this will format the source and add any missing license headers.\n3. If the changes look good and the project still compiles, add the formatting changes to your staged code.\n\nIf things go wrong, you can run `git checkout -- .` to drop the formatting changes. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeltmedia%2Fdropwizard-mongo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeltmedia%2Fdropwizard-mongo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeltmedia%2Fdropwizard-mongo/lists"}