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 2024/02/12 10:22:50 UTC
(camel) branch model-fac created (now a1bb0095781)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a change to branch model-fac
in repository https://gitbox.apache.org/repos/asf/camel.git
at a1bb0095781 CAMEL-20409: camel-core - ModelReifierFactory should detect custom on classpath
This branch includes the following new commits:
new a1bb0095781 CAMEL-20409: camel-core - ModelReifierFactory should detect custom on classpath
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(camel) 01/01: CAMEL-20409: camel-core - ModelReifierFactory should detect custom on classpath
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch model-fac
in repository https://gitbox.apache.org/repos/asf/camel.git
commit a1bb00957813c243feefbea0aa3e95feac93677b
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Feb 12 11:22:33 2024 +0100
CAMEL-20409: camel-core - ModelReifierFactory should detect custom on classpath
---
.../org/apache/camel/spi/ModelReifierFactory.java | 32 ++++++++++++++++++++++
.../org/apache/camel/impl/DefaultCamelContext.java | 19 +++++++++++++
2 files changed, 51 insertions(+)
diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/ModelReifierFactory.java b/core/camel-api/src/main/java/org/apache/camel/spi/ModelReifierFactory.java
index 727f2d4b32a..b82e5c4ebd0 100644
--- a/core/camel-api/src/main/java/org/apache/camel/spi/ModelReifierFactory.java
+++ b/core/camel-api/src/main/java/org/apache/camel/spi/ModelReifierFactory.java
@@ -28,22 +28,54 @@ import org.apache.camel.Route;
*/
public interface ModelReifierFactory {
+ /**
+ * Service factory key for custom factories.
+ */
+ String FACTORY = "model-reifier-factory";
+
+ /**
+ * Creates the route from the model.
+ */
Route createRoute(CamelContext camelContext, Object routeDefinition);
+ /**
+ * Creates the data format from the model.
+ */
DataFormat createDataFormat(CamelContext camelContext, Object dataFormatDefinition);
+ /**
+ * Creates the error handler for the route processor.
+ */
Processor createErrorHandler(Route route, Processor processor) throws Exception;
+ /**
+ * Creates the error handler using the factory for the route processor.
+ */
Processor createErrorHandler(Route route, ErrorHandlerFactory errorHandlerFactory, Processor processor) throws Exception;
+ /**
+ * Creates the default error handler.
+ */
ErrorHandlerFactory createDefaultErrorHandler();
+ /**
+ * Creates the expression from the model.
+ */
Expression createExpression(CamelContext camelContext, Object expressionDefinition);
+ /**
+ * Creates the predicate from the model.
+ */
Predicate createPredicate(CamelContext camelContext, Object expressionDefinition);
+ /**
+ * Creates the transformer from the model.
+ */
Transformer createTransformer(CamelContext camelContext, Object transformerDefinition);
+ /**
+ * Creates the validator from the model.
+ */
Validator createValidator(CamelContext camelContext, Object transformerDefinition);
}
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 cd355df1836..f7e164a792a 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
@@ -22,6 +22,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import java.util.Set;
import java.util.function.Function;
@@ -79,6 +80,7 @@ import org.apache.camel.spi.Validator;
import org.apache.camel.support.CamelContextHelper;
import org.apache.camel.support.DefaultRegistry;
import org.apache.camel.support.LocalBeanRegistry;
+import org.apache.camel.support.ResolverHelper;
import org.apache.camel.support.SimpleUuidGenerator;
import org.apache.camel.util.ObjectHelper;
import org.apache.camel.util.OrderedLocationProperties;
@@ -136,6 +138,8 @@ public class DefaultCamelContext extends SimpleCamelContext implements ModelCame
public DefaultCamelContext(boolean init) {
super(init);
+ // setup model factory which must be done very early
+ setModelReifierFactory(createModelReifierFactory());
if (isDisableJmx()) {
disableJMX();
}
@@ -147,6 +151,11 @@ public class DefaultCamelContext extends SimpleCamelContext implements ModelCame
OPTIONS.remove();
}
+ @Override
+ protected void initPlugins() {
+ super.initPlugins();
+ }
+
@Override
protected void doDumpRoutes() {
DumpRoutesStrategy strategy = CamelContextHelper.findSingleByType(this, DumpRoutesStrategy.class);
@@ -841,4 +850,14 @@ public class DefaultCamelContext extends SimpleCamelContext implements ModelCame
}
}
+ protected ModelReifierFactory createModelReifierFactory() {
+ Optional<ModelReifierFactory> result = ResolverHelper.resolveService(
+ this,
+ this.getCamelContextExtension().getBootstrapFactoryFinder(),
+ ModelReifierFactory.FACTORY,
+ ModelReifierFactory.class);
+
+ return result.orElseGet(DefaultModelReifierFactory::new);
+ }
+
}