Skip to content

Commit 4bdd92c

Browse files
jxblumchristophstrobl
authored andcommitted
Add more StartupSteps to ApplicationStartup (JFR).
Adds a StartupStep for the creation of the target SD module Repository object (e.g. SD JPA). This could vary significantly from 1 SD module to another. Adds a StartupStep for the creation of the SD Repository Proxy. Renames the StartupStep wrapping the Repository composition logic to 'spring.data.repository.composition'. Moves the construction/initialization of the ApplicationStartup instance after the assertions in the getRepository(..) method.
1 parent d183ddf commit 4bdd92c

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/main/java/org/springframework/data/repository/core/support/RepositoryFactorySupport.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -274,27 +274,30 @@ public <T> T getRepository(Class<T> repositoryInterface, RepositoryFragments fra
274274
logger.debug(LogMessage.format("Initializing repository instance for %s…", repositoryInterface.getName()));
275275
}
276276

277-
ApplicationStartup applicationStartup = getStartup();
278-
279277
Assert.notNull(repositoryInterface, "Repository interface must not be null!");
280278
Assert.notNull(fragments, "RepositoryFragments must not be null!");
281279

280+
ApplicationStartup applicationStartup = getStartup();
281+
282282
StartupStep repositoryInit = applicationStartup.start("spring.data.repository.init");
283283

284284
StartupStep repositoryMetadataStep = applicationStartup.start("spring.data.repository.metadata");
285285
RepositoryMetadata metadata = getRepositoryMetadata(repositoryInterface);
286286
repositoryMetadataStep.end();
287287

288-
StartupStep repositoryCompositionStep = applicationStartup.start("spring.data.repository.metadata");
288+
StartupStep repositoryCompositionStep = applicationStartup.start("spring.data.repository.composition");
289289
RepositoryComposition composition = getRepositoryComposition(metadata, fragments);
290290
RepositoryInformation information = getRepositoryInformation(metadata, composition);
291291
repositoryCompositionStep.end();
292292

293293
validate(information, composition);
294294

295+
StartupStep repositoryTargetStep = applicationStartup.start("spring.data.repository.target");
295296
Object target = getTargetRepository(information);
297+
repositoryTargetStep.end();
296298

297299
// Create proxy
300+
StartupStep repositoryProxyStep = applicationStartup.start("spring.data.repository.proxy");
298301
ProxyFactory result = new ProxyFactory();
299302
result.setTarget(target);
300303
result.setInterfaces(repositoryInterface, Repository.class, TransactionalProxy.class);
@@ -323,10 +326,11 @@ public <T> T getRepository(Class<T> repositoryInterface, RepositoryFragments fra
323326
result.addAdvice(new ImplementationMethodExecutionInterceptor(information, composition, methodInvocationListeners));
324327

325328
T repository = (T) result.getProxy(classLoader);
329+
repositoryProxyStep.end();
326330

327331
if (logger.isDebugEnabled()) {
328-
logger
329-
.debug(LogMessage.format("Finished creation of repository instance for {}.", repositoryInterface.getName()));
332+
logger.debug(LogMessage.format("Finished creation of repository instance for {}.",
333+
repositoryInterface.getName()));
330334
}
331335

332336
repositoryInit.end();
@@ -336,7 +340,11 @@ public <T> T getRepository(Class<T> repositoryInterface, RepositoryFragments fra
336340
ApplicationStartup getStartup() {
337341

338342
try {
339-
ApplicationStartup applicationStartup = beanFactory != null ? beanFactory.getBean(ApplicationStartup.class) : ApplicationStartup.DEFAULT;
343+
344+
ApplicationStartup applicationStartup = beanFactory != null
345+
? beanFactory.getBean(ApplicationStartup.class)
346+
: ApplicationStartup.DEFAULT;
347+
340348
return applicationStartup != null ? applicationStartup : ApplicationStartup.DEFAULT;
341349
}
342350
catch (NoSuchBeanDefinitionException e) {

0 commit comments

Comments
 (0)