Added support for MS-SQL and Azure SQL DB

Added support for MS-SQL and Azure SQL DB
This commit is contained in:
GuillermoTantachuco
2015-07-13 22:04:29 -05:00
parent ae773dcaf4
commit 0ab513cd94
5 changed files with 55 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
package org.springframework.cloud.cloudfoundry;
import org.springframework.cloud.service.common.SqlServerServiceInfo;
public class SqlServerServiceInfoCreator extends
RelationalServiceInfoCreator<SqlServerServiceInfo> {
public SqlServerServiceInfoCreator() {
super(new Tags(), SqlServerServiceInfo.SQLSERVER_SCHEME); }
@Override
public SqlServerServiceInfo createServiceInfo(String id, String url) {
return new SqlServerServiceInfo(id, url);
}
}

View File

@@ -7,3 +7,4 @@ org.springframework.cloud.cloudfoundry.MonitoringServiceInfoCreator
org.springframework.cloud.cloudfoundry.SmtpServiceInfoCreator
org.springframework.cloud.cloudfoundry.OracleServiceInfoCreator
org.springframework.cloud.cloudfoundry.DB2ServiceInfoCreator
org.springframework.cloud.cloudfoundry.SqlServerServiceInfoCreator

View File

@@ -0,0 +1,22 @@
package org.springframework.cloud.service.common;
import org.springframework.cloud.service.ServiceInfo;
@ServiceInfo.ServiceLabel("sqlserver")
public class SqlServerServiceInfo extends RelationalServiceInfo {
private static final String JDBC_URL_TYPE = "sqlserver";
public static final String SQLSERVER_SCHEME = JDBC_URL_TYPE;
public SqlServerServiceInfo(String id, String url) {
super(id, url, JDBC_URL_TYPE);
}
@Override
public String getJdbcUrl()
{
return String.format("jdbc:%s://%s:%d;database=%s;user=%s;password=%s;",
jdbcUrlDatabaseType,
getHost(), getPort(), getPath(), getUserName(), getPassword());
}
}

View File

@@ -0,0 +1,15 @@
package org.springframework.cloud.service.relational;
import org.springframework.cloud.service.common.SqlServerServiceInfo;
import org.springframework.cloud.service.relational.DataSourceCreator;
public class SqlServerDataSourceCreator extends DataSourceCreator<SqlServerServiceInfo> {
private static final String[] DRIVERS = new String[]{"com.microsoft.sqlserver.jdbc.SQLServerDriver"};
private static final String VALIDATION_QUERY = "SELECT 1";
public SqlServerDataSourceCreator() {
super("spring-cloud.sqlserver.driver", DRIVERS, VALIDATION_QUERY);
}
}

View File

@@ -6,3 +6,4 @@ org.springframework.cloud.service.keyval.RedisConnectionFactoryCreator
org.springframework.cloud.service.document.MongoDbFactoryCreator
org.springframework.cloud.service.messaging.RabbitConnectionFactoryCreator
org.springframework.cloud.service.smtp.MailSenderCreator
org.springframework.cloud.service.relational.SqlServerDataSourceCreator