<commit_before>[![Build Status](https://travis-ci.org/SolaceLabs/sl-spring-cloud-connectors.svg?branch=master)](https://travis-ci.org/SolaceLabs/sl-spring-cloud-connectors)

# Solace Messaging Spring Cloud Connectors

A Spring Cloud Connector for an instance of SolaceMessaging in Cloud Foundry. Specifically a ServiceInfo and ServiceInfoCreator implementation for SolaceMessaging in Cloud Foundry.

## Contents

* [Overview](#overview)
* [Spring Cloud Connectors](#spring-cloud-connectors)
* [Java Applications](#java-applications)
* [Spring Applications](#spring-applications)
* [Using it in your Application](#using-it-in-your-application)
* [Checking out and Building](#checking-out-and-building)
* [Contributing](#contributing)
* [Versioning](#versioning)
* [Authors](#authors)
* [License](#license)
* [Resources](#resources)


---

## Overview

This project provides an implementation of the ServiceInfo and ServiceInfoCreator interfaces to extend the Spring Cloud Connectors project the SolaceMessaging Clound Foundry service. Using this in your Spring application can make consuming the Solace messaging service simpler than straight parsing of the `VCAP_SERVICES` environment variable.

The Spring cloud documentation provides both a nice introduction to Cloud Connectors and a nice overview of the options for [extending Spring Cloud](http://cloud.spring.io/spring-cloud-connectors/spring-cloud-connectors.html#_extending_spring_cloud_connectors). This project provides a Cloud Service Support extension to make it easy to consume the SolaceMessaging Cloud Foundry Service in your Cloud Foundry application.

## Spring Cloud connectors

This a project extends Spring Cloud Connectors. If you are new to Spring Cloud Connectors, check out their project on GitHub here: https://github.com/spring-cloud/spring-cloud-connectors

The following is a brief introduction copied from their README:

>Spring Cloud Connectors simplifies the process of connecting to services and gaining operating environment awareness in cloud platforms such as Cloud Foundry and Heroku, especially for Spring applications. It is designed for extensibility: you can use one of the provided cloud connectors or write one for your cloud platform, and you can use the built-in support for commonly-used services (relational databases, MongoDB, Redis, RabbitMQ) or extend Spring Cloud Connectors to work with your own services.

## Java Applications

Applications can use this connector with Spring Cloud to access the information in VCAP_SERVICES environment variable, necessary to connect to a Solace Messaging Service Instance. The code finds the `SolaceMessaging` Cloud Foundry service instance and uses the `SolaceMessagingInfo` object to connect a Solace Messaging API for Java (JCSMP) session.

```java
CloudFactory cloudFactory = new CloudFactory();
Cloud cloud = cloudFactory.getCloud();
SolaceMessagingInfo solacemessaging = (SolaceMessagingInfo) cloud.getServiceInfo("MyService");

// Setting up the JCSMP Connection
final JCSMPProperties props = new JCSMPProperties();
props.setProperty(JCSMPProperties.HOST, solacemessaging.getSmfHost());
props.setProperty(JCSMPProperties.VPN_NAME, solacemessaging.getMsgVpnName());
props.setProperty(JCSMPProperties.USERNAME, solacemessaging.getClientUsername());
props.setProperty(JCSMPProperties.PASSWORD, solacemessaging.getClientPassword());

JCSMPSession session = JCSMPFactory.onlyInstance().createSession(props);
session.connect();
```

## Spring Applications

TODO: Add details.


## Using it in your Application

If you're building with Gradle, you can simply add the following to your dependencies:

### Using it with Gradle

```
// Solace Cloud
compile("com.solace.labs.cloud.cloudfoundry:solace-labs-spring-cloud-connector:0.1+")
```

### Using it with Maven

```
<!-- Solace Cloud -->
<dependency>
  <groupId>com.solace.labs.cloud.cloudfoundry</groupId>
  <artifactId>solace-labs-spring-cloud-connector</artifactId>
  <version>0.1+</version>
</dependency>
```

## Checking out and Building

This project depends on maven for building. To build the jar locally, check out the project and build from source by doing the following:<commit_msg>Editorial changes to how to use it.<commit_after>[![Build Status](https://travis-ci.org/SolaceLabs/sl-spring-cloud-connectors.svg?branch=master)](https://travis-ci.org/SolaceLabs/sl-spring-cloud-connectors)

# Solace Messaging Spring Cloud Connectors

A Spring Cloud Connector for an instance of SolaceMessaging in Cloud Foundry. Specifically a ServiceInfo and ServiceInfoCreator implementation for SolaceMessaging in Cloud Foundry.

## Contents

* [Overview](#overview)
* [Spring Cloud Connectors](#spring-cloud-connectors)
* [Java Applications](#java-applications)
* [Spring Applications](#spring-applications)
* [Using it in your Application](#using-it-in-your-application)
* [Checking out and Building](#checking-out-and-building)
* [Contributing](#contributing)
* [Versioning](#versioning)
* [Authors](#authors)
* [License](#license)
* [Resources](#resources)


---

## Overview

This project provides an implementation of the ServiceInfo and ServiceInfoCreator interfaces to extend the Spring Cloud Connectors project the SolaceMessaging Clound Foundry service. Using this in your Spring application can make consuming the Solace messaging service simpler than straight parsing of the `VCAP_SERVICES` environment variable.

The Spring cloud documentation provides both a nice introduction to Cloud Connectors and a nice overview of the options for [extending Spring Cloud](http://cloud.spring.io/spring-cloud-connectors/spring-cloud-connectors.html#_extending_spring_cloud_connectors). This project provides a Cloud Service Support extension to make it easy to consume the SolaceMessaging Cloud Foundry Service in your Cloud Foundry application.

## Spring Cloud connectors

This a project extends Spring Cloud Connectors. If you are new to Spring Cloud Connectors, check out their project on GitHub here: https://github.com/spring-cloud/spring-cloud-connectors

The following is a brief introduction copied from their README:

>Spring Cloud Connectors simplifies the process of connecting to services and gaining operating environment awareness in cloud platforms such as Cloud Foundry and Heroku, especially for Spring applications. It is designed for extensibility: you can use one of the provided cloud connectors or write one for your cloud platform, and you can use the built-in support for commonly-used services (relational databases, MongoDB, Redis, RabbitMQ) or extend Spring Cloud Connectors to work with your own services.

## Java Applications

Applications can use this connector with Spring Cloud to access the information in VCAP_SERVICES environment variable, necessary to connect to a Solace Messaging Service Instance. The code finds the `SolaceMessaging` Cloud Foundry service instance and uses the `SolaceMessagingInfo` object to connect a Solace Messaging API for Java (JCSMP) session.

```java
CloudFactory cloudFactory = new CloudFactory();
Cloud cloud = cloudFactory.getCloud();
SolaceMessagingInfo solacemessaging = (SolaceMessagingInfo) cloud.getServiceInfo("MyService");

// Setting up the JCSMP Connection
final JCSMPProperties props = new JCSMPProperties();
props.setProperty(JCSMPProperties.HOST, solacemessaging.getSmfHost());
props.setProperty(JCSMPProperties.VPN_NAME, solacemessaging.getMsgVpnName());
props.setProperty(JCSMPProperties.USERNAME, solacemessaging.getClientUsername());
props.setProperty(JCSMPProperties.PASSWORD, <PASSWORD>());

JCSMPSession session = JCSMPFactory.onlyInstance().createSession(props);
session.connect();
```

## Spring Applications

TODO: Add details.


## Using it in your Application

This releases from this project are hosted in [Maven Central](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.solace.labs.cloud.cloudfoundry%22%20AND%20a%3A%22solace-labs-spring-cloud-connector%22)

Here is how to include it in your project using Gradle and Maven.

### Using it with Gradle

```
// Solace Cloud
compile("com.solace.labs.cloud.cloudfoundry:solace-labs-spring-cloud-connector:0.1+")
```

### Using it with Maven

```
<!-- Solace Cloud -->
<dependency>
  <groupId>com.solace.labs.cloud.cloudfoundry</groupId>
  <artifactId>solace-labs-spring-cloud-connector</artifactId>
  <version>0.1+</version>
</dependency>
```

## Checking out and Building

This project depends on maven for building. To build the jar locally, check out the project and build from source by doing the following:
{'fraction_non_alphanumeric': 0.0852059925093633, 'fraction_numerical': 0.003043071161048689, 'mean_word_length': 5.986917416189698, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 24, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '158454', 'n_tokens_mistral': 2375, 'n_tokens_neox': 2236, 'n_words': 838}