This is an automated email from the ASF dual-hosted git repository. orpiske pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit 8035189c401bc382a3963ac2650f3237602ffcd1 Author: Otavio Rodolfo Piske <angusyo...@gmail.com> AuthorDate: Mon Apr 3 19:22:34 2023 +0200 CAMEL-15105: cleanup plugin initialization --- .../camel/impl/engine/AbstractCamelContext.java | 23 ++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java index 79795930364..9a8e3a00d70 100644 --- a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java +++ b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java @@ -333,6 +333,21 @@ public abstract class AbstractCamelContext extends BaseService this.internalServiceManager = new InternalServiceManager(this, internalRouteStartupManager, startupListeners); + initPlugins(); + + if (build) { + try { + build(); + } catch (Exception e) { + throw new RuntimeException("Error initializing CamelContext", e); + } + } + } + + /** + * Called during object construction to initialize context plugins + */ + protected void initPlugins() { camelContextExtension.addContextPlugin(CamelBeanPostProcessor.class, createBeanPostProcessor()); camelContextExtension.addContextPlugin(CamelDependencyInjectionAnnotationFactory.class, createDependencyInjectionAnnotationFactory()); @@ -369,14 +384,6 @@ public abstract class AbstractCamelContext extends BaseService camelContextExtension.lazyAddContextPlugin(DeferServiceFactory.class, this::createDeferServiceFactory); camelContextExtension.lazyAddContextPlugin(AnnotationBasedProcessorFactory.class, this::createAnnotationBasedProcessorFactory); - - if (build) { - try { - build(); - } catch (Exception e) { - throw new RuntimeException("Error initializing CamelContext", e); - } - } } protected static <T> T lookup(CamelContext context, String ref, Class<T> type) {