spring-cloud-nfs-connector-cloudfoundry

Spring Cloud NFS Connector for Cloud Foundry

License

License

GroupId

GroupId

com.github.paulcwarren
ArtifactId

ArtifactId

spring-cloud-nfs-connector-cloudfoundry
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

spring-cloud-nfs-connector-cloudfoundry
Spring Cloud NFS Connector for Cloud Foundry
Project URL

Project URL

https://github.com/paulcwarren/spring-cloud-nfs-connector-cloudfoundry/
Project Organization

Project Organization

Paul Warren
Source Code Management

Source Code Management

https://github.com/paulcwarren/spring-cloud-nfs-connector-cloudfoundry

Download spring-cloud-nfs-connector-cloudfoundry

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.paulcwarren/spring-cloud-nfs-connector-cloudfoundry/ -->
<dependency>
    <groupId>com.github.paulcwarren</groupId>
    <artifactId>spring-cloud-nfs-connector-cloudfoundry</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.paulcwarren/spring-cloud-nfs-connector-cloudfoundry/
implementation 'com.github.paulcwarren:spring-cloud-nfs-connector-cloudfoundry:1.0.0'
// https://jarcasting.com/artifacts/com.github.paulcwarren/spring-cloud-nfs-connector-cloudfoundry/
implementation ("com.github.paulcwarren:spring-cloud-nfs-connector-cloudfoundry:1.0.0")
'com.github.paulcwarren:spring-cloud-nfs-connector-cloudfoundry:jar:1.0.0'
<dependency org="com.github.paulcwarren" name="spring-cloud-nfs-connector-cloudfoundry" rev="1.0.0">
  <artifact name="spring-cloud-nfs-connector-cloudfoundry" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.paulcwarren', module='spring-cloud-nfs-connector-cloudfoundry', version='1.0.0')
)
libraryDependencies += "com.github.paulcwarren" % "spring-cloud-nfs-connector-cloudfoundry" % "1.0.0"
[com.github.paulcwarren/spring-cloud-nfs-connector-cloudfoundry "1.0.0"]

Dependencies

compile (5)

Group / Artifact Type Version
org.springframework.cloud : spring-cloud-core jar
org.springframework.cloud : spring-cloud-cloudfoundry-connector jar
org.springframework.cloud : spring-cloud-spring-service-connector jar
org.projectlombok : lombok jar
org.hamcrest : hamcrest-all jar 1.3

test (4)

Group / Artifact Type Version
junit : junit jar
org.mockito : mockito-core jar
com.github.paulcwarren : ginkgo4j jar 1.0.9
com.fasterxml.jackson.core : jackson-databind jar

Project Modules

There are no modules declared in this project.

spring-cloud-nfs-connector-cloudfoundry

Build Status Apache Version 2 Licence

Spring Cloud NFS Service Connectors for CloudFoundry Volume Services.

When running in CloudFoundry this Spring Cloud Connector allows you to easily configure your application to write to reliable, non-ephemeral nfs volumes.

Add a connector to your project

The maven coordinates for this Spring Cloud Connector are as follows:

<dependency>
  <groupId>com.github.paulcwarren</groupId>
  <artifactId>spring-cloud-nfs-connector-cloudfoundry</artifactId>
  <version>1.0.0</version>
</dependency>

In your Spring application create an @Configuration class that extends AbstractCloudConfig to create a NFSConnector bean. This bean provides access to the nfs volumes bund to the application.

@Configuration
public class NFSConfig extends AbstractCloudConfig {

	@Bean
    	public NFSServiceConnector nfs() {
        	return connectionFactory().service(NFSServiceConnector.class);
    	}
}

Usage example:

@Component
public class ExampleNFS {

    @Autowired
    NFSServiceConnector nfs;

    public void writeFile(String name, InputStream contents){
    	File file = new File(nfs.getVolumeMounts()[0].getContainerDir(), name);
        IOUtils.copyToFile(contents, file);
    }

    public InputStream readFile(String name){
    	File file = new File(nfs.getVolumeMounts()[0].getContainerDir(), name);
        return IOUtils.openInputStream(file);
    }
}

Deploy and run

Cloud Foundry

  1. Create an NFS service from the marketplace using the NFS 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

Versions

Version
1.0.0