gnodet-bot commented on code in PR #28496:
URL: https://github.com/apache/camel/pull/28496#discussion_r4412675166
##########
components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaHelper.java:
##########
@@ -83,6 +88,34 @@ public static EntityManager getTargetEntityManager(
return em;
}
+ /**
+ * Gets the {@link TransactionStrategy} to use when none has been
configured: the single {@link TransactionStrategy}
+ * in the registry if there is one and autowiring is enabled, otherwise a
new {@link DefaultTransactionStrategy} (a
+ * WARN is logged when the registry has more than one).
+ *
+ * @param camelContext the camel context, or <tt>null</tt> if not
available (then the registry is not used)
+ * @param entityManagerFactory the entity manager factory
+ * @param autowiredEnabled whether autowiring is enabled (otherwise
the registry is not used)
+ * @return the transaction strategy (is never null)
+ */
+ public static TransactionStrategy resolveTransactionStrategy(
+ CamelContext camelContext, EntityManagerFactory
entityManagerFactory, boolean autowiredEnabled) {
+ if (camelContext != null && autowiredEnabled) {
+ TransactionStrategy strategy =
camelContext.getRegistry().findSingleByType(TransactionStrategy.class);
+ if (strategy != null) {
+ LOG.info("Using TransactionStrategy found in registry: {}",
strategy);
+ return strategy;
Review Comment:
🔧 **Nit (still open from previous review):** `LOG.info` for registry
discovery should be `LOG.debug`. This fires at component/endpoint startup —
Camel's convention for internal autowiring resolution is `DEBUG` (cf.
`DefaultCamelContextExtension.autowireProperties`). `INFO` here will appear in
every application that registers a `TransactionStrategy` bean.
```suggestion
LOG.debug("Using TransactionStrategy found in registry: {}",
strategy);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]