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 2014/08/17 09:15:08 UTC

[3/4] git commit: CAMEL-7711: camel-servletlistener - Store created CamelContext on ServletContext attribute

CAMEL-7711: camel-servletlistener - Store created CamelContext on ServletContext attribute


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

Branch: refs/heads/camel-2.13.x
Commit: 82b3e07851ea7f0a51e70afa057b6b2796fed682
Parents: 3fe4630
Author: Claus Ibsen <da...@apache.org>
Authored: Sun Aug 17 09:09:35 2014 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sun Aug 17 09:14:44 2014 +0200

----------------------------------------------------------------------
 .../servletlistener/CamelServletContextListener.java    | 12 ++++++++++++
 1 file changed, 12 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/82b3e078/components/camel-servletlistener/src/main/java/org/apache/camel/component/servletlistener/CamelServletContextListener.java
----------------------------------------------------------------------
diff --git a/components/camel-servletlistener/src/main/java/org/apache/camel/component/servletlistener/CamelServletContextListener.java b/components/camel-servletlistener/src/main/java/org/apache/camel/component/servletlistener/CamelServletContextListener.java
index 5ea3e82..efe1fdd 100644
--- a/components/camel-servletlistener/src/main/java/org/apache/camel/component/servletlistener/CamelServletContextListener.java
+++ b/components/camel-servletlistener/src/main/java/org/apache/camel/component/servletlistener/CamelServletContextListener.java
@@ -64,6 +64,11 @@ public abstract class CamelServletContextListener<R extends Registry> implements
      */
     public static ServletCamelContext instance;
 
+    /**
+     * Key to store the created {@link org.apache.camel.CamelContext} as an attribute on the {@link javax.servlet.ServletContext}.
+     */
+    public static final String CAMEL_CONTEXT_KEY = "CamelContext";
+
     protected static final Logger LOG = LoggerFactory.getLogger(CamelServletContextListener.class);
     protected ServletCamelContext camelContext;
     protected CamelContextLifecycle<R> camelContextLifecycle;
@@ -189,6 +194,9 @@ public abstract class CamelServletContextListener<R extends Registry> implements
             instance = camelContext;
         }
 
+        // store the CamelContext as an attribute
+        sce.getServletContext().setAttribute(CAMEL_CONTEXT_KEY, camelContext);
+
         LOG.info("CamelContextServletListener initialized");
     }
 
@@ -211,6 +219,10 @@ public abstract class CamelServletContextListener<R extends Registry> implements
         camelContext = null;
         registry = null;
         instance = null;
+
+        // store the CamelContext as an attribute
+        sce.getServletContext().removeAttribute(CAMEL_CONTEXT_KEY);
+
         LOG.info("CamelContextServletListener destroyed");
     }