users@glassfish.java.net

Re: stateless session bean accessing helper class

From: Sahoo <sahoo_at_sun.com>
Date: Fri, 26 Oct 2007 09:37:37 +0530

Let's say two clients call downloadANdInsert concurrently. A server can
create two instances of ProcessBean in two separate threads and call
downloadANdInsert. It is no different from you spawning two threads in a
Java SE program where each thread creates a new instance of ProcessBean
and calls downloadANDInsert method. I hope this is sufficient for you to
analyse the impact at your end.

Thanks,
Sahoo

glassfish_at_javadesktop.org wrote:
> Hi ALl
>
> I have a helper class that I want my stateless session beans to access.
> I am a bit confusedon this part and need some assistance its liket his my stateless session bean calls a helper class that is a singleton to download a file and return it and then the session bean parses the file and inserts into the DB.Now it is possible that the same helper class may be triggered more than once by two beans and if that happens two beans will try to retrieve and create the same table (for which I have now added a timeestamp so don't care) but anyways if they had the same name the two beans would overwrite each other and I may at some point have a corrupted file.. to process.. A collegeue of mine believes that since this helper is called from a thread safe context so the downloads are also thread safe ..I would like to understand exactly what happens cuold someone help me out
> CHeers
> Subu
>
>
> so in code
> @Stateless
> public ProcessBean implements ProcessLocal
>
> public void downloadANdInsert()
> {
> File f=TestSingleton.getInstance().downloadFile();
> //then insert into db;
> }
> [Message sent by forum member 'priyasubu' (priyasubu)]
>
> http://forums.java.net/jive/thread.jspa?messageID=242262
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>