public final class ConnectionFactoryOptions extends Object
ConnectionFactory
s.
A ConnectionFactoryOptions
represents a configuration state that consists of one or more Option
objects. Each configuration option can be specified at most once to associate a
value with its key.
New objects are constructed through builder()
or by parsing
a R2DBC Connection URL.
ConnectionFactoryOptions
can be augmented to allow staged construction of the configuration state using a initialized builder
to create a new ConnectionFactoryOptions
objects with mutations applied. Values of this class are immutable once created. Builder initializers are left unchanged.
Example usage:
ConnectionFactoryOptions options = ConnectionFactoryOptions.builder() .option(ConnectionFactoryOptions.DRIVER, "a-driver") .option(ConnectionFactoryOptions.PROTOCOL, "pipes") .option(ConnectionFactoryOptions.HOST, "localhost") .option(ConnectionFactoryOptions.PORT, 3306) .option(ConnectionFactoryOptions.DATABASE, "my_database") .option(Option.valueOf("locale"), "en_US") .build();
Note that Connection URL Parsing cannot access Option
type information T
due to Java's type erasure. Options configured by URL parsing are represented as String
values.
ConnectionFactories
Modifier and Type | Class and Description |
---|---|
static class |
ConnectionFactoryOptions.Builder
A builder for
ConnectionFactoryOptions instances. |
Modifier and Type | Field and Description |
---|---|
static Option<Duration> |
CONNECT_TIMEOUT
Connection timeout.
|
static Option<String> |
DATABASE
Initial database name.
|
static Option<String> |
DRIVER
Driver name.
|
static Option<String> |
HOST
Endpoint host name.
|
static Option<Duration> |
LOCK_WAIT_TIMEOUT
Lock timeout.
|
static Option<CharSequence> |
PASSWORD
Password for authentication.
|
static Option<Integer> |
PORT
Endpoint port number.
|
static Option<String> |
PROTOCOL
Driver protocol name.
|
static Option<Boolean> |
SSL
Whether to require SSL.
|
static Option<Duration> |
STATEMENT_TIMEOUT
Statement timeout.
|
static Option<String> |
USER
User for authentication.
|
Modifier and Type | Method and Description |
---|---|
static ConnectionFactoryOptions.Builder |
builder()
Returns a new
ConnectionFactoryOptions.Builder . |
boolean |
equals(Object o) |
Object |
getRequiredValue(Option<?> option)
Returns the value for an option if it exists.
|
Object |
getValue(Option<?> option)
Returns the value for an option if it exists, otherwise
null . |
int |
hashCode() |
boolean |
hasOption(Option<?> option)
Returns
true if the option exists, otherwise false . |
ConnectionFactoryOptions.Builder |
mutate()
Returns a new
ConnectionFactoryOptions.Builder initialized with this ConnectionFactoryOptions . |
static ConnectionFactoryOptions |
parse(CharSequence url)
Parses a R2DBC Connection URL and returns the parsed
ConnectionFactoryOptions . |
String |
toString() |
public static final Option<CharSequence> PASSWORD
public static final Option<String> PROTOCOL
tcp
or a database vendor-specific protocol string.public static final Option<Duration> STATEMENT_TIMEOUT
public static ConnectionFactoryOptions.Builder builder()
ConnectionFactoryOptions.Builder
.ConnectionFactoryOptions.Builder
public static ConnectionFactoryOptions parse(CharSequence url)
ConnectionFactoryOptions
.
URL format:
r2dbc:driver[:protocol]
://[user:password@]host[:port][/path][?option=value]}.url
- the R2DBC URL.ConnectionFactoryOptions
.public ConnectionFactoryOptions.Builder mutate()
ConnectionFactoryOptions.Builder
initialized with this ConnectionFactoryOptions
.ConnectionFactoryOptions.Builder
public Object getRequiredValue(Option<?> option)
option
- the option to retrieve the value forIllegalArgumentException
- if option
is null
NoSuchOptionException
- if option
is not configured or there is no value for option
@Nullable public Object getValue(Option<?> option)
null
.option
- the option to retrieve the value fornull
IllegalArgumentException
- if option
is null
public boolean hasOption(Option<?> option)
true
if the option exists, otherwise false
.option
- the option to test fortrue
if the option exists, otherwise false
IllegalArgumentException
- if option
is null
Copyright © 2022. All rights reserved.