You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2020/07/31 12:43:09 UTC

[camel] branch master updated: CAMEL-15312: Add ModelLifecycleStratey

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new 728e5c5  CAMEL-15312: Add ModelLifecycleStratey
728e5c5 is described below

commit 728e5c5f2176227291065c177069d56611b1224d
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Jul 31 14:08:20 2020 +0200

    CAMEL-15312: Add ModelLifecycleStratey
---
 .../docs/modules/eips/pages/dynamicRouter-eip.adoc |  4 +-
 .../org/apache/camel/impl/DefaultCamelContext.java | 11 ++++
 .../java/org/apache/camel/impl/DefaultModel.java   | 32 +++++++++-
 .../camel/impl/lw/LightweightCamelContext.java     | 11 ++++
 .../main/java/org/apache/camel/model/Model.java    | 14 +++++
 .../apache/camel/model/ModelLifecycleStrategy.java | 55 +++++++++++++++++
 .../camel/model/ModelLifecycleStrategySupport.java | 43 +++++++++++++
 .../core/xml/AbstractCamelContextFactoryBean.java  | 13 ++++
 .../camel/builder/RouteModelLifecycleTest.java     | 63 +++++++++++++++++++
 .../builder/RouteTemplateModelLifecycleTest.java   | 71 ++++++++++++++++++++++
 .../camel/main/DefaultConfigurationConfigurer.java |  5 ++
 11 files changed, 317 insertions(+), 5 deletions(-)

diff --git a/core/camel-core-engine/src/main/docs/modules/eips/pages/dynamicRouter-eip.adoc b/core/camel-core-engine/src/main/docs/modules/eips/pages/dynamicRouter-eip.adoc
index c404f5f..e5bc5ce 100644
--- a/core/camel-core-engine/src/main/docs/modules/eips/pages/dynamicRouter-eip.adoc
+++ b/core/camel-core-engine/src/main/docs/modules/eips/pages/dynamicRouter-eip.adoc
@@ -43,8 +43,8 @@ The Dynamic Router EIP supports 3 options which are listed below:
 |===
 | Name | Description | Default | Type
 | *uriDelimiter* | Sets the uri delimiter to use | , | String
-| *ignoreInvalidEndpoints* | Ignore the invalidate endpoint exception when try to create a producer with that endpoint | false | Boolean
-| *cacheSize* | Sets the maximum size used by the org.apache.camel.spi.ProducerCache which is used to cache and reuse producers when using this routing slip, when uris are reused. Beware that when using dynamic endpoints then it affects how well the cache can be utilized. If each dynamic endpoint is unique then its best to turn of caching by setting this to -1, which allows Camel to not cache both the producers and endpoints; they are regarded as prototype scoped and will be stopped and  [...]
+| *ignoreInvalidEndpoints* | Ignore the invalidate endpoint exception when try to create a producer with that endpoint |  | String
+| *cacheSize* | Sets the maximum size used by the org.apache.camel.spi.ProducerCache which is used to cache and reuse producers when using this dynamic router, when uris are reused. Beware that when using dynamic endpoints then it affects how well the cache can be utilized. If each dynamic endpoint is unique then its best to turn of caching by setting this to -1, which allows Camel to not cache both the producers and endpoints; they are regarded as prototype scoped and will be stopped an [...]
 |===
 // eip options: END
 
diff --git a/core/camel-core-engine/src/main/java/org/apache/camel/impl/DefaultCamelContext.java b/core/camel-core-engine/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
index e719a2e..f5fd679 100644
--- a/core/camel-core-engine/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
+++ b/core/camel-core-engine/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
@@ -39,6 +39,7 @@ import org.apache.camel.model.FaultToleranceConfigurationDefinition;
 import org.apache.camel.model.HystrixConfigurationDefinition;
 import org.apache.camel.model.Model;
 import org.apache.camel.model.ModelCamelContext;
+import org.apache.camel.model.ModelLifecycleStrategy;
 import org.apache.camel.model.ProcessorDefinition;
 import org.apache.camel.model.Resilience4jConfigurationDefinition;
 import org.apache.camel.model.RouteDefinition;
@@ -115,6 +116,16 @@ public class DefaultCamelContext extends SimpleCamelContext implements ModelCame
     }
 
     @Override
