Package dk.kosmisk.postgresql.it
Class PostgresITDataSource.Builder
- java.lang.Object
-
- dk.kosmisk.postgresql.it.PostgresITDataSource.Builder
-
- Enclosing class:
- PostgresITDataSource
public static final class PostgresITDataSource.Builder extends Object
Builder pattern for aPostgresITDataSource
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PostgresITDataSourcebuild()Build a DataSourcePostgresITDataSource.BuilderfromEnvironment(String environmentName)Search environment variable for database locationPostgresITDataSource.BuilderfromProperty(String databaseName)Set database name, take port from postgresql.${name}.port propertyPostgresITDataSource.BuilderfromProperty(String databaseName, String portPropertyName)Set database name and port propertyPostgresITDataSource.BuilderwithFallback()Allow use of $PG* environment variables for database discovery user is $PGUSER or ${user.name} password is $PGPASSWORD or ${user.name} host is $PGHOST or 127.0.0.1 port is $PGPORT or 5432 database is $PGDATABASE or ${user.name}PostgresITDataSource.BuilderwithoutFallback()Disallow fallback definition
-
-
-
Method Detail
-
fromProperty
public PostgresITDataSource.Builder fromProperty(String databaseName, String portPropertyName)
Set database name and port propertyRemember to export port using the maven-failsafe-plugin plugin
- Parameters:
databaseName- name of databaseportPropertyName- name of system property containing port- Returns:
- self
-
fromProperty
public PostgresITDataSource.Builder fromProperty(String databaseName)
Set database name, take port from postgresql.${name}.port propertyRemember to export port using the maven-failsafe-plugin plugin
- Parameters:
databaseName- name of database- Returns:
- self
-
fromEnvironment
public PostgresITDataSource.Builder fromEnvironment(String environmentName)
Search environment variable for database locationEnvironment variable should contain a uri with:
- no schema or schema 'postgres' or 'postgresql'
- user
- password
- hostname
- port (optional defaults to 5432)
- database
- Parameters:
environmentName- name if environment variable to examine- Returns:
- self
-
withoutFallback
public PostgresITDataSource.Builder withoutFallback()
Disallow fallback definition- Returns:
- self
-
withFallback
public PostgresITDataSource.Builder withFallback()
Allow use of $PG* environment variables for database discovery- user is $PGUSER or ${user.name}
- password is $PGPASSWORD or ${user.name}
- host is $PGHOST or 127.0.0.1
- port is $PGPORT or 5432
- database is $PGDATABASE or ${user.name}
- Returns:
- self
-
build
public PostgresITDataSource build()
Build a DataSource- Returns:
- new dataSource
-
-