You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by "Qureshi, Affan" <aq...@cars.com> on 2004/03/09 18:58:01 UTC

Singleton

I have a batch process in the application to send emails. The emails are construced from XML generated from Velocity. I was considering using singleton -vs- seperate instance for it. Singleton has the advantage of caching the templates once and using them over. But in this case when the emails are sent in batches caching would not be an issue coz we will be parsing the templates once and using them over for all the emails per batch. 

Also would the Single instance of the Velocity Template engine become a bottle-neck in some case? Is the Template Engine thread-safe in case the application is used in a Multi-threaded way? 

Thanks,

Affan

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: Singleton

Posted by Geir Magnusson Jr <ge...@4quarters.com>.
On Mar 9, 2004, at 12:58 PM, Qureshi, Affan wrote:

> I have a batch process in the application to send emails. The emails 
> are construced from XML generated from Velocity. I was considering 
> using singleton -vs- seperate instance for it. Singleton has the 
> advantage of caching the templates once and using them over. But in 
> this case when the emails are sent in batches caching would not be an 
> issue coz we will be parsing the templates once and using them over 
> for all the emails per batch.

Right - I don't think the singleton helps you here.

>
> Also would the Single instance of the Velocity Template engine become 
> a bottle-neck in some case?

Yes, you can have contention for things, such as in he introspector, 
but that's in a highly multi-threaded environment.  I don't think you 
will notice.


>  Is the Template Engine thread-safe in case the application is used in 
> a Multi-threaded way?

Yes

>
> Thanks,
>
> Affan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
-- 
Geir Magnusson Jr                                   203-247-1713(m)
geir@4quarters.com


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org