public static interface DataSource.Builder
DataSource
s. This type is
immutable once configured. No property can be set more than once. No
property can be set after build()
is called.
ISSUE: Probably need property(DataSourceProperty prop, Object value).Modifier and Type | Method | Description |
---|---|---|
DataSource |
build() |
Return a DataSource configured as specified.
|
DataSource.Builder |
defaultSessionProperty(SessionProperty property,
java.lang.Object value) |
Specify the value of a
Session property that will be set by default on
all Session s produced by this DataSource . |
default DataSource.Builder |
password(java.lang.String password) |
A convenience method for setting the
AdbaSessionProperty.PASSWORD . |
DataSource.Builder |
property(DataSourceProperty p,
java.lang.Object v) |
Specify a property and its value for the built
DataSource . |
default DataSource.Builder |
registerSessionProperty(SessionProperty property) |
Make a user defined property known to the implementation.
|
DataSource.Builder |
requestHook(java.util.function.LongConsumer request) |
Provide a method that the built
DataSource will call to control the
rate of Session creations. |
DataSource.Builder |
sessionProperty(SessionProperty property,
java.lang.Object value) |
Specify the value of a
Session property that will be set on
all Session s produced by the built DataSource . |
default DataSource.Builder |
url(java.lang.String url) |
A convenience method for setting the
AdbaSessionProperty.URL . |
default DataSource.Builder |
username(java.lang.String name) |
A convenience method for setting the
AdbaSessionProperty.USER . |
DataSource.Builder property(DataSourceProperty p, java.lang.Object v)
DataSource
.p
- DataSourceProperty
to set. Not null
.v
- value for the propertyDataSource.Builder
java.lang.IllegalArgumentException
- if p.validate(v)
does not return
true, if this method has already been called with the property
p
, or the implementation does not support the
DataSourceProperty
.default DataSource.Builder url(java.lang.String url)
AdbaSessionProperty.URL
.url
- the value to be set for AdbaSessionProperty.URL
DataSource.Builder
sessionProperty(jdk.incubator.sql2.SessionProperty,java.lang.Object)
default DataSource.Builder username(java.lang.String name)
AdbaSessionProperty.USER
.name
- the value to be set for AdbaSessionProperty.USER
DataSource.Builder
sessionProperty(jdk.incubator.sql2.SessionProperty,java.lang.Object)
default DataSource.Builder password(java.lang.String password)
AdbaSessionProperty.PASSWORD
.password
- the value to be set for AdbaSessionProperty.PASSWORD
DataSource.Builder
sessionProperty(jdk.incubator.sql2.SessionProperty,java.lang.Object)
DataSource.Builder defaultSessionProperty(SessionProperty property, java.lang.Object value)
Session
property that will be set by default on
all Session
s produced by this DataSource
. A different value can be set
for a particular Session
via Session.Builder.property(jdk.incubator.sql2.SessionProperty, java.lang.Object)
.property
- the SessionProperty
to be set. May not be null
.value
- the value to be set for property
DataSource.Builder
java.lang.IllegalArgumentException
- if property.validate(value)
does not
return true
. If it throws an Exception
that Exception
is the cause. Or if
this property has been specified previously to this method or
sessionProperty(jdk.incubator.sql2.SessionProperty,java.lang.Object)
or registerSessionProperty(jdk.incubator.sql2.SessionProperty)
.java.lang.IllegalStateException
- if build()
has previously been called.DataSource.Builder sessionProperty(SessionProperty property, java.lang.Object value)
Session
property that will be set on
all Session
s produced by the built DataSource
.
Attempting to set a different value via
Session.Builder.property(jdk.incubator.sql2.SessionProperty, java.lang.Object)
will throw
IllegalArgumentException
.property
- the SessionProperty
to set. May not be
null
.value
- the value to set as the default for property
DataSource.Builder
java.lang.IllegalArgumentException
- if property.validate(value)
does
not return true
. If it throws an Exception
that
Exception
is the cause. Or if this property has been specified
previously to this method or defaultSessionProperty(jdk.incubator.sql2.SessionProperty,java.lang.Object)
or
registerSessionProperty(jdk.incubator.sql2.SessionProperty)
.java.lang.IllegalStateException
- if build()
has previously been
called.default DataSource.Builder registerSessionProperty(SessionProperty property)
DataSource
doesn't know about the property then it cannot know to
set the default value. Convenience method.property
- the SessionProperty
to make known. May not be
null
.java.lang.IllegalArgumentException
- if this property has been specified
previously to this method or sessionProperty(jdk.incubator.sql2.SessionProperty,java.lang.Object)
or
defaultSessionProperty(jdk.incubator.sql2.SessionProperty,java.lang.Object)
.java.lang.IllegalStateException
- if build()
has previously been
called.DataSource.Builder requestHook(java.util.function.LongConsumer request)
DataSource
will call to control the
rate of Session
creations. The built
DataSource
will call request
with a positive argument
when the DataSource
is able to accept more calls to
DataSource.builder()
. The difference between
the sum of all arguments passed to request
and the number of
calls to DataSource.builder()
is the
demand. The demand must always be non-negative. If a call is made to
DataSource.builder()
that would make the demand negative, that call
throws IllegalStateException
. If requestHook
is not called,
the demand is defined to be infinite.
Since the user thread is never blocked, a user thread could in theory
create, attach, use, and close Session
s faster than the underlying
implementation can process the submitted work. At some point work would
start timing out or Java would run out of memory to store the queued
Operation
s. This is a poor way address the issue. This method
allows user code to get feedback from the DataSource
as to whether
the DataSource
can accept more work.
request
- accepts calls to increase the demand. Not null.DataSource.Builder
java.lang.IllegalStateException
- if this method has been called previouslyDataSource build()
DataSource
. Not null
.java.lang.IllegalArgumentException
- if unable to return a DataSource
due to
problems with the configuration such is missing or conflicting properties.Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2017, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.
DRAFT JDBC 4.4 EA5