66package org .hibernate .reactive .context .impl ;
77
88import java .lang .invoke .MethodHandles ;
9+ import java .util .concurrent .ConcurrentHashMap ;
10+ import java .util .concurrent .ConcurrentMap ;
911
1012import io .vertx .core .Vertx ;
1113import io .vertx .core .impl .ContextInternal ;
14+ import io .vertx .core .spi .context .storage .AccessMode ;
1215
1316import org .hibernate .reactive .context .Context ;
1417import org .hibernate .reactive .logging .impl .Log ;
1720import org .hibernate .service .spi .ServiceRegistryAwareService ;
1821import org .hibernate .service .spi .ServiceRegistryImplementor ;
1922
20- import static org .hibernate .reactive .context .impl .ContextualDataStorage .contextualDataMap ;
21-
2223/**
2324 * An adaptor for the Vert.x {@link io.vertx.core.Context}.
2425 *
@@ -41,7 +42,7 @@ public <T> void put(Key<T> key, T instance) {
4142 final ContextInternal context = ContextInternal .current ();
4243 if ( context != null ) {
4344 if ( trace ) LOG .tracef ( "Putting key,value in context: [%1$s, %2$s]" , key , instance );
44- ContextualDataStorage .<T >contextualDataMap ( context ).put ( key , instance );
45+ VertxContext .<T >contextualDataMap ( context ).put ( key , instance );
4546 }
4647 else {
4748 if ( trace ) LOG .tracef ( "Context is null for key,value: [%1$s, %2$s]" , key , instance );
@@ -53,7 +54,7 @@ public <T> void put(Key<T> key, T instance) {
5354 public <T > T get (Key <T > key ) {
5455 final ContextInternal context = ContextInternal .current ();
5556 if ( context != null ) {
56- T local = ContextualDataStorage .<T >contextualDataMap ( context ).get ( key );
57+ T local = VertxContext .<T >contextualDataMap ( context ).get ( key );
5758 if ( trace ) LOG .tracef ( "Getting value %2$s from context for key %1$s" , key , local );
5859 return local ;
5960 }
@@ -93,4 +94,13 @@ public void execute(Runnable runnable) {
9394 runnable .run ();
9495 }
9596 }
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+ }
96106}
0 commit comments