Ok now I'm confused again :)

Say I have my transformer with following code (hope the indentation stays)

MyTransformer extends AbstractDOMTransformer implements LogEnabled,
Cacheable {
        //instance variable
        private StringBuffer sb;
        
        public void transform....{
                ///
        }

        public void startDocument ... {
                sb=new StringBuffer();
        }
        
        public void startElement(...) ...{
                //add certain elements to our stringbuffer
        }

        public void endDocument ... {
                //process stringbuffer
                sb.append(...);
                sb.replace(....);

                sb = null;
        }
}

Can my stringbuffer be overwritten by the second request during processing
of the first request if two near concurrent requests hit the same pipeline?

Sorry to drill down into this but I need to be sure.

Thanks
Jorg


-----Original Message-----
From: Vadim Gritsenko [mailto:[EMAIL PROTECTED] 
Sent: Montag, 1. September 2003 21:06
To: [EMAIL PROTECTED]
Subject: Re: thread safety of cocoon

Upayavira wrote:

> Jorg Heymans wrote:
>
>> Say i write my own transformer (or serializer, or generator doesn't 
>> matter),
>

Transformers, in particular, can not be threadsafe. They are all 
Recyclable. This is due Transformer interface design (setContentHandler 
method in AbstractXMLProducer.java).

Vadim


>> is it true then that a new instance of my custom class is created 
>> each time
>> it is executed in a pipeline? (uncached)
>>
>> My code relies on a few instance variables (simple ones like Logger 
>> but also
>> more crucial ones like StringBuffers for SAX parsing ), I'ld really 
>> hate to
>> find out now that instance variables aren't thread safe in cocoon.
>>
> AFAIU, you need to make your component implement ThreadSafe for it to 
> be shared across threads. The default is that a new component is 
> created for each invocation.
>
> Regards, Upayavira




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

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

Reply via email to