You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Manuel Sugawara <ma...@fciencias.unam.mx> on 2007/09/12 19:46:20 UTC

How to synchronize a service

Hi all, I'm using tapestry 4.0 and have a service that what roughly
does is create a PDF file in the tmp dir if it does not exists. If the
file exists or after its creation the service returns its contents to
the client. Now I'm worried about synchronization issues in this
code. Mi first idea was synchronize the method that looks for the file
and creates one if none exists, but this will not work if multiple
instances of the service are concurrently running. So, can I safely
assume that there is only one instance of the service running?, I
think not but wanted to be sure. If there may be many instances of the
service running, is Ok to synchronize on some global object? (global
as in <state-object scope="application").

Any pointer to the docs are wellcome!. Thanks in advance.

Regards,
Manuel.



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


Re: How to synchronize a service

Posted by Manuel Sugawara <ma...@fciencias.unam.mx>.
Manuel Sugawara <ma...@fciencias.unam.mx> writes:

> So, can I safely assume that there is only one instance of the
> service running?

No, of course not. For set-object to work there should be an instance
for client.

Regards,
Manuel.

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


Re: How to synchronize a service

Posted by Manuel Sugawara <ma...@fciencias.unam.mx>.
"Renat Zubairov" <re...@gmail.com> writes:
> Hi
>
> If you are refering to a "service" as a hivemind service, then you can
> hava  look on the service modles which are threaded, pooled, primitive
> and singleton. 

Yes, as a hivemind service. Didn't know of the different models
tough. I guess I have to check out the docs.

> But I guess better approach would be to put non-multithreaded part
> of your functionality to the singleton service and have other
> threaded services reading data prepared by singleton service.

I did something like this, thanks for the answer anyway.

Regards,
Manuel.

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


Re: How to synchronize a service

Posted by Renat Zubairov <re...@gmail.com>.
Hi

If you are refering to a "service" as a hivemind service, then you can
hava  look on the service modles which are threaded, pooled, primitive
and singleton. Singleton service model will ensure that only one
instance of service exists. After you know that you can synchronize
part of the code which is responsible for checking and creating
directories.
But I guess better approach would be to put non-multithreaded part of
your functionality to the singleton service and have other threaded
services reading data prepared by singleton service.

Renat

On 12/09/2007, Manuel Sugawara <ma...@fciencias.unam.mx> wrote:
> Hi all, I'm using tapestry 4.0 and have a service that what roughly
> does is create a PDF file in the tmp dir if it does not exists. If the
> file exists or after its creation the service returns its contents to
> the client. Now I'm worried about synchronization issues in this
> code. Mi first idea was synchronize the method that looks for the file
> and creates one if none exists, but this will not work if multiple
> instances of the service are concurrently running. So, can I safely
> assume that there is only one instance of the service running?, I
> think not but wanted to be sure. If there may be many instances of the
> service running, is Ok to synchronize on some global object? (global
> as in <state-object scope="application").
>
> Any pointer to the docs are wellcome!. Thanks in advance.
>
> Regards,
> Manuel.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Best regards,
Renat Zubairov

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