I created a spring boot starter project in place of this boilerplate. It should be much easier to use: https://github.com/spgreenberg/spring-boot-starter-cf-service-broker
Spring MVC framework app for V2 CloudFoundry service brokers
The goal is to provide a boilerplate Spring MVC application that can be used to quickly implement new Service Brokers in CloudFoundry. The boilerplate implements the restful controllers required of service brokers and provides a set of 3 simple interfaces to implement for a new service.
To use:
gradle build
cf push <your-broker> --path build/libs/<war>
cf add-service-broker <service-broker-name>
When you register your broker with the cloud controller, you are prompted to enter a username and password. This is used by the broker to verify requests.
By default, the broker uses Spring Security to protect access to resources. The username and password are stored in: /src/main/webapp/WEB-INF/spring/security-context.xml". By default, the password should be encoded using the Spring BCryptPasswordEncoder. A utility class is included to provide encryption. You can encrypt the password executing:
java com.pivotal.cf.broker.util.PasswordEncoder password-to-encrypt
Integration tests are included to test the controllers. You are responsible for testing your service implementation. You can run the tests with gradle (gradle test
).
Endpoint tests using a RestTemplate are "coming soon."
An example implementation is included in the mongodb branch. This implementation broker an external mongodb installation. The mongo install could be manual, could be deployed by bosh, or other.
This example does the following:
The example uses Spring Data Mongo for persistence of service instance and binding information.f It uses the MongoClient java driver for manipulating mongo (creating dbs, users, etc). The configuration is separated so each capability can be used separately or be split into multiple mongos.
The following configuration files have been added for this implementation:
The test suite includes integration tests that require a running mongo instance. This is configured in:
src/test/java/com/pivotal/cf/broker/mongodb/MongoConfiguration
The tests cleanup after themselves but will not affect existing databases.