+    public void addModelLifecycleStrategy(ModelLifecycleStrategy modelLifecycleStrategy) {
+        model.addModelLifecycleStrategy(modelLifecycleStrategy);
+    }
+
+    @Override
+    public List<ModelLifecycleStrategy> getModelLifecycleStrategies() {
+        return model.getModelLifecycleStrategies();
+    }
+
+    @Override
     public List<RouteDefinition> getRouteDefinitions() {
         return model.getRouteDefinitions();
     }
diff --git a/core/camel-core-engine/src/main/java/org/apache/camel/impl/DefaultModel.java b/core/camel-core-engine/src/main/java/org/apache/camel/impl/DefaultModel.java
index bf433ba..72a300c 100644
--- a/core/camel-core-engine/src/main/java/org/apache/camel/impl/DefaultModel.java
+++ b/core/camel-core-engine/src/main/java/org/apache/camel/impl/DefaultModel.java
@@ -33,6 +33,7 @@ import org.apache.camel.model.FaultToleranceConfigurationDefinition;
 import org.apache.camel.model.HystrixConfigurationDefinition;
 import org.apache.camel.model.Model;
 import org.apache.camel.model.ModelCamelContext;
+import org.apache.camel.model.ModelLifecycleStrategy;
 import org.apache.camel.model.ProcessorDefinition;
 import org.apache.camel.model.ProcessorDefinitionHelper;
 import org.apache.camel.model.Resilience4jConfigurationDefinition;
