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

commit 9f5f0400392742eb5d4842ab1ded45978c726cea
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon May 18 10:49:43 2020 +0200

    camel-core - Optimize and move internal route controller to own class and 
make it final
---
 .../camel/impl/engine/AbstractCamelContext.java    |  89 +--------------
 .../camel/impl/engine/InternalRouteController.java | 123 +++++++++++++++++++++
 2 files changed, 126 insertions(+), 86 deletions(-)

diff --git 
a/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
 
b/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
index 277e2e8..58fd21e 100644
--- 
a/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
+++ 
b/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
@@ -275,6 +275,7 @@ public abstract class AbstractCamelContext extends 
BaseService
     private volatile UuidGenerator uuidGenerator;
     private volatile UnitOfWorkFactory unitOfWorkFactory;
     private volatile RouteController routeController;
+    private final RouteController internalRouteController = new 
InternalRouteController(this);
     private volatile ScheduledExecutorService errorHandlerExecutorService;
     private volatile BeanIntrospection beanIntrospection;
     private volatile Tracer tracer;
@@ -4569,91 +4570,7 @@ public abstract class AbstractCamelContext extends 
BaseService
 
     @Override
     public RouteController getInternalRouteController() {
-        return new RouteController() {
-            @Override
-            public SupervisingRouteController supervising() {
-                throw new UnsupportedOperationException();
-            }
-
-            @Override
-            public <T extends RouteController> T adapt(Class<T> type) {
-                return type.cast(this);
-            }
-
-            @Override
-            public Collection<Route> getControlledRoutes() {
-                return AbstractCamelContext.this.getRoutes();
-            }
-
-            @Override
-            public void startAllRoutes() throws Exception {
-                AbstractCamelContext.this.startAllRoutes();
-            }
-
-            @Override
-            public boolean isStartingRoutes() {
-                return AbstractCamelContext.this.isStartingRoutes();
-            }
-
-            @Override
-            public ServiceStatus getRouteStatus(String routeId) {
-                return AbstractCamelContext.this.getRouteStatus(routeId);
-            }
-
-            @Override
-            public void startRoute(String routeId) throws Exception {
-                AbstractCamelContext.this.startRoute(routeId);
-            }
-
-            @Override
-            public void stopRoute(String routeId) throws Exception {
-                AbstractCamelContext.this.stopRoute(routeId);
-            }
-
-            @Override
-            public void stopRoute(String routeId, long timeout, TimeUnit 
timeUnit) throws Exception {
-                AbstractCamelContext.this.stopRoute(routeId, timeout, 
timeUnit);
-            }
-
-            @Override
-            public boolean stopRoute(String routeId, long timeout, TimeUnit 
timeUnit, boolean abortAfterTimeout) throws Exception {
-                return AbstractCamelContext.this.stopRoute(routeId, timeout, 
timeUnit, abortAfterTimeout);
-            }
-
-            @Override
-            public void suspendRoute(String routeId) throws Exception {
-                AbstractCamelContext.this.suspendRoute(routeId);
-            }
-
-            @Override
-            public void suspendRoute(String routeId, long timeout, TimeUnit 
timeUnit) throws Exception {
-                AbstractCamelContext.this.suspendRoute(routeId, timeout, 
timeUnit);
-            }
-
-            @Override
-            public void resumeRoute(String routeId) throws Exception {
-                AbstractCamelContext.this.resumeRoute(routeId);
-            }
-
-            @Override
-            public void setCamelContext(CamelContext camelContext) {
-                throw new UnsupportedOperationException();
-            }
-
-            @Override
-            public CamelContext getCamelContext() {
-                throw new UnsupportedOperationException();
-            }
-
-            @Override
-            public void start() {
-                throw new UnsupportedOperationException();
-            }
-
-            @Override
-            public void stop() {
-                throw new UnsupportedOperationException();
-            }
-        };
+        return internalRouteController;
     }
 }
+
diff --git 
a/core/camel-base/src/main/java/org/apache/camel/impl/engine/InternalRouteController.java
 
b/core/camel-base/src/main/java/org/apache/camel/impl/engine/InternalRouteController.java
new file mode 100644
index 0000000..f83d717
--- /dev/null
+++ 
b/core/camel-base/src/main/java/org/apache/camel/impl/engine/InternalRouteController.java
@@ -0,0 +1,123 @@
+/*
+ * 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.engine;
+
+import java.util.Collection;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Route;
+import org.apache.camel.ServiceStatus;
+import org.apache.camel.spi.RouteController;
+import org.apache.camel.spi.SupervisingRouteController;
+
+/**
+ * Internal {@link RouteController} used internally by {@link 
AbstractCamelContext}.
+ */
+class InternalRouteController implements RouteController {
+
+    private final AbstractCamelContext abstractCamelContext;
+
+    public InternalRouteController(AbstractCamelContext abstractCamelContext) {
+        this.abstractCamelContext = abstractCamelContext;
+    }
+
+    @Override
+    public SupervisingRouteController supervising() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public <T extends RouteController> T adapt(Class<T> type) {
+        return type.cast(this);
+    }
+
+    @Override
+    public Collection<Route> getControlledRoutes() {
+        return abstractCamelContext.getRoutes();
+    }
+
+    @Override
+    public void startAllRoutes() throws Exception {
+        abstractCamelContext.startAllRoutes();
+    }
+
+    @Override
+    public boolean isStartingRoutes() {
+        return abstractCamelContext.isStartingRoutes();
+    }
+
+    @Override
+    public ServiceStatus getRouteStatus(String routeId) {
+        return abstractCamelContext.getRouteStatus(routeId);
+    }
+
+    @Override
+    public void startRoute(String routeId) throws Exception {
+        abstractCamelContext.startRoute(routeId);
+    }
+
+    @Override
+    public void stopRoute(String routeId) throws Exception {
+        abstractCamelContext.stopRoute(routeId);
+    }
+
+    @Override
+    public void stopRoute(String routeId, long timeout, TimeUnit timeUnit) 
throws Exception {
+        abstractCamelContext.stopRoute(routeId, timeout, timeUnit);
+    }
+
+    @Override
+    public boolean stopRoute(String routeId, long timeout, TimeUnit timeUnit, 
boolean abortAfterTimeout) throws Exception {
+        return abstractCamelContext.stopRoute(routeId, timeout, timeUnit, 
abortAfterTimeout);
+    }
+
+    @Override
+    public void suspendRoute(String routeId) throws Exception {
+        abstractCamelContext.suspendRoute(routeId);
+    }
+
+    @Override
+    public void suspendRoute(String routeId, long timeout, TimeUnit timeUnit) 
throws Exception {
+        abstractCamelContext.suspendRoute(routeId, timeout, timeUnit);
+    }
+
+    @Override
+    public void resumeRoute(String routeId) throws Exception {
+        abstractCamelContext.resumeRoute(routeId);
+    }
+
+    @Override
+    public void setCamelContext(CamelContext camelContext) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public CamelContext getCamelContext() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void start() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void stop() {
+        throw new UnsupportedOperationException();
+    }
+}

Reply via email to