-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
49db19a
commit dfe2267
Showing
4 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...ersistence/src/test/java/de/marmeladenoma/susceptor/persistence/DatastoreFactoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} |