OWB-1123 removing cdi beans from session on passivation, adding tomee.session.remove-cdi-beans-on-passivate flag to set it to false in OWB config if desired
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/c0e6d70f Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/c0e6d70f Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/c0e6d70f Branch: refs/heads/master Commit: c0e6d70f1b2ebef600ab4f3356d75ef3e5d415ea Parents: 475b1e0 Author: Romain manni-Bucau <rmannibu...@gmail.com> Authored: Fri Jun 24 09:39:09 2016 +0200 Committer: Romain manni-Bucau <rmannibu...@gmail.com> Committed: Fri Jun 24 09:39:09 2016 +0200 ---------------------------------------------------------------------- .../server/httpd/EndWebBeansListener.java | 23 +++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tomee/blob/c0e6d70f/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/EndWebBeansListener.java ---------------------------------------------------------------------- diff --git a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/EndWebBeansListener.java b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/EndWebBeansListener.java index 722c56c..661b972 100644 --- a/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/EndWebBeansListener.java +++ b/server/openejb-http/src/main/java/org/apache/openejb/server/httpd/EndWebBeansListener.java @@ -5,14 +5,14 @@ * 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. + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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.openejb.server.httpd; @@ -40,6 +40,7 @@ public class EndWebBeansListener implements ServletContextListener, ServletReque */ protected WebBeansContext webBeansContext; private final CdiAppContextsService contextsService; + private final boolean cleanUpSession; /** * Default constructor @@ -50,8 +51,11 @@ public class EndWebBeansListener implements ServletContextListener, ServletReque this.webBeansContext = webBeansContext; if (webBeansContext != null) { this.contextsService = CdiAppContextsService.class.cast(webBeansContext.getService(ContextsService.class)); + this.cleanUpSession = Boolean.parseBoolean(webBeansContext.getOpenWebBeansConfiguration() + .getProperty("tomee.session.remove-cdi-beans-on-passivate", "true")); } else { this.contextsService = null; + this.cleanUpSession = false; // ignored anyway } } @@ -95,6 +99,9 @@ public class EndWebBeansListener implements ServletContextListener, ServletReque return; } + if (cleanUpSession) { + event.getSession().removeAttribute("openWebBeansSessionContext"); + } WebBeansListenerHelper.destroyFakedRequest(this); }