camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [4/4] git commit: CAMEL-7711: camel-servletlistener - Store created CamelContext on ServletContext attribute
Date Sun, 17 Aug 2014 07:15:09 GMT
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/c12e7695
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/c12e7695
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/c12e7695

Branch: refs/heads/camel-2.12.x
Commit: c12e76955e851d77a865c3e070da689f1f714abc
Parents: 3bca492
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Sun Aug 17 09:09:35 2014 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sun Aug 17 09:14:54 2014 +0200

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


http://git-wip-us.apache.org/repos/asf/camel/blob/c12e7695/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 6ffcf07..1e49afa 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;
@@ -172,6 +177,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");
     }
 
@@ -194,6 +202,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");
     }
 


Mime
View raw message