cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jorg Heymans <Jorg.Heym...@12snap.com>
Subject RE: thread safety of cocoon
Date Tue, 02 Sep 2003 09:56:41 GMT
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:vadim.gritsenko@verizon.net] 
Sent: Montag, 1. September 2003 21:06
To: users@cocoon.apache.org
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: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message