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();
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<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<String> |
USER
User for authentication.
|
Modifier and Type | Method and Description |
---|---|
static ConnectionFactoryOptions.Builder |
builder()
Returns a new
ConnectionFactoryOptions.Builder . |
<T> T |
getRequiredValue(Option<T> option)
Returns the value for an option if it exists.
|
<T> T |
getValue(Option<T> option)
Returns the value for an option if it exists, otherwise
null . |
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 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 <T> T getRequiredValue(Option<T> option)
T
- the type of the valueoption
- the option to retrieve the value forIllegalArgumentException
- if option
is null
IllegalStateException
- if there is no value for option
@Nullable public <T> T getValue(Option<T> option)
null
.T
- the type of the valueoption
- 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 © 2019. All rights reserved.