Spring Cloud for Cloud Foundry.hidden { display: none; } .switch { border-width: 1px 1px 0 1px; border-style: solid; border-color: #7a2518; display: inline-block; } .switch--item { padding: 10px; background-color: #ffffff; color: #7a2518; display: inline-block; cursor: pointer; } .switch--item:not(:first-child) { border-width: 0 0 0 1px; border-style: solid; border-color: #7a2518; } .switch--item.selected { background-color: #7a2519; color: #ffffff; } function addBlockSwitches() { for (var primary of document.querySelectorAll('.primary')) { var switchItem = createSwitchItem(primary, createBlockSwitch(primary)); switchItem.item.classList.add("selected"); var title = primary.querySelector('.title') title.remove(); } for (var secondary of document.querySelectorAll('.secondary')) { var primary = findPrimary(secondary); if (primary === null) { console.error("Found secondary block with no primary sibling"); } else { var switchItem = createSwitchItem(secondary, primary.querySelector('.switch')); switchItem.content.classList.add("hidden"); primary.append(switchItem.content); secondary.remove(); } } } function createElementFromHtml(html) { var template = document.createElement('template'); template.innerHTML = html; return template.content.firstChild; } function createBlockSwitch(primary) { var blockSwitch = createElementFromHtml('\
\'); primary.prepend(blockSwitch) return blockSwitch; } function findPrimary(secondary) { var candidate = secondary.previousElementSibling; while (candidate != null && !candidate.classList.contains('primary')) { candidate = candidate.previousElementSibling; } return candidate; } function createSwitchItem(block, blockSwitch) { var blockName = block.querySelector('.title').textContent; var content = block.querySelectorAll('.content').item(0); var colist = nextSibling(block, '.colist'); if (colist != null) { content.append(colist); } var item = createElementFromHtml('\
' + blockName + '\'); item.dataset.blockName = blockName; content.dataset.blockName = blockName; blockSwitch.append(item); return {'item': item, 'content': content}; } function nextSibling(element, selector) { var sibling = element.nextElementSibling; while (sibling) { if (sibling.matches(selector)) { return sibling; } sibling = sibling.nextElementSibling; } } function globalSwitch() { document.querySelectorAll(".switch--item").forEach(function(item) { var blockId = blockIdForSwitchItem(item); var handler = function(event) { selectedText = event.target.textContent; window.localStorage.setItem(blockId, selectedText); for (var switchItem of document.querySelectorAll(".switch--item")) { if (blockIdForSwitchItem(switchItem) === blockId && switchItem.textContent === selectedText) { select(switchItem); } } } item.addEventListener("click", handler); if (item.textContent === window.localStorage.getItem(blockId)) { select(item); } }); } function select(selected) { for (var child of selected.parentNode.children) { child.classList.remove("selected"); } selected.classList.add("selected"); for (var child of selected.parentNode.parentNode.children) { if (child.classList.contains("content")) { if (selected.dataset.blockName === child.dataset.blockName) { child.classList.remove("hidden"); } else { child.classList.add("hidden"); } } } } function blockIdForSwitchItem(item) { idComponents = [] for (var switchItem of item.parentNode.querySelectorAll(".switch--item")) { idComponents.push(switchItem.textContent.toLowerCase()); } return idComponents.sort().join("-") } window.onload = function() { addBlockSwitches(); globalSwitch(); }; # Spring Cloud for Cloud Foundry Table of Contents * [1. Discovery](#discovery) * [2. Single Sign On](#single-sign-on) * [3. Configuration](#configuration) Spring Cloud for Cloudfoundry makes it easy to run[Spring Cloud](https://github.com/spring-cloud) apps in[Cloud Foundry](https://github.com/cloudfoundry) (the Platform as a Service). Cloud Foundry has the notion of a "service", which is middlware that you "bind" to an app, essentially providing it with an environment variable containing credentials (e.g. the location and username to use for the service). The `spring-cloud-cloudfoundry-commons` module configures the Reactor-based Cloud Foundry Java client, v 3.0, and can be used standalone. The `spring-cloud-cloudfoundry-web` project provides basic support for some enhanced features of webapps in Cloud Foundry: binding automatically to single-sign-on services and optionally enabling sticky routing for discovery. The `spring-cloud-cloudfoundry-discovery` project provides an implementation of Spring Cloud Commons `DiscoveryClient` so you can`@EnableDiscoveryClient` and provide your credentials as`spring.cloud.cloudfoundry.discovery.[username,password]` (also `*.url` if you are not connecting to [Pivotal Web Services](https://run.pivotal.io)) and then you can use the `DiscoveryClient` directly or via a `LoadBalancerClient`. The first time you use it the discovery client might be slow owing to the fact that it has to get an access token from Cloud Foundry. ## [](#discovery)[1. Discovery](#discovery) Here’s a Spring Cloud app with Cloud Foundry discovery: app.groovy ``` @Grab('org.springframework.cloud:spring-cloud-cloudfoundry') @RestController @EnableDiscoveryClient class Application { @Autowired DiscoveryClient client @RequestMapping('/') String home() { 'Hello from ' + client.getLocalServiceInstance() } } ``` If you run it without any service bindings: ``` $ spring jar app.jar app.groovy $ cf push -p app.jar ``` It will show its app name in the home page. The `DiscoveryClient` can lists all the apps in a space, according to the credentials it is authenticated with, where the space defaults to the one the client is running in (if any). If neither org nor space are configured, they default per the user’s profile in Cloud Foundry. ## [](#single-sign-on)[2. Single Sign On](#single-sign-on) | |All of the OAuth2 SSO and resource server features moved to Spring Boot
in version 1.3. You can find documentation in the[Spring Boot user guide](https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/).| |---|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| This project provides automatic binding from CloudFoundry service credentials to the Spring Boot features. If you have a CloudFoundry service called "sso", for instance, with credentials containing "client\_id", "client\_secret" and "auth\_domain", it will bind automatically to the Spring OAuth2 client that you enable with`@EnableOAuth2Sso` (from Spring Boot). The name of the service can be parameterized using `spring.oauth2.sso.serviceId`. ## [](#configuration)[3. Configuration](#configuration) To see the list of all Spring Cloud Sloud Foundry related configuration properties please check [the Appendix page](appendix.html). if (window.parent == window) {(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1\*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');ga('create', 'UA-2728886-23', 'auto', {'siteSpeedSampleRate': 100});ga('send', 'pageview');}