diff --git a/bearchoke-backend/.idea/workspace.xml b/bearchoke-backend/.idea/workspace.xml index 971d021..6c3e66c 100644 --- a/bearchoke-backend/.idea/workspace.xml +++ b/bearchoke-backend/.idea/workspace.xml @@ -44,10 +44,11 @@ - + + @@ -62,28 +63,33 @@ - - - - + - - + + - - + + - - + + + + + + + + + + @@ -99,15 +105,18 @@ - + + + + - + - + @@ -137,11 +146,6 @@ @@ -239,62 +248,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -595,6 +548,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -630,11 +639,11 @@ + - @@ -652,14 +661,14 @@ + - - + @@ -1317,12 +1326,13 @@ - + + - @@ -1422,46 +1432,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1494,10 +1464,6 @@ - - - - @@ -1505,7 +1471,6 @@ - @@ -1570,6 +1535,7 @@ + @@ -1582,7 +1548,6 @@ - @@ -1636,7 +1601,6 @@ - @@ -1691,7 +1655,6 @@ - @@ -1699,7 +1662,6 @@ - @@ -1707,9 +1669,6 @@ - - - @@ -1724,22 +1683,10 @@ - - - - - - - - - - - - @@ -1747,7 +1694,6 @@ - @@ -1755,15 +1701,6 @@ - - - - - - - - - @@ -1771,7 +1708,6 @@ - @@ -1787,60 +1723,120 @@ + + + + + + + - + - - + + + + + + + + + + - + + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + - - - + - - - + + + + + + + - + - - + + - + - - + + + + + + + + + + + + diff --git a/bearchoke-backend/bearchoke-mongo-core/src/main/java/com/bearchoke/platform/mongo/config/MongoLocalConfig.java b/bearchoke-backend/bearchoke-mongo-core/src/main/java/com/bearchoke/platform/mongo/config/MongoLocalConfig.java index 530816d..5949cab 100644 --- a/bearchoke-backend/bearchoke-mongo-core/src/main/java/com/bearchoke/platform/mongo/config/MongoLocalConfig.java +++ b/bearchoke-backend/bearchoke-mongo-core/src/main/java/com/bearchoke/platform/mongo/config/MongoLocalConfig.java @@ -26,6 +26,7 @@ import org.springframework.context.annotation.PropertySource; import org.springframework.core.env.Environment; import org.springframework.data.authentication.UserCredentials; +import org.springframework.data.mongodb.MongoDbFactory; import org.springframework.data.mongodb.core.SimpleMongoDbFactory; import javax.inject.Inject; @@ -63,10 +64,13 @@ public Mongo mongo() throws UnknownHostException { return new MongoClient(sa, options); } - @Bean + @Bean(name = "mongoDbFactory") public SimpleMongoDbFactory mongoDbFactory() throws Exception { return new SimpleMongoDbFactory(mongo(), environment.getProperty("mongodb.database")); } - + @Bean(name = "axonMongoDbFactory") + public SimpleMongoDbFactory axonMongoDbFactory() throws Exception { + return mongoDbFactory(); + } } diff --git a/bearchoke-backend/bearchoke-platform-base/src/main/java/com/bearchoke/platform/platform/base/config/AxonCQRSCloudConfig.java b/bearchoke-backend/bearchoke-platform-base/src/main/java/com/bearchoke/platform/platform/base/config/AxonCQRSCloudConfig.java new file mode 100644 index 0000000..048ec61 --- /dev/null +++ b/bearchoke-backend/bearchoke-platform-base/src/main/java/com/bearchoke/platform/platform/base/config/AxonCQRSCloudConfig.java @@ -0,0 +1,34 @@ +/* + * Copyright 2015 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.bearchoke.platform.platform.base.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.PropertySource; + +/** + * Created by Bjorn Harvold + * Date: 1/9/14 + * Time: 11:55 PM + * Responsibility: + */ +@Configuration +@Profile("mongodb-cloud") +@PropertySource(value = "classpath:cqrs-cloud.properties") +public class AxonCQRSCloudConfig { + +} diff --git a/bearchoke-backend/bearchoke-platform-base/src/main/java/com/bearchoke/platform/platform/base/config/CQRSConfig.java b/bearchoke-backend/bearchoke-platform-base/src/main/java/com/bearchoke/platform/platform/base/config/AxonCQRSConfig.java similarity index 80% rename from bearchoke-backend/bearchoke-platform-base/src/main/java/com/bearchoke/platform/platform/base/config/CQRSConfig.java rename to bearchoke-backend/bearchoke-platform-base/src/main/java/com/bearchoke/platform/platform/base/config/AxonCQRSConfig.java index 30faf46..8dbbcc9 100644 --- a/bearchoke-backend/bearchoke-platform-base/src/main/java/com/bearchoke/platform/platform/base/config/CQRSConfig.java +++ b/bearchoke-backend/bearchoke-platform-base/src/main/java/com/bearchoke/platform/platform/base/config/AxonCQRSConfig.java @@ -16,6 +16,7 @@ package com.bearchoke.platform.platform.base.config; +import org.apache.commons.lang3.StringUtils; import org.axonframework.commandhandling.CommandBus; import org.axonframework.commandhandling.CommandDispatchInterceptor; import org.axonframework.commandhandling.SimpleCommandBus; @@ -34,6 +35,7 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.core.env.Environment; import org.springframework.core.task.TaskExecutor; import org.springframework.data.mongodb.MongoDbFactory; import org.springframework.messaging.SubscribableChannel; @@ -49,7 +51,10 @@ * Responsibility: */ @Configuration -public class CQRSConfig { +public class AxonCQRSConfig { + + @Inject + private Environment environment; @Inject @Qualifier("threadPoolTaskExecutor") @@ -102,8 +107,27 @@ public SpringMessagingEventBus eventBus() { @Bean(name = "axonMongoTemplate") public MongoTemplate axonMongoTemplate() { - // this is not good!! Axon doesn't support just using the mongoDbFactory that is supplied by the cloud connector - return new DefaultMongoTemplate(mongoDbFactory.getDb().getMongo(), "CloudFoundry_691iug0t_9kmtciq3", "domainevents", "snapshotevents", "axon", "axon".toCharArray()); + MongoTemplate mongoTemplate; + + String username = environment.getProperty("mongodb.axon.username"); + String password = environment.getProperty("mongodb.axon.password"); + String database = environment.getProperty("mongodb.axon.database"); + + if (StringUtils.isNotBlank(username) && StringUtils.isNotBlank(password) && StringUtils.isNotBlank(database)) { + // this is not good!! Axon doesn't support just using the mongoDbFactory that is supplied by the cloud connector + mongoTemplate = new DefaultMongoTemplate( + mongoDbFactory.getDb().getMongo(), + database, + "domainevents", + "snapshotevents", + username, + password.toCharArray() + ); + } else { + mongoTemplate = new DefaultMongoTemplate(mongoDbFactory.getDb().getMongo()); + } + + return mongoTemplate; } @Bean diff --git a/bearchoke-backend/bearchoke-platform-base/src/main/java/com/bearchoke/platform/platform/base/config/AxonCQRSLocalConfig.java b/bearchoke-backend/bearchoke-platform-base/src/main/java/com/bearchoke/platform/platform/base/config/AxonCQRSLocalConfig.java new file mode 100644 index 0000000..5fa4123 --- /dev/null +++ b/bearchoke-backend/bearchoke-platform-base/src/main/java/com/bearchoke/platform/platform/base/config/AxonCQRSLocalConfig.java @@ -0,0 +1,34 @@ +/* + * Copyright 2015 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.bearchoke.platform.platform.base.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; +import org.springframework.context.annotation.PropertySource; + +/** + * Created by Bjorn Harvold + * Date: 1/9/14 + * Time: 11:55 PM + * Responsibility: + */ +@Configuration +@Profile("mongodb-local") +@PropertySource(value = "classpath:cqrs-local.properties") +public class AxonCQRSLocalConfig { + +} diff --git a/bearchoke-backend/bearchoke-platform-base/src/main/resources/cqrs-cloud.properties b/bearchoke-backend/bearchoke-platform-base/src/main/resources/cqrs-cloud.properties new file mode 100644 index 0000000..6fcf7da --- /dev/null +++ b/bearchoke-backend/bearchoke-platform-base/src/main/resources/cqrs-cloud.properties @@ -0,0 +1,19 @@ +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +mongodb.axon.username=axon +mongodb.axon.password=axon +mongodb.axon.database=CloudFoundry_691iug0t_9kmtciq3 \ No newline at end of file diff --git a/bearchoke-backend/bearchoke-platform-base/src/main/resources/cqrs-local.properties b/bearchoke-backend/bearchoke-platform-base/src/main/resources/cqrs-local.properties new file mode 100644 index 0000000..f9fbff3 --- /dev/null +++ b/bearchoke-backend/bearchoke-platform-base/src/main/resources/cqrs-local.properties @@ -0,0 +1,19 @@ +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +mongodb.axon.username= +mongodb.axon.password= +mongodb.axon.database= \ No newline at end of file diff --git a/bearchoke-backend/bearchoke-todo/src/main/java/com/bearchoke/platform/todo/ToDoItemRunner.java b/bearchoke-backend/bearchoke-todo/src/main/java/com/bearchoke/platform/todo/ToDoItemRunner.java index 87bae7e..7cc5092 100644 --- a/bearchoke-backend/bearchoke-todo/src/main/java/com/bearchoke/platform/todo/ToDoItemRunner.java +++ b/bearchoke-backend/bearchoke-todo/src/main/java/com/bearchoke/platform/todo/ToDoItemRunner.java @@ -19,7 +19,7 @@ import com.bearchoke.platform.api.todo.CreateToDoItemCommand; import com.bearchoke.platform.api.todo.MarkToDoItemAsCompleteCommand; import com.bearchoke.platform.api.todo.ToDoIdentifier; -import com.bearchoke.platform.platform.base.config.CQRSConfig; +import com.bearchoke.platform.platform.base.config.AxonCQRSConfig; import com.bearchoke.platform.todo.config.ToDoConfig; import com.bearchoke.platform.platform.base.config.RabbitMQLocalConfig; import com.bearchoke.platform.platform.base.config.SchedulerConfig; @@ -41,7 +41,7 @@ public static void main(String[] args) { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext( SchedulerConfig.class, RabbitMQLocalConfig.class, - CQRSConfig.class, + AxonCQRSConfig.class, ToDoConfig.class ); diff --git a/bearchoke-frontend/.idea/workspace.xml b/bearchoke-frontend/.idea/workspace.xml index eb35ce7..acd9919 100644 --- a/bearchoke-frontend/.idea/workspace.xml +++ b/bearchoke-frontend/.idea/workspace.xml @@ -178,7 +178,17 @@ - + + + + + + + + + @@ -371,17 +381,7 @@ - - - - - - - - - + @@ -667,11 +667,12 @@ + - @@ -686,7 +687,6 @@ - @@ -696,11 +696,12 @@ - + + @@ -736,14 +737,14 @@ - - - + + + @@ -1016,7 +1017,6 @@ - @@ -1047,7 +1047,6 @@ - @@ -1055,7 +1054,6 @@ - @@ -1063,7 +1061,6 @@ - @@ -1071,7 +1068,6 @@ - @@ -1087,7 +1083,6 @@ -