Discussions

EJB design: java.util.concurrent in stateless session bean

  1. java.util.concurrent in stateless session bean (1 messages)

    Hello, I want to write some code which would use the java.util.concurrent.locks.ReentrantReadWriteLock to provide a read write lock to some basic types of file access (for example create file, delete file, upload file, download file). I want to put this code in a stateless session bean and make it available within a possibly clustered environment. I don't think the use of the java.util.concurrent package is encourage within an EJB due to its own synchronization. Could I get some views on this? Thanks so much for your help. I know there is a EJB singleton coming out in EJB 3.1, but I probably cannot wait for that. Thanks again.
  2. Well, if we ignore for a while that the specs directly forbid the usage of thread synchronization and IO (disk IO in your case), there is another problem: The thread syncronization approach to protect file access from concurrency issues will only work when isolated to a single JVM. However, you mention a clustred environent. There you will have no means to prevent concurrent access to the same file resources from clustred environments by simply syncronizing on a jvm-local instance. You probably want to have some sort of singleton handling the file access if concurrency is an issue for you. /N