6
6
package org .hibernate .reactive .context .impl ;
7
7
8
8
import java .lang .invoke .MethodHandles ;
9
- import java .util .concurrent .ConcurrentHashMap ;
10
- import java .util .concurrent .ConcurrentMap ;
11
9
12
10
import io .vertx .core .Vertx ;
13
11
import io .vertx .core .impl .ContextInternal ;
14
- import io .vertx .core .spi .context .storage .AccessMode ;
15
12
16
13
import org .hibernate .reactive .context .Context ;
17
14
import org .hibernate .reactive .logging .impl .Log ;
20
17
import org .hibernate .service .spi .ServiceRegistryAwareService ;
21
18
import org .hibernate .service .spi .ServiceRegistryImplementor ;
22
19
20
+ import static org .hibernate .reactive .context .impl .ContextualDataStorage .contextualDataMap ;
21
+
23
22
/**
24
23
* An adaptor for the Vert.x {@link io.vertx.core.Context}.
25
24
*
@@ -42,7 +41,7 @@ public <T> void put(Key<T> key, T instance) {
42
41
final ContextInternal context = ContextInternal .current ();
43
42
if ( context != null ) {
44
43
if ( trace ) LOG .tracef ( "Putting key,value in context: [%1$s, %2$s]" , key , instance );
45
- VertxContext .<T >contextualDataMap ( context ).put ( key , instance );
44
+ ContextualDataStorage .<T >contextualDataMap ( context ).put ( key , instance );
46
45
}
47
46
else {
48
47
if ( trace ) LOG .tracef ( "Context is null for key,value: [%1$s, %2$s]" , key , instance );
@@ -54,7 +53,7 @@ public <T> void put(Key<T> key, T instance) {
54
53
public <T > T get (Key <T > key ) {
55
54
final ContextInternal context = ContextInternal .current ();
56
55
if ( context != null ) {
57
- T local = VertxContext .<T >contextualDataMap ( context ).get ( key );
56
+ T local = ContextualDataStorage .<T >contextualDataMap ( context ).get ( key );
58
57
if ( trace ) LOG .tracef ( "Getting value %2$s from context for key %1$s" , key , local );
59
58
return local ;
60
59
}
@@ -94,13 +93,4 @@ public void execute(Runnable runnable) {
94
93
runnable .run ();
95
94
}
96
95
}
97
-
98
- @ SuppressWarnings ({ "unchecked" })
99
- private static <T > ConcurrentMap <Key <T >, T > contextualDataMap (ContextInternal vertxContext ) {
100
- return vertxContext .getLocal (
101
- ContextualDataStorage .CONTEXTUAL_DATA_KEY ,
102
- AccessMode .CONCURRENT ,
103
- ConcurrentHashMap ::new
104
- );
105
- }
106
96
}
0 commit comments