66package org .hibernate .reactive .context .impl ;
77
88import java .lang .invoke .MethodHandles ;
9- import java .util .concurrent .ConcurrentHashMap ;
10- import java .util .concurrent .ConcurrentMap ;
119
1210import io .vertx .core .Vertx ;
1311import io .vertx .core .impl .ContextInternal ;
14- import io .vertx .core .spi .context .storage .AccessMode ;
1512
1613import org .hibernate .reactive .context .Context ;
1714import org .hibernate .reactive .logging .impl .Log ;
2017import org .hibernate .service .spi .ServiceRegistryAwareService ;
2118import org .hibernate .service .spi .ServiceRegistryImplementor ;
2219
20+ import static org .hibernate .reactive .context .impl .ContextualDataStorage .contextualDataMap ;
21+
2322/**
2423 * An adaptor for the Vert.x {@link io.vertx.core.Context}.
2524 *
@@ -42,7 +41,7 @@ public <T> void put(Key<T> key, T instance) {
4241 final ContextInternal context = ContextInternal .current ();
4342 if ( context != null ) {
4443 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 );
4645 }
4746 else {
4847 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) {
5453 public <T > T get (Key <T > key ) {
5554 final ContextInternal context = ContextInternal .current ();
5655 if ( context != null ) {
57- T local = VertxContext .<T >contextualDataMap ( context ).get ( key );
56+ T local = ContextualDataStorage .<T >contextualDataMap ( context ).get ( key );
5857 if ( trace ) LOG .tracef ( "Getting value %2$s from context for key %1$s" , key , local );
5958 return local ;
6059 }
@@ -94,13 +93,4 @@ public void execute(Runnable runnable) {
9493 runnable .run ();
9594 }
9695 }
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- }
10696}
0 commit comments