@@ -50,6 +51,7 @@ public class DefaultModel implements Model {
 
     private final CamelContext camelContext;
 
+    private final List<ModelLifecycleStrategy> modelLifecycleStrategies = new ArrayList<>();
     private final List<RouteDefinition> routeDefinitions = new ArrayList<>();
     private final List<RouteTemplateDefinition> routeTemplateDefinitions = new ArrayList<>();
     private final List<RestDefinition> restDefinitions = new ArrayList<>();
@@ -71,6 +73,16 @@ public class DefaultModel implements Model {
     }
 
     @Override
+    public void addModelLifecycleStrategy(ModelLifecycleStrategy modelLifecycleStrategy) {
+        this.modelLifecycleStrategies.add(modelLifecycleStrategy);
+    }
+
+    @Override
+    public List<ModelLifecycleStrategy> getModelLifecycleStrategies() {
+        return modelLifecycleStrategies;
+    }
+
+    @Override
     public synchronized void addRouteDefinitions(Collection<RouteDefinition> routeDefinitions) throws Exception {
         if (routeDefinitions == null || routeDefinitions.isEmpty()) {
             return;
@@ -83,7 +95,10 @@ public class DefaultModel implements Model {
         });
 
         removeRouteDefinitions(list);
-        this.routeDefinitions.addAll(list);
+        list.forEach(r -> {
+            modelLifecycleStrategies.forEach(s -> s.onAddRouteDefinition(r));
+            this.routeDefinitions.add(r);
+        });
         if (shouldStartRoutes()) {
             getCamelContext().adapt(ModelCamelContext.class).startRouteDefinitions(list);
         }
@@ -111,6 +126,9 @@ public class DefaultModel implements Model {
             camelContext.removeRoute(id);
             toBeRemoved = getRouteDefinition(id);
         }
+        for (ModelLifecycleStrategy s : modelLifecycleStrategies) {
+            s.onRemoveRouteDefinition(toBeRemoved);
+        }
         this.routeDefinitions.remove(toBeRemoved);
     }
 
@@ -149,7 +167,10 @@ public class DefaultModel implements Model {
         if (routeTemplateDefinitions == null || routeTemplateDefinitions.isEmpty()) {
             return;
         }
-        this.routeTemplateDefinitions.addAll(routeTemplateDefinitions);
+        routeTemplateDefinitions.forEach(r -> {
+            modelLifecycleStrategies.forEach(s -> s.onAddRouteTemplateDefinition(r));
+            this.routeTemplateDefinitions.add(r);
+        });
     }
 
     @Override
@@ -159,11 +180,16 @@ public class DefaultModel implements Model {
 
     @Override
     public void removeRouteTemplateDefinitions(Collection<RouteTemplateDefinition> routeTemplateDefinitions) throws Exception {
-        routeTemplateDefinitions.removeAll(routeTemplateDefinitions);
+        for (RouteTemplateDefinition r : routeTemplateDefinitions) {
+            removeRouteTemplateDefinition(r);
+        }
     }
 
     @Override
     public void removeRouteTemplateDefinition(RouteTemplateDefinition routeTemplateDefinition) throws Exception {
+        for (ModelLifecycleStrategy s : modelLifecycleStrategies) {
+            s.onRemoveRouteTemplateDefinition(routeTemplateDefinition);
+        }
         routeTemplateDefinitions.remove(routeTemplateDefinition);
     }
 
diff --git a/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightCamelContext.java b/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightCamelContext.java
index 97bb0f383..fffc202 100644
--- a/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightCamelContext.java
+++ b/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightCamelContext.java
@@ -60,6 +60,7 @@ import org.apache.camel.model.DataFormatDefinition;
 import org.apache.camel.model.FaultToleranceConfigurationDefinition;
 import org.apache.camel.model.HystrixConfigurationDefinition;
 import org.apache.camel.model.ModelCamelContext;
+import org.apache.camel.model.ModelLifecycleStrategy;
 import org.apache.camel.model.ProcessorDefinition;
 import org.apache.camel.model.Resilience4jConfigurationDefinition;
 import org.apache.camel.model.RouteDefinition;
@@ -1469,6 +1470,16 @@ public class LightweightCamelContext implements ExtendedCamelContext, CatalogCam
     }
 
     @Override
+    public void addModelLifecycleStrategy(ModelLifecycleStrategy modelLifecycleStrategy) {
+        getModelCamelContext().addModelLifecycleStrategy(modelLifecycleStrategy);
+    }
+
+    @Override
+    public List<ModelLifecycleStrategy> getModelLifecycleStrategies() {
+        return getModelCamelContext().getModelLifecycleStrategies();
+    }
+
+    @Override
     public List<RouteDefinition> getRouteDefinitions() {
         return getModelCamelContext().getRouteDefinitions();
     }
diff --git a/core/camel-core-engine/src/main/java/org/apache/camel/model/Model.java b/core/camel-core-engine/src/main/java/org/apache/camel/model/Model.java
index 8dda92f..f558a33 100644
--- a/core/camel-core-engine/src/main/java/org/apache/camel/model/Model.java
+++ b/core/camel-core-engine/src/main/java/org/apache/camel/model/Model.java
@@ -34,6 +34,20 @@ import org.apache.camel.support.PatternHelper;
 public interface Model {
 
     /**
+     * Adds the given model lifecycle strategy to be used.
+     *
+     * @param modelLifecycleStrategy the strategy
+     */
+    void addModelLifecycleStrategy(ModelLifecycleStrategy modelLifecycleStrategy);
+
+    /**
+     * Returns the model lifecycle strategies used to handle lifecycle notifications
+     *
+     * @return the lifecycle strategies
+     */
+    List<ModelLifecycleStrategy> getModelLifecycleStrategies();
+
+    /**
      * Returns a list of the current route definitions
      *
      * @return list of the current route definitions
diff --git a/core/camel-core-engine/src/main/java/org/apache/camel/model/ModelLifecycleStrategy.java b/core/camel-core-engine/src/main/java/org/apache/camel/model/ModelLifecycleStrategy.java
new file mode 100644
index 0000000..c6c4d80
--- /dev/null
+++ b/core/camel-core-engine/src/main/java/org/apache/camel/model/ModelLifecycleStrategy.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.model;
+
+/**
+ * Strategy for model definitions notifications.
+ *
+ * A custom strategy must be added to {@link ModelCamelContext} before any routes or route templates are added.
+ * In other words add your custom strategy as early as possible.
+ */
+public interface ModelLifecycleStrategy {
+
+    /**
+     * Notification when a route definition is being added to {@link org.apache.camel.CamelContext}
+     *
+     * @param routeDefinition the route definition
+     */
+    void onAddRouteDefinition(RouteDefinition routeDefinition);
+
+    /**
+     * Notification when a route definition is being removed from {@link org.apache.camel.CamelContext}
+     *
+     * @param routeDefinition the route definition
+     */
+    void onRemoveRouteDefinition(RouteDefinition routeDefinition) throws Exception;
+
+    /**
+     * Notification when a route template definition is added to {@link org.apache.camel.CamelContext}
+     *
+     * @param routeTemplateDefinition the route template definition
+     */
+    void onAddRouteTemplateDefinition(RouteTemplateDefinition routeTemplateDefinition);
+
+    /**
+     * Notification when a route template definition is removed from {@link org.apache.camel.CamelContext}
+     *
+     * @param routeTemplateDefinition the route template definition
+     */
+    void onRemoveRouteTemplateDefinition(RouteTemplateDefinition routeTemplateDefinition);
+
+}
diff --git a/core/camel-core-engine/src/main/java/org/apache/camel/model/ModelLifecycleStrategySupport.java b/core/camel-core-engine/src/main/java/org/apache/camel/model/ModelLifecycleStrategySupport.java
new file mode 100644
index 0000000..dfab112
--- /dev/null
+++ b/core/camel-core-engine/src/main/java/org/apache/camel/model/ModelLifecycleStrategySupport.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.model;
+
+/**
+ * Base class for {@link ModelLifecycleStrategy}.
+ */
+public class ModelLifecycleStrategySupport implements ModelLifecycleStrategy {
+
+    @Override
+    public void onAddRouteDefinition(RouteDefinition routeDefinition) {
+        // noop
+    }
+
+    @Override
+    public void onRemoveRouteDefinition(RouteDefinition routeDefinition) throws Exception {
+        // noop
+    }
+
+    @Override
+    public void onAddRouteTemplateDefinition(RouteTemplateDefinition routeTemplateDefinition) {
+        // noop
+    }
+
+    @Override
+    public void onRemoveRouteTemplateDefinition(RouteTemplateDefinition routeTemplateDefinition) {
+        // noop
+    }
+}
diff --git a/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java b/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
index 30c00d2..0ca43f3 100644
--- a/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
+++ b/core/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
@@ -63,6 +63,7 @@ import org.apache.camel.model.InterceptDefinition;
 import org.apache.camel.model.InterceptFromDefinition;
 import org.apache.camel.model.InterceptSendToEndpointDefinition;
 import org.apache.camel.model.ModelCamelContext;
+import org.apache.camel.model.ModelLifecycleStrategy;
 import org.apache.camel.model.OnCompletionDefinition;
 import org.apache.camel.model.OnExceptionDefinition;
 import org.apache.camel.model.PackageScanDefinition;
@@ -332,6 +333,18 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex
                 }
             }
         }
