public class Cloud extends Object
ServiceInfos obtained using the
underlying CloudConnector and allows translating those to service connector such as a DataSource.
It also passes along information obtained through CloudConnector to let application take control on how
to use bound services.
NOTE: Users or cloud providers shouldn't need to instantiate an instance of this class
(constructor has package-access only for unit-testing purpose). Instead, they can obtain an appropriate
instance through CloudFactory
| Modifier and Type | Method and Description |
|---|---|
ApplicationInstanceInfo |
getApplicationInstanceInfo() |
Properties |
getCloudProperties()
Get properties for app and services.
|
<SC> SC |
getServiceConnector(String serviceId,
Class<SC> serviceConnectorType,
ServiceConnectorConfig serviceConnectorConfig)
Get a service connector for the given service id, the connector type, configured with the given config
|
ServiceInfo |
getServiceInfo(String serviceId)
Get
ServiceInfo for the given service id |
List<ServiceInfo> |
getServiceInfos() |
<T> List<ServiceInfo> |
getServiceInfos(Class<T> serviceConnectorType)
Get
ServiceInfos for the bound services that could be mapped to the given service connector type. |
<SC> SC |
getSingletonServiceConnector(Class<SC> serviceConnectorType,
ServiceConnectorConfig serviceConnectorConfig)
Get the singleton service connector for the given connector type, configured with the given config
|
void |
registerServiceConnectorCreator(ServiceConnectorCreator<?,? extends ServiceInfo> serviceConnectorCreator)
Register a new service connector creator
|
public ApplicationInstanceInfo getApplicationInstanceInfo()
CloudConnector.getApplicationInstanceInfo()public ServiceInfo getServiceInfo(String serviceId)
ServiceInfo for the given service idserviceId - service idpublic List<ServiceInfo> getServiceInfos()
CloudConnector.getServiceInfos()public <T> List<ServiceInfo> getServiceInfos(Class<T> serviceConnectorType)
ServiceInfos for the bound services that could be mapped to the given service connector type.
For example, if the connector type is DataSource, then the method will return
all ServiceInfo objects matching bound relational database services.
serviceConnectorType - service connector type.
Passing null returns all ServiceInfos (matching that of getServiceInfos()public <SC> SC getServiceConnector(String serviceId, Class<SC> serviceConnectorType, ServiceConnectorConfig serviceConnectorConfig)
serviceId - the service idserviceConnectorType - The expected class of service connector such as, DataSource.class.serviceConnectorConfig - service connector configuration (such as pooling parameters).public <SC> SC getSingletonServiceConnector(Class<SC> serviceConnectorType, ServiceConnectorConfig serviceConnectorConfig)
serviceConnectorType - The expected class of service connector such as, DataSource.class.serviceConnectorConfig - service connector configuration (such as pooling parameters).public void registerServiceConnectorCreator(ServiceConnectorCreator<?,? extends ServiceInfo> serviceConnectorCreator)
serviceConnectorCreator - public Properties getCloudProperties()
Application properties always include cloud.application.app-id
and cloud.application.instance-id with values bound to application id and
instance id. The rest of the properties are cloud-provider specific, but take the
cloud.application.<property-name> form.
cloud.application.app-id = helloworld
cloud.application.instance-id = instance-0-0fab098f
cloud.application.<property-name> = <property-value>
Service specific properties are exposed for each bound service, with each key starting
in cloud.services. Like application properties, these too are cloud and service specific.
Each key for a specific service starts with cloud.services.<service-id>
cloud.services.customerDb.type = mysql-5.1
cloud.services.customerDb.plan = free
cloud.services.customerDb.connection.hostname = ...
cloud.services.customerDb.connection.port = ...
etc...
If a there is only a single service of a given type, that service is
aliased to the service type. Keys for such properties start in cloud.services.<service-type>.
For example, if there is only a single MySQL service bound to the application, the service properties will also be
exposed starting with 'cloud.services.mysql' key:
cloud.services.mysql.type = mysql-5.1
cloud.services.mysql.plan = free
cloud.services.mysql.connection.hostname = ...
cloud.services.mysql.connection.port = ...
etc...