26
26
* Simple detection for well known cloud platforms. Detection can be forced using the
27
27
* {@code "spring.main.cloud-platform"} configuration property.
28
28
*
29
- * <p>
30
- * For more advanced cloud platform integration, consider using a platform-specific
31
- * library such as <a href="https://github.com/pivotal-cf/java-cfenv">Java CFEnv</a> or
32
- * <a href="https://spring.io/projects/spring-cloud-kubernetes">Spring Cloud
33
- * Kubernetes</a>.
34
- *
35
29
* @author Phillip Webb
36
30
* @author Brian Clozel
37
31
* @since 1.3.0
@@ -44,7 +38,7 @@ public enum CloudPlatform {
44
38
NONE {
45
39
46
40
@ Override
47
- public boolean isAutoDetected (Environment environment ) {
41
+ public boolean isDetected (Environment environment ) {
48
42
return false ;
49
43
}
50
44
@@ -56,7 +50,7 @@ public boolean isAutoDetected(Environment environment) {
56
50
CLOUD_FOUNDRY {
57
51
58
52
@ Override
59
- public boolean isAutoDetected (Environment environment ) {
53
+ public boolean isDetected (Environment environment ) {
60
54
return environment .containsProperty ("VCAP_APPLICATION" ) || environment .containsProperty ("VCAP_SERVICES" );
61
55
}
62
56
@@ -68,7 +62,7 @@ public boolean isAutoDetected(Environment environment) {
68
62
HEROKU {
69
63
70
64
@ Override
71
- public boolean isAutoDetected (Environment environment ) {
65
+ public boolean isDetected (Environment environment ) {
72
66
return environment .containsProperty ("DYNO" );
73
67
}
74
68
@@ -80,7 +74,7 @@ public boolean isAutoDetected(Environment environment) {
80
74
SAP {
81
75
82
76
@ Override
83
- public boolean isAutoDetected (Environment environment ) {
77
+ public boolean isDetected (Environment environment ) {
84
78
return environment .containsProperty ("HC_LANDSCAPE" );
85
79
}
86
80
@@ -100,7 +94,7 @@ public boolean isAutoDetected(Environment environment) {
100
94
private static final String SERVICE_PORT_SUFFIX = "_SERVICE_PORT" ;
101
95
102
96
@ Override
103
- public boolean isAutoDetected (Environment environment ) {
97
+ public boolean isDetected (Environment environment ) {
104
98
if (environment instanceof ConfigurableEnvironment ) {
105
99
return isAutoDetected ((ConfigurableEnvironment ) environment );
106
100
}
@@ -143,30 +137,29 @@ private boolean isAutoDetected(EnumerablePropertySource<?> environmentPropertySo
143
137
* @return if the platform is active.
144
138
*/
145
139
public boolean isActive (Environment environment ) {
146
- return isEnforced (environment ) || isAutoDetected (environment );
140
+ return isEnforced (environment ) || isDetected (environment );
147
141
}
148
142
149
143
/**
150
- * Detemines if the platform is enforced by looking at the
144
+ * Determines if the platform is enforced by looking at the
151
145
* {@code "spring.main.cloud-platform"} configuration property.
152
146
* @param environment the environment
153
147
* @return if the platform is enforced
148
+ * @since 2.3.0
154
149
*/
155
150
public boolean isEnforced (Environment environment ) {
156
151
String platform = environment .getProperty ("spring.main.cloud-platform" );
157
- if (platform != null ) {
158
- return this .name ().equalsIgnoreCase (platform );
159
- }
160
- return false ;
152
+ return (platform != null ) ? this .name ().equalsIgnoreCase (platform ) : false ;
161
153
}
162
154
163
155
/**
164
- * Determines if the platform is auto- detected by looking for platform-specific
165
- * environment variables.
156
+ * Determines if the platform is detected by looking for platform-specific environment
157
+ * variables.
166
158
* @param environment the environment
167
159
* @return if the platform is auto-detected.
160
+ * @since 2.3.0
168
161
*/
169
- public abstract boolean isAutoDetected (Environment environment );
162
+ public abstract boolean isDetected (Environment environment );
170
163
171
164
/**
172
165
* Returns if the platform is behind a load balancer and uses
0 commit comments