Skip to content

Commit

Permalink
Add some docs and deprecated typo
Browse files Browse the repository at this point in the history
  • Loading branch information
felixklauke committed Sep 6, 2020
1 parent 49db19a commit dfe2267
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 1 deletion.
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,48 @@
# susceptor
Library and utilities supporting rapid development and centralized management of common development practices.

## Getting Started

This section desribed how to integrate susceptor in your development workflow and where and
how it can help you developing plugins.

## Features

This brievly describes the core features of this library. You can find further information
in the correspondign sub directories.

### Dependency Injection

Implemented in [susceptor-dependency-injection](susceptor-dependency-injection).

Susceptor defines [Google Guice](https://github.com/google/guice) as a dependency injection framework.

### Persistence

Implemented in [susceptor-persistence](susceptor-persistence).

The persistence module introduces MongoDB as a database and uses [Morphia](https://morphia.dev/)
as orm for MongoDB.

For getting started you should take a look at the [PersistenceModule](susceptor-persistence/src/main/java/de/marmeladenoma/susceptor/persistence/inject/PersistenceModule.java).
This module contains several bindings for bootstrapping your persistence layer with MongoDB. The usage is pretty straight forward:

```java
var config = PersistenceConfig.newBuilder()
.withMongoConnectionString("")
.withMongoUser("")
.withMongoPassword("")
.withMongoSource("")
.build();
var injector = Guice.createInjector(PersistenceModule.create(config));
```

The injector prepares a MongoDB Client that can be easily used via the
[DatastoreFactory](susceptor-persistence/src/main/java/de/marmeladenoma/susceptor/persistence/DatastoreFactory.java):

```java
var datastoreFactory = injector.getInstance(DatastoreFactory.class);
datastoreFactory.createDatastore("test_database");
```

Ready, Steady, Go!
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {

subprojects {
group "de.marmeladenoma"
version "0.2.0"
version "0.2.1"

apply plugin: 'java'
apply plugin: 'checkstyle'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public static final class PersistenceConfigBuilder {
private PersistenceConfigBuilder() {
}

@Deprecated
public PersistenceConfigBuilder withMongoConnectionStrong(
String mongoConnectionString
) {
Expand All @@ -90,6 +91,14 @@ public PersistenceConfigBuilder withMongoConnectionStrong(
return this;
}

public PersistenceConfigBuilder withMongoConnectionString(
String mongoConnectionString
) {
Preconditions.checkNotNull(mongoConnectionString);
this.mongoConnectionString = mongoConnectionString;
return this;
}

public PersistenceConfigBuilder withMongoUser(String mongoUser) {
Preconditions.checkNotNull(mongoUser);
this.mongoUser = mongoUser;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package de.marmeladenoma.susceptor.persistence;

import com.google.inject.Guice;
import com.google.inject.Injector;
import de.marmeladenoma.susceptor.persistence.inject.PersistenceConfig;
import de.marmeladenoma.susceptor.persistence.inject.PersistenceModule;

class DatastoreFactoryTest {
public static void main(String[] args) {
var config = PersistenceConfig.newBuilder()
.withMongoConnectionString("")
.withMongoUser("")
.withMongoPassword("")
.withMongoSource("")
.build();
var injector = Guice.createInjector(PersistenceModule.create(config));
var datastoreFactory = injector.getInstance(DatastoreFactory.class);
datastoreFactory.createDatastore("test_database");
}
}

0 comments on commit dfe2267

Please sign in to comment.