17
17
import io .quarkus .hibernate .orm .deployment .integration .QuarkusClassFileLocator ;
18
18
import io .quarkus .hibernate .orm .deployment .integration .QuarkusEnhancementContext ;
19
19
import net .bytebuddy .ClassFileVersion ;
20
- import net .bytebuddy .dynamic .ClassFileLocator ;
21
20
22
21
/**
23
22
* Used to transform bytecode by registering to
@@ -37,11 +36,15 @@ public final class HibernateEntityEnhancer implements BiFunction<String, ClassVi
37
36
ClassFileVersion .JAVA_V17 );
38
37
39
38
//Choose this set to include Jakarta annotations, basic Java types such as String and Map, Hibernate annotations, and Panache supertypes:
40
- private static final CoreTypePool CORE_POOL = new CoreTypePool ("jakarta.persistence." , "java." ,
39
+ private static final CoreTypePool CORE_POOL = new CoreTypePool (
40
+ "java." ,
41
+ "jakarta." ,
42
+ "org.hibernate.bytecode.enhance.spi." ,
43
+ "org.hibernate.engine.spi." ,
41
44
"org.hibernate.annotations." ,
42
- "io.quarkus.hibernate.reactive.panache." , "io.quarkus.hibernate.orm.panache." ,
43
- "org. hibernate.search.mapper.pojo.mapping.definition.annotation ." ,
44
- "jakarta.validation.constraints ." );
45
+ "io.quarkus.hibernate.reactive.panache." ,
46
+ "io.quarkus. hibernate.orm.panache ." ,
47
+ "org.hibernate.search.mapper.pojo.mapping.definition.annotation ." );
45
48
46
49
private final EnhancerHolder enhancerHolder = new EnhancerHolder ();
47
50
@@ -99,46 +102,14 @@ public Enhancer getEnhancer() {
99
102
if (actualEnhancer == null ) {
100
103
synchronized (this ) {
101
104
if (actualEnhancer == null ) {
102
- actualEnhancer = PROVIDER .getEnhancer (QuarkusEnhancementContext .INSTANCE , new ThreadsafeLocator ());
105
+ EnhancerClassLocator enhancerClassLocator = ModelTypePool
106
+ .buildModelTypePool (QuarkusClassFileLocator .INSTANCE , CORE_POOL );
107
+ actualEnhancer = PROVIDER .getEnhancer (QuarkusEnhancementContext .INSTANCE , enhancerClassLocator );
103
108
}
104
109
}
105
110
}
106
111
return actualEnhancer ;
107
112
}
108
113
}
109
114
110
- private static final class ThreadsafeLocator implements EnhancerClassLocator {
111
-
112
- final ThreadLocal <EnhancerClassLocator > localLocator = ThreadLocal
113
- .withInitial (() -> ModelTypePool .buildModelTypePool (QuarkusClassFileLocator .INSTANCE ,
114
- CORE_POOL ));
115
-
116
- @ Override
117
- public void registerClassNameAndBytes (String s , byte [] bytes ) {
118
- localLocator .get ().registerClassNameAndBytes (s , bytes );
119
- }
120
-
121
- @ Override
122
- public void deregisterClassNameAndBytes (String s ) {
123
- localLocator .get ().deregisterClassNameAndBytes (s );
124
- }
125
-
126
- @ Override
127
- public ClassFileLocator asClassFileLocator () {
128
- return localLocator .get ().asClassFileLocator ();
129
- }
130
-
131
- @ Override
132
- public Resolution describe (String s ) {
133
- return localLocator .get ().describe (s );
134
- }
135
-
136
- @ Override
137
- public void clear () {
138
- //not essential as it gets discarded, but could help:
139
- localLocator .get ().clear ();
140
- localLocator .remove ();
141
- }
142
- }
143
-
144
115
}
0 commit comments