Skip to content

spiegela/spring-cloud-ecs-connector

Repository files navigation

Spring-cloud-ECS-connectors

Codacy Badge Codacy Badge Build Status Apache Version 2 Licence

Spring cloud ECS service connectors to use EMC ECS in CloudFoundry

Add the connector as a dependency in your app

via Maven:

<dependency>
    <groupId>com.emc.ecs</groupId>
    <artifactId>spring-cloud-ecs-connector</artifactId>
    <version>1.0.0</version>
</dependency>

or Gradle:

compile 'com.emc.ecs:spring-cloud-ecs-connector:1.0.0'

or just grab it from it's page on search.maven.org.

Add a connector to your project

Here the bootstrap for your spring boot app to get a S3Connector including bucket name, the HTTP endpoint and a pre-configured AWS S3 SDK Client.

@Configuration
public class S3Config extends AbstractCloudConfig {

	@Bean
    public S3Connector s3() {
        return connectionFactory().service(S3Connector.class);
    }
}

Usage example:

@Component
public class ExampleS3 {

    @Autowired
    S3Connector s3;

    private final static String filename = "mysuperfile.txt";

    public void pushData(){
        s3.getClient().putObject(new PutObjectRequest(s3.getBucket(), filename, newFile(file)));
    }

    public void retrieveData(){
       s3.getClient().getObejct(new GetObjectRequest(s3.getBucket(), filename));
    }
}

Deploy and run

Cloud Foundry

  1. Create an ECS service from the marketplace using the ECS CF Service Broker.
  2. Push your app with cf push
  3. After the app has been pushed bind your new created service to your app (e.g: cf bs nameofmyapp nameofmyservice)
  4. Restage your app: cf restage nameofmyapp

Contributing

Report any issues or pull request on this repo.

using the ECS CF Service BrokerAll feedbacks is welcome!

About

Spring Cloud Service Connectors for EMC Elastic Cloud Storage

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages