Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9d4ad71

Browse files
committed
Reactive stream, Column navigation
1 parent 42efb78 commit 9d4ad71

14 files changed

+632
-83
lines changed

‎java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/CountOperation.java‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ class CountOperation<T> extends ParameterizedOperation<T>
4242
* Factory method to create CountOperations.
4343
*
4444
* @param <S> the type of the value of the CountOperation
45-
* @param conn the Connection the CountOperation belongs to
45+
* @param session the Session the CountOperation belongs to
4646
* @param grp the GroupOperation the CountOperation is a member of
4747
* @param sql the SQL string to execute. Must return a count.
4848
* @return a new CountOperation that will execute sql.
4949
*/
50-
static <S> CountOperation<S> newCountOperation(Connectionconn, OperationGroup grp, String sql) {
51-
return new CountOperation<>(conn, grp, sql);
50+
static <S> CountOperation<S> newCountOperation(Sessionsession, OperationGroup grp, String sql) {
51+
return new CountOperation<>(session, grp, sql);
5252
}
5353

5454
// attributes
@@ -57,8 +57,8 @@ static <S> CountOperation<S> newCountOperation(Connection conn, OperationGroup g
5757

5858
PreparedStatement jdbcStatement;
5959

60-
CountOperation(Connectionconn, OperationGroup operationGroup, String sql) {
61-
super(conn, operationGroup);
60+
CountOperation(Sessionsession, OperationGroup operationGroup, String sql) {
61+
super(session, operationGroup);
6262
countProcessor = DEFAULT_PROCESSOR;
6363
sqlString = sql;
6464
}
@@ -93,7 +93,7 @@ CompletionStage<T> follows(CompletionStage<?> predecessor, Executor executor) {
9393
private T executeQuery(Object ignore) {
9494
checkCanceled();
9595
try {
96-
jdbcStatement = connection.prepareStatement(sqlString);
96+
jdbcStatement = session.prepareStatement(sqlString);
9797
setParameters.forEach((String k, ParameterValue v) -> {
9898
v.set(jdbcStatement, k);
9999
});

‎java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSource.java‎

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,53 +15,53 @@
1515
*/
1616
package com.oracle.adbaoverjdbc;
1717

18-
import jdk.incubator.sql2.ConnectionProperty;
18+
import jdk.incubator.sql2.SessionProperty;
1919
import java.util.HashSet;
2020
import java.util.Map;
2121
import java.util.Set;
2222

2323
/**
24-
* Bare bones DataSource. No support for Connection caching.
24+
* Bare bones DataSource. No support for Session caching.
2525
*
2626
*/
2727
class DataSource implements jdk.incubator.sql2.DataSource {
2828

29-
static DataSource newDataSource(Map<ConnectionProperty, Object> defaultConnectionProperties,
30-
Map<ConnectionProperty, Object> requiredConnectionProperties) {
31-
return new DataSource(defaultConnectionProperties, requiredConnectionProperties);
29+
static DataSource newDataSource(Map<SessionProperty, Object> defaultSessionProperties,
30+
Map<SessionProperty, Object> requiredSessionProperties) {
31+
return new DataSource(defaultSessionProperties, requiredSessionProperties);
3232
}
3333

34-
protected final Map<ConnectionProperty, Object> defaultConnectionProperties;
35-
protected final Map<ConnectionProperty, Object> requiredConnectionProperties;
34+
protected final Map<SessionProperty, Object> defaultSessionProperties;
35+
protected final Map<SessionProperty, Object> requiredSessionProperties;
3636

37-
protected final Set<Connection> openConnections = new HashSet<>();
37+
protected final Set<Session> openSessions = new HashSet<>();
3838

39-
protected DataSource(Map<ConnectionProperty, Object> defaultProps,
40-
Map<ConnectionProperty, Object> requiredProps) {
39+
protected DataSource(Map<SessionProperty, Object> defaultProps,
40+
Map<SessionProperty, Object> requiredProps) {
4141
super();
42-
defaultConnectionProperties = defaultProps;
43-
requiredConnectionProperties = requiredProps;
42+
defaultSessionProperties = defaultProps;
43+
requiredSessionProperties = requiredProps;
4444
}
4545

4646
@Override
47-
public Connection.Builder builder() {
48-
return ConnectionBuilder.newConnectionBuilder(this, defaultConnectionProperties, requiredConnectionProperties);
47+
public Session.Builder builder() {
48+
return SessionBuilder.newSessionBuilder(this, defaultSessionProperties, requiredSessionProperties);
4949
}
5050

5151
@Override
5252
public void close() {
53-
openConnections.stream().forEach( c -> c.close() );
53+
openSessions.stream().forEach( c -> c.close() );
5454
}
5555

5656

5757

58-
DataSource registerConnection(Connection c) {
59-
openConnections.add(c);
58+
DataSource registerSession(Session c) {
59+
openSessions.add(c);
6060
return this;
6161
}
6262

63-
DataSource deregisterConnection(Connection c) {
64-
openConnections.remove(c);
63+
DataSource deregisterSession(Session c) {
64+
openSessions.remove(c);
6565
return this;
6666
}
6767

‎java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/DataSourceBuilder.java‎

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
*/
1616
package com.oracle.adbaoverjdbc;
1717

18-
import jdk.incubator.sql2.ConnectionProperty;
18+
import jdk.incubator.sql2.SessionProperty;
1919
import java.util.HashMap;
2020
import java.util.Map;
21-
import java.util.function.Consumer;
21+
import java.util.function.LongConsumer;
22+
import jdk.incubator.sql2.DataSourceProperty;
2223

2324
/**
2425
*
@@ -31,54 +32,71 @@ static DataSourceBuilder newDataSourceBuilder() {
3132

3233
protected boolean isBuilt = false;
3334

35+
Map<DataSourceProperty, Object> dataSourceProperties = new HashMap<>();
36+
3437
/**
35-
* defaultConnectionProperties can be overridden by a ConnectionBuilder
38+
* defaultSessionProperties can be overridden by a SessionBuilder
3639
*/
37-
Map<ConnectionProperty, Object> defaultConnectionProperties = new HashMap<>();
40+
Map<SessionProperty, Object> defaultSessionProperties = new HashMap<>();
3841

3942
/**
40-
* it is an error if a ConnectionBuilder tries to override requiredConnectionProperties
43+
* it is an error if a SessionBuilder tries to override requiredSessionProperties
4144
*/
42-
Map<ConnectionProperty, Object> requiredConnectionProperties = new HashMap<>();
45+
Map<SessionProperty, Object> requiredSessionProperties = new HashMap<>();
46+
47+
@Override
48+
public jdk.incubator.sql2.DataSource.Builder property(DataSourceProperty property, Object value) {
49+
if (isBuilt) {
50+
throw new IllegalStateException("TODO");
51+
}
52+
if (dataSourceProperties.containsKey(property)) {
53+
throw new IllegalArgumentException("cannot set a property multiple times");
54+
}
55+
if (!property.validate(value)) {
56+
throw new IllegalArgumentException("TODO");
57+
}
58+
dataSourceProperties.put(property, value);
59+
return this;
60+
}
4361

4462
@Override
45-
public jdk.incubator.sql2.DataSource.Builder defaultConnectionProperty(ConnectionProperty property, Object value) {
63+
public jdk.incubator.sql2.DataSource.Builder defaultSessionProperty(SessionProperty property, Object value) {
4664
if (isBuilt) {
4765
throw new IllegalStateException("TODO");
4866
}
49-
if (defaultConnectionProperties.containsKey(property)) {
67+
if (defaultSessionProperties.containsKey(property)) {
5068
throw new IllegalArgumentException("cannot set a default multiple times");
5169
}
52-
if (requiredConnectionProperties.containsKey(property)) {
70+
if (requiredSessionProperties.containsKey(property)) {
5371
throw new IllegalArgumentException("cannot set a default that is already required");
5472
}
5573
if (!property.validate(value)) {
5674
throw new IllegalArgumentException("TODO");
5775
}
58-
defaultConnectionProperties.put(property, value);
76+
defaultSessionProperties.put(property, value);
5977
return this;
6078
}
6179

6280
@Override
63-
public jdk.incubator.sql2.DataSource.Builder connectionProperty(ConnectionProperty property, Object value) {
81+
public jdk.incubator.sql2.DataSource.Builder sessionProperty(SessionProperty property, Object value) {
6482
if (isBuilt) {
6583
throw new IllegalStateException("TODO");
6684
}
67-
if (defaultConnectionProperties.containsKey(property)) {
85+
if (defaultSessionProperties.containsKey(property)) {
6886
throw new IllegalArgumentException("cannot set a required prop that has a default");
6987
}
70-
if (requiredConnectionProperties.containsKey(property)) {
88+
if (requiredSessionProperties.containsKey(property)) {
7189
throw new IllegalArgumentException("cannot set a required prop multiple times");
7290
}
7391
if (!property.validate(value)) {
7492
throw new IllegalArgumentException("TODO");
7593
}
76-
requiredConnectionProperties.put(property, value);
94+
requiredSessionProperties.put(property, value);
7795
return this;
7896
}
7997

8098
@Override
81-
public jdk.incubator.sql2.DataSource.Builder requestHook(Consumer<Long> request) {
99+
public jdk.incubator.sql2.DataSource.Builder requestHook(LongConsumer request) {
82100
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
83101
}
84102

@@ -88,7 +106,7 @@ public jdk.incubator.sql2.DataSource build() {
88106
throw new IllegalStateException("cannot build more than once. All objects are use-once");
89107
}
90108
isBuilt = true;
91-
return DataSource.newDataSource(defaultConnectionProperties, requiredConnectionProperties);
109+
return DataSource.newDataSource(defaultSessionProperties, requiredSessionProperties);
92110
}
93111

94112
}

‎java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/JdbcConnectionProperties.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
import java.util.Properties;
1919

2020
/**
21-
* An ADBA ConnectionProperty that specifies a set of JDBC connection properties.
21+
* An ADBA SessionProperty that specifies a set of JDBC Connection properties.
2222
* Its value is a java.util.Properties. This value is passed as the info argument
2323
* when creating a java.sql.Connection.
2424
*
2525
*/
26-
public class JdbcConnectionProperties implements jdk.incubator.sql2.ConnectionProperty {
26+
public class JdbcConnectionProperties implements jdk.incubator.sql2.SessionProperty {
2727

2828
public static final JdbcConnectionProperties JDBC_CONNECTION_PROPERTIES
2929
= new JdbcConnectionProperties();
@@ -33,7 +33,7 @@ private JdbcConnectionProperties() {
3333

3434
@Override
3535
public String name() {
36-
return "JDBC_CONNECTION_PROPERTIES";
36+
return "JDBC_SESSION_PROPERTIES";
3737
}
3838

3939
@Override

‎java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/Operation.java‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,16 +146,19 @@ static Throwable unwrapException(Throwable ex) {
146146
protected Consumer<Throwable> errorHandler = null;
147147

148148
// internal state
149-
protected final Connectionconnection;
149+
protected final Sessionsession;
150150
protected final OperationGroup<T, ?> group;
151151
protected OperationLifecycle operationLifecycle = OperationLifecycle.MUTABLE;
152+
153+
// used only by Session
154+
protected Operation() {
155+
session = (Session)this;
156+
group = (OperationGroup)this;
157+
}
152158

153-
Operation(Connection conn, OperationGroup operationGroup) {
154-
// passing null for connection and operationGroup is a hack. It is not
155-
// possible to pass _this_ to a super constructor so we define null to mean
156-
// _this_. Yuck. Only used by Connection.
157-
connection = conn == null ? (Connection) this : conn;
158-
group = operationGroup == null ? (OperationGroup) this : operationGroup;
159+
Operation(Session session, OperationGroup operationGroup) {
160+
this.session = session;
161+
group = operationGroup;
159162
}
160163

161164
@Override
@@ -216,7 +219,7 @@ long getTimeoutMillis() {
216219
}
217220

218221
protected Executor getExecutor() {
219-
return connection.getExecutor();
222+
return session.getExecutor();
220223
}
221224

222225
/**

‎java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/OperationGroup.java‎

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import jdk.incubator.sql2.OutOperation;
2121
import jdk.incubator.sql2.ParameterizedRowOperation;
2222
import jdk.incubator.sql2.Submission;
23-
import jdk.incubator.sql2.Transaction;
2423
import jdk.incubator.sql2.TransactionOutcome;
2524
import java.time.Duration;
2625
import java.util.concurrent.CompletableFuture;
@@ -33,6 +32,7 @@
3332
import jdk.incubator.sql2.ParameterizedRowCountOperation;
3433
import jdk.incubator.sql2.ParameterizedRowPublisherOperation;
3534
import jdk.incubator.sql2.ArrayRowCountOperation;
35+
import jdk.incubator.sql2.TransactionEnd;
3636

3737
/**
3838
* Only sequential, dependent, unconditional supported.
@@ -77,8 +77,8 @@ class OperationGroup<S, T> extends com.oracle.adbaoverjdbc.Operation<T>
7777
(a, b) -> null,
7878
a -> null);
7979

80-
static <U, V> OperationGroup<U, V> newOperationGroup(Connectionconn) {
81-
return new OperationGroup(conn, conn);
80+
static <U, V> OperationGroup<U, V> newOperationGroup(Sessionsession) {
81+
return new OperationGroup(session, session);
8282
}
8383

8484
static final Logger NULL_LOGGER = Logger.getAnonymousLogger();
@@ -118,8 +118,17 @@ static <U, V> OperationGroup<U, V> newOperationGroup(Connection conn) {
118118
*/
119119
private CompletionStage<S> memberTail;
120120

121-
protected OperationGroup(Connection conn, OperationGroup<? super T, ?> group) {
122-
super(conn, group);
121+
// used only by Session. Will break if used by any other class.
122+
protected OperationGroup() {
123+
super();
124+
held = new CompletableFuture();
125+
head = new CompletableFuture();
126+
memberTail = head;
127+
collector = DEFAULT_COLLECTOR;
128+
}
129+
130+
protected OperationGroup(Session session, OperationGroup<? super T, ?> group) {
131+
super(session, group);
123132
held = new CompletableFuture();
124133
head = new CompletableFuture();
125134
memberTail = head;
@@ -174,7 +183,7 @@ public OperationGroup<S, T> collect(Collector<S, ?, T> c) {
174183
@Override
175184
public Operation<S> catchOperation() {
176185
if (! isHeld() ) throw new IllegalStateException("TODO");
177-
return UnskippableOperation.newOperation(connection, this, op -> null);
186+
return UnskippableOperation.newOperation(session, this, op -> null);
178187
}
179188

180189
@Override
@@ -187,13 +196,13 @@ public <R extends S> ArrayRowCountOperation<R> arrayRowCountOperation(String sql
187196
public <R extends S> ParameterizedRowCountOperation<R> rowCountOperation(String sql) {
188197
if ( ! isHeld() ) throw new IllegalStateException("TODO");
189198
if (sql == null) throw new IllegalArgumentException("TODO");
190-
return CountOperation.newCountOperation(connection, this, sql);
199+
return CountOperation.newCountOperation(session, this, sql);
191200
}
192201

193202
@Override
194203
public SqlOperation<S> operation(String sql) {
195204
if ( !isHeld() ) throw new IllegalStateException("TODO");
196-
return SqlOperation.newOperation(connection, this, sql);
205+
return SqlOperation.newOperation(session, this, sql);
197206
}
198207

199208
@Override
@@ -206,7 +215,7 @@ public <R extends S> OutOperation<R> outOperation(String sql) {
206215
public <R extends S> ParameterizedRowOperation<R> rowOperation(String sql) {
207216
if ( ! isHeld() ) throw new IllegalStateException("TODO");
208217
if (sql == null) throw new IllegalArgumentException("TODO");
209-
return RowOperation.newRowOperation(connection, this, sql);
218+
return RowOperation.newRowOperation(session, this, sql);
210219
}
211220

212221
@Override
@@ -222,12 +231,12 @@ public <R extends S> MultiOperation<R> multiOperation(String sql) {
222231
}
223232

224233
@Override
225-
public SimpleOperation<TransactionOutcome> endTransactionOperation(Transaction trans) {
234+
public SimpleOperation<TransactionOutcome> endTransactionOperation(TransactionEnd trans) {
226235
if ( ! isHeld() ) throw new IllegalStateException("TODO");
227236
return com.oracle.adbaoverjdbc.SimpleOperation.<TransactionOutcome>newOperation(
228-
connection,
237+
session,
229238
(OperationGroup<Object,T>)this,
230-
op -> connection.jdbcEndTransaction(op, (com.oracle.adbaoverjdbc.Transaction)trans));
239+
op -> session.jdbcEndTransaction(op, (com.oracle.adbaoverjdbc.TransactionEnd)trans));
231240
}
232241

233242
@Override

‎java/AoJ/src/com/oracle/adbaoverjdbc/com/oracle/adbaoverjdbc/ParameterizedOperation.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ public abstract class ParameterizedOperation<T> extends Operation<T>
3535
protected final Map<String, ParameterValue> setParameters;
3636
protected CompletionStage futureParameters;
3737

38-
ParameterizedOperation(Connectionconn, OperationGroup operationGroup) {
39-
super(conn, operationGroup);
38+
ParameterizedOperation(Sessionsession, OperationGroup operationGroup) {
39+
super(session, operationGroup);
4040
setParameters = new HashMap<>();
4141
}
4242

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /