ppalaga commented on a change in pull request #1088: Lightweight context
without init / start phases
URL: https://github.com/apache/camel-quarkus/pull/1088#discussion_r409358659
##########
File path:
extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelRecorder.java
##########
@@ -69,23 +69,42 @@ public void
addTypeConverterLoader(RuntimeValue<TypeConverterRegistry> registry,
String version,
CamelConfig config) {
- FastCamelContext context = new FastCamelContext(
- factoryFinderResolver.getValue(),
- version,
- xmlLoader.getValue(),
- xmlModelDumper.getValue());
-
- context.setDefaultExtension(RuntimeCamelCatalog.class, () -> new
CamelRuntimeCatalog(config.runtimeCatalog));
- context.setRegistry(registry.getValue());
- context.setTypeConverterRegistry(typeConverterRegistry.getValue());
- context.setLoadTypeConverters(false);
- context.setModelJAXBContextFactory(contextFactory.getValue());
- context.build();
-
- // register to the container
- beanContainer.instance(CamelProducers.class).setContext(context);
-
- return new RuntimeValue<>(context);
+ if (config.main.lightweight) {
+ FastLightweightCamelContext context = new
FastLightweightCamelContext(
+ factoryFinderResolver.getValue(),
+ version,
+ xmlLoader.getValue(),
+ xmlModelDumper.getValue());
+ context.setRuntimeCamelCatalog(new
CamelRuntimeCatalog(config.runtimeCatalog));
+ context.setRegistry(registry.getValue());
+ context.setTypeConverterRegistry(typeConverterRegistry.getValue());
+ context.setLoadTypeConverters(false);
+ context.setModelJAXBContextFactory(contextFactory.getValue());
+ context.build();
+
+ // register to the container
+ beanContainer.instance(CamelProducers.class).setContext(context);
+
+ return new RuntimeValue<>(context);
+ } else {
+ FastCamelContext context = new FastCamelContext(
+ null,
+ factoryFinderResolver.getValue(),
+ version,
+ xmlLoader.getValue(),
+ xmlModelDumper.getValue());
+ context.setRuntimeCamelCatalog(new
CamelRuntimeCatalog(config.runtimeCatalog));
+ context.setRegistry(registry.getValue());
+ context.setTypeConverterRegistry(typeConverterRegistry.getValue());
+ context.setLoadTypeConverters(false);
+ context.setModelJAXBContextFactory(contextFactory.getValue());
+ context.build();
+
+ // register to the container
+ beanContainer.instance(CamelProducers.class).setContext(context);
+
+ return new RuntimeValue<>(context);
+ }
Review comment:
This would be easier to read an maintain:
```suggestion
final ExtendedCamelContext context;
if (config.main.lightweight) {
context = new FastLightweightCamelContext(
factoryFinderResolver.getValue(),
version,
xmlLoader.getValue(),
xmlModelDumper.getValue());
} else {
context = new FastCamelContext(
null,
factoryFinderResolver.getValue(),
version,
xmlLoader.getValue(),
xmlModelDumper.getValue());
}
context.setRuntimeCamelCatalog(new
CamelRuntimeCatalog(config.runtimeCatalog));
context.setRegistry(registry.getValue());
context.setTypeConverterRegistry(typeConverterRegistry.getValue());
context.setLoadTypeConverters(false);
context.setModelJAXBContextFactory(contextFactory.getValue());
context.build();
// register to the container
beanContainer.instance(CamelProducers.class).setContext(context);
return new RuntimeValue<>(context);
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services