Skip to content

Commit f27741d

Browse files
committed
[hibernate#950] Move previous methods in different interfaces
1 parent e5107d0 commit f27741d

12 files changed

+222
-198
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/* Hibernate, Relational Persistence for Idiomatic Java
2+
*
3+
* SPDX-License-Identifier: Apache-2.0
4+
* Copyright: Red Hat Inc. and Hibernate Authors
5+
*/
6+
package org.hibernate.reactive.common.spi;
7+
8+
import java.util.function.Function;
9+
10+
import org.hibernate.reactive.mutiny.Mutiny;
11+
12+
/**
13+
* @deprecated It will be removed
14+
*/
15+
@Deprecated
16+
public interface MutinyImplementor {
17+
18+
/**
19+
* Obtain a new {@link Mutiny.Session reactive session}, the main
20+
* interaction point between the user's program and Hibernate
21+
* Reactive.
22+
* <p>
23+
* The underlying database connection is obtained lazily when
24+
* the returned {@link Mutiny.Session} needs to access the database.
25+
* <p>
26+
* The client must explicitly close the session by calling
27+
* {@link Mutiny.Session#close()}.
28+
*
29+
* @see Mutiny.SessionFactory#withSession(Function)
30+
* @see Mutiny.SessionFactory#openSession()
31+
*/
32+
Mutiny.Session newSession();
33+
34+
/**
35+
* Obtain a new {@link Mutiny.Session reactive session} for a
36+
* specified tenant.
37+
* <p>
38+
* The underlying database connection is obtained lazily when
39+
* the returned {@link Mutiny.Session} needs to access the database.
40+
* <p>
41+
* The client must explicitly close the session by calling
42+
* {@link Mutiny.Session#close()}.
43+
*
44+
* @param tenantId the id of the tenant
45+
*
46+
* @see Mutiny.SessionFactory#withSession(String, Function)
47+
* @see Mutiny.SessionFactory#openSession(String)
48+
*/
49+
Mutiny.Session newSession(String tenantId);
50+
51+
/**
52+
* Obtain a {@link Mutiny.StatelessSession reactive stateless session}.
53+
* <p>
54+
* The underlying database connection is obtained lazily when
55+
* the returned {@link Mutiny.StatelessSession} needs to access the
56+
* database.
57+
* <p>
58+
* The client must explicitly close the session by calling
59+
* {@link Mutiny.StatelessSession#close()}.
60+
*
61+
* @see Mutiny.SessionFactory#openStatelessSession()
62+
* @see Mutiny.SessionFactory#withStatelessSession(Function)
63+
*/
64+
Mutiny.StatelessSession newStatelessSession();
65+
66+
/**
67+
* Obtain a {@link Mutiny.StatelessSession reactive stateless session}.
68+
* <p>
69+
* The underlying database connection is obtained lazily when
70+
* the returned {@link Mutiny.StatelessSession} needs to access the
71+
* database.
72+
* <p>
73+
* The client must explicitly close the session by calling
74+
* {@link Mutiny.StatelessSession#close()}.
75+
*
76+
* @param tenantId the id of the tenant
77+
*
78+
* @see Mutiny.SessionFactory#openStatelessSession(String)
79+
* @see Mutiny.SessionFactory#withSession(String, Function)
80+
*/
81+
Mutiny.StatelessSession newStatelessSession(String tenantId);
82+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/* Hibernate, Relational Persistence for Idiomatic Java
2+
*
3+
* SPDX-License-Identifier: Apache-2.0
4+
* Copyright: Red Hat Inc. and Hibernate Authors
5+
*/
6+
package org.hibernate.reactive.common.spi;
7+
8+
import org.hibernate.reactive.stage.Stage;
9+
10+
/**
11+
* @deprecated It will be removed
12+
*/
13+
@Deprecated
14+
public interface StageImplementor {
15+
/**
16+
* Obtain a new {@link Stage.Session reactive session}, the main
17+
* interaction point between the user's program and Hibernate
18+
* Reactive.
19+
* <p>
20+
* The underlying database connection is obtained lazily when
21+
* the returned {@link Stage.Session} needs to access the database.
22+
* <p>
23+
* The client must explicitly close the session by calling
24+
* {@link Stage.Session#close()}.
25+
*
26+
* @see Stage.SessionFactory#withSession(Function)
27+
* @see Stage.SessionFactory#openSession()
28+
*/
29+
Stage.Session newSession();
30+
31+
/**
32+
* Obtain a new {@link Stage.Session reactive session} for a
33+
* specified tenant.
34+
* <p>
35+
* The underlying database connection is obtained lazily when
36+
* the returned {@link Stage.Session} needs to access the database.
37+
* <p>
38+
* The client must explicitly close the session by calling
39+
* {@link Stage.Session#close()}.
40+
*
41+
* @param tenantId the id of the tenant
42+
*
43+
* @see Stage.SessionFactory#withSession(Function)
44+
* @see Stage.SessionFactory#openSession(String)
45+
* @deprecated
46+
*/
47+
Stage.Session newSession(String tenantId);
48+
49+
/**
50+
* Obtain a {@link Stage.StatelessSession reactive stateless session}.
51+
* <p>
52+
* The underlying database connection is obtained lazily when
53+
* the returned {@link Stage.StatelessSession} needs to access the
54+
* database.
55+
* <p>
56+
* The client must explicitly close the session by calling
57+
* {@link Stage.StatelessSession#close()}.
58+
*
59+
* @see Stage.SessionFactory#openStatelessSession()
60+
* @see Stage.SessionFactory#withStatelessSession(Function)
61+
* @deprecated
62+
*/
63+
Stage.StatelessSession newStatelessSession();
64+
65+
/**
66+
* Obtain a {@link Stage.StatelessSession reactive stateless session}.
67+
* <p>
68+
* The underlying database connection is obtained lazily when
69+
* the returned {@link Stage.StatelessSession} needs to access the
70+
* database.
71+
* <p>
72+
* The client must explicitly close the session by calling
73+
* {@link Stage.StatelessSession#close()}.
74+
*
75+
* @param tenantId the id of the tenant
76+
*
77+
* @see Stage.SessionFactory#openStatelessSession(String
78+
* @see Stage.SessionFactory#withStatelessSession(String, Function)
79+
*/
80+
Stage.StatelessSession newStatelessSession(String tenantId);
81+
}

hibernate-reactive-core/src/main/java/org/hibernate/reactive/mutiny/Mutiny.java

+4-76
Original file line numberDiff line numberDiff line change
@@ -1527,7 +1527,7 @@ interface SessionFactory extends AutoCloseable {
15271527
*
15281528
* @see #withSession(Function)
15291529
*/
1530-
Uni<Session> newSession();
1530+
Uni<Session> openSession();
15311531

15321532
/**
15331533
* Obtain a new {@link Session reactive session} {@link Uni} for a
@@ -1542,7 +1542,7 @@ interface SessionFactory extends AutoCloseable {
15421542
*
15431543
* @see #withSession(Function)
15441544
*/
1545-
Uni<Session> newSession(String tenantId);
1545+
Uni<Session> openSession(String tenantId);
15461546

15471547
/**
15481548
* Obtain a {@link StatelessSession reactive stateless session}
@@ -1555,7 +1555,7 @@ interface SessionFactory extends AutoCloseable {
15551555
*
15561556
* @see #withStatelessSession(Function)
15571557
*/
1558-
Uni<StatelessSession> newStatelessSession();
1558+
Uni<StatelessSession> openStatelessSession();
15591559

15601560
/**
15611561
* Obtain a {@link StatelessSession reactive stateless session}
@@ -1570,80 +1570,8 @@ interface SessionFactory extends AutoCloseable {
15701570
*
15711571
* @see #withStatelessSession(String, Function)
15721572
*/
1573-
Uni<StatelessSession> newStatelessSession(String tenantId);
1573+
Uni<StatelessSession> openStatelessSession(String tenantId);
15741574

1575-
/**
1576-
* Obtain a new {@link Session reactive session}, the main
1577-
* interaction point between the user's program and Hibernate
1578-
* Reactive.
1579-
* <p>
1580-
* The underlying database connection is obtained lazily when
1581-
* the returned {@link Session} needs to access the database.
1582-
* <p>
1583-
* The client must explicitly close the session by calling
1584-
* {@link Session#close()}.
1585-
*
1586-
* @see #withSession(Function)
1587-
* @see #newSession()
1588-
* @deprecated It will be removed before the final
1589-
*/
1590-
@Deprecated
1591-
Session openSession();
1592-
1593-
/**
1594-
* Obtain a new {@link Session reactive session} for a
1595-
* specified tenant.
1596-
* <p>
1597-
* The underlying database connection is obtained lazily when
1598-
* the returned {@link Session} needs to access the database.
1599-
* <p>
1600-
* The client must explicitly close the session by calling
1601-
* {@link Session#close()}.
1602-
*
1603-
* @param tenantId the id of the tenant
1604-
*
1605-
* @see #withSession(String, Function)
1606-
* @see #newSession(String)
1607-
* @deprecated It will be removed before the final
1608-
*
1609-
*/
1610-
@Deprecated
1611-
Session openSession(String tenantId);
1612-
1613-
/**
1614-
* Obtain a {@link StatelessSession reactive stateless session}.
1615-
* <p>
1616-
* The underlying database connection is obtained lazily when
1617-
* the returned {@link StatelessSession} needs to access the
1618-
* database.
1619-
* <p>
1620-
* The client must explicitly close the session by calling
1621-
* {@link StatelessSession#close()}.
1622-
*
1623-
* @deprecated It will be removed before the final
1624-
* @see #newStatelessSession()
1625-
* @see #withStatelessSession(Function)
1626-
*/
1627-
@Deprecated
1628-
StatelessSession openStatelessSession();
1629-
1630-
/**
1631-
* Obtain a {@link StatelessSession reactive stateless session}.
1632-
* <p>
1633-
* The underlying database connection is obtained lazily when
1634-
* the returned {@link StatelessSession} needs to access the
1635-
* database.
1636-
* <p>
1637-
* The client must explicitly close the session by calling
1638-
* {@link StatelessSession#close()}.
1639-
*
1640-
* @param tenantId the id of the tenant
1641-
* @see #newStatelessSession(String)
1642-
* @see #withSession(String, Function)
1643-
* @deprecated Will be removed before the final
1644-
*/
1645-
@Deprecated
1646-
StatelessSession openStatelessSession(String tenantId);
16471575

16481576
/**
16491577
* Perform work using a {@link Session reactive session}.

hibernate-reactive-core/src/main/java/org/hibernate/reactive/mutiny/impl/MutinySessionFactoryImpl.java

+14-13
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.hibernate.internal.SessionCreationOptions;
1818
import org.hibernate.internal.SessionFactoryImpl;
1919
import org.hibernate.reactive.common.spi.Implementor;
20+
import org.hibernate.reactive.common.spi.MutinyImplementor;
2021
import org.hibernate.reactive.context.Context;
2122
import org.hibernate.reactive.context.impl.BaseKey;
2223
import org.hibernate.reactive.context.impl.MultitenantKey;
@@ -37,7 +38,7 @@
3738
* <p>
3839
* Obtained by calling {@link org.hibernate.SessionFactory#unwrap(Class)}.
3940
*/
40-
public class MutinySessionFactoryImpl implements Mutiny.SessionFactory, Implementor {
41+
public class MutinySessionFactoryImpl implements Mutiny.SessionFactory, Implementor, MutinyImplementor {
4142

4243
private final SessionFactoryImpl delegate;
4344
private final ReactiveConnectionPool connectionPool;
@@ -81,7 +82,7 @@ public Context getContext() {
8182
}
8283

8384
@Override
84-
public Mutiny.Session openSession() {
85+
public Mutiny.Session newSession() {
8586
SessionCreationOptions options = options();
8687
return new MutinySessionImpl(
8788
new ReactiveSessionImpl( delegate, options, proxyConnection( options.getTenantIdentifier() ) ),
@@ -90,7 +91,7 @@ public Mutiny.Session openSession() {
9091
}
9192

9293
@Override
93-
public Mutiny.Session openSession(String tenantId) {
94+
public Mutiny.Session newSession(String tenantId) {
9495
Objects.requireNonNull( tenantId, "parameter 'tenantId' is required" );
9596
return new MutinySessionImpl(
9697
new ReactiveSessionImpl( delegate, options( tenantId ), proxyConnection( tenantId ) ),
@@ -99,15 +100,15 @@ public Mutiny.Session openSession(String tenantId) {
99100
}
100101

101102
@Override
102-
public Uni<Mutiny.Session> newSession() {
103+
public Uni<Mutiny.Session> openSession() {
103104
SessionCreationOptions options = options();
104105
return uni( () -> connection( options.getTenantIdentifier() ) )
105106
.chain( reactiveConnection -> create( reactiveConnection, () -> new ReactiveSessionImpl( delegate, options, reactiveConnection ) ) )
106107
.map( s -> new MutinySessionImpl(s, this) );
107108
}
108109

109110
@Override
110-
public Uni<Mutiny.Session> newSession(String tenantId) {
111+
public Uni<Mutiny.Session> openSession(String tenantId) {
111112
return uni( () -> connection( tenantId ) )
112113
.chain( reactiveConnection -> create( reactiveConnection, () -> new ReactiveSessionImpl( delegate, options( tenantId ), reactiveConnection ) ) )
113114
.map( s -> new MutinySessionImpl(s, this) );
@@ -122,7 +123,7 @@ private <S> Uni<S> create(ReactiveConnection connection, Supplier<S> supplier) {
122123
}
123124

124125
@Override
125-
public Mutiny.StatelessSession openStatelessSession() {
126+
public Mutiny.StatelessSession newStatelessSession() {
126127
SessionCreationOptions options = options();
127128
return new MutinyStatelessSessionImpl(
128129
new ReactiveStatelessSessionImpl( delegate, options, proxyConnection( options.getTenantIdentifier() ) ),
@@ -131,23 +132,23 @@ public Mutiny.StatelessSession openStatelessSession() {
131132
}
132133

133134
@Override
134-
public Mutiny.StatelessSession openStatelessSession(String tenantId) {
135+
public Mutiny.StatelessSession newStatelessSession(String tenantId) {
135136
return new MutinyStatelessSessionImpl(
136137
new ReactiveStatelessSessionImpl( delegate, options( tenantId ), proxyConnection( tenantId ) ),
137138
this
138139
);
139140
}
140141

141142
@Override
142-
public Uni<Mutiny.StatelessSession> newStatelessSession() {
143+
public Uni<Mutiny.StatelessSession> openStatelessSession() {
143144
SessionCreationOptions options = options();
144145
return uni( () -> connection( options.getTenantIdentifier() ) )
145146
.chain( reactiveConnection -> create( reactiveConnection, () -> new ReactiveStatelessSessionImpl( delegate, options, reactiveConnection ) ) )
146147
.map( s -> new MutinyStatelessSessionImpl(s, this) );
147148
}
148149

149150
@Override
150-
public Uni<Mutiny.StatelessSession> newStatelessSession(String tenantId) {
151+
public Uni<Mutiny.StatelessSession> openStatelessSession(String tenantId) {
151152
return uni( () -> connection( tenantId ) )
152153
.chain( reactiveConnection -> create( reactiveConnection, () -> new ReactiveStatelessSessionImpl( delegate, options( tenantId ), reactiveConnection ) ) )
153154
.map( s -> new MutinyStatelessSessionImpl( s, this ) );
@@ -183,7 +184,7 @@ public <T> Uni<T> withSession(Function<Mutiny.Session, Uni<T>> work) {
183184
if ( current != null && current.isOpen() ) {
184185
return work.apply( current );
185186
}
186-
return withSession( newSession(), work, contextKeyForSession );
187+
return withSession( openSession(), work, contextKeyForSession );
187188
}
188189

189190
@Override
@@ -195,7 +196,7 @@ public <T> Uni<T> withSession(String tenantId, Function<Mutiny.Session, Uni<T>>
195196
if ( current!=null && current.isOpen() ) {
196197
return work.apply( current );
197198
}
198-
return withSession( newSession( tenantId ), work, key );
199+
return withSession( openSession( tenantId ), work, key );
199200
}
200201

201202
@Override
@@ -205,7 +206,7 @@ public <T> Uni<T> withStatelessSession(Function<Mutiny.StatelessSession, Uni<T>>
205206
if ( current != null && current.isOpen() ) {
206207
return work.apply( current );
207208
}
208-
return withSession( newStatelessSession(), work, contextKeyForStatelessSession );
209+
return withSession( openStatelessSession(), work, contextKeyForStatelessSession );
209210
}
210211

211212
@Override
@@ -217,7 +218,7 @@ public <T> Uni<T> withStatelessSession(String tenantId, Function<Mutiny.Stateles
217218
if ( current != null && current.isOpen() ) {
218219
return work.apply( current );
219220
}
220-
return withSession( newStatelessSession(tenantId), work, key );
221+
return withSession( openStatelessSession( tenantId), work, key );
221222
}
222223

223224
private<S extends Mutiny.Closeable, T> Uni<T> withSession(

0 commit comments

Comments
 (0)