You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by gn...@apache.org on 2020/03/06 13:51:20 UTC

[camel] 02/07: Extract the Route implementation into its own top level class

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

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

commit 752a714265e94482b917bf11265386d565ae6d2e
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Wed Mar 4 23:52:23 2020 +0100

    Extract the Route implementation into its own top level class
---
 .../org/apache/camel/impl/DefaultModelRoute.java   | 37 ++++++++++++++++++++++
 .../org/apache/camel/reifier/RouteReifier.java     | 10 ++----
 2 files changed, 39 insertions(+), 8 deletions(-)

diff --git a/core/camel-core-engine/src/main/java/org/apache/camel/impl/DefaultModelRoute.java b/core/camel-core-engine/src/main/java/org/apache/camel/impl/DefaultModelRoute.java
new file mode 100644
index 0000000..19f0026
--- /dev/null
+++ b/core/camel-core-engine/src/main/java/org/apache/camel/impl/DefaultModelRoute.java
@@ -0,0 +1,37 @@
+/*
+ * 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.impl;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Processor;
+import org.apache.camel.impl.engine.DefaultRoute;
+import org.apache.camel.model.RouteDefinition;
+import org.apache.camel.reifier.errorhandler.ErrorHandlerReifier;
+
+public class DefaultModelRoute extends DefaultRoute {
+
+    public DefaultModelRoute(CamelContext camelContext, RouteDefinition definition, String id, Endpoint endpoint) {
+        super(camelContext, definition, id, endpoint);
+    }
+
+    @Override
+    public Processor createErrorHandler(Processor processor) throws Exception {
+        return ErrorHandlerReifier.reifier(this, getErrorHandlerFactory())
+                .createErrorHandler(processor);
+    }
+}
diff --git a/core/camel-core-engine/src/main/java/org/apache/camel/reifier/RouteReifier.java b/core/camel-core-engine/src/main/java/org/apache/camel/reifier/RouteReifier.java
index 3936aea..0e7cfb4 100644
--- a/core/camel-core-engine/src/main/java/org/apache/camel/reifier/RouteReifier.java
+++ b/core/camel-core-engine/src/main/java/org/apache/camel/reifier/RouteReifier.java
@@ -35,6 +35,7 @@ import org.apache.camel.builder.AdviceWithRouteBuilder;
 import org.apache.camel.builder.AdviceWithTask;
 import org.apache.camel.builder.EndpointConsumerBuilder;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.DefaultModelRoute;
 import org.apache.camel.impl.engine.DefaultRoute;
 import org.apache.camel.model.Model;
 import org.apache.camel.model.ProcessorDefinition;
@@ -44,7 +45,6 @@ import org.apache.camel.model.RoutesDefinition;
 import org.apache.camel.processor.CamelInternalProcessor;
 import org.apache.camel.processor.ContractAdvice;
 import org.apache.camel.processor.Pipeline;
-import org.apache.camel.reifier.errorhandler.ErrorHandlerReifier;
 import org.apache.camel.reifier.rest.RestBindingReifier;
 import org.apache.camel.spi.Contract;
 import org.apache.camel.spi.LifecycleStrategy;
@@ -257,13 +257,7 @@ public class RouteReifier extends ProcessorReifier<RouteDefinition> {
 
         // create route
         String id = definition.idOrCreate(camelContext.adapt(ExtendedCamelContext.class).getNodeIdFactory());
-        DefaultRoute route = new DefaultRoute(camelContext, definition, id, endpoint) {
-            @Override
-            public Processor createErrorHandler(Processor processor) throws Exception {
-                return ErrorHandlerReifier.reifier(this, getErrorHandlerFactory())
-                        .createErrorHandler(processor);
-            }
-        };
+        DefaultRoute route = new DefaultModelRoute(camelContext, definition, id, endpoint);
 
         // configure error handler
         route.setErrorHandlerFactory(definition.getErrorHandlerFactory());