users
[Top] [All Lists]

Re: [cinjug-users] tag handler reuse question

To: "Mitchell, John" <jlmitchell@xxxxxxxx>
Subject: Re: [cinjug-users] tag handler reuse question
From: "Mike Ball" <mwball@xxxxxxxxx>
Date: Tue, 27 Mar 2007 13:00:39 -0400
Cc: users@xxxxxxxxxx
Delivered-to: mailing list users@cinjug.org
Dkim-signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=cOssGG4iSWUzdyk47w48l+Y/IGK8HmZcs34Sgf8l2X7uJng2Z5Mn4BYCrcq9Df8bmQ2TTM48OSA745RDD9PAGDfyAIGoTNVua9wh6wFCGnobKGu+2hRhvsec1uyAQ1ZEGigZTnLRS/ODq3huZFkRUTK7HioXfUDU3OkHJOhunxA=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=nOJWsBmnkpSDxrGc5B9Pyn3w+9BpNiuMnTq/AsMAbUhUsfrYccXKNlsyWtZV3ONg5EZiS6OXYhhXMYEOAZYMg19gDPe03CuX1Ny8qeK0sLuSlXtD8dmJWvCIfzASUJ7Wcb61u1GZh/TUrNNT/d74wrzKzN8qpyIrw+d29DGWFoU=
In-reply-to: <870BD6A2013B444F9A41ABC3DFE1B1230EC7A4DC@CVGEXCEMAIL001.ga.afginc.com>
Mailing-list: contact users-help@cinjug.org; run by ezmlm
References: <870BD6A2013B444F9A41ABC3DFE1B1230EC7A4DC@CVGEXCEMAIL001.ga.afginc.com>
Tag handler pooling/reuse is implemented differently in many
containers.  For example Websphere has a few strategies you can choose
from like thread level, page level, etc.

If you are using pooling/reuse it is best practice to get your tag
back to it's original state before it is returned to the pool.  But in
Websphere the release() method is not called before the tag is reused,
it is called at the end of the page/request/whatever, but the doEndTag
is always called.

I don't know if Weblogic supports tag pooling/reuse, but Tomcat does
as well as some other servlet containers.  It's probably in your best
interest to have the release and doEndTag methods implemented to
ensure that the tag is returned to it's original state so your
application can take advantage of whatever optimization the container
provides.



On 3/27/07, Mitchell, John <jlmitchell@xxxxxxxx> wrote:



I just noticed some code in a doEndTag() which raised my eyebrows.

In J2EE, I understand that the container (implementation of the spec) can
pool session beans, and that this is configurable.  ...likewise with
connection pools.

Everything else I had thought was either...(1) a static class (rather,
static methods in a class) which would have application scope (more than one
session can affect the same attributes, raising some coding considerations),
or...(2) an instance of a class, having - at the most - session scope via a
reference put in the session (unless explicitly given a reference in the
application scope).

The following code implies that the container (weblogic, in my case) might
decide to keep a tag handler instance for reuse by other sessions, or at
least by my session once again (not sure if the former).

If the former, that would seem to put the responsibility on the developer to
'clean up' or null-out attributes before being done, and even synchronize
the scope from doStartTag() through doEndTag().  If the later, puts the same
responsibility on the developer (apparently), but of course there is no
concurrence concern.

Any input on this?  I had never heard of this before.  (...assuming the
logic was placed there by someone correctly understanding the container
capability/discretion to reuse an instance...)

Thanks,

John Mitchell

  public int doEndTag() throws JspException {
    //reinit properties in case tag instance reused by container
    crudOperation = null;
    crudOperationBean = null;
        [ ...etc. ]

users@xxxxxxxxxx
**********************************************************************
The content of this e-mail message and any attachments are confidential and
may be legally privileged, intended solely for the addressee. If you are not
the intended recipient, be advised that any use, dissemination,
distribution, or copying of this e-mail is strictly prohibited. If you
receive this message in error, please notify the sender immediately by reply
email and destroy the message and its attachments.
**********************************************************************

<Prev in Thread] Current Thread [Next in Thread>