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


The following commit(s) were added to refs/heads/main by this push:
     new 82a29254688 (chores): remove lightweight Camel support
82a29254688 is described below

commit 82a2925468862a6d1ae3d24e38945b6686b1eeb6
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Tue Apr 25 15:28:01 2023 +0200

    (chores): remove lightweight Camel support
    
    This is a bit different than the LightweightContext (removed as part of
    CAMEL-19292). This was related to an special mode that cleaned up some
    references after Camel finished booting
---
 .../org/apache/camel/ExtendedCamelContext.java     |  12 --
 .../camel/impl/engine/AbstractCamelContext.java    |  13 --
 .../impl/engine/DefaultCamelContextExtension.java  |  11 --
 .../camel/impl/ExtendedCamelContextConfigurer.java |   6 -
 .../org/apache/camel/impl/DefaultCamelContext.java | 195 +--------------------
 .../camel/main/DefaultConfigurationConfigurer.java |   1 -
 .../apache/camel/main/MainBootstrapCloseable.java  |  28 ---
 .../java/org/apache/camel/main/MainSupport.java    |   2 +-
 8 files changed, 9 insertions(+), 259 deletions(-)

diff --git 
a/core/camel-api/src/main/java/org/apache/camel/ExtendedCamelContext.java 
b/core/camel-api/src/main/java/org/apache/camel/ExtendedCamelContext.java
index 375b41825fc..27b39b61576 100644
--- a/core/camel-api/src/main/java/org/apache/camel/ExtendedCamelContext.java
+++ b/core/camel-api/src/main/java/org/apache/camel/ExtendedCamelContext.java
@@ -414,18 +414,6 @@ public interface ExtendedCamelContext {
      */
     Processor createErrorHandler(Route route, Processor processor) throws 
Exception;
 
-    /**
-     * Whether to run in lightweight mode which triggers some optimizations 
and memory reduction. Danger this causes
-     * Camel to be less dynamic such as adding new route after Camel is 
started would not be possible.
-     */
-    boolean isLightweight();
-
-    /**
-     * Whether to run in lightweight mode which triggers some optimizations 
and memory reduction. Danger this causes
-     * Camel to be less dynamic such as adding new route after Camel is 
started would not be possible.
-     */
-    void setLightweight(boolean lightweight);
-
     /**
      * Danger!!! This will dispose the route model from the {@link 
CamelContext} which is used for lightweight mode.
      * This means afterwards no new routes can be dynamically added. Any 
operations on the
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 2aa03445e97..a04a7f28df4 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
@@ -2501,11 +2501,6 @@ public abstract class AbstractCamelContext extends 
BaseService
                     "Pooled mode enabled. Camel pools and reuses objects to 
reduce JVM object allocations. The pool capacity is: {} elements.",
                     camelContextExtension.getExchangeFactory().getCapacity());
         }
-        if (camelContextExtension.isLightweight()) {
-            LOG.info("Lightweight mode enabled. Performing optimizations and 
memory reduction.");
-            ReifierStrategy.clearReifiers();
-            disposeModel();
-        }
     }
 
     protected void logDuplicateComponents() {
@@ -4124,14 +4119,6 @@ public abstract class AbstractCamelContext extends 
BaseService
         }
     }
 
-    public boolean isLightweight() {
-        return camelContextExtension.isLightweight();
-    }
-
-    public void setLightweight(boolean lightweight) {
-        camelContextExtension.setLightweight(lightweight);
-    }
-
     public String resolvePropertyPlaceholders(String text, boolean 
keepUnresolvedOptional) {
         return camelContextExtension.resolvePropertyPlaceholders(text, 
keepUnresolvedOptional);
     }
diff --git 
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultCamelContextExtension.java
 
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultCamelContextExtension.java
index dc728c9faec..5d37f197259 100644
--- 
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultCamelContextExtension.java
+++ 
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultCamelContextExtension.java
@@ -97,7 +97,6 @@ class DefaultCamelContextExtension implements 
ExtendedCamelContext {
     @Deprecated
     private ErrorHandlerFactory errorHandlerFactory;
     private String basePackageScan;
-    private boolean lightweight;
 
     private final Object lock = new Object();
 
@@ -425,16 +424,6 @@ class DefaultCamelContextExtension implements 
ExtendedCamelContext {
         this.basePackageScan = basePackageScan;
     }
 
-    @Override
-    public boolean isLightweight() {
-        return lightweight;
-    }
-
-    @Override
-    public void setLightweight(boolean lightweight) {
-        this.lightweight = lightweight;
-    }
-
     @Override
     public HeadersMapFactory getHeadersMapFactory() {
         return headersMapFactory;
diff --git 
a/core/camel-core-engine/src/generated/java/org/apache/camel/impl/ExtendedCamelContextConfigurer.java
 
b/core/camel-core-engine/src/generated/java/org/apache/camel/impl/ExtendedCamelContextConfigurer.java
index 91e4bd7b0f2..f1074957424 100644
--- 
a/core/camel-core-engine/src/generated/java/org/apache/camel/impl/ExtendedCamelContextConfigurer.java
+++ 
b/core/camel-core-engine/src/generated/java/org/apache/camel/impl/ExtendedCamelContextConfigurer.java
@@ -37,8 +37,6 @@ public class ExtendedCamelContextConfigurer extends 
org.apache.camel.support.com
         case "ExchangeFactoryManager": 
target.setExchangeFactoryManager(property(camelContext, 
org.apache.camel.spi.ExchangeFactoryManager.class, value)); return true;
         case "headersmapfactory":
         case "HeadersMapFactory": 
target.setHeadersMapFactory(property(camelContext, 
org.apache.camel.spi.HeadersMapFactory.class, value)); return true;
-        case "lightweight":
-        case "Lightweight": target.setLightweight(property(camelContext, 
boolean.class, value)); return true;
         case "name":
         case "Name": target.setName(property(camelContext, 
java.lang.String.class, value)); return true;
         case "processorexchangefactory":
@@ -72,8 +70,6 @@ public class ExtendedCamelContextConfigurer extends 
org.apache.camel.support.com
         case "ExchangeFactoryManager": return 
org.apache.camel.spi.ExchangeFactoryManager.class;
         case "headersmapfactory":
         case "HeadersMapFactory": return 
org.apache.camel.spi.HeadersMapFactory.class;
-        case "lightweight":
-        case "Lightweight": return boolean.class;
         case "name":
         case "Name": return java.lang.String.class;
         case "processorexchangefactory":
@@ -108,8 +104,6 @@ public class ExtendedCamelContextConfigurer extends 
org.apache.camel.support.com
         case "ExchangeFactoryManager": return 
target.getExchangeFactoryManager();
         case "headersmapfactory":
         case "HeadersMapFactory": return target.getHeadersMapFactory();
-        case "lightweight":
-        case "Lightweight": return target.isLightweight();
         case "name":
         case "Name": return target.getName();
         case "processorexchangefactory":
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 76714f28ff1..4e5217c4b45 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
@@ -287,97 +287,61 @@ public class DefaultCamelContext extends 
SimpleCamelContext implements ModelCame
 
     @Override
     public void addModelLifecycleStrategy(ModelLifecycleStrategy 
modelLifecycleStrategy) {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         model.addModelLifecycleStrategy(modelLifecycleStrategy);
     }
 
     @Override
     public List<ModelLifecycleStrategy> getModelLifecycleStrategies() {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         return model.getModelLifecycleStrategies();
     }
 
     @Override
     public void addRouteConfiguration(RouteConfigurationDefinition 
routesConfiguration) {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         model.addRouteConfiguration(routesConfiguration);
     }
 
     @Override
     public void addRouteConfigurations(List<RouteConfigurationDefinition> 
routesConfigurations) {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         model.addRouteConfigurations(routesConfigurations);
     }
 
     @Override
     public List<RouteConfigurationDefinition> 
getRouteConfigurationDefinitions() {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         return model.getRouteConfigurationDefinitions();
     }
 
     @Override
     public RouteConfigurationDefinition getRouteConfigurationDefinition(String 
id) {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         return model.getRouteConfigurationDefinition(id);
     }
 
     @Override
     public void removeRouteConfiguration(RouteConfigurationDefinition 
routeConfigurationDefinition) throws Exception {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         model.removeRouteConfiguration(routeConfigurationDefinition);
     }
 
     @Override
     public List<RouteDefinition> getRouteDefinitions() {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         return model.getRouteDefinitions();
     }
 
     @Override
     public RouteDefinition getRouteDefinition(String id) {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         return model.getRouteDefinition(id);
     }
 
     @Override
     public void addRouteDefinitions(Collection<RouteDefinition> 
routeDefinitions) throws Exception {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         model.addRouteDefinitions(routeDefinitions);
     }
 
     @Override
     public void addRouteDefinition(RouteDefinition routeDefinition) throws 
Exception {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         model.addRouteDefinition(routeDefinition);
     }
 
     @Override
     public void removeRouteDefinitions(Collection<RouteDefinition> 
routeDefinitions) throws Exception {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         if (!isLockModel()) {
             model.removeRouteDefinitions(routeDefinitions);
         }
@@ -385,9 +349,6 @@ public class DefaultCamelContext extends SimpleCamelContext 
implements ModelCame
 
     @Override
     public void removeRouteDefinition(RouteDefinition routeDefinition) throws 
Exception {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         if (!isLockModel()) {
             model.removeRouteDefinition(routeDefinition);
         }
@@ -395,41 +356,28 @@ public class DefaultCamelContext extends 
SimpleCamelContext implements ModelCame
 
     @Override
     public List<RouteTemplateDefinition> getRouteTemplateDefinitions() {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         return model.getRouteTemplateDefinitions();
     }
 
     @Override
     public RouteTemplateDefinition getRouteTemplateDefinition(String id) {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         return model.getRouteTemplateDefinition(id);
     }
 
     @Override
     public void 
addRouteTemplateDefinitions(Collection<RouteTemplateDefinition> 
routeTemplateDefinitions) throws Exception {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         model.addRouteTemplateDefinitions(routeTemplateDefinitions);
     }
 
     @Override
     public void addRouteTemplateDefinition(RouteTemplateDefinition 
routeTemplateDefinition) throws Exception {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
+
         model.addRouteTemplateDefinition(routeTemplateDefinition);
     }
 
     @Override
     public void 
removeRouteTemplateDefinitions(Collection<RouteTemplateDefinition> 
routeTemplateDefinitions) throws Exception {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
+
         if (!isLockModel()) {
             model.removeRouteTemplateDefinitions(routeTemplateDefinitions);
         }
@@ -437,9 +385,6 @@ public class DefaultCamelContext extends SimpleCamelContext 
implements ModelCame
 
     @Override
     public void removeRouteTemplateDefinition(RouteTemplateDefinition 
routeTemplateDefinition) throws Exception {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         if (!isLockModel()) {
             model.removeRouteTemplateDefinition(routeTemplateDefinition);
         }
@@ -447,9 +392,6 @@ public class DefaultCamelContext extends SimpleCamelContext 
implements ModelCame
 
     @Override
     public void removeRouteTemplateDefinitions(String pattern) throws 
Exception {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         if (!isLockModel()) {
             model.removeRouteTemplateDefinitions(pattern);
         }
@@ -457,27 +399,21 @@ public class DefaultCamelContext extends 
SimpleCamelContext implements ModelCame
 
     @Override
     public void addRouteTemplateDefinitionConverter(String templateIdPattern, 
RouteTemplateDefinition.Converter converter) {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
+
         model.addRouteTemplateDefinitionConverter(templateIdPattern, 
converter);
     }
 
     @Override
     public String addRouteFromTemplate(String routeId, String routeTemplateId, 
Map<String, Object> parameters)
             throws Exception {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
+
         return model.addRouteFromTemplate(routeId, routeTemplateId, 
parameters);
     }
 
     @Override
     public String addRouteFromTemplate(String routeId, String routeTemplateId, 
String prefixId, Map<String, Object> parameters)
             throws Exception {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
+
         return model.addRouteFromTemplate(routeId, routeTemplateId, prefixId, 
parameters);
     }
 
@@ -485,26 +421,20 @@ public class DefaultCamelContext extends 
SimpleCamelContext implements ModelCame
     public String addRouteFromTemplate(
             String routeId, String routeTemplateId, String prefixId, 
RouteTemplateContext routeTemplateContext)
             throws Exception {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
+
         return model.addRouteFromTemplate(routeId, routeTemplateId, prefixId, 
routeTemplateContext);
     }
 
     @Override
     public void addRouteFromTemplatedRoute(TemplatedRouteDefinition 
templatedRouteDefinition)
             throws Exception {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
+
         model.addRouteFromTemplatedRoute(templatedRouteDefinition);
     }
 
     @Override
     public void removeRouteTemplates(String pattern) throws Exception {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
+
         if (!isLockModel()) {
             model.removeRouteTemplateDefinitions(pattern);
         }
@@ -512,225 +442,141 @@ public class DefaultCamelContext extends 
SimpleCamelContext implements ModelCame
 
     @Override
     public List<RestDefinition> getRestDefinitions() {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         return model.getRestDefinitions();
     }
 
     @Override
     public void addRestDefinitions(Collection<RestDefinition> restDefinitions, 
boolean addToRoutes) throws Exception {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         model.addRestDefinitions(restDefinitions, addToRoutes);
     }
 
     @Override
     public void setDataFormats(Map<String, DataFormatDefinition> dataFormats) {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         model.setDataFormats(dataFormats);
     }
 
     @Override
     public Map<String, DataFormatDefinition> getDataFormats() {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         return model.getDataFormats();
     }
 
     @Override
     public DataFormatDefinition resolveDataFormatDefinition(String name) {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         return model.resolveDataFormatDefinition(name);
     }
 
     @Override
     public ProcessorDefinition<?> getProcessorDefinition(String id) {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         return model.getProcessorDefinition(id);
     }
 
     @Override
     public <T extends ProcessorDefinition<T>> T getProcessorDefinition(String 
id, Class<T> type) {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         return model.getProcessorDefinition(id, type);
     }
 
     @Override
     public void setValidators(List<ValidatorDefinition> validators) {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         model.setValidators(validators);
     }
 
     @Override
     public Resilience4jConfigurationDefinition 
getResilience4jConfiguration(String id) {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         return model.getResilience4jConfiguration(id);
     }
 
     @Override
     public void 
setResilience4jConfiguration(Resilience4jConfigurationDefinition configuration) 
{
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         model.setResilience4jConfiguration(configuration);
     }
 
     @Override
     public void 
setResilience4jConfigurations(List<Resilience4jConfigurationDefinition> 
configurations) {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         model.setResilience4jConfigurations(configurations);
     }
 
     @Override
     public void addResilience4jConfiguration(String id, 
Resilience4jConfigurationDefinition configuration) {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         model.addResilience4jConfiguration(id, configuration);
     }
 
     @Override
     public FaultToleranceConfigurationDefinition 
getFaultToleranceConfiguration(String id) {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         return model.getFaultToleranceConfiguration(id);
     }
 
     @Override
     public void 
setFaultToleranceConfiguration(FaultToleranceConfigurationDefinition 
configuration) {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         model.setFaultToleranceConfiguration(configuration);
     }
 
     @Override
     public void 
setFaultToleranceConfigurations(List<FaultToleranceConfigurationDefinition> 
configurations) {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         model.setFaultToleranceConfigurations(configurations);
     }
 
     @Override
     public void addFaultToleranceConfiguration(String id, 
FaultToleranceConfigurationDefinition configuration) {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         model.addFaultToleranceConfiguration(id, configuration);
     }
 
     @Override
     public List<ValidatorDefinition> getValidators() {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         return model.getValidators();
     }
 
     @Override
     public void setTransformers(List<TransformerDefinition> transformers) {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         model.setTransformers(transformers);
     }
 
     @Override
     public List<TransformerDefinition> getTransformers() {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         return model.getTransformers();
     }
 
     @Override
     public ServiceCallConfigurationDefinition 
getServiceCallConfiguration(String serviceName) {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         return model.getServiceCallConfiguration(serviceName);
     }
 
     @Override
     public void setServiceCallConfiguration(ServiceCallConfigurationDefinition 
configuration) {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         model.setServiceCallConfiguration(configuration);
     }
 
     @Override
     public void 
setServiceCallConfigurations(List<ServiceCallConfigurationDefinition> 
configurations) {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         model.setServiceCallConfigurations(configurations);
     }
 
     @Override
     public void addServiceCallConfiguration(String serviceName, 
ServiceCallConfigurationDefinition configuration) {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         model.addServiceCallConfiguration(serviceName, configuration);
     }
 
     @Override
     public void setRouteFilterPattern(String include, String exclude) {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         model.setRouteFilterPattern(include, exclude);
     }
 
     @Override
     public void setRouteFilter(Function<RouteDefinition, Boolean> filter) {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         model.setRouteFilter(filter);
     }
 
     @Override
     public Function<RouteDefinition, Boolean> getRouteFilter() {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         return model.getRouteFilter();
     }
 
     @Override
     public ModelReifierFactory getModelReifierFactory() {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         return model.getModelReifierFactory();
     }
 
     @Override
     public void setModelReifierFactory(ModelReifierFactory 
modelReifierFactory) {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         model.setModelReifierFactory(modelReifierFactory);
     }
 
@@ -778,9 +624,6 @@ public class DefaultCamelContext extends SimpleCamelContext 
implements ModelCame
 
     @Override
     public void startRouteDefinitions() throws Exception {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         List<RouteDefinition> routeDefinitions = model.getRouteDefinitions();
         if (routeDefinitions != null) {
             // defensive copy of routes to be started as kamelets
@@ -792,9 +635,6 @@ public class DefaultCamelContext extends SimpleCamelContext 
implements ModelCame
 
     @Override
     public void removeRouteDefinitionsFromTemplate() throws Exception {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         List<RouteDefinition> toBeRemoved = new ArrayList<>();
         for (RouteDefinition rd : model.getRouteDefinitions()) {
             if (rd.isTemplate() != null && rd.isTemplate()) {
@@ -805,10 +645,6 @@ public class DefaultCamelContext extends 
SimpleCamelContext implements ModelCame
     }
 
     public void startRouteDefinitions(List<RouteDefinition> routeDefinitions) 
throws Exception {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
-
         // indicate we are staring the route using this thread so
         // we are able to query this if needed
         boolean alreadyStartingRoutes = isStartingRoutes();
@@ -965,33 +801,21 @@ public class DefaultCamelContext extends 
SimpleCamelContext implements ModelCame
 
     @Override
     public Processor createErrorHandler(Route route, Processor processor) 
throws Exception {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         return model.getModelReifierFactory().createErrorHandler(route, 
processor);
     }
 
     @Override
     public Expression createExpression(ExpressionDefinition definition) {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         return model.getModelReifierFactory().createExpression(this, 
definition);
     }
 
     @Override
     public Predicate createPredicate(ExpressionDefinition definition) {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         return model.getModelReifierFactory().createPredicate(this, 
definition);
     }
 
     @Override
     public void registerValidator(ValidatorDefinition def) {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         model.getValidators().add(def);
         Validator validator = 
model.getModelReifierFactory().createValidator(this, def);
         getValidatorRegistry().put(createValidatorKey(def), validator);
@@ -1003,9 +827,6 @@ public class DefaultCamelContext extends 
SimpleCamelContext implements ModelCame
 
     @Override
     public void registerTransformer(TransformerDefinition def) {
-        if (model == null && isLightweight()) {
-            throw new IllegalStateException("Access to model not supported in 
lightweight mode");
-        }
         model.getTransformers().add(def);
         Transformer transformer = 
model.getModelReifierFactory().createTransformer(this, def);
         getTransformerRegistry().put(createTransformerKey(def), transformer);
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 71cefa2418b..710d7f030d8 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
@@ -136,7 +136,6 @@ public final class DefaultConfigurationConfigurer {
         
ecc.getStartupStepRecorder().setRecordingDir(config.getStartupRecorderDir());
         
ecc.getStartupStepRecorder().setRecordingProfile(config.getStartupRecorderProfile());
 
-        ecc.setLightweight(config.isLightweight());
         
PluginHelper.getBeanPostProcessor(ecc).setEnabled(config.isBeanPostProcessorEnabled());
         final BeanIntrospection beanIntrospection = 
PluginHelper.getBeanIntrospection(ecc);
         
beanIntrospection.setExtendedStatistics(config.isBeanIntrospectionExtendedStatistics());
diff --git 
a/core/camel-main/src/main/java/org/apache/camel/main/MainBootstrapCloseable.java
 
b/core/camel-main/src/main/java/org/apache/camel/main/MainBootstrapCloseable.java
index 4ba6bda99c4..eec4cc723a6 100644
--- 
a/core/camel-main/src/main/java/org/apache/camel/main/MainBootstrapCloseable.java
+++ 
b/core/camel-main/src/main/java/org/apache/camel/main/MainBootstrapCloseable.java
@@ -20,36 +20,8 @@ import org.apache.camel.spi.BootstrapCloseable;
 
 public class MainBootstrapCloseable implements BootstrapCloseable {
 
-    private final MainSupport main;
-
-    public MainBootstrapCloseable(MainSupport main) {
-        this.main = main;
-    }
-
     @Override
     public void close() {
-        // in lightweight mode then clear up memory after bootstrap
-        boolean lightweight = true;
-        if (main.getCamelContext() != null) {
-            lightweight = 
main.getCamelContext().getCamelContextExtension().isLightweight();
-        }
-
-        if (lightweight) {
-            if (main.initialProperties != null) {
-                main.initialProperties.clear();
-                main.initialProperties = null;
-            }
-            if (main.overrideProperties != null) {
-                main.overrideProperties.clear();
-                main.overrideProperties = null;
-            }
-            main.wildcardProperties.clear();
-            main.wildcardProperties = null;
 
-            // no longer in use
-            main.mainConfigurationProperties.close();
-            main.mainConfigurationProperties = null;
-            main.routesCollector = null;
-        }
     }
 }
diff --git 
a/core/camel-main/src/main/java/org/apache/camel/main/MainSupport.java 
b/core/camel-main/src/main/java/org/apache/camel/main/MainSupport.java
index fddbf12f595..45ba4fbb302 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/MainSupport.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/MainSupport.java
@@ -192,7 +192,7 @@ public abstract class MainSupport extends BaseMainSupport {
     protected void registerMainBootstrap() {
         CamelContext context = getCamelContext();
         if (context != null) {
-            context.getCamelContextExtension().addBootstrap(new 
MainBootstrapCloseable(this));
+            context.getCamelContextExtension().addBootstrap(new 
MainBootstrapCloseable());
         }
     }
 

Reply via email to