[EMAIL PROTECTED] wrote:

> "Roytman, Alex" <[EMAIL PROTECTED]> wrote:
> > One part which is sensitive to thread origin in my opinion is Extensions
> > In extensions people can do all sorts of things.
>
> Yep, I can see that.  It sounds like we should at least provide a property
> to turn off the threading, which we should probably do in any case.  I'm
> not sure I can do this in time for our upcoming 2.0 release, as it feels a
> little destabilizing, but let me sleep on it.
>

In Tomcat 4.0 we implement the JNDI naming context stuff so that you can call
"new InitialContext()" and get the context that is relevant for your webapp.
This relies on the thread having been initialized correctly by the container.
It sounds like "extension" might be problematic.

There are also restrictions on the time when it is valid for an application
level thread to reference the request and response objects that are handed to
the service() method.  Basically, after service() returns those object instances
are off limits, so you also need to ensure that any threads you create do not
maintain any live references to the request and response outside the safe time
interval.

>
> The best solution for this is to have some sort of discoverable interface
> for Xalan to create threads with.  You would think that the EJB stuff could
> somehow override thread construction globally, so this stuff would all be
> hidden.  But I'm sure there are good reasons it can not.
>

While it might be possible to create such an interface in a servlet container,
my understanding is that EJBs are prohibited from creating new threads (and, in
many app servers, will be actively prohibited from doing so by the security
manager that the bean code runs under).

>
> > Do extension run on the second (created by Xalan) thread?
>
> Yes.  The main thread is the parser event thread.  The second thread, which
> I call the transform thread, performs the transformation, executing
> extensions as it goes, and sends parse events to the Result interface,
> which is probably a serializer.  If the main thread finishes before the
> transform thread, it 'joins' with the transform thread.  If you chain
> several Transformers or XMLReaders together you get another thread for each
> pipe.  This is good and bad, since the number of threads increases, but the
> pipeline tends to keep moving along... pipe number three can be getting
> bytes to the wire while pipe number 1 is just getting started.
>
> The transform thread's run method is to be found in
> org.apache.xalan.transformer.TransformerImpl#run(), and the thread is
> created in org.apache.xalan.stree.SourceTreeHandler#startDocument(), and
> does the join in org.apache.xalan.stree.SourceTreeHandler#endDocument().
>
> If you are using a DOM as the source, you are not running the second
> thread... this only happens when Xalan can create it's own source tree.
>
> -scott
>

Craig McClanahan



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to