Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
01c7623f
Commit
01c7623f
authored
Apr 03, 2020
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
577bc1ce
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
20 deletions
+13
-20
CloudPlatform.java
...in/java/org/springframework/boot/cloud/CloudPlatform.java
+13
-20
No files found.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/cloud/CloudPlatform.java
View file @
01c7623f
...
@@ -26,12 +26,6 @@ import org.springframework.core.env.StandardEnvironment;
...
@@ -26,12 +26,6 @@ import org.springframework.core.env.StandardEnvironment;
* Simple detection for well known cloud platforms. Detection can be forced using the
* Simple detection for well known cloud platforms. Detection can be forced using the
* {@code "spring.main.cloud-platform"} configuration property.
* {@code "spring.main.cloud-platform"} configuration property.
*
*
* <p>
* For more advanced cloud platform integration, consider using a platform-specific
* library such as <a href="https://github.com/pivotal-cf/java-cfenv">Java CFEnv</a> or
* <a href="https://spring.io/projects/spring-cloud-kubernetes">Spring Cloud
* Kubernetes</a>.
*
* @author Phillip Webb
* @author Phillip Webb
* @author Brian Clozel
* @author Brian Clozel
* @since 1.3.0
* @since 1.3.0
...
@@ -44,7 +38,7 @@ public enum CloudPlatform {
...
@@ -44,7 +38,7 @@ public enum CloudPlatform {
NONE
{
NONE
{
@Override
@Override
public
boolean
is
Auto
Detected
(
Environment
environment
)
{
public
boolean
isDetected
(
Environment
environment
)
{
return
false
;
return
false
;
}
}
...
@@ -56,7 +50,7 @@ public enum CloudPlatform {
...
@@ -56,7 +50,7 @@ public enum CloudPlatform {
CLOUD_FOUNDRY
{
CLOUD_FOUNDRY
{
@Override
@Override
public
boolean
is
Auto
Detected
(
Environment
environment
)
{
public
boolean
isDetected
(
Environment
environment
)
{
return
environment
.
containsProperty
(
"VCAP_APPLICATION"
)
||
environment
.
containsProperty
(
"VCAP_SERVICES"
);
return
environment
.
containsProperty
(
"VCAP_APPLICATION"
)
||
environment
.
containsProperty
(
"VCAP_SERVICES"
);
}
}
...
@@ -68,7 +62,7 @@ public enum CloudPlatform {
...
@@ -68,7 +62,7 @@ public enum CloudPlatform {
HEROKU
{
HEROKU
{
@Override
@Override
public
boolean
is
Auto
Detected
(
Environment
environment
)
{
public
boolean
isDetected
(
Environment
environment
)
{
return
environment
.
containsProperty
(
"DYNO"
);
return
environment
.
containsProperty
(
"DYNO"
);
}
}
...
@@ -80,7 +74,7 @@ public enum CloudPlatform {
...
@@ -80,7 +74,7 @@ public enum CloudPlatform {
SAP
{
SAP
{
@Override
@Override
public
boolean
is
Auto
Detected
(
Environment
environment
)
{
public
boolean
isDetected
(
Environment
environment
)
{
return
environment
.
containsProperty
(
"HC_LANDSCAPE"
);
return
environment
.
containsProperty
(
"HC_LANDSCAPE"
);
}
}
...
@@ -100,7 +94,7 @@ public enum CloudPlatform {
...
@@ -100,7 +94,7 @@ public enum CloudPlatform {
private
static
final
String
SERVICE_PORT_SUFFIX
=
"_SERVICE_PORT"
;
private
static
final
String
SERVICE_PORT_SUFFIX
=
"_SERVICE_PORT"
;
@Override
@Override
public
boolean
is
Auto
Detected
(
Environment
environment
)
{
public
boolean
isDetected
(
Environment
environment
)
{
if
(
environment
instanceof
ConfigurableEnvironment
)
{
if
(
environment
instanceof
ConfigurableEnvironment
)
{
return
isAutoDetected
((
ConfigurableEnvironment
)
environment
);
return
isAutoDetected
((
ConfigurableEnvironment
)
environment
);
}
}
...
@@ -143,30 +137,29 @@ public enum CloudPlatform {
...
@@ -143,30 +137,29 @@ public enum CloudPlatform {
* @return if the platform is active.
* @return if the platform is active.
*/
*/
public
boolean
isActive
(
Environment
environment
)
{
public
boolean
isActive
(
Environment
environment
)
{
return
isEnforced
(
environment
)
||
is
Auto
Detected
(
environment
);
return
isEnforced
(
environment
)
||
isDetected
(
environment
);
}
}
/**
/**
* Detemines if the platform is enforced by looking at the
* Dete
r
mines if the platform is enforced by looking at the
* {@code "spring.main.cloud-platform"} configuration property.
* {@code "spring.main.cloud-platform"} configuration property.
* @param environment the environment
* @param environment the environment
* @return if the platform is enforced
* @return if the platform is enforced
* @since 2.3.0
*/
*/
public
boolean
isEnforced
(
Environment
environment
)
{
public
boolean
isEnforced
(
Environment
environment
)
{
String
platform
=
environment
.
getProperty
(
"spring.main.cloud-platform"
);
String
platform
=
environment
.
getProperty
(
"spring.main.cloud-platform"
);
if
(
platform
!=
null
)
{
return
(
platform
!=
null
)
?
this
.
name
().
equalsIgnoreCase
(
platform
)
:
false
;
return
this
.
name
().
equalsIgnoreCase
(
platform
);
}
return
false
;
}
}
/**
/**
* Determines if the platform is
auto-detected by looking for platform-specific
* Determines if the platform is
detected by looking for platform-specific environment
*
environment
variables.
* variables.
* @param environment the environment
* @param environment the environment
* @return if the platform is auto-detected.
* @return if the platform is auto-detected.
* @since 2.3.0
*/
*/
public
abstract
boolean
is
Auto
Detected
(
Environment
environment
);
public
abstract
boolean
isDetected
(
Environment
environment
);
/**
/**
* Returns if the platform is behind a load balancer and uses
* Returns if the platform is behind a load balancer and uses
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment