Return-Path: Delivered-To: apmail-myfaces-dev-archive@www.apache.org Received: (qmail 96366 invoked from network); 14 Jan 2010 13:17:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 14 Jan 2010 13:17:09 -0000 Received: (qmail 77274 invoked by uid 500); 14 Jan 2010 13:17:08 -0000 Delivered-To: apmail-myfaces-dev-archive@myfaces.apache.org Received: (qmail 77201 invoked by uid 500); 14 Jan 2010 13:17:08 -0000 Mailing-List: contact dev-help@myfaces.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "MyFaces Development" Delivered-To: mailing list dev@myfaces.apache.org Received: (qmail 77193 invoked by uid 99); 14 Jan 2010 13:17:08 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Jan 2010 13:17:08 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of bernhard.huemer@gmail.com designates 209.85.219.225 as permitted sender) Received: from [209.85.219.225] (HELO mail-ew0-f225.google.com) (209.85.219.225) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Jan 2010 13:16:58 +0000 Received: by ewy25 with SMTP id 25so3900534ewy.25 for ; Thu, 14 Jan 2010 05:16:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=q+dg0plYtN9Eh2qVh6tJFUFgCB8H1mjsSePAxE9PGb8=; b=ApIJo3zrvh7Rf7MxHqRSGyeOtdJfOohbMyWmS9EzEL9tknv1EEBOXKPmh2jTB7qarh RUTXsa0yVw/NiSUobBoLc3hL3R2F1YHsz13hVQMhYIVomiKY7GfGgXvYG9j6JzDTVfYe 0mw8gyzb8uaMZY6kO0+fA32nN6cGEF0DjNQUM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; b=EQ13v6d4wiXNrWeQ3d1D0iKRKlUkzjD/+9rFW0TroZFAibb9OZbck/AyY52ZB/RDlw AkmZNRDekI+FnDjP5cMMhAGWIgYJ4knW+hvS5WXFa/ezj3QXLS7QLJifRHHiq1Adglj0 SJvPbn+PIbMWKFr4uUneq3g2plgj60nRzBh/E= Received: by 10.213.109.148 with SMTP id j20mr2714951ebp.2.1263474996041; Thu, 14 Jan 2010 05:16:36 -0800 (PST) Received: from ?192.168.1.2? (62-47-35-57.adsl.highway.telekom.at [62.47.35.57]) by mx.google.com with ESMTPS id 16sm529326ewy.10.2010.01.14.05.16.34 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 14 Jan 2010 05:16:35 -0800 (PST) Message-ID: <4B4F1931.9020704@gmail.com> Date: Thu, 14 Jan 2010 14:16:33 +0100 From: Bernhard Huemer User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: MyFaces Development Subject: Re: [core] Introduce ManagedBeanRegistry References: <237ac0b1001131207p1aa80e48qd887251bd2ac03bc@mail.gmail.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Hey, sorry, I haven't noticed this thread, so I've already commented on the according JIRA issue (https://issues.apache.org/jira/browse/MYFACES-2485). Basically I've already mentioned it there, but I think the reason why only the "contextDestroyed"-callbacks are invoked is that Tomcat, by default, serializes and preserves sessions once it shuts down. However, I'm pretty much sure that implementing such a registry introduces more issues than it resolves (assuming that you consider this to be an issue at all - which I wouldn't do). As Jan-Kees has already pointed out, you can't just invalidate sessions once a container shuts down in a clustered environment. I think it would break the whole idea of a clustered environment. regards, Bernhard Jakob Korherr wrote on 01/13/2010 09:17 PM (GMT): > Hi, > > MyFaces is already using all available Listeners > (HttpSessionAttributeListener, HttpSessionListener, > ServletContextListener, ServletContextAttributeListener, > ServletRequestListener, ServletRequestAttributeListener) to invoke > @PreDestroy on the Managed Beans and this happens via a pass-through > from StartupServletContextListener, so you don't have to configure two > listeners in web.xml (or tld). > > The problem is, as you thought, that those listeners (e.g. > HttpSessionListener) are not invoked on a container shutdown/restart. > Only contextDestroyed from ServletContextListener is invoked (tested > today on Apache Tomcat 6). > > I will not change anything of the existing behavior, I just want to make > sure that all still existing ManagedBeans get their @PreDestroy method > called in contextDestroyed. But I would not get a reference to them, if > I do not register them in a ManagedBeanRegistry. > > Regards, > Jakob > > 2010/1/13 Jan-Kees van Andel > > > Hey, > > How about an HttpSessionListener? I'm not sure if > HttpSessionListener.contextDestroyed is invoked on shutdownthough. > Probably not... > > I'm afraid the only option is custom bookkeeping, maybe using an > HttpSessionListener/ServletContextListener to publish events to the > Registry. > I see some issues with this approach: > 1 Configuration becomes more difficult for the application developer, > because these two Listeners become required configuration. > 2 Managing objects yourself may be tricky business. An option could be > to use WeakReference/WeakHashMap for this so you don't accidentally > keep your objects alive. > 3 What to do with regards to session replication on a clustered > environment? I'm not sure this will become an issue, but it wouldn't > surprise me if it will. > > Regards, > Jan-Kees > > > 2010/1/13 Jakob Korherr >: > > Hi guys, > > > > To ensure the execution of the ManagedBean's @PreDestroy methods on a > > container shutdown/restart, I would like to introduce a > ManagedBeanRegistry, > > in which all active ManagedBeans from all scopes are referenced. > > > > The problem is the following: At the moment on a container > shutdown or > > restart, only contextDestroyed is invoked (tested in tomcat 6), > thus only > > the @PreDestroy methods of all ApplicationScoped ManagedBeans will be > > invoked, but not those of any existing ManagedBeans in session, > request, > > view (and maybe also custom) scope, because they can not be > referenced in > > contextDestroyed(). > > > > Any opinions on that? > > > > Thanks in advance! > > > > Regards, > > Jakob > > > >