anchor.diff:  Cloud cloud = cloudFactory.getCloud();
   ----
   +
  -Note that you must have a `CloudConnector` suitable for your deployment environment on your classpath.  For example, if you are deploying the application to Cloud Foundry, you must add the <<cloudfoundry-connector.adoc#,Cloud Foundry Connector>> to your classpath. If no suitable `CloudConnector` is found, the `getCloud()` method will throw a `CloudException`.
  +Note that you must have a `CloudConnector` suitable for your deployment environment on your classpath.  For example, if you are deploying the application to Cloud Foundry, you must add the <<_spring_cloud_cloud_foundry_connector,Cloud Foundry Connector>> to your classpath. If no suitable `CloudConnector` is found, the `getCloud()` method will throw a `CloudException`.
   
   * Use the `Cloud` instance to access application and service information and to create service connectors.
   
  
positive.code: 
  [source,java]
  ----
  // find the `ServiceInfo` definitions suitable for connecting to a particular service type
  List<ServiceInfo> databaseInfos = cloud.getServiceInfos(DataSource.class);
  ----
  
  [source,java]
  ----
  // Alternately, let Spring Cloud create a service connector for you
  String serviceId = "inventory-db";
  DataSource ds = cloud.getServiceConnector(serviceId, DataSource.class, null /* default config */);
  ----
  
  === Adding cloud connectors
  
  A cloud provider may extend Spring Cloud by adding a new `CloudConnector` to make Spring Cloud work with a new cloud platform. The connector is responsible for telling whether the application is running in the specific cloud, identifying application information (such as the name and instance ID of the particular running instance), and mapping bound services (such as URIs exposed in environment variables) as `ServiceInfo` objects.
  
  See the <<cloudfoundry-connector.adoc#,Cloud Foundry Connector>> and <<heroku-connector.adoc#,Heroku Connector>> for examples.
  
  Spring Cloud uses the Java SPI to discover available connectors. New cloud connectors should list the fully-qualified class name in the provider-configuration file at
  
  ----
  META-INF/services/org.springframework.cloud.CloudConnector
  ----
  
  === Adding service discovery
  
  To allow Spring Cloud to discover a new type of service (`HelloWorldService`), create a `ServiceInfo` class containing the information necessary to connect to your service. If your service can be specified via a URI, extend `UriBasedServiceInfo` and provide the URI scheme in a call to the `super` constructor.
  
  This class will expose information for a service available at
  
  ----
  helloworld://username:password@host:port/Bonjour
  ----
  
  [source,java]
  ----
  public class HelloWorldServiceInfo extends UriBasedServiceInfo {
      public static final String URI_SCHEME = "helloworld";
  
    // needed to support structured service definitions like Cloud Foundry
      public HelloWorldServiceInfo(String id, String host, int port, String username, String password, String greeting) {
      super(id, URI_SCHEME, host, port, username, password, greeting);
      }
  
      // needed to support URI-based service definitions like Heroku
      public HelloWorldServiceInfo(String id, String uri) {
          super(id, uri);
      }
  }
  ----
  
  Then you will need to create a `ServiceInfoCreator` for each cloud platform you want to support.  You will probably want to extend the appropriate creator base class(es), such as `HerokuServiceInfoCreator`. This is often as simple as writing a method that instantiates a new `HelloWorldServiceInfo`.
  
  Register your `ServiceInfoCreator` classes in the appropriate provider-configuration file for your cloud's `ServiceInfoCreator` base class.
  
  === Adding service connectors
  
  A service connector consumes a `ServiceInfo` discovered by the cloud connector and converts it into the appropriate service object, such as a `DataSource` for a service definition representing a SQL database.
  
  Service connectors may be tightly bound to the framework whose service objects they are creating; for example, some connectors in the <<spring-cloud-spring-service-connector.adoc#,Spring service connector>> create connection factories defined by Spring Data, for use in building Spring Data templates.
  
  To add new service connectors, implement `ServiceConnectorCreator` in your connector classes and list the fully-qualified class names in the provider-configuration file at
  
  ----
  META-INF/services/org.springframework.cloud.service.ServiceConnectorCreator
  ----
  
  == Spring Cloud Spring Service Connector
  
  [[spring-cloud-connectors-install]]
  
  This library provides `ServiceConnectorCreator` implementations for `javax.sql.DataSource` and various link:http://projects.spring.io/spring-data/[Spring Data] connector factories. It also provides Java configuration and XML namespace support for connecting to cloud services, accessing cloud services, and accessing application properties.
  
  === The Java Configuration
  
  Typical use of the Java configuration involves extending the `AbstractCloudConfig` class and creating beans for services by annotating methods with the `@Bean` annotation. If you are migrating an application that uses link:https://spring.io/blog/2011/11/04/using-cloud-foundry-services-with-spring-part-2-auto-reconfiguration/[auto-reconfiguration], you might first try the <<spring-cloud-spring-service-connector.adoc#_scanning_for_services,service-scanning approach>> until you need more explicit control.  The Spring Service Connector Java configuration also offers a way to expose application and service properties in case you want lower-level access when creating your own service connectors (or for debugging purposes, etc.).  
  
  ==== Creating Service Beans
  
  
negative.code:         return connectionFactory().mongoDbFactory();
      }
      
      // (More beans to obtain service connectors)
  }
  ----
  
  