public class AmazonRdsDataSourceFactoryBean extends org.springframework.beans.factory.config.AbstractFactoryBean<DataSource>
FactoryBean implementation that creates a datasource backed by an Amazon
Relational Database service instance. This factory bean retrieves all the metadata from the AWS RDS service in
order to create and configure a datasource. This class uses the AmazonRDS service to retrieve the metadata
and the DataSourceFactory to actually create the datasource.| Constructor and Description |
|---|
AmazonRdsDataSourceFactoryBean(com.amazonaws.services.rds.AmazonRDS amazonRds,
String dbInstanceIdentifier,
String password)
Constructor which retrieves all mandatory objects to allow the object to be constructed.
|
| Modifier and Type | Method and Description |
|---|---|
protected DataSource |
createDataSourceInstance(String identifier)
Creates a data source based in the instance name.
|
protected DataSource |
createInstance() |
protected void |
destroyInstance(DataSource instance) |
protected com.amazonaws.services.rds.model.DBInstance |
getDbInstance(String identifier)
Retrieves the
DBInstance information |
protected String |
getDbInstanceIdentifier() |
Class<DataSource> |
getObjectType() |
void |
setDatabaseName(String databaseName)
Configures an own database name to be used if the default database (that is configured in the meta-data) should not
be used.
|
void |
setDataSourceFactory(DataSourceFactory dataSourceFactory)
Allows to configure a different DataSourceFactory in order to use a different DataSource implementation.
|
void |
setResourceIdResolver(org.springframework.cloud.aws.core.env.ResourceIdResolver resourceIdResolver)
Configures an optional
ResourceIdResolver used to resolve a logical name to a
physical one. |
void |
setUsername(String username)
Allows to set a different user then the master user name in order to connect to the database.
|
public AmazonRdsDataSourceFactoryBean(com.amazonaws.services.rds.AmazonRDS amazonRds,
String dbInstanceIdentifier,
String password)
amazonRds - - The amazonRds instance used to connect to the service. This object will be used to actually retrieve the
datasource metadata from the Amazon RDS service.dbInstanceIdentifier - - the unique database instance identifier in the Amazon RDS servicepassword - - The password used to connect to the datasource. For security reasons the password is not available in the
metadata (in contrast to the user) so it must be provided in order to connect to the database with JDBC.public void setDataSourceFactory(DataSourceFactory dataSourceFactory)
TomcatJdbcDataSourceFactory by default if not configured.dataSourceFactory - - A fully configured DataSourceFactory instance, will be used to actually create the
datasource.public void setUsername(String username)
username - - The username to connect to the database, every value provided (even empty ones) are used to connect to the
database.public void setDatabaseName(String databaseName)
databaseName - - the database name to be used while connectingpublic void setResourceIdResolver(org.springframework.cloud.aws.core.env.ResourceIdResolver resourceIdResolver)
ResourceIdResolver used to resolve a logical name to a
physical one.resourceIdResolver - - the resourceIdResolver instance, might be null or not called at allpublic Class<DataSource> getObjectType()
getObjectType in interface org.springframework.beans.factory.FactoryBean<DataSource>getObjectType in class org.springframework.beans.factory.config.AbstractFactoryBean<DataSource>protected DataSource createInstance() throws Exception
createInstance in class org.springframework.beans.factory.config.AbstractFactoryBean<DataSource>Exceptionprotected void destroyInstance(DataSource instance) throws Exception
destroyInstance in class org.springframework.beans.factory.config.AbstractFactoryBean<DataSource>Exceptionprotected DataSource createDataSourceInstance(String identifier) throws Exception
identifier - - the database identifier for the data source configured in amazon rdsDataSourceIllegalStateException - if no database has been foundException - in case of underlying exceptionsprotected com.amazonaws.services.rds.model.DBInstance getDbInstance(String identifier) throws IllegalStateException
DBInstance informationidentifier - - the database identifier usedIllegalStateException - if the db instance is not foundprotected String getDbInstanceIdentifier()
Copyright © 2017 Pivotal Software, Inc.. All rights reserved.