27
27
28
28
import org .slf4j .Logger ;
29
29
import org .slf4j .LoggerFactory ;
30
+ import org .springframework .beans .factory .BeanClassLoaderAware ;
30
31
import org .springframework .jdbc .core .JdbcOperations ;
31
32
import org .springframework .jdbc .core .ResultSetExtractor ;
32
33
import org .springframework .jdbc .core .RowMapper ;
37
38
import org .springframework .modulith .events .core .PublicationTargetIdentifier ;
38
39
import org .springframework .transaction .annotation .Transactional ;
39
40
import org .springframework .util .Assert ;
41
+ import org .springframework .util .ClassUtils ;
40
42
41
43
/**
42
44
* JDBC-based repository to store {@link EventPublication}s.
45
47
* @author Björn Kieling
46
48
* @author Oliver Drotbohm
47
49
*/
48
- class JdbcEventPublicationRepository implements EventPublicationRepository {
50
+ class JdbcEventPublicationRepository implements EventPublicationRepository , BeanClassLoaderAware {
49
51
50
52
private static final Logger LOGGER = LoggerFactory .getLogger (JdbcEventPublicationRepository .class );
51
53
@@ -102,6 +104,7 @@ INSERT INTO EVENT_PUBLICATION (ID, EVENT_TYPE, LISTENER_ID, PUBLICATION_DATE, SE
102
104
private final JdbcOperations operations ;
103
105
private final EventSerializer serializer ;
104
106
private final DatabaseType databaseType ;
107
+ private ClassLoader classLoader ;
105
108
106
109
/**
107
110
* Creates a new {@link JdbcEventPublicationRepository} for the given {@link JdbcOperations}, {@link EventSerializer}
@@ -123,6 +126,15 @@ public JdbcEventPublicationRepository(JdbcOperations operations, EventSerializer
123
126
this .databaseType = databaseType ;
124
127
}
125
128
129
+ /*
130
+ * (non-Javadoc)
131
+ * @see org.springframework.beans.factory.BeanClassLoaderAware#setBeanClassLoader(java.lang.ClassLoader)
132
+ */
133
+ @ Override
134
+ public void setBeanClassLoader (ClassLoader classLoader ) {
135
+ this .classLoader = classLoader ;
136
+ }
137
+
126
138
/*
127
139
* (non-Javadoc)
128
140
* @see org.springframework.modulith.events.EventPublicationRepository#create(org.springframework.modulith.events.EventPublication)
@@ -270,7 +282,7 @@ private UUID getUuidFromResultSet(ResultSet rs) throws SQLException {
270
282
private Class <?> loadClass (UUID id , String className ) {
271
283
272
284
try {
273
- return Class .forName (className );
285
+ return ClassUtils .forName (className , classLoader );
274
286
} catch (ClassNotFoundException e ) {
275
287
LOGGER .warn ("Event '{}' of unknown type '{}' found" , id , className );
276
288
return null ;
0 commit comments