diff --git a/.travis.yml b/.travis.yml index b7fd2cf..a26c6e3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,12 +13,11 @@ cache: directories: - "$HOME/.m2/repository" -install: /bin/true +install: + - rm ~/.m2/settings.xml + - if [ $TRAVIS_PULL_REQUEST = false ] && [ $TRAVIS_BRANCH = master ]; then GOAL=deploy; else GOAL=install; fi -script: - - mvn -q -B -U -Pstaging,javadoc,compatibility install jacoco:report - - mvn -q -B coveralls:report -DrepoToken=$COVERALLS_TOKEN +script: mvn -q -U -T 2 -Pcompatibility,snapshots,javadoc $GOAL jacoco:report + +after_success: mvn -q coveralls:report -DrepoToken=$COVERALLS_TOKEN -after_success: - - echo "sonatype-nexus-snapshots\${env.SONATYPE_USER}\${env.SONATYPE_PASS}" > ~/settings.xml - - "[[ $TRAVIS_PULL_REQUEST == \"false\" && $TRAVIS_BRANCH == \"master\" ]] && mvn -q deploy --settings ~/settings.xml -DskipTests=true -Pjavadoc" diff --git a/core/pom.xml b/core/pom.xml new file mode 100644 index 0000000..aca5458 --- /dev/null +++ b/core/pom.xml @@ -0,0 +1,49 @@ + + + 4.0.0 + + + org.seedstack.addons + mongodb + 1.0.0-M1-SNAPSHOT + + + mongodb-core + + + + org.mongodb + mongo-java-driver + ${mongodb.version} + provided + + + org.mongodb + mongodb-driver-async + ${mongodb.version} + provided + + + org.seedstack.seed + seed-testing + ${seed.version} + test + + + ch.qos.logback + logback-classic + ${logback.version} + test + + + + diff --git a/src/it/java/org/seedstack/seed/persistence/mongodb/MongoDbAsyncIT.java b/core/src/it/java/org/seedstack/seed/persistence/mongodb/MongoDbAsyncIT.java similarity index 93% rename from src/it/java/org/seedstack/seed/persistence/mongodb/MongoDbAsyncIT.java rename to core/src/it/java/org/seedstack/seed/persistence/mongodb/MongoDbAsyncIT.java index 63accc2..ed8cf58 100644 --- a/src/it/java/org/seedstack/seed/persistence/mongodb/MongoDbAsyncIT.java +++ b/core/src/it/java/org/seedstack/seed/persistence/mongodb/MongoDbAsyncIT.java @@ -1,7 +1,5 @@ /** - * Copyright (c) 2013-2015 by The SeedStack authors. All rights reserved. - * - * This file is part of SeedStack, An enterprise-oriented full development stack. + * Copyright (c) 2013-2015, The SeedStack authors * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/it/java/org/seedstack/seed/persistence/mongodb/MongoDbIT.java b/core/src/it/java/org/seedstack/seed/persistence/mongodb/MongoDbIT.java similarity index 90% rename from src/it/java/org/seedstack/seed/persistence/mongodb/MongoDbIT.java rename to core/src/it/java/org/seedstack/seed/persistence/mongodb/MongoDbIT.java index a6887fc..2702d8a 100644 --- a/src/it/java/org/seedstack/seed/persistence/mongodb/MongoDbIT.java +++ b/core/src/it/java/org/seedstack/seed/persistence/mongodb/MongoDbIT.java @@ -1,7 +1,5 @@ /** - * Copyright (c) 2013-2015 by The SeedStack authors. All rights reserved. - * - * This file is part of SeedStack, An enterprise-oriented full development stack. + * Copyright (c) 2013-2015, The SeedStack authors * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/it/resources/META-INF/configuration/org.seedstack.seed.persistence.mongo.props b/core/src/it/resources/META-INF/configuration/org.seedstack.seed.persistence.mongo.props similarity index 80% rename from src/it/resources/META-INF/configuration/org.seedstack.seed.persistence.mongo.props rename to core/src/it/resources/META-INF/configuration/org.seedstack.seed.persistence.mongo.props index cddc2a0..ce5f3d5 100644 --- a/src/it/resources/META-INF/configuration/org.seedstack.seed.persistence.mongo.props +++ b/core/src/it/resources/META-INF/configuration/org.seedstack.seed.persistence.mongo.props @@ -1,7 +1,5 @@ # -# Copyright (c) 2013-2015 by The SeedStack authors. All rights reserved. -# -# This file is part of SeedStack, An enterprise-oriented full development stack. +# Copyright (c) 2013-2015, The SeedStack authors # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/it/resources/logback-test.xml b/core/src/it/resources/logback-test.xml similarity index 77% rename from src/it/resources/logback-test.xml rename to core/src/it/resources/logback-test.xml index 7db11a5..206a61c 100644 --- a/src/it/resources/logback-test.xml +++ b/core/src/it/resources/logback-test.xml @@ -1,9 +1,7 @@ + + 4.0.0 + + + org.seedstack.addons + mongodb + 1.0.0-M1-SNAPSHOT + + + mongodb-morphia + + + + org.seedstack.addons + mongodb-core + ${project.version} + + + org.seedstack.business + business-specs + ${business.version} + true + + + org.mongodb.morphia + morphia + ${morphia.version} + + + org.seedstack.seed + seed-testing + ${seed.version} + test + + + ch.qos.logback + logback-classic + ${logback.version} + test + + + org.seedstack.business + business-core + ${business.version} + test + + + org.mongodb + mongodb-driver-async + ${mongodb.version} + test + + + + diff --git a/morphia/src/it/java/org/seedstack/seed/business/mongodb/MongodbRepositoryIT.java b/morphia/src/it/java/org/seedstack/seed/business/mongodb/MongodbRepositoryIT.java new file mode 100644 index 0000000..8de81b2 --- /dev/null +++ b/morphia/src/it/java/org/seedstack/seed/business/mongodb/MongodbRepositoryIT.java @@ -0,0 +1,143 @@ +/** + * Copyright (c) 2013-2015, The SeedStack authors + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.seedstack.seed.business.mongodb; + +import org.assertj.core.api.Assertions; +import org.junit.Test; +import org.seedstack.business.api.domain.Repository; +import org.seedstack.seed.core.api.SeedException; +import org.seedstack.seed.it.AbstractSeedIT; +import org.seedstack.seed.mongodb.domain.dummyobject.Dummy1; +import org.seedstack.seed.mongodb.domain.dummyobject.Dummy2; +import org.seedstack.seed.mongodb.domain.dummyobject.Dummy3; +import org.seedstack.seed.mongodb.domain.dummyobject.Dummy4; +import org.seedstack.seed.mongodb.domain.dummyobject.Dummy5; +import org.seedstack.seed.mongodb.domain.dummyobject.Dummy6; +import org.seedstack.seed.mongodb.domain.user.Address; +import org.seedstack.seed.mongodb.domain.user.User; +import org.seedstack.seed.persistence.mongodb.api.Morphia; +import org.seedstack.seed.persistence.mongodb.api.MorphiaErrorCodes; + +import com.google.inject.Inject; +import com.google.inject.Injector; +import com.google.inject.Key; +import com.google.inject.ProvisionException; +import com.google.inject.TypeLiteral; +import com.google.inject.util.Types; + +public class MongodbRepositoryIT extends AbstractSeedIT { + + @Inject + @Morphia + private Repository userRepository; + + @Inject + private Injector injector; + + @Test + public void repository_injection_test_no_client_for_aggregate() { + try { + + injector.getInstance( + Key.get(TypeLiteral.get(Types.newParameterizedType(Repository.class, Dummy1.class, Long.class)), + Morphia.class)); + } catch (ProvisionException e) { + Assertions.assertThat(e.getCause().getMessage()) + .isEqualTo(SeedException.createNew(MorphiaErrorCodes.UNKNOW_DATASTORE_CLIENT).getMessage()); + } + } + + @Test + public void repository_injection_test_no_dbName_for_aggregate() { + try { + injector.getInstance( + Key.get(TypeLiteral.get(Types.newParameterizedType(Repository.class, Dummy2.class, Long.class)), + Morphia.class)); + } catch (ProvisionException e) { + Assertions.assertThat(e.getCause().getMessage()) + .isEqualTo(SeedException.createNew(MorphiaErrorCodes.UNKNOW_DATASTORE_DATABASE).getMessage()); + } + } + + @Test + public void repository_injection_test_no_mongoDb_client() { + try { + injector.getInstance( + Key.get(TypeLiteral.get(Types.newParameterizedType(Repository.class, Dummy3.class, Long.class)), + Morphia.class)); + } catch (ProvisionException e) { + Assertions.assertThat(e.getCause().getMessage()) + .isEqualTo(SeedException.createNew(MorphiaErrorCodes.UNKNOW_DATASTORE_CLIENT).getMessage()); + } + } + + @Test + public void repository_injection_test_no_mongoDb_database() { + try { + injector.getInstance( + Key.get(TypeLiteral.get(Types.newParameterizedType(Repository.class, Dummy4.class, Long.class)), + Morphia.class)); + } catch (ProvisionException e) { + Assertions.assertThat(e.getCause().getMessage()) + .isEqualTo(SeedException.createNew(MorphiaErrorCodes.UNKNOW_DATABASE_NAME).getMessage()); + } + } + + @Test + public void repository_injection_test_no_mongodb_for_aggregate() { + try { + injector.getInstance( + Key.get(TypeLiteral.get(Types.newParameterizedType(Repository.class, Dummy5.class, Long.class)), + Morphia.class)); + } catch (ProvisionException e) { + Assertions.assertThat(e.getCause().getMessage()) + .isEqualTo(SeedException.createNew(MorphiaErrorCodes.UNKNOW_DATASTORE_CONFIGURATION).getMessage()); + } + } + + @Test + public void repository_injection_async_client() { + try { + injector.getInstance( + Key.get(TypeLiteral.get(Types.newParameterizedType(Repository.class, Dummy6.class, Long.class)), + Morphia.class)); + } catch (ProvisionException e) { + Assertions.assertThat(e.getCause().getMessage()) + .isEqualTo(SeedException.createNew(MorphiaErrorCodes.ERROR_ASYNC_CLIENT).getMessage()); + } + } + + + @Test + public void mongodb_repository_test() { + Assertions.assertThat(userRepository).isNotNull(); + User user1 = getUser(1L, "N°", "1"); + userRepository.persist(user1); + User user2 = userRepository.load(user1.getEntityId()); + Assertions.assertThat(user1.getId()).isEqualTo(user2.getId()); + Assertions.assertThat(user1.getEntityId()).isEqualTo(user2.getEntityId()); + userRepository.delete(user1); + User user3 = userRepository.load(user1.getEntityId()); + Assertions.assertThat(user3).isEqualTo(null); + User user5 = getUser(2L, "N°", "2"); + userRepository.delete(user5); + userRepository.save(user5); + User user6 = userRepository.load(user5.getEntityId()); + Assertions.assertThat(user6.getId()).isEqualTo(user5.getId()); + userRepository.delete(user5); + user6 = userRepository.load(user5.getEntityId()); + Assertions.assertThat(user6).isEqualTo(null); + userRepository.persist(user5); + Assertions.assertThat(userRepository.load(2L)).isNotEqualTo(null); + } + + public User getUser(long id, String firstname, String lastName) { + return new User(id, firstname, lastName, new Address("France", "75001", "Paris", "Champ Elysee avenue", 1)); + } + +} diff --git a/morphia/src/it/java/org/seedstack/seed/mongodb/domain/dummyobject/Dummy1.java b/morphia/src/it/java/org/seedstack/seed/mongodb/domain/dummyobject/Dummy1.java new file mode 100644 index 0000000..88a47c7 --- /dev/null +++ b/morphia/src/it/java/org/seedstack/seed/mongodb/domain/dummyobject/Dummy1.java @@ -0,0 +1,19 @@ +/** + * Copyright (c) 2013-2015, The SeedStack authors + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.seedstack.seed.mongodb.domain.dummyobject; + +import org.seedstack.business.api.domain.BaseAggregateRoot; + +public class Dummy1 extends BaseAggregateRoot { + + @Override + public Long getEntityId() { + return null; + } + +} diff --git a/morphia/src/it/java/org/seedstack/seed/mongodb/domain/dummyobject/Dummy2.java b/morphia/src/it/java/org/seedstack/seed/mongodb/domain/dummyobject/Dummy2.java new file mode 100644 index 0000000..4e28b08 --- /dev/null +++ b/morphia/src/it/java/org/seedstack/seed/mongodb/domain/dummyobject/Dummy2.java @@ -0,0 +1,19 @@ +/** + * Copyright (c) 2013-2015, The SeedStack authors + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.seedstack.seed.mongodb.domain.dummyobject; + +import org.seedstack.business.api.domain.BaseAggregateRoot; + +public class Dummy2 extends BaseAggregateRoot { + + @Override + public Long getEntityId() { + return null; + } + +} diff --git a/morphia/src/it/java/org/seedstack/seed/mongodb/domain/dummyobject/Dummy3.java b/morphia/src/it/java/org/seedstack/seed/mongodb/domain/dummyobject/Dummy3.java new file mode 100644 index 0000000..3508d03 --- /dev/null +++ b/morphia/src/it/java/org/seedstack/seed/mongodb/domain/dummyobject/Dummy3.java @@ -0,0 +1,19 @@ +/** + * Copyright (c) 2013-2015, The SeedStack authors + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.seedstack.seed.mongodb.domain.dummyobject; + +import org.seedstack.business.api.domain.BaseAggregateRoot; + +public class Dummy3 extends BaseAggregateRoot { + + @Override + public Long getEntityId() { + return null; + } + +} diff --git a/morphia/src/it/java/org/seedstack/seed/mongodb/domain/dummyobject/Dummy4.java b/morphia/src/it/java/org/seedstack/seed/mongodb/domain/dummyobject/Dummy4.java new file mode 100644 index 0000000..baad94b --- /dev/null +++ b/morphia/src/it/java/org/seedstack/seed/mongodb/domain/dummyobject/Dummy4.java @@ -0,0 +1,20 @@ +/** + * Copyright (c) 2013-2015, The SeedStack authors + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.seedstack.seed.mongodb.domain.dummyobject; + +import org.seedstack.business.api.domain.BaseAggregateRoot; + +public class Dummy4 extends BaseAggregateRoot { + + @Override + public Long getEntityId() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/morphia/src/it/java/org/seedstack/seed/mongodb/domain/dummyobject/Dummy5.java b/morphia/src/it/java/org/seedstack/seed/mongodb/domain/dummyobject/Dummy5.java new file mode 100644 index 0000000..e4d4344 --- /dev/null +++ b/morphia/src/it/java/org/seedstack/seed/mongodb/domain/dummyobject/Dummy5.java @@ -0,0 +1,20 @@ +/** + * Copyright (c) 2013-2015, The SeedStack authors + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.seedstack.seed.mongodb.domain.dummyobject; + +import org.seedstack.business.api.domain.BaseAggregateRoot; + +public class Dummy5 extends BaseAggregateRoot { + + @Override + public Long getEntityId() { + // TODO Auto-generated method stub + return null; + } + +} \ No newline at end of file diff --git a/morphia/src/it/java/org/seedstack/seed/mongodb/domain/dummyobject/Dummy6.java b/morphia/src/it/java/org/seedstack/seed/mongodb/domain/dummyobject/Dummy6.java new file mode 100644 index 0000000..fe1eb14 --- /dev/null +++ b/morphia/src/it/java/org/seedstack/seed/mongodb/domain/dummyobject/Dummy6.java @@ -0,0 +1,20 @@ +/** + * Copyright (c) 2013-2015, The SeedStack authors + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.seedstack.seed.mongodb.domain.dummyobject; + +import org.seedstack.business.api.domain.BaseAggregateRoot; + +public class Dummy6 extends BaseAggregateRoot { + + @Override + public Long getEntityId() { + // TODO Auto-generated method stub + return null; + } + +} \ No newline at end of file diff --git a/morphia/src/it/java/org/seedstack/seed/mongodb/domain/user/Address.java b/morphia/src/it/java/org/seedstack/seed/mongodb/domain/user/Address.java new file mode 100644 index 0000000..136aee9 --- /dev/null +++ b/morphia/src/it/java/org/seedstack/seed/mongodb/domain/user/Address.java @@ -0,0 +1,67 @@ +/** + * Copyright (c) 2013-2015, The SeedStack authors + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.seedstack.seed.mongodb.domain.user; + +import org.mongodb.morphia.annotations.Embedded; +import org.seedstack.business.api.domain.ValueObject; + +@Embedded +public class Address implements ValueObject{ + private String country; + private String zipcode; + private String city; + private String street; + private Integer number; + + + + public Address() { + super(); + } + public Address(String country, String zipcode, String city, String street, Integer number) { + super(); + this.country = country; + this.zipcode = zipcode; + this.city = city; + this.street = street; + this.number = number; + } + public String getCountry() { + return country; + } + public void setCountry(String country) { + this.country = country; + } + public String getZipcode() { + return zipcode; + } + public void setZipcode(String zipcode) { + this.zipcode = zipcode; + } + public String getCity() { + return city; + } + public void setCity(String city) { + this.city = city; + } + public String getStreet() { + return street; + } + public void setStreet(String street) { + this.street = street; + } + public Integer getNumber() { + return number; + } + public void setNumber(Integer number) { + this.number = number; + } + + + +} diff --git a/morphia/src/it/java/org/seedstack/seed/mongodb/domain/user/User.java b/morphia/src/it/java/org/seedstack/seed/mongodb/domain/user/User.java new file mode 100644 index 0000000..a41f9a2 --- /dev/null +++ b/morphia/src/it/java/org/seedstack/seed/mongodb/domain/user/User.java @@ -0,0 +1,80 @@ +/** + * Copyright (c) 2013-2015, The SeedStack authors + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.seedstack.seed.mongodb.domain.user; + +import org.mongodb.morphia.annotations.Entity; +import org.mongodb.morphia.annotations.Id; +import org.seedstack.business.api.domain.AggregateRoot; + +@Entity +public class User implements AggregateRoot{ + + + + public User() { + super(); + // TODO Auto-generated constructor stub + } + + public User(long id, String name, String lastname, Address address) { + super(); + this.id = id; + this.name = name; + this.lastname = lastname; + this.address = address; + } + + @Id + private long id; + + private String name; + + private String lastname; + + private Address address; + + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getLastname() { + return lastname; + } + + public void setLastname(String lastname) { + this.lastname = lastname; + } + + public Address getAddress() { + return address; + } + + public void setAddress(Address address) { + this.address = address; + } + + @Override + public Long getEntityId() { + return id; + } + + +} diff --git a/morphia/src/it/java/org/seedstack/seed/persistence/mongodb/MongoDbIT.java b/morphia/src/it/java/org/seedstack/seed/persistence/mongodb/MongoDbIT.java new file mode 100644 index 0000000..2702d8a --- /dev/null +++ b/morphia/src/it/java/org/seedstack/seed/persistence/mongodb/MongoDbIT.java @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2013-2015, The SeedStack authors + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.seedstack.seed.persistence.mongodb; + +import com.mongodb.MongoClient; +import com.mongodb.client.MongoDatabase; +import org.bson.Document; +import org.junit.Test; +import org.seedstack.seed.it.AbstractSeedIT; + +import javax.inject.Inject; +import javax.inject.Named; + +import static org.assertj.core.api.Assertions.assertThat; + +public class MongoDbIT extends AbstractSeedIT { + @Inject + @Named("client1") + MongoClient client1; + + @Inject + @Named("db1") + MongoDatabase db1; + + @Inject + MongoClient implicitClient; + + @Inject + MongoDatabase implicitDatabase; + + @Test + public void mongo_clients_are_injectable() { + assertThat(client1).isNotNull(); + assertThat(implicitClient).isNotNull(); + } + + @Test + public void mongo_databases_are_injectable() { + assertThat(db1).isNotNull(); + assertThat(implicitDatabase).isNotNull(); + } + + @Test + public void test_insert_into_collection() { + Document doc = new Document("name", "MongoDB") + .append("type", "database") + .append("count", 1) + .append("info", new Document("x", 203).append("y", 102)); + + db1.getCollection("test1").insertOne(doc); + } +} diff --git a/morphia/src/it/java/org/seedstack/seed/persistence/mongodb/morphia/MorphiaIT.java b/morphia/src/it/java/org/seedstack/seed/persistence/mongodb/morphia/MorphiaIT.java new file mode 100644 index 0000000..a81be10 --- /dev/null +++ b/morphia/src/it/java/org/seedstack/seed/persistence/mongodb/morphia/MorphiaIT.java @@ -0,0 +1,33 @@ +/** + * Copyright (c) 2013-2015, The SeedStack authors + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.seedstack.seed.persistence.mongodb.morphia; + +import org.assertj.core.api.Assertions; +import org.junit.Test; +import org.mongodb.morphia.Datastore; +import org.mongodb.morphia.Key; +import org.seedstack.seed.it.AbstractSeedIT; +import org.seedstack.seed.mongodb.domain.user.Address; +import org.seedstack.seed.mongodb.domain.user.User; +import org.seedstack.seed.persistence.mongodb.api.MorphiaDatastore; + +import com.google.inject.Inject; + + +public class MorphiaIT extends AbstractSeedIT{ + @Inject + @MorphiaDatastore(clientName = "client1",dbName="db1") + private Datastore datastore; + + @Test + public void datastore_test(){ + User user = new User(1L,"Gerard", "menvuça", new Address("France", "78300", "Poissy", "avenue de l'europe", 1)); + Key keyUser = datastore.save(user); + Assertions.assertThat(keyUser).isNotNull(); + } +} diff --git a/morphia/src/it/resources/META-INF/configuration/org.seedstack.seed.persistence.mongo.props b/morphia/src/it/resources/META-INF/configuration/org.seedstack.seed.persistence.mongo.props new file mode 100644 index 0000000..277b291 --- /dev/null +++ b/morphia/src/it/resources/META-INF/configuration/org.seedstack.seed.persistence.mongo.props @@ -0,0 +1,50 @@ +# +# Copyright (c) 2013-2015, The SeedStack authors +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +[org.seedstack.seed.persistence.mongodb] +clients = client1, client2, client3 + +[org.seedstack.seed.persistence.mongodb.client.client1] +hosts = localhost +option.connectionsPerHost = 50 +databases = db1 + +[org.seedstack.seed.persistence.mongodb.client.client2] +async = true +hosts = localhost +setting.connectionPool.maxSize = 50 +databases = db2 + +[org.seedstack.seed.persistence.mongodb.client.client3] +async = true +hosts = localhost +databases = db2 +alias.db2 = db3 + + +[org.seedstack.seed.mongodb.domain.user.*] +morphia.clientName = client1 +morphia.dbName = db1 + +[org.seedstack.seed.mongodb.domain.dummyobject.Dummy1] +morphia.dbName = db4 + +[org.seedstack.seed.mongodb.domain.dummyobject.Dummy2] +morphia.clientName = clien1 + +[org.seedstack.seed.mongodb.domain.dummyobject.Dummy3] +morphia.dbName = client7 +morphia.dbName = db6 + +[org.seedstack.seed.mongodb.domain.dummyobject.Dummy4] +morphia.clientName = client1 +morphia.dbName = db6 + +[org.seedstack.seed.mongodb.domain.dummyobject.Dummy6] +morphia.clientName = client2 +morphia.dbName = db2 \ No newline at end of file diff --git a/morphia/src/it/resources/logback-test.xml b/morphia/src/it/resources/logback-test.xml new file mode 100644 index 0000000..206a61c --- /dev/null +++ b/morphia/src/it/resources/logback-test.xml @@ -0,0 +1,20 @@ + + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + \ No newline at end of file diff --git a/morphia/src/main/java/org/seedstack/seed/business/mongodb/BaseMongodbRepository.java b/morphia/src/main/java/org/seedstack/seed/business/mongodb/BaseMongodbRepository.java new file mode 100644 index 0000000..25a0faa --- /dev/null +++ b/morphia/src/main/java/org/seedstack/seed/business/mongodb/BaseMongodbRepository.java @@ -0,0 +1,73 @@ +/** + * Copyright (c) 2013-2015, The SeedStack authors + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.seedstack.seed.business.mongodb; + +import org.mongodb.morphia.Datastore; +import org.seedstack.business.api.domain.AggregateRoot; +import org.seedstack.business.api.domain.BaseRepository; +import org.seedstack.seed.core.api.Application; +import org.seedstack.seed.persistence.mongodb.internal.MorphiaPlugin; + +import com.google.inject.Inject; +import com.google.inject.Injector; +import com.google.inject.Key; + +/** + * This class serves as inheritance base for the Mongodb repositories. + * + * @param + * Mongodb Entity Type (DDD: Aggregate) + * @param + * key type + * @author redouane.loulou@ext.mpsa.com Date: 20/10/2015 + */ +public abstract class BaseMongodbRepository, K> extends BaseRepository { + + private Datastore datastore; + + public Datastore getDatastore() { + return datastore; + } + + public void setDatastore(Datastore datastore) { + this.datastore = datastore; + } + + @Inject + private void initDatastore(Application application, Injector injector) { + datastore = injector.getInstance(Key.get(Datastore.class, MorphiaPlugin.getMongoDatastore(application, aggregateRootClass))); + } + + @Override + protected A doLoad(K id) { + return datastore.get(aggregateRootClass, id); + } + + @Override + protected void doDelete(K id) { + datastore.delete(aggregateRootClass, id); + } + + @Override + protected void doDelete(A aggregate) { + datastore.delete(aggregate); + + } + + @Override + protected void doPersist(A aggregate) { + datastore.save(aggregate); + + } + + @Override + protected A doSave(A aggregate) { + return datastore.get(aggregateRootClass, datastore.save(aggregate).getId()); + } + +} \ No newline at end of file diff --git a/morphia/src/main/java/org/seedstack/seed/business/mongodb/internal/DefaultMongodbRepository.java b/morphia/src/main/java/org/seedstack/seed/business/mongodb/internal/DefaultMongodbRepository.java new file mode 100644 index 0000000..ef3a09c --- /dev/null +++ b/morphia/src/main/java/org/seedstack/seed/business/mongodb/internal/DefaultMongodbRepository.java @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2013-2015, The SeedStack authors + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.seedstack.seed.business.mongodb.internal; + +import javax.inject.Inject; + +import org.seedstack.business.api.domain.AggregateRoot; +import org.seedstack.business.spi.GenericImplementation; +import org.seedstack.seed.business.mongodb.BaseMongodbRepository; +import org.seedstack.seed.core.utils.SeedCheckUtils; +import org.seedstack.seed.persistence.mongodb.api.Morphia; + +import com.google.inject.assistedinject.Assisted; + +/** + * Default Morphia implementation for Repository. Used only when no implementation is provided for an aggregate. + * + * To inject this implementation you have to use {@link org.seedstack.business.api.domain.Repository} as follows: + *
+ * {@literal @}Inject
+ * Repository{@literal } myAggregateRepository;
+ * 
+ * + * @param the aggregate root + * @param the aggregate key + * @author redouane.loulou@ext.mpsa.com + * @see org.seedstack.business.api.domain.Repository + * @see org.seedstack.business.mongodb.BaseMongodbRepository + */ +@Morphia +@GenericImplementation +public class DefaultMongodbRepository, KEY> extends BaseMongodbRepository { + + /** + * Constructs a DefaultMongodbRepository. + * + * @param genericClasses the resolved generics for the aggregate root class and the key class + */ + @SuppressWarnings("unchecked") + @Inject + public DefaultMongodbRepository(@Assisted Object[] genericClasses) { + Object[] clonedClasses = genericClasses.clone(); + SeedCheckUtils.checkIfNotNull(clonedClasses); + SeedCheckUtils.checkIf(clonedClasses.length == 2); + this.aggregateRootClass = (Class) clonedClasses[0]; + this.keyClass = (Class) clonedClasses[1]; + } +} \ No newline at end of file diff --git a/morphia/src/main/java/org/seedstack/seed/persistence/mongodb/api/Morphia.java b/morphia/src/main/java/org/seedstack/seed/persistence/mongodb/api/Morphia.java new file mode 100644 index 0000000..9c974e0 --- /dev/null +++ b/morphia/src/main/java/org/seedstack/seed/persistence/mongodb/api/Morphia.java @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2013-2015, The SeedStack authors + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.seedstack.seed.persistence.mongodb.api; + +import javax.inject.Qualifier; +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * This qualifier marks the use of the Morphia persistence. + * + * @author redouane.loulou@ext.mpsa.com + * Date: 20/10/2015 + */ +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Qualifier +public @interface Morphia { +} diff --git a/morphia/src/main/java/org/seedstack/seed/persistence/mongodb/api/MorphiaDatastore.java b/morphia/src/main/java/org/seedstack/seed/persistence/mongodb/api/MorphiaDatastore.java new file mode 100644 index 0000000..2b952d7 --- /dev/null +++ b/morphia/src/main/java/org/seedstack/seed/persistence/mongodb/api/MorphiaDatastore.java @@ -0,0 +1,31 @@ +/** + * Copyright (c) 2013-2015, The SeedStack authors + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.seedstack.seed.persistence.mongodb.api; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import com.google.inject.BindingAnnotation; + +/** + * This qualifier marks the use of the Mongodb persistence. + * + * @author redouane.loulou@ext.mpsa.com + * Date: 20/10/2015 + */ +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target({ ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) +@BindingAnnotation +public @interface MorphiaDatastore { + String clientName(); + String dbName(); +} \ No newline at end of file diff --git a/morphia/src/main/java/org/seedstack/seed/persistence/mongodb/api/MorphiaErrorCodes.java b/morphia/src/main/java/org/seedstack/seed/persistence/mongodb/api/MorphiaErrorCodes.java new file mode 100644 index 0000000..8cf9f04 --- /dev/null +++ b/morphia/src/main/java/org/seedstack/seed/persistence/mongodb/api/MorphiaErrorCodes.java @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2013-2015, The SeedStack authors + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.seedstack.seed.persistence.mongodb.api; + +import org.seedstack.seed.core.api.ErrorCode; + +/** + * + * @author redouane.loulou@ext.mpsa.com + * + */ +public enum MorphiaErrorCodes implements ErrorCode { + UNKNOW_DATASTORE_CONFIGURATION, + UNKNOW_DATASTORE_CLIENT, + UNKNOW_DATASTORE_DATABASE, + UNKNOW_DATABASE_NAME, + ERROR_ASYNC_CLIENT +} diff --git a/morphia/src/main/java/org/seedstack/seed/persistence/mongodb/internal/DatastoreProvider.java b/morphia/src/main/java/org/seedstack/seed/persistence/mongodb/internal/DatastoreProvider.java new file mode 100644 index 0000000..a560103 --- /dev/null +++ b/morphia/src/main/java/org/seedstack/seed/persistence/mongodb/internal/DatastoreProvider.java @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2013-2015, The SeedStack authors + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.seedstack.seed.persistence.mongodb.internal; + +import org.mongodb.morphia.Datastore; +import org.mongodb.morphia.Morphia; +import org.seedstack.seed.core.api.Application; +import org.seedstack.seed.persistence.mongodb.api.MorphiaDatastore; + +import com.google.inject.Inject; +import com.google.inject.Injector; +import com.google.inject.Key; +import com.google.inject.Provider; +import com.google.inject.name.Names; +import com.mongodb.MongoClient; +/** + * + * @author redouane.loulou@ext.mpsa.com + * + */ +class DatastoreProvider implements Provider { + + @Inject + private Injector injector; + + @Inject + private Application application; + + private Class mappedclass; + + private MorphiaDatastore morphiaDatastore; + + private final Morphia morphia; + + @Override + public Datastore get() { + MongoClient mongoClient = injector + .getInstance(Key.get(MongoClient.class, Names.named(morphiaDatastore.clientName()))); + return morphia.createDatastore(mongoClient, morphiaDatastore.dbName()); + } + + public DatastoreProvider(MorphiaDatastore morphiaDatastore, Morphia morphia) { + super(); + this.morphiaDatastore = morphiaDatastore; + this.morphia = morphia; + } + +} diff --git a/morphia/src/main/java/org/seedstack/seed/persistence/mongodb/internal/MorphiaDatastoreImpl.java b/morphia/src/main/java/org/seedstack/seed/persistence/mongodb/internal/MorphiaDatastoreImpl.java new file mode 100644 index 0000000..3eb2f54 --- /dev/null +++ b/morphia/src/main/java/org/seedstack/seed/persistence/mongodb/internal/MorphiaDatastoreImpl.java @@ -0,0 +1,74 @@ +/** + * Copyright (c) 2013-2015, The SeedStack authors + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.seedstack.seed.persistence.mongodb.internal; + +import java.io.Serializable; +import java.lang.annotation.Annotation; + +import org.seedstack.seed.persistence.mongodb.api.MorphiaDatastore; +/** + * + * @author redouane.loulou@ext.mpsa.com + * + */ +class MorphiaDatastoreImpl implements MorphiaDatastore, Serializable { + + private static final long serialVersionUID = 3861460142806494075L; + private String clientName; + private String dbName; + + public MorphiaDatastoreImpl(String clientName, String dbName) { + this.clientName = clientName; + this.dbName = dbName; + } + + @Override + public Class annotationType() { + return MorphiaDatastore.class; + } + + @Override + public String dbName() { + return dbName; + } + + @Override + public String clientName() { + return clientName; + } + + @Override + public int hashCode() { + return ((127 * "clientName".hashCode()) ^ clientName.hashCode()) + + ((127 * "dbName".hashCode()) ^ dbName.hashCode()); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (!(obj instanceof MorphiaDatastore)) + return false; + MorphiaDatastoreImpl other = (MorphiaDatastoreImpl) obj; + if (clientName == null) { + if (other.clientName != null) + return false; + } else if (!clientName.equals(other.clientName)) + return false; + if (dbName == null) { + if (other.dbName != null) + return false; + } else if (!dbName.equals(other.dbName)) + return false; + return true; + } + + +} \ No newline at end of file diff --git a/morphia/src/main/java/org/seedstack/seed/persistence/mongodb/internal/MorphiaModule.java b/morphia/src/main/java/org/seedstack/seed/persistence/mongodb/internal/MorphiaModule.java new file mode 100644 index 0000000..73075e2 --- /dev/null +++ b/morphia/src/main/java/org/seedstack/seed/persistence/mongodb/internal/MorphiaModule.java @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2013-2015, The SeedStack authors + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +/** + * + */ +package org.seedstack.seed.persistence.mongodb.internal; + +import java.util.Collection; + +import org.mongodb.morphia.Datastore; +import org.mongodb.morphia.Morphia; +import org.seedstack.seed.persistence.mongodb.api.MorphiaDatastore; + +import com.google.inject.AbstractModule; +import com.google.inject.Key; + +/** + * @author redouane.loulou@ext.mpsa.com + * + */ +class MorphiaModule extends AbstractModule{ + + private Collection morphiaDatastoresAnnotation; + private final Morphia morphia; + + public MorphiaModule(Collection morphiaDatastoresAnnotation, Morphia morphia) { + super(); + this.morphiaDatastoresAnnotation = morphiaDatastoresAnnotation; + this.morphia = morphia; + } + + @Override + protected void configure() { + if(morphiaDatastoresAnnotation!=null && !morphiaDatastoresAnnotation.isEmpty()){ + for (MorphiaDatastore morphiaDatastore : morphiaDatastoresAnnotation) { + DatastoreProvider datastoreProvider = new DatastoreProvider(morphiaDatastore, morphia); + requestInjection(datastoreProvider); + bind(Key.get(Datastore.class, morphiaDatastore)).toProvider(datastoreProvider); + } + } + } + + + +} diff --git a/morphia/src/main/java/org/seedstack/seed/persistence/mongodb/internal/MorphiaPlugin.java b/morphia/src/main/java/org/seedstack/seed/persistence/mongodb/internal/MorphiaPlugin.java new file mode 100644 index 0000000..b658421 --- /dev/null +++ b/morphia/src/main/java/org/seedstack/seed/persistence/mongodb/internal/MorphiaPlugin.java @@ -0,0 +1,167 @@ +/** + * Copyright (c) 2013-2015, The SeedStack authors + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package org.seedstack.seed.persistence.mongodb.internal; + +import static org.seedstack.seed.core.utils.BaseClassSpecifications.classIsAbstract; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; + +import org.apache.commons.configuration.Configuration; +import org.kametic.specifications.Specification; +import org.mongodb.morphia.Morphia; +import org.mongodb.morphia.annotations.Embedded; +import org.mongodb.morphia.annotations.Entity; +import org.seedstack.seed.core.api.Application; +import org.seedstack.seed.core.api.SeedException; +import org.seedstack.seed.core.internal.application.ApplicationPlugin; +import org.seedstack.seed.core.utils.BaseClassSpecifications; +import org.seedstack.seed.persistence.mongodb.api.MongoDbErrorCodes; +import org.seedstack.seed.persistence.mongodb.api.MorphiaDatastore; +import org.seedstack.seed.persistence.mongodb.api.MorphiaErrorCodes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import io.nuun.kernel.api.Plugin; +import io.nuun.kernel.api.plugin.InitState; +import io.nuun.kernel.api.plugin.PluginException; +import io.nuun.kernel.api.plugin.context.InitContext; +import io.nuun.kernel.api.plugin.request.ClasspathScanRequest; +import io.nuun.kernel.core.AbstractPlugin; + +/** + * + * @author redouane.loulou@ext.mpsa.com + * + */ +public class MorphiaPlugin extends AbstractPlugin { + public static final String MONGO_PLUGIN_CONFIGURATION_PREFIX = "org.seedstack.seed.persistence.mongodb"; + + private static final Logger LOGGER = LoggerFactory.getLogger(MorphiaPlugin.class); + + private static final Specification> MORPHIA_MAPPED_CLASSES_SPECS = morphiaSpecification(); + + private Collection> morphiaScannedClasses; + + private Collection morphiaDatastores = new HashSet(); + + private final Morphia morphia = new Morphia(); + + + @Override + public String name() { + return "seed-persistence-morphia-plugin"; + } + + @Override + public InitState init(InitContext initContext) { + Application application = null; + for (Plugin plugin : initContext.pluginsRequired()) { + if (plugin instanceof ApplicationPlugin) { + application = ((ApplicationPlugin) plugin).getApplication(); + } + } + + if (application == null) { + throw new PluginException("Unable to find application plugin"); + } + + if(MORPHIA_MAPPED_CLASSES_SPECS!=null){ + morphiaScannedClasses = initContext.scannedTypesBySpecification().get(MORPHIA_MAPPED_CLASSES_SPECS); + + if(morphiaScannedClasses != null && !morphiaScannedClasses.isEmpty()){ + morphia.map(new HashSet(morphiaScannedClasses)); + for (Class morphiaClass : morphiaScannedClasses) { + MorphiaDatastore morphiaDatastore = getMongoDatastore(application, morphiaClass); + if(!morphiaDatastores.contains(morphiaDatastore)){ + morphiaDatastores.add(morphiaDatastore); + } + } + } + } + return InitState.INITIALIZED; + } + + /** + * if the morphia configuration is ok, Return an instance of the annatation MorphiaDatastore + * @param application Application + * @param morphiaClass persistent morphia object + * @return MorphiaDatastore + */ + public static MorphiaDatastore getMongoDatastore(Application application, Class morphiaClass) { + Configuration morphiaEntityConfiguration = application.getConfiguration(morphiaClass).subset("morphia"); + if (morphiaEntityConfiguration.isEmpty()) { + throw SeedException.createNew(MorphiaErrorCodes.UNKNOW_DATASTORE_CONFIGURATION).put("aggregate", + morphiaClass.getName()); + } + String clientName = morphiaEntityConfiguration.getString("clientName"); + String dbName = morphiaEntityConfiguration.getString("dbName"); + if (clientName == null) { + throw SeedException.createNew(MorphiaErrorCodes.UNKNOW_DATASTORE_CLIENT) + .put("aggregate", morphiaClass.getName()).put("clientName", clientName); + } + if (dbName == null) { + throw SeedException.createNew(MorphiaErrorCodes.UNKNOW_DATASTORE_DATABASE) + .put("aggregate", morphiaClass.getName()).put("clientName", clientName).put("dbName", dbName); + } + checkMongoClient(application, morphiaClass, clientName, dbName); + MorphiaDatastore morphiaDatastore = new MorphiaDatastoreImpl(clientName, dbName); + return morphiaDatastore; + } + + private static void checkMongoClient(Application application, Class mappedClass, String clientName, String dbName) { + Configuration configurationClientMongodb = application.getConfiguration().subset(MongoDbPlugin.MONGO_PLUGIN_CONFIGURATION_PREFIX + ".client." + clientName); + if (configurationClientMongodb.isEmpty()) { + throw SeedException.createNew(MongoDbErrorCodes.UNKNOWN_CLIENT_SPECIFIED) + .put("aggregate", mappedClass.getName()).put("clientName", clientName).put("dbName", dbName); + } + boolean async = configurationClientMongodb.getBoolean("async", false); + if(async){ + throw SeedException.createNew(MorphiaErrorCodes.ERROR_ASYNC_CLIENT) + .put("aggregate", mappedClass.getName()).put("clientName", clientName).put("dbName", dbName); + } + String[] dbNames = configurationClientMongodb.getStringArray("databases"); + if (dbNames != null && dbNames.length>0 && !Arrays.asList(dbNames).contains(dbName)) { + throw SeedException.createNew(MorphiaErrorCodes.UNKNOW_DATABASE_NAME) + .put("aggregate", mappedClass.getName()).put("clientName", clientName).put("dbName", dbName); + } + } + + @Override + public Collection> requiredPlugins() { + Collection> plugins = new ArrayList>(); + plugins.add(ApplicationPlugin.class); + plugins.add(MongoDbPlugin.class); + return plugins; + } + + @Override + public Collection classpathScanRequests() { + return classpathScanRequestBuilder().specification(MORPHIA_MAPPED_CLASSES_SPECS).build(); + } + + @SuppressWarnings("unchecked") + private static Specification> morphiaSpecification() { + Specification> specification = null; + specification = BaseClassSpecifications.and( + BaseClassSpecifications.or(BaseClassSpecifications.classAnnotatedWith(Entity.class), + BaseClassSpecifications.classAnnotatedWith(Embedded.class)), + BaseClassSpecifications.not(classIsAbstract())); + + return specification; + } + + @Override + public Object nativeUnitModule() { + return new MorphiaModule(morphiaDatastores, morphia); + } + + +} \ No newline at end of file diff --git a/morphia/src/main/resources/META-INF/errors/org.seedstack.seed.persistence.mongodb.api.MorphiaErrorCodes.properties b/morphia/src/main/resources/META-INF/errors/org.seedstack.seed.persistence.mongodb.api.MorphiaErrorCodes.properties new file mode 100644 index 0000000..622c7ce --- /dev/null +++ b/morphia/src/main/resources/META-INF/errors/org.seedstack.seed.persistence.mongodb.api.MorphiaErrorCodes.properties @@ -0,0 +1,18 @@ +# +# Copyright (c) 2013-2015, The SeedStack authors +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +UNKNOW_DATASTORE_CONFIGURATION.message = Unable to instantiate Repository datastore, unknown morphia configuration for aggregate "${aggregate}" +UNKNOW_DATASTORE_CONFIGURATION.fix = Please refer Seed documentation for linking domains to specifics Mongodb configurations +UNKNOW_DATASTORE_CLIENT.message = Unable to instantiate Repository datastore, no clientName configuration for aggregate "${aggregate}" +UNKNOW_DATASTORE_CLIENT.fix = Please refer to Seed documentation for linking domains to specifics Mongodb clients +UNKNOW_DATASTORE_DATABASE.message = Unable to instantiate Repository datastore, no dbName for aggregate "${aggregate}" +UNKNOW_DATASTORE_DATABASE.fix = Please refer to Seed documentation for linking domains to specifics Mongodb databases +UNKNOW_DATABASE_NAME.message = Unable to instantiate Repository datastore, unfound database "${dbName}" for Mongodb client "${clientName}" +UNKNOW_DATABASE_NAME.fix = Please refer to Seed documentation for specifying a Mongodb client +ERROR_ASYNC_CLIENT = Mongodb Repositories does not support asynchronous clients, please check client "${clientName}" for aggregate "${aggregate}" + diff --git a/morphia/src/main/resources/META-INF/services/io.nuun.kernel.api.Plugin b/morphia/src/main/resources/META-INF/services/io.nuun.kernel.api.Plugin new file mode 100644 index 0000000..9be6f1e --- /dev/null +++ b/morphia/src/main/resources/META-INF/services/io.nuun.kernel.api.Plugin @@ -0,0 +1 @@ +org.seedstack.seed.persistence.mongodb.internal.MorphiaPlugin \ No newline at end of file diff --git a/morphia/src/test/resources/logback-test.xml b/morphia/src/test/resources/logback-test.xml new file mode 100644 index 0000000..206a61c --- /dev/null +++ b/morphia/src/test/resources/logback-test.xml @@ -0,0 +1,20 @@ + + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 2b7ec17..476aeec 100644 --- a/pom.xml +++ b/pom.xml @@ -1,8 +1,6 @@