+        // set the node lifecycle strategy if defined
+        Map<String, ModelLifecycleStrategy> modelLifecycleStrategies = getContext().getRegistry().findByTypeWithName(ModelLifecycleStrategy.class);
+        if (modelLifecycleStrategies != null && !modelLifecycleStrategies.isEmpty()) {
+            for (Entry<String, ModelLifecycleStrategy> entry : modelLifecycleStrategies.entrySet()) {
+                ModelLifecycleStrategy strategy = entry.getValue();
+                ModelCamelContext mcc = getContext().adapt(ModelCamelContext.class);
+                if (!mcc.getModelLifecycleStrategies().contains(strategy)) {
+                    LOG.info("Using custom ModelLifecycleStrategy with id: {} and implementation: {}", entry.getKey(), strategy);
+                    mcc.addModelLifecycleStrategy(strategy);
+                }
+            }
+        }
         // cluster service
         Map<String, CamelClusterService> clusterServices = getContext().getRegistry().findByTypeWithName(CamelClusterService.class);
         if (clusterServices != null && !clusterServices.isEmpty()) {
diff --git a/core/camel-core/src/test/java/org/apache/camel/builder/RouteModelLifecycleTest.java b/core/camel-core/src/test/java/org/apache/camel/builder/RouteModelLifecycleTest.java
new file mode 100644
index 0000000..20acfd2
--- /dev/null
+++ b/core/camel-core/src/test/java/org/apache/camel/builder/RouteModelLifecycleTest.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.builder;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.model.ModelCamelContext;
+import org.apache.camel.model.ModelLifecycleStrategySupport;
+import org.apache.camel.model.RouteDefinition;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class RouteModelLifecycleTest extends ContextTestSupport {
+
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    @Test
+    public void testModelLifecycle() throws Exception {
+        // add lifecycle before we add routes
+        context.adapt(ModelCamelContext.class).addModelLifecycleStrategy(new ModelLifecycleStrategySupport() {
+            @Override
+            public void onAddRouteDefinition(RouteDefinition route) {
+                // lets mutate the template a bit
+                route.getInput().setUri("direct:two");
+            }
+        });
+
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:one")
+                    .to("mock:result");
+            }
+        });
+
+        context.start();
+
+        Assertions.assertEquals(1, context.getRoutes().size());
+
+        getMockEndpoint("mock:result").expectedMessageCount(1);
+        template.sendBody("direct:two", "Hello World");
+        assertMockEndpointsSatisfied();
+
+        context.stop();
+    }
+
+}
diff --git a/core/camel-core/src/test/java/org/apache/camel/builder/RouteTemplateModelLifecycleTest.java b/core/camel-core/src/test/java/org/apache/camel/builder/RouteTemplateModelLifecycleTest.java
new file mode 100644
index 0000000..49fc602
--- /dev/null
+++ b/core/camel-core/src/test/java/org/apache/camel/builder/RouteTemplateModelLifecycleTest.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.builder;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.RouteTemplateParameterBuilder;
+import org.apache.camel.model.ModelCamelContext;
+import org.apache.camel.model.ModelLifecycleStrategySupport;
+import org.apache.camel.model.RouteTemplateDefinition;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class RouteTemplateModelLifecycleTest extends ContextTestSupport {
+
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    @Test
+    public void testModelLifecycle() throws Exception {
+        // add lifecycle before we add routes
+        context.adapt(ModelCamelContext.class).addModelLifecycleStrategy(new ModelLifecycleStrategySupport() {
+            @Override
+            public void onAddRouteTemplateDefinition(RouteTemplateDefinition template) {
+                // lets mutate the template a bit
+                template.getRoute().getInput().setUri("seda:{{foo}}");
+            }
+        });
+
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                routeTemplate("myTemplate").templateParameter("foo").templateParameter("bar")
+                        .from("direct:{{foo}}")
+                        .to("mock:{{bar}}");
+            }
+        });
+
+        new RouteTemplateParameterBuilder(context, "myTemplate")
+            .parameter("foo", "one")
+            .parameter("bar", "result")
+            .routeId("myRoute")
+            .build();
+
+        context.start();
+
+        Assertions.assertEquals(1, context.getRoutes().size());
+
+        getMockEndpoint("mock:result").expectedMessageCount(1);
+        template.sendBody("seda:one", "Hello World");
+        assertMockEndpointsSatisfied();
+
+        context.stop();
+    }
+
+}
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationConfigurer.java b/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationConfigurer.java
index 7cb17af..34015fa 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationConfigurer.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationConfigurer.java
@@ -31,6 +31,8 @@ import org.apache.camel.cluster.CamelClusterService;
 import org.apache.camel.health.HealthCheckRegistry;
 import org.apache.camel.health.HealthCheckRepository;
 import org.apache.camel.model.Model;
+import org.apache.camel.model.ModelCamelContext;
+import org.apache.camel.model.ModelLifecycleStrategy;
 import org.apache.camel.processor.interceptor.BacklogTracer;
 import org.apache.camel.spi.AsyncProcessorAwaitManager;
 import org.apache.camel.spi.ClassResolver;
@@ -341,6 +343,9 @@ public final class DefaultConfigurationConfigurer {
         registerPropertiesForBeanTypesWithCondition(registry, LifecycleStrategy.class, containsLifecycleStrategy.negate(), camelContext::addLifecycleStrategy);
         final Predicate<LogListener> containsLogListener = camelContext.adapt(ExtendedCamelContext.class).getLogListeners()::contains;
         registerPropertiesForBeanTypesWithCondition(registry, LogListener.class, containsLogListener.negate(), camelContext.adapt(ExtendedCamelContext.class)::addLogListener);
+        ModelCamelContext mcc = camelContext.adapt(ModelCamelContext.class);
+        final Predicate<ModelLifecycleStrategy> containsModelLifecycleStrategy = mcc.getModelLifecycleStrategies()::contains;
+        registerPropertiesForBeanTypesWithCondition(registry, ModelLifecycleStrategy.class, containsModelLifecycleStrategy.negate(), mcc::addModelLifecycleStrategy);
 
         // service registry
         Map<String, ServiceRegistry> serviceRegistries = registry.findByTypeWithName(ServiceRegistry.class);