类 CloudFoundryVcapEnvironmentPostProcessor
java.lang.Object
org.springframework.boot.cloud.CloudFoundryVcapEnvironmentPostProcessor
- 所有已实现的接口:
EnvironmentPostProcessor,Ordered
public class CloudFoundryVcapEnvironmentPostProcessor
extends Object
implements EnvironmentPostProcessor, Ordered
An
EnvironmentPostProcessor that knows where to find VCAP (a.k.a. Cloud
Foundry) metadata in the existing environment. It parses out the VCAP_APPLICATION and
VCAP_SERVICES metadata and dumps it in a form that is easily consumed by
Environment users. If the app is running in Cloud Foundry then both metadata
items are JSON objects encoded in OS environment variables. VCAP_APPLICATION is a
shallow hash with basic information about the application (name, instance id, instance
index, etc.), and VCAP_SERVICES is a hash of lists where the keys are service labels
and the values are lists of hashes of service instance metadata. Examples are:
VCAP_APPLICATION: {"instance_id":"2ce0ac627a6c8e47e936d829a3a47b5b","instance_index":0,
"version":"0138c4a6-2a73-416b-aca0-572c09f7ca53","name":"foo",
"uris":["foo.cfapps.io"], ...}
VCAP_SERVICES: {"rds-mysql-1.0":[{"name":"mysql","label":"rds-mysql-1.0","plan":"10mb",
"credentials":{"name":"d04fb13d27d964c62b267bbba1cffb9da","hostname":"mysql-service-public.clqg2e2w3ecf.us-east-1.rds.amazonaws.com",
"host":"mysql-service-public.clqg2e2w3ecf.us-east-1.rds.amazonaws.com","port":3306,"user":"urpRuqTf8Cpe6",
"username":"urpRuqTf8Cpe6","password":"pxLsGVpsC9A5S"}
}]}
These objects are flattened into properties. The VCAP_APPLICATION object goes straight
to vcap.application.* in a fairly obvious way, and the VCAP_SERVICES object is
unwrapped so that it is a hash of objects with key equal to the service instance name
(e.g. "mysql" in the example above), and value equal to that instances properties, and
then flattened in the same way. E.g.
vcap.application.instance_id: 2ce0ac627a6c8e47e936d829a3a47b5b vcap.application.version: 0138c4a6-2a73-416b-aca0-572c09f7ca53 vcap.application.name: foo vcap.application.uris[0]: foo.cfapps.io vcap.services.mysql.name: mysql vcap.services.mysql.label: rds-mysql-1.0 vcap.services.mysql.credentials.name: d04fb13d27d964c62b267bbba1cffb9da vcap.services.mysql.credentials.port: 3306 vcap.services.mysql.credentials.host: mysql-service-public.clqg2e2w3ecf.us-east-1.rds.amazonaws.com vcap.services.mysql.credentials.username: urpRuqTf8Cpe6 vcap.services.mysql.credentials.password: pxLsGVpsC9A5S ...N.B. this initializer is mainly intended for informational use (the application and instance ids are particularly useful). For service binding you might find that Spring Cloud is more convenient and more robust against potential changes in Cloud Foundry.
- 从以下版本开始:
- 1.3.0
- 作者:
- Dave Syer, Andy Wilkinson
-
字段概要
从接口继承的字段 org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明intgetOrder()voidpostProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) Post-process the givenenvironment.voidsetOrder(int order)
-
构造器详细资料
-
CloudFoundryVcapEnvironmentPostProcessor
Create a newCloudFoundryVcapEnvironmentPostProcessorinstance.- 参数:
logFactory- the log factory to use- 从以下版本开始:
- 3.0.0
-
-
方法详细资料
-
setOrder
public void setOrder(int order) -
getOrder
public int getOrder() -
postProcessEnvironment
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) 从接口复制的说明:EnvironmentPostProcessorPost-process the givenenvironment.- 指定者:
postProcessEnvironment在接口中EnvironmentPostProcessor- 参数:
environment- the environment to post-processapplication- the application to which the environment belongs
-