@@ -277,28 +277,52 @@ public <T> T getRepository(Class<T> repositoryInterface, RepositoryFragments fra
277
277
278
278
ApplicationStartup applicationStartup = getStartup ();
279
279
280
- StartupStep repositoryInit = applicationStartup .start ("spring.data.repository.init" );
281
- repositoryInit .tag ("repository" , () -> repositoryInterface .getName ());
280
+ StartupStep repositoryInit = onEvent (applicationStartup , "spring.data.repository.init" , repositoryInterface );
282
281
283
- StartupStep repositoryMetadataStep = applicationStartup .start ("spring.data.repository.metadata" );
282
+ repositoryBaseClass .ifPresent (it -> repositoryInit .tag ("baseClass" , it .getName ()));
283
+
284
+ StartupStep repositoryMetadataStep = onEvent (applicationStartup , "spring.data.repository.metadata" ,
285
+ repositoryInterface );
284
286
RepositoryMetadata metadata = getRepositoryMetadata (repositoryInterface );
285
287
repositoryMetadataStep .end ();
286
288
287
- StartupStep repositoryCompositionStep = applicationStartup .start ("spring.data.repository.composition" );
288
- repositoryCompositionStep .tag ("fragment.count" , () -> String .valueOf (fragments .size ()));
289
+ StartupStep repositoryCompositionStep = onEvent (applicationStartup , "spring.data.repository.composition" ,
290
+ repositoryInterface );
291
+ repositoryCompositionStep .tag ("fragment.count" , String .valueOf (fragments .size ()));
289
292
290
293
RepositoryComposition composition = getRepositoryComposition (metadata , fragments );
291
294
RepositoryInformation information = getRepositoryInformation (metadata , composition );
295
+
296
+ repositoryCompositionStep .tag ("fragments" , () -> {
297
+
298
+ StringBuilder fragmentsTag = new StringBuilder ();
299
+
300
+ for (RepositoryFragment <?> fragment : composition .getFragments ()) {
301
+
302
+ if (fragmentsTag .length () > 0 ) {
303
+ fragmentsTag .append (";" );
304
+ }
305
+
306
+ fragmentsTag .append (fragment .getSignatureContributor ().getName ());
307
+ fragmentsTag .append (fragment .getImplementation ().map (it -> ":" + it .getClass ().getName ()).orElse ("" ));
308
+ }
309
+
310
+ return fragmentsTag .toString ();
311
+ });
312
+
292
313
repositoryCompositionStep .end ();
293
314
294
315
validate (information , composition );
295
316
296
- StartupStep repositoryTargetStep = applicationStartup .start ("spring.data.repository.target" );
317
+ StartupStep repositoryTargetStep = onEvent (applicationStartup , "spring.data.repository.target" ,
318
+ repositoryInterface );
297
319
Object target = getTargetRepository (information );
320
+
321
+ repositoryTargetStep .tag ("target" , target .getClass ().getName ());
298
322
repositoryTargetStep .end ();
299
323
300
324
// Create proxy
301
- StartupStep repositoryProxyStep = applicationStartup . start ( "spring.data.repository.proxy" );
325
+ StartupStep repositoryProxyStep = onEvent ( applicationStartup , "spring.data.repository.proxy" , repositoryInterface );
302
326
ProxyFactory result = new ProxyFactory ();
303
327
result .setTarget (target );
304
328
result .setInterfaces (repositoryInterface , Repository .class , TransactionalProxy .class );
@@ -309,30 +333,33 @@ public <T> T getRepository(Class<T> repositoryInterface, RepositoryFragments fra
309
333
310
334
result .addAdvisor (ExposeInvocationInterceptor .ADVISOR );
311
335
312
- StartupStep repositoryPostprocessorsStep = applicationStartup .start ("spring.data.repository.postprocessors" );
313
- postProcessors .forEach (processor -> {
314
-
315
- StartupStep singlePostProcessor = applicationStartup .start ("spring.data.repository.postprocessor" );
316
- singlePostProcessor .tag ("type" , processor .getClass ().getName ());
317
- processor .postProcess (result , information );
318
- singlePostProcessor .end ();
319
- });
320
- repositoryPostprocessorsStep .end ();
336
+ if (!postProcessors .isEmpty ()) {
337
+ StartupStep repositoryPostprocessorsStep = onEvent (applicationStartup , "spring.data.repository.postprocessors" ,
338
+ repositoryInterface );
339
+ postProcessors .forEach (processor -> {
340
+
341
+ StartupStep singlePostProcessor = onEvent (applicationStartup , "spring.data.repository.postprocessor" ,
342
+ repositoryInterface );
343
+ singlePostProcessor .tag ("type" , processor .getClass ().getName ());
344
+ processor .postProcess (result , information );
345
+ singlePostProcessor .end ();
346
+ });
347
+ repositoryPostprocessorsStep .end ();
348
+ }
321
349
322
350
if (DefaultMethodInvokingMethodInterceptor .hasDefaultMethods (repositoryInterface )) {
323
351
result .addAdvice (new DefaultMethodInvokingMethodInterceptor ());
324
352
}
325
353
326
- StartupStep queryExecutorsStep = applicationStartup .start ("spring.data.repository.queryexecutors" );
327
354
ProjectionFactory projectionFactory = getProjectionFactory (classLoader , beanFactory );
328
355
Optional <QueryLookupStrategy > queryLookupStrategy = getQueryLookupStrategy (queryLookupStrategyKey ,
329
356
evaluationContextProvider );
330
357
result .addAdvice (new QueryExecutorMethodInterceptor (information , projectionFactory , queryLookupStrategy ,
331
358
namedQueries , queryPostProcessors , methodInvocationListeners ));
332
- queryExecutorsStep .end ();
333
359
334
- composition = composition .append (RepositoryFragment .implemented (target ));
335
- result .addAdvice (new ImplementationMethodExecutionInterceptor (information , composition , methodInvocationListeners ));
360
+ RepositoryComposition compositionToUse = composition .append (RepositoryFragment .implemented (target ));
361
+ result .addAdvice (
362
+ new ImplementationMethodExecutionInterceptor (information , compositionToUse , methodInvocationListeners ));
336
363
337
364
T repository = (T ) result .getProxy (classLoader );
338
365
repositoryProxyStep .end ();
@@ -346,19 +373,6 @@ public <T> T getRepository(Class<T> repositoryInterface, RepositoryFragments fra
346
373
return repository ;
347
374
}
348
375
349
- ApplicationStartup getStartup () {
350
-
351
- try {
352
-
353
- ApplicationStartup applicationStartup = beanFactory != null ? beanFactory .getBean (ApplicationStartup .class )
354
- : ApplicationStartup .DEFAULT ;
355
-
356
- return applicationStartup != null ? applicationStartup : ApplicationStartup .DEFAULT ;
357
- } catch (NoSuchBeanDefinitionException e ) {
358
- return ApplicationStartup .DEFAULT ;
359
- }
360
- }
361
-
362
376
/**
363
377
* Returns the {@link ProjectionFactory} to be used with the repository instances created.
364
378
*
@@ -540,6 +554,25 @@ protected final <R> R getTargetRepositoryViaReflection(Class<?> baseClass, Objec
540
554
baseClass , Arrays .stream (constructorArguments ).map (Object ::getClass ).collect (Collectors .toList ()))));
541
555
}
542
556
557
+ private ApplicationStartup getStartup () {
558
+
559
+ try {
560
+
561
+ ApplicationStartup applicationStartup = beanFactory != null ? beanFactory .getBean (ApplicationStartup .class )
562
+ : ApplicationStartup .DEFAULT ;
563
+
564
+ return applicationStartup != null ? applicationStartup : ApplicationStartup .DEFAULT ;
565
+ } catch (NoSuchBeanDefinitionException e ) {
566
+ return ApplicationStartup .DEFAULT ;
567
+ }
568
+ }
569
+
570
+ private StartupStep onEvent (ApplicationStartup applicationStartup , String name , Class <?> repositoryInterface ) {
571
+
572
+ StartupStep step = applicationStartup .start (name );
573
+ return step .tag ("repository" , repositoryInterface .getName ());
574
+ }
575
+
543
576
/**
544
577
* Method interceptor that calls methods on the {@link RepositoryComposition}.
545
578
*
0 commit comments