Skip to content

Commit

Permalink
Cloud Foundry deployment code updated. Some js libraries updated.
Browse files Browse the repository at this point in the history
  • Loading branch information
bjornharvold committed Jan 1, 2015
1 parent 9763b47 commit d5e334b
Show file tree
Hide file tree
Showing 21 changed files with 12,612 additions and 503 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Welcome to Bearchoke Tempest. This platform aims to be a best practices framework using the latest Java based frameworks, Enterprise Integration Patterns (EIP) and specifically focusing on using an asynchronous, message based, event driven approach to creating web-based software. The current push in the user interface space is SPA/SPI (Single Page Applications / Single Page Interface). The samples will leverage AngularJS to showcase this. Bearchoke Tempest was created to show how an SPA can interface with the Spring server world as well as leverage other SPA modular goodies.

If you just want to check out the demo, you can check out the Cloud Foundry hosted instance here: [bearchoke-frontend.cfapps.io](https://bearchoke-frontend.cfapps.io).
If you just want to check out the demo, you can check out the Cloud Foundry hosted instance here: [www.bearchoke.com](https://www.bearchoke.com).

Key frameworks that I've leveraged to make this work are:

Expand Down Expand Up @@ -196,6 +196,12 @@ There are a few things the Bearchoke Tempest gives you out of the box.
* MailChimp integration
* Facebook integration with [angular-easyfb](https://github.com/pc035860/angular-easyfb)

## Limitations

* Cloud Foundry does not yet support HTML5 push. You cannot go straight to a url unless it's the root url. E.g. https://www.bearchoke.com is ok. https://www.bearchoke.com/ui/chat is not ok.
* Web socket on Cloud Foundry is not working at the moment. Having CORS issues.


## Next release features
This framework is for me a way to prove that the technologies can co-exist together [peacefully] and that they work and are testable. As my other projects require new features, I will add these here first as a test bed. Upcoming features I already want to add are:

Expand Down
519 changes: 344 additions & 175 deletions bearchoke-backend/.idea/workspace.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@

package com.bearchoke.platform.mongo.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.config.java.AbstractCloudConfig;
import org.springframework.cloud.service.document.MongoDbFactoryConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.data.mongodb.MongoDbFactory;
import org.springframework.data.mongodb.core.MongoTemplate;

import javax.inject.Inject;

/**
* Created by Bjorn Harvold
Expand All @@ -32,11 +35,23 @@
*/
@Configuration
@Profile("mongodb-cloud")
@PropertySource(value = "classpath:mongodb-cloud.properties")
@Slf4j
public class MongoCloudConfig extends AbstractCloudConfig {

@Bean
@Inject
private Environment environment;

@Bean(name = "mongoDbFactory")
public MongoDbFactory mongoDbFactory() {
return connectionFactory().mongoDbFactory();
log.info("Retrieving mongoDbFactory for application. Service ID: " + environment.getProperty("cf.bearchoke.mongodb.serviceid"));
return connectionFactory().mongoDbFactory(environment.getProperty("cf.bearchoke.mongodb.serviceid"));
}

@Bean(name = "axonMongoDbFactory")
public MongoDbFactory axonMongoDbFactory() {
log.info("Retrieving mongoDbFactory for axon. Service ID: " + environment.getProperty("cf.bearchoke.axon.serviceid"));
return connectionFactory().mongoDbFactory(environment.getProperty("cf.bearchoke.axon.serviceid"));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public Mongo mongo() throws UnknownHostException {
// location of db
ServerAddress sa = new ServerAddress(
environment.getProperty("mongodb.host"),
environment.getProperty("mongodb.port", Integer.class));
environment.getProperty("mongodb.port", Integer.class)
);

// set optional default parameters here
MongoClientOptions.Builder builder = MongoClientOptions.builder();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# Copyright 2014 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.
#

cf.bearchoke.mongodb.serviceid=bearchoke-mongodb
cf.bearchoke.axon.serviceid=bearchoke-axon
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package com.bearchoke.platform.platform.base.config;

import com.mongodb.Mongo;
import org.axonframework.commandhandling.CommandBus;
import org.axonframework.commandhandling.CommandDispatchInterceptor;
import org.axonframework.commandhandling.SimpleCommandBus;
Expand All @@ -32,15 +31,13 @@
import org.axonframework.saga.repository.mongo.MongoSagaRepository;
import org.axonframework.saga.spring.SpringResourceInjector;
import org.axonframework.springmessaging.eventbus.SpringMessagingEventBus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.TaskExecutor;
import org.springframework.data.mongodb.MongoDbFactory;
import org.springframework.messaging.SubscribableChannel;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import javax.annotation.Resource;
import javax.inject.Inject;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -59,7 +56,8 @@ public class CQRSConfig {
private TaskExecutor taskExecutor;

@Inject
private Mongo mongo;
@Qualifier("axonMongoDbFactory")
private MongoDbFactory mongoDbFactory;

@Inject
@Qualifier("webSocketInputChannel")
Expand Down Expand Up @@ -104,12 +102,13 @@ public SpringMessagingEventBus eventBus() {

@Bean(name = "axonMongoTemplate")
public MongoTemplate axonMongoTemplate() {
return new DefaultMongoTemplate(mongo);
// 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());
}

@Bean
public org.axonframework.saga.repository.mongo.MongoTemplate mongoSagaTemplate() {
return new org.axonframework.saga.repository.mongo.DefaultMongoTemplate(mongo);
return new org.axonframework.saga.repository.mongo.DefaultMongoTemplate(mongoDbFactory.getDb().getMongo(), "CloudFoundry_691iug0t_9kmtciq3", "sagas", "axon", "axon".toCharArray());
}

@Bean(name = "eventStore")
Expand Down
2 changes: 1 addition & 1 deletion bearchoke-backend/bearchoke-server/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ applications:
host: bearchoke-server
path: target/bearchoke-server-0.0.1-SNAPSHOT.war
env:
SPRING_PROFILES_ACTIVE: in-memory,redis-cloud,rabbit-cloud
SPRING_PROFILES_ACTIVE: mongodb-cloud,redis-cloud,rabbit-cloud
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ protected void doFilterInternal(HttpServletRequest request,
FilterChain filterChain)
throws ServletException, IOException {

if (log.isDebugEnabled()) {
log.debug("CORS filter in effect. Adding required header values.");
}

// Get the origin of the request... all origins will be allowed
String origin = request.getHeader("Origin");

Expand Down Expand Up @@ -103,13 +107,14 @@ protected void doFilterInternal(HttpServletRequest request,
}
response.getWriter().print("OK");
response.getWriter().flush();

return;
} else {
// Pass on to the other filters
filterChain.doFilter(request, response);
}

// Pass on to the other filters
// Pass on to the other filters
filterChain.doFilter(request, response);
if (log.isDebugEnabled()) {
log.debug("CORS filter successful!");
}
}

// Inner class helper
Expand Down
Loading

0 comments on commit d5e334b

Please sign in to comment.