001/* 002 * Copyright 2012-2018 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.boot.autoconfigure.cloud; 018 019import org.springframework.boot.autoconfigure.AutoConfigureOrder; 020import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 021import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 022import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; 023import org.springframework.cloud.Cloud; 024import org.springframework.cloud.app.ApplicationInstanceInfo; 025import org.springframework.cloud.config.java.CloudScan; 026import org.springframework.cloud.config.java.CloudScanConfiguration; 027import org.springframework.context.annotation.Configuration; 028import org.springframework.context.annotation.Import; 029import org.springframework.context.annotation.Profile; 030import org.springframework.core.Ordered; 031 032/** 033 * {@link EnableAutoConfiguration Auto-configuration} for Spring Cloud Service Connectors. 034 * <p> 035 * Activates when there is no bean of type {@link Cloud} and the "cloud" profile is 036 * active. 037 * <p> 038 * Once in effect, the auto-configuration is the equivalent of adding the 039 * {@link CloudScan} annotation in one of the configuration file. Specifically, it adds a 040 * bean for each service bound to the application and one for 041 * {@link ApplicationInstanceInfo}. 042 * 043 * @author Ramnivas Laddad 044 * @since 2.1.0 045 */ 046@Configuration 047@Profile("cloud") 048@AutoConfigureOrder(CloudServiceConnectorsAutoConfiguration.ORDER) 049@ConditionalOnClass(CloudScanConfiguration.class) 050@ConditionalOnMissingBean(Cloud.class) 051@Import(CloudScanConfiguration.class) 052public class CloudServiceConnectorsAutoConfiguration { 053 054 // Cloud configuration needs to happen early (before data, mongo etc.) 055 public static final int ORDER = Ordered.HIGHEST_PRECEDENCE + 20; 056 057}