camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject [1/4] git commit: [CAMEL-6115] Add a global interceptor strategy
Date Fri, 17 May 2013 11:33:27 GMT
Updated Branches:
  refs/heads/master 4dc4dc361 -> 66939043e


[CAMEL-6115] Add a global interceptor strategy


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/5270d5c1
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/5270d5c1
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/5270d5c1

Branch: refs/heads/master
Commit: 5270d5c1020ed0863cadfde3ce9c5318b70fc8ef
Parents: 4dc4dc3
Author: Guillaume Nodet <gnodet@gmail.com>
Authored: Thu May 16 11:24:15 2013 +0200
Committer: Guillaume Nodet <gnodet@gmail.com>
Committed: Fri May 17 13:33:01 2013 +0200

----------------------------------------------------------------------
 .../org/apache/camel/impl/DefaultCamelContext.java |    3 +
 .../main/java/org/apache/camel/spi/Container.java  |   78 +++++++++++++++
 2 files changed, 81 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/5270d5c1/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
index 459de34..e721837 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
@@ -90,6 +90,7 @@ import org.apache.camel.processor.interceptor.Tracer;
 import org.apache.camel.spi.CamelContextNameStrategy;
 import org.apache.camel.spi.ClassResolver;
 import org.apache.camel.spi.ComponentResolver;
+import org.apache.camel.spi.Container;
 import org.apache.camel.spi.DataFormat;
 import org.apache.camel.spi.DataFormatResolver;
 import org.apache.camel.spi.Debugger;
@@ -231,6 +232,8 @@ public class DefaultCamelContext extends ServiceSupport implements ModelCamelCon
         } else {
             packageScanClassResolver = new DefaultPackageScanClassResolver();
         }
+
+        Container.Instance.manage(this);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/camel/blob/5270d5c1/camel-core/src/main/java/org/apache/camel/spi/Container.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/spi/Container.java b/camel-core/src/main/java/org/apache/camel/spi/Container.java
new file mode 100644
index 0000000..71d8a43
--- /dev/null
+++ b/camel-core/src/main/java/org/apache/camel/spi/Container.java
@@ -0,0 +1,78 @@
+/**
+ * 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.spi;
+
+import org.apache.camel.CamelContext;
+
+/**
+ * The <code>Container</code> interface defines an object that can be used
+ * to customize all Camel contexts created.
+ *
+ * A container can be used to globally intercept and customize Camel contexts,
+ * by registering a <code>LifecycleStrategy</code>, a <code>ProcessorFactory</code>,
+ * or any other SPI object.
+ */
+public interface Container {
+
+    /**
+     * The <code>Instance</code> class holds a <code>Container</code>
singleton.
+     */
+    public static final class Instance {
+
+        private Instance() {}
+
+        private static Container container;
+
+        /**
+         * Access the registered Container.
+         *
+         * @return the Container singleton
+         */
+        public static Container get() {
+            return container;
+        }
+
+        /**
+         * Register the Container.
+         *
+         * @param container the Container to register
+         */
+        public static void set(Container container) {
+            Instance.container = container;
+        }
+
+        /**
+         * Called by Camel when a <code>CamelContext</code> has been created.
+         *
+         * @param camelContext the newly created CamelContext
+         */
+        public static void manage(CamelContext camelContext) {
+            Container cnt = container;
+            if (cnt != null) {
+                cnt.manage(camelContext);
+            }
+        }
+    }
+
+    /**
+     * Called by Camel when a <code>CamelContext</code> has been created.
+     *
+     * @param camelContext the newly created CamelContext
+     */
+    void manage(CamelContext camelContext);
+
+}


Mime
View